X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fpci%2Fhotplug%2Frpaphp_core.c;h=1572054280e2c10973fa83fdbb65ed39514f6125;hb=d939d46ba7caa14e960be18e18f5c07be8806d7a;hp=2fe394ace6b6c7b715a4444210e75151652303a6;hpb=86090fcac5e27b630656fe3d963a6b80e26dac44;p=linux-2.6.git diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c index 2fe394ace..157205428 100644 --- a/drivers/pci/hotplug/rpaphp_core.c +++ b/drivers/pci/hotplug/rpaphp_core.c @@ -54,7 +54,7 @@ MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); -module_param(debug, int, 0644); +module_param(debug, bool, 0644); static int enable_slot(struct hotplug_slot *slot); static int disable_slot(struct hotplug_slot *slot); @@ -63,7 +63,6 @@ static int get_power_status(struct hotplug_slot *slot, u8 * value); static int get_attention_status(struct hotplug_slot *slot, u8 * value); static int get_adapter_status(struct hotplug_slot *slot, u8 * value); static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value); -static int get_cur_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value); struct hotplug_slot_ops rpaphp_hotplug_slot_ops = { .owner = THIS_MODULE, @@ -74,18 +73,8 @@ struct hotplug_slot_ops rpaphp_hotplug_slot_ops = { .get_attention_status = get_attention_status, .get_adapter_status = get_adapter_status, .get_max_bus_speed = get_max_bus_speed, - .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 +89,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 +122,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 +138,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 +148,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 +169,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) { @@ -231,18 +206,6 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe return 0; } -/* return dummy value because not sure if PRA provides 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__); - - if (slot == NULL) - return -ENODEV; - - *value = PCI_SPEED_UNKNOWN; - return 0; -} - int rpaphp_remove_slot(struct slot *slot) { int retval = 0; @@ -268,24 +231,24 @@ static int is_php_dn(struct device_node *dn, int **indexes, int **names, int **t { *indexes = (int *) get_property(dn, "ibm,drc-indexes", NULL); if (!*indexes) - return (0); + return 0; /* &names[1] contains NULL terminated slot names */ *names = (int *) get_property(dn, "ibm,drc-names", NULL); if (!*names) - return (0); + return 0; /* &types[1] contains NULL terminated slot types */ *types = (int *) get_property(dn, "ibm,drc-types", NULL); if (!*types) - return (0); + return 0; /* power_domains[1...n] are the slot power domains */ *power_domains = (int *) get_property(dn, "ibm,drc-power-domains", NULL); if (!*power_domains) - return (0); + return 0; if (strcmp(dn->name, "pci") == 0 && - !get_property(dn, "ibm,fw-pci-hot-plug-ctrl", NULL)) - return (0); - return (1); + !get_property(dn, "ibm,fw-pci-hot-plug-ctrl", NULL)) + return 0; + return 1; } static inline int is_vdevice_root(struct device_node *dn) @@ -293,10 +256,10 @@ static inline int is_vdevice_root(struct device_node *dn) return !strcmp(dn->name, "vdevice"); } -/************************************* - * Add Hot Plug slot(s) to sysfs +/** + * rpaphp_add_slot: Add Hot Plug slot(s) to sysfs * - ************************************/ + */ int rpaphp_add_slot(struct device_node *dn) { struct slot *slot; @@ -320,8 +283,9 @@ int rpaphp_add_slot(struct device_node *dn) name = (char *) &names[1]; type = (char *) &types[1]; for (i = 0; i < indexes[0]; - i++, - name += (strlen(name) + 1), type += (strlen(type) + 1)) { + i++, + name += (strlen(name) + 1), + type += (strlen(type) + 1)) { if (!(slot = alloc_slot_struct(dn, indexes[i + 1], name, power_domains[i + 1]))) { retval = -ENOMEM; @@ -334,38 +298,28 @@ int rpaphp_add_slot(struct device_node *dn) } /* for indexes */ } /* end of PCI device_node */ - exit: +exit: dbg("%s - Exit: num_slots=%d rc[%d]\n", __FUNCTION__, num_slots, retval); return retval; } -/* - * init_slots - initialize 'struct slot' structures for each slot - * - */ -static void init_slots(void) +static int __init init_rpa(void) { struct device_node *dn; - for (dn = find_all_nodes(); dn; dn = dn->next) - rpaphp_add_slot(dn); -} - -static int init_rpa(void) -{ - init_MUTEX(&rpaphp_sem); /* initialize internal data structure etc. */ - init_slots(); + for (dn = find_all_nodes(); dn; dn = dn->next) + rpaphp_add_slot(dn); if (!num_slots) return -ENODEV; return 0; } -static void cleanup_slots(void) +static void __exit cleanup_slots(void) { struct list_head *tmp, *n; struct slot *slot; @@ -400,10 +354,7 @@ static void __exit rpaphp_exit(void) static int enable_slot(struct hotplug_slot *hotplug_slot) { int retval = 0; - struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); - - if (slot == NULL) - return -ENODEV; + struct slot *slot = (struct slot *)hotplug_slot->private; if (slot->state == CONFIGURED) { dbg("%s: %s is already enabled\n", __FUNCTION__, slot->name); @@ -431,10 +382,7 @@ static int enable_slot(struct hotplug_slot *hotplug_slot) static int disable_slot(struct hotplug_slot *hotplug_slot) { int retval; - struct slot *slot = get_slot(hotplug_slot, __FUNCTION__); - - if (slot == NULL) - return -ENODEV; + struct slot *slot = (struct slot *)hotplug_slot->private; dbg("%s - Entry: slot[%s]\n", __FUNCTION__, slot->name);