ChangeSet 1.1587.12.7, 2004/04/29 14:23:32-07:00, eike-hotplug@sf-tec.de [PATCH] PCI Hotplug: Clean up acpiphp_core.c: slot_paranoia_check Matthew Wilcox wrote: > On Thu, Apr 22, 2004 at 01:18:23PM +0200, Rolf Eike Beer wrote: > > slot_paranoia_check is only another kind of checking everything for NULL. > > Removing this leads to function get_slot is reduced to a simple cast, so > > this function can be killed also. > > Since private is void *, you don't even need the casts. > > > static int enable_slot (struct hotplug_slot *hotplug_slot) > > { > > - struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); > > + struct slot *slot = (struct slot *)hotplug_slot->private; > > struct slot *slot = hotplug_slot->private; > > is enough. Fixed. drivers/pci/hotplug/acpiphp_core.c | 56 +++++-------------------------------- 1 files changed, 8 insertions(+), 48 deletions(-) diff -Nru a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c --- a/drivers/pci/hotplug/acpiphp_core.c Mon May 17 17:08:11 2004 +++ b/drivers/pci/hotplug/acpiphp_core.c Mon May 17 17:08:11 2004 @@ -88,42 +88,6 @@ .get_cur_bus_speed = get_cur_bus_speed, }; - -/* Inline functions to check the sanity of a pointer that is passed to us */ -static inline int slot_paranoia_check (struct slot *slot, const char *function) -{ - if (!slot) { - dbg("%s - slot == NULL\n", function); - return -1; - } - if (slot->magic != SLOT_MAGIC) { - dbg("%s - bad magic number for slot\n", function); - return -1; - } - if (!slot->hotplug_slot) { - dbg("%s - slot->hotplug_slot == NULL!\n", function); - return -1; - } - return 0; -} - - -static inline struct slot *get_slot (struct hotplug_slot *hotplug_slot, const char *function) -{ - struct slot *slot; - - if (!hotplug_slot) { - dbg("%s - hotplug_slot == NULL\n", function); - return NULL; - } - - slot = (struct slot *)hotplug_slot->private; - if (slot_paranoia_check(slot, function)) - return NULL; - return slot; -} - - /** * enable_slot - power on and enable a slot * @hotplug_slot: slot to enable @@ -133,7 +97,7 @@ */ static int enable_slot (struct hotplug_slot *hotplug_slot) { - struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); + struct slot *slot = hotplug_slot->private; int retval = 0; dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); @@ -154,7 +118,7 @@ */ static int disable_slot (struct hotplug_slot *hotplug_slot) { - struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); + struct slot *slot = hotplug_slot->private; int retval = 0; dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); @@ -205,7 +169,7 @@ */ static int hardware_test (struct hotplug_slot *hotplug_slot, u32 value) { - struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); + struct slot *slot = hotplug_slot->private; int retval = 0; dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); @@ -228,7 +192,7 @@ */ static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value) { - struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); + struct slot *slot = hotplug_slot->private; int retval = 0; dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); @@ -269,7 +233,7 @@ */ static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value) { - struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); + struct slot *slot = hotplug_slot->private; int retval = 0; dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); @@ -291,7 +255,7 @@ */ static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value) { - struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); + struct slot *slot = hotplug_slot->private; int retval = 0; dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); @@ -310,7 +274,7 @@ */ static int get_address (struct hotplug_slot *hotplug_slot, u32 *value) { - struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); + struct slot *slot = hotplug_slot->private; int retval = 0; dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); @@ -324,8 +288,6 @@ /* return dummy value because ACPI doesn't provide any method... */ static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) { - struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); - *value = PCI_SPEED_UNKNOWN; return 0; @@ -335,8 +297,6 @@ /* return dummy value because ACPI doesn't provide any method... */ static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) { - struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); - *value = PCI_SPEED_UNKNOWN; return 0; @@ -378,7 +338,7 @@ */ static void release_slot(struct hotplug_slot *hotplug_slot) { - struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); + struct slot *slot = hotplug_slot->private; dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);