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

[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.
parent e74a5d2f
......@@ -62,8 +62,6 @@ extern int debug;
#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 @@ extern int debug;
* struct slot - slot information for each *physical* slot
*/
struct slot {
u32 magic;
int state;
u32 index;
u32 type;
......
......@@ -77,15 +77,6 @@ struct hotplug_slot_ops rpaphp_hotplug_slot_ops = {
.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 rpaphp_get_attention_status(struct slot *slot)
*/
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 set_attention_status(struct hotplug_slot *hotplug_slot, u8 value)
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_power_status(struct hotplug_slot *hotplug_slot, u8 * value)
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_attention_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 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_adapter_status(struct hotplug_slot *hotplug_slot, u8 * value)
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) {
......
......@@ -58,13 +58,10 @@ void rpaphp_sysfs_remove_attr_location (struct hotplug_slot *slot)
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);
}
......
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