Commit 192e1cac authored by Rolf Eike Beer's avatar Rolf Eike Beer Committed by Deepak Saxena

[PATCH] Compaq PCI Hotplug: remove useless NULL checks

Remove some useless NULL and magic checks from Compaq PCI Hotplug driver.
If one of this pointers is invalid we are in bad trouble anyway.
parent d8758fa7
......@@ -257,9 +257,7 @@ struct pci_func {
struct pci_dev* pci_dev;
};
#define SLOT_MAGIC 0x67267321
struct slot {
u32 magic;
struct slot *next;
u8 bus;
u8 device;
......@@ -452,40 +450,6 @@ extern u8 cpqhp_disk_irq;
/* inline functions */
/* 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", function);
return -1;
}
if (slot->magic != SLOT_MAGIC) {
dbg("%s - bad magic number for slot", function);
return -1;
}
if (!slot->hotplug_slot) {
dbg("%s - slot->hotplug_slot == NULL!", 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;
}
/*
* return_resource
*
......@@ -688,9 +652,6 @@ static inline int cpq_get_attention_status(struct controller *ctrl, struct slot
{
u8 hp_slot;
if (slot == NULL)
return 1;
hp_slot = slot->device - ctrl->slot_device_offset;
return read_amber_LED(ctrl, hp_slot);
......@@ -701,9 +662,6 @@ static inline int get_slot_enabled(struct controller *ctrl, struct slot *slot)
{
u8 hp_slot;
if (slot == NULL)
return 1;
hp_slot = slot->device - ctrl->slot_device_offset;
return is_slot_enabled(ctrl, hp_slot);
......@@ -715,9 +673,6 @@ static inline int cpq_get_latch_status(struct controller *ctrl, struct slot *slo
u32 status;
u8 hp_slot;
if (slot == NULL)
return 1;
hp_slot = slot->device - ctrl->slot_device_offset;
dbg("%s: slot->device = %d, ctrl->slot_device_offset = %d \n",
__FUNCTION__, slot->device, ctrl->slot_device_offset);
......@@ -734,9 +689,6 @@ static inline int get_presence_status(struct controller *ctrl, struct slot *slot
u8 hp_slot;
u32 tempdword;
if (slot == NULL)
return 0;
hp_slot = slot->device - ctrl->slot_device_offset;
tempdword = readl(ctrl->hpc_reg + INT_INPUT_CLEAR);
......
......@@ -314,7 +314,7 @@ static void *get_SMBIOS_entry (void *smbios_start, void *smbios_table, u8 type,
static void release_slot(struct hotplug_slot *hotplug_slot)
{
struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
struct slot *slot = hotplug_slot->private;
if (slot == NULL)
return;
......@@ -374,7 +374,6 @@ static int ctrl_slot_setup (struct controller * ctrl, void *smbios_start, void *
return -ENOMEM;
}
new_slot->magic = SLOT_MAGIC;
new_slot->ctrl = ctrl;
new_slot->bus = ctrl->bus;
new_slot->device = slot_device;
......@@ -600,7 +599,7 @@ static int cpqhp_set_attention_status (struct controller *ctrl, struct pci_func
static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status)
{
struct pci_func *slot_func;
struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
struct slot *slot = hotplug_slot->private;
struct controller *ctrl;
u8 bus;
u8 devfn;
......@@ -632,25 +631,18 @@ static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status)
}
static int process_SI (struct hotplug_slot *hotplug_slot)
static int process_SI(struct hotplug_slot *hotplug_slot)
{
struct pci_func *slot_func;
struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
struct controller *ctrl;
struct slot *slot = hotplug_slot->private;
struct controller *ctrl = slot->ctrl;
u8 bus;
u8 devfn;
u8 device;
u8 function;
if (slot == NULL)
return -ENODEV;
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
ctrl = slot->ctrl;
if (ctrl == NULL)
return -ENODEV;
if (cpqhp_get_bus_dev(ctrl, &bus, &devfn, slot->number) == -1)
return -ENODEV;
......@@ -672,25 +664,18 @@ static int process_SI (struct hotplug_slot *hotplug_slot)
}
static int process_SS (struct hotplug_slot *hotplug_slot)
static int process_SS(struct hotplug_slot *hotplug_slot)
{
struct pci_func *slot_func;
struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
struct controller *ctrl;
struct slot *slot = hotplug_slot->private;
struct controller *ctrl = slot->ctrl;
u8 bus;
u8 devfn;
u8 device;
u8 function;
if (slot == NULL)
return -ENODEV;
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
ctrl = slot->ctrl;
if (ctrl == NULL)
return -ENODEV;
if (cpqhp_get_bus_dev(ctrl, &bus, &devfn, slot->number) == -1)
return -ENODEV;
......@@ -708,112 +693,70 @@ static int process_SS (struct hotplug_slot *hotplug_slot)
}
static int hardware_test (struct hotplug_slot *hotplug_slot, u32 value)
static int hardware_test(struct hotplug_slot *hotplug_slot, u32 value)
{
struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
struct controller *ctrl;
struct slot *slot = hotplug_slot->private;
struct controller *ctrl = slot->ctrl;
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
if (slot == NULL)
return -ENODEV;
ctrl = slot->ctrl;
if (ctrl == NULL)
return -ENODEV;
return cpqhp_hardware_test (ctrl, value);
}
static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value)
static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
{
struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
struct controller *ctrl;
if (slot == NULL)
return -ENODEV;
struct slot *slot = hotplug_slot->private;
struct controller *ctrl = slot->ctrl;
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
ctrl = slot->ctrl;
if (ctrl == NULL)
return -ENODEV;
*value = get_slot_enabled(ctrl, slot);
return 0;
}
static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value)
static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
{
struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
struct controller *ctrl;
if (slot == NULL)
return -ENODEV;
struct slot *slot = hotplug_slot->private;
struct controller *ctrl = slot->ctrl;
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
ctrl = slot->ctrl;
if (ctrl == NULL)
return -ENODEV;
*value = cpq_get_attention_status(ctrl, slot);
return 0;
}
static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value)
static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
{
struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
struct controller *ctrl;
if (slot == NULL)
return -ENODEV;
struct slot *slot = hotplug_slot->private;
struct controller *ctrl = slot->ctrl;
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
ctrl = slot->ctrl;
if (ctrl == NULL)
return -ENODEV;
*value = cpq_get_latch_status (ctrl, slot);
*value = cpq_get_latch_status(ctrl, slot);
return 0;
}
static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value)
static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
{
struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
struct controller *ctrl;
if (slot == NULL)
return -ENODEV;
struct slot *slot = hotplug_slot->private;
struct controller *ctrl = slot->ctrl;
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
ctrl = slot->ctrl;
if (ctrl == NULL)
return -ENODEV;
*value = get_presence_status (ctrl, slot);
*value = get_presence_status(ctrl, slot);
return 0;
}
static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value)
{
struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
struct controller *ctrl;
if (slot == NULL)
return -ENODEV;
struct slot *slot = hotplug_slot->private;
struct controller *ctrl = slot->ctrl;
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
ctrl = slot->ctrl;
if (ctrl == NULL)
return -ENODEV;
*value = ctrl->speed_capability;
return 0;
......@@ -821,18 +764,11 @@ static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp
static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value)
{
struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
struct controller *ctrl;
if (slot == NULL)
return -ENODEV;
struct slot *slot = hotplug_slot->private;
struct controller *ctrl = slot->ctrl;
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
ctrl = slot->ctrl;
if (ctrl == NULL)
return -ENODEV;
*value = ctrl->speed;
return 0;
......
......@@ -143,12 +143,7 @@ static u8 handle_switch_change(u8 change, struct controller * ctrl)
*/
struct slot *cpqhp_find_slot(struct controller *ctrl, u8 device)
{
struct slot *slot;
if (!ctrl)
return NULL;
slot = ctrl->slot;
struct slot *slot = ctrl->slot;
while (slot && (slot->device != device)) {
slot = slot->next;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment