ChangeSet 1.1587.12.50, 2004/04/30 14:48:11-07:00, eike-hotplug@sf-tec.de

[PATCH] RPA PCI Hotplug: Remove useless NULL checks

Remove useless NULL checks and magic numbers from rpaphp. If one of these
ever becomes invalid we are in serious trouble anyway.


 drivers/pci/hotplug/rpaphp.h      |    3 ---
 drivers/pci/hotplug/rpaphp_core.c |   35 ++++++-----------------------------
 drivers/pci/hotplug/rpaphp_slot.c |    7 ++-----
 3 files changed, 8 insertions(+), 37 deletions(-)


diff -Nru a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h
--- a/drivers/pci/hotplug/rpaphp.h	Mon May 17 17:00:51 2004
+++ b/drivers/pci/hotplug/rpaphp.h	Mon May 17 17:00:51 2004
@@ -62,8 +62,6 @@
 #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
 #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
 
-#define SLOT_MAGIC	0x67267322
-
 /* slot types */
 #define VIO_DEV	1
 #define PCI_DEV	2
@@ -79,7 +77,6 @@
  * struct slot - slot information for each *physical* slot
  */
 struct slot {
-	u32 magic;
 	int state;
 	u32 index;
 	u32 type;
diff -Nru a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
--- a/drivers/pci/hotplug/rpaphp_core.c	Mon May 17 17:00:51 2004
+++ b/drivers/pci/hotplug/rpaphp_core.c	Mon May 17 17:00:51 2004
@@ -77,15 +77,6 @@
 	.get_cur_bus_speed = get_cur_bus_speed,
 };
 
-static inline struct slot *get_slot (struct hotplug_slot *hotplug_slot, const char *function)
-{
-	if (!hotplug_slot) {
-		dbg("%s - hotplug_slot == NULL\n", function);
-		return NULL;
-	}
-	return (struct slot *)hotplug_slot->private;
-}
-
 static int rpaphp_get_attention_status(struct slot *slot)
 {
 	return slot->hotplug_slot->info->attention_status;
@@ -100,11 +91,8 @@
  */
 static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 value)
 {
-	int retval = 0;
-	struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
-
-	if (slot == NULL)
-		return -ENODEV;
+	int retval;
+	struct slot *slot = (struct slot *)hotplug_slot->private;
 
 	down(&rpaphp_sem);
 	switch (value) {
@@ -136,10 +124,7 @@
 static int get_power_status(struct hotplug_slot *hotplug_slot, u8 * value)
 {
 	int retval;
-	struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
-
-	if (slot == NULL)
-		return -ENODEV;
+	struct slot *slot = (struct slot *)hotplug_slot->private;
 
 	down(&rpaphp_sem);
 	retval = rpaphp_get_power_status(slot, value);
@@ -155,10 +140,7 @@
 static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 * value)
 {
 	int retval = 0;
-	struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
-
-	if (slot == NULL)
-		return -ENODEV;
+	struct slot *slot = (struct slot *)hotplug_slot->private;
 
 	down(&rpaphp_sem);
 	*value = rpaphp_get_attention_status(slot);
@@ -168,11 +150,9 @@
 
 static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 * value)
 {
-	struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
+	struct slot *slot = (struct slot *)hotplug_slot->private;
 	int retval = 0;
 
-	if (slot == NULL)
-		return -ENODEV;
 	down(&rpaphp_sem);
 	/*  have to go through this */
 	switch (slot->dev_type) {
@@ -191,10 +171,7 @@
 
 static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value)
 {
-	struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
-
-	if (slot == NULL)
-		return -ENODEV;
+	struct slot *slot = (struct slot *)hotplug_slot->private;
 
 	down(&rpaphp_sem);
 	switch (slot->type) {
diff -Nru a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c
--- a/drivers/pci/hotplug/rpaphp_slot.c	Mon May 17 17:00:51 2004
+++ b/drivers/pci/hotplug/rpaphp_slot.c	Mon May 17 17:00:51 2004
@@ -58,13 +58,10 @@
 	sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_location.attr);
 }
 
-/* free up the memory user by a slot */
+/* free up the memory used by a slot */
 static void rpaphp_release_slot(struct hotplug_slot *hotplug_slot)
 {
-	struct slot *slot = hotplug_slot? (struct slot *) hotplug_slot->private:NULL;
-
-	if (slot == NULL)
-		return;
+	struct slot *slot = (struct slot *) hotplug_slot->private;
 
 	dealloc_slot_struct(slot);
 }
