diff options
Diffstat (limited to 'drivers/pci/hotplug/rpaphp_slot.c')
-rw-r--r-- | drivers/pci/hotplug/rpaphp_slot.c | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c index d4ee8723fcb3..8ad3debb3794 100644 --- a/drivers/pci/hotplug/rpaphp_slot.c +++ b/drivers/pci/hotplug/rpaphp_slot.c | |||
@@ -33,23 +33,31 @@ | |||
33 | #include <asm/rtas.h> | 33 | #include <asm/rtas.h> |
34 | #include "rpaphp.h" | 34 | #include "rpaphp.h" |
35 | 35 | ||
36 | static ssize_t location_read_file (struct hotplug_slot *php_slot, char *buf) | 36 | static ssize_t address_read_file (struct hotplug_slot *php_slot, char *buf) |
37 | { | 37 | { |
38 | char *value; | 38 | int retval; |
39 | int retval = -ENOENT; | ||
40 | struct slot *slot = (struct slot *)php_slot->private; | 39 | struct slot *slot = (struct slot *)php_slot->private; |
40 | struct pci_bus *bus; | ||
41 | 41 | ||
42 | if (!slot) | 42 | if (!slot) |
43 | return retval; | 43 | return -ENOENT; |
44 | |||
45 | bus = slot->bus; | ||
46 | if (!bus) | ||
47 | return -ENOENT; | ||
48 | |||
49 | if (bus->self) | ||
50 | retval = sprintf(buf, pci_name(bus->self)); | ||
51 | else | ||
52 | retval = sprintf(buf, "%04x:%02x:00.0", | ||
53 | pci_domain_nr(bus), bus->number); | ||
44 | 54 | ||
45 | value = slot->location; | ||
46 | retval = sprintf (buf, "%s\n", value); | ||
47 | return retval; | 55 | return retval; |
48 | } | 56 | } |
49 | 57 | ||
50 | static struct hotplug_slot_attribute php_attr_location = { | 58 | static struct hotplug_slot_attribute php_attr_address = { |
51 | .attr = {.name = "phy_location", .mode = S_IFREG | S_IRUGO}, | 59 | .attr = {.name = "address", .mode = S_IFREG | S_IRUGO}, |
52 | .show = location_read_file, | 60 | .show = address_read_file, |
53 | }; | 61 | }; |
54 | 62 | ||
55 | /* free up the memory used by a slot */ | 63 | /* free up the memory used by a slot */ |
@@ -64,7 +72,6 @@ void dealloc_slot_struct(struct slot *slot) | |||
64 | kfree(slot->hotplug_slot->info); | 72 | kfree(slot->hotplug_slot->info); |
65 | kfree(slot->hotplug_slot->name); | 73 | kfree(slot->hotplug_slot->name); |
66 | kfree(slot->hotplug_slot); | 74 | kfree(slot->hotplug_slot); |
67 | kfree(slot->location); | ||
68 | kfree(slot); | 75 | kfree(slot); |
69 | } | 76 | } |
70 | 77 | ||
@@ -83,16 +90,13 @@ struct slot *alloc_slot_struct(struct device_node *dn, | |||
83 | GFP_KERNEL); | 90 | GFP_KERNEL); |
84 | if (!slot->hotplug_slot->info) | 91 | if (!slot->hotplug_slot->info) |
85 | goto error_hpslot; | 92 | goto error_hpslot; |
86 | slot->hotplug_slot->name = kmalloc(BUS_ID_SIZE + 1, GFP_KERNEL); | 93 | slot->hotplug_slot->name = kmalloc(strlen(drc_name) + 1, GFP_KERNEL); |
87 | if (!slot->hotplug_slot->name) | 94 | if (!slot->hotplug_slot->name) |
88 | goto error_info; | 95 | goto error_info; |
89 | slot->location = kmalloc(strlen(drc_name) + 1, GFP_KERNEL); | ||
90 | if (!slot->location) | ||
91 | goto error_name; | ||
92 | slot->name = slot->hotplug_slot->name; | 96 | slot->name = slot->hotplug_slot->name; |
97 | strcpy(slot->name, drc_name); | ||
93 | slot->dn = dn; | 98 | slot->dn = dn; |
94 | slot->index = drc_index; | 99 | slot->index = drc_index; |
95 | strcpy(slot->location, drc_name); | ||
96 | slot->power_domain = power_domain; | 100 | slot->power_domain = power_domain; |
97 | slot->hotplug_slot->private = slot; | 101 | slot->hotplug_slot->private = slot; |
98 | slot->hotplug_slot->ops = &rpaphp_hotplug_slot_ops; | 102 | slot->hotplug_slot->ops = &rpaphp_hotplug_slot_ops; |
@@ -100,8 +104,6 @@ struct slot *alloc_slot_struct(struct device_node *dn, | |||
100 | 104 | ||
101 | return (slot); | 105 | return (slot); |
102 | 106 | ||
103 | error_name: | ||
104 | kfree(slot->hotplug_slot->name); | ||
105 | error_info: | 107 | error_info: |
106 | kfree(slot->hotplug_slot->info); | 108 | kfree(slot->hotplug_slot->info); |
107 | error_hpslot: | 109 | error_hpslot: |
@@ -133,8 +135,8 @@ int rpaphp_deregister_slot(struct slot *slot) | |||
133 | 135 | ||
134 | list_del(&slot->rpaphp_slot_list); | 136 | list_del(&slot->rpaphp_slot_list); |
135 | 137 | ||
136 | /* remove "phy_location" file */ | 138 | /* remove "address" file */ |
137 | sysfs_remove_file(&php_slot->kobj, &php_attr_location.attr); | 139 | sysfs_remove_file(&php_slot->kobj, &php_attr_address.attr); |
138 | 140 | ||
139 | retval = pci_hp_deregister(php_slot); | 141 | retval = pci_hp_deregister(php_slot); |
140 | if (retval) | 142 | if (retval) |
@@ -166,8 +168,8 @@ int rpaphp_register_slot(struct slot *slot) | |||
166 | return retval; | 168 | return retval; |
167 | } | 169 | } |
168 | 170 | ||
169 | /* create "phy_location" file */ | 171 | /* create "address" file */ |
170 | retval = sysfs_create_file(&php_slot->kobj, &php_attr_location.attr); | 172 | retval = sysfs_create_file(&php_slot->kobj, &php_attr_address.attr); |
171 | if (retval) { | 173 | if (retval) { |
172 | err("sysfs_create_file failed with error %d\n", retval); | 174 | err("sysfs_create_file failed with error %d\n", retval); |
173 | goto sysfs_fail; | 175 | goto sysfs_fail; |
@@ -175,8 +177,7 @@ int rpaphp_register_slot(struct slot *slot) | |||
175 | 177 | ||
176 | /* add slot to our internal list */ | 178 | /* add slot to our internal list */ |
177 | list_add(&slot->rpaphp_slot_list, &rpaphp_slot_head); | 179 | list_add(&slot->rpaphp_slot_list, &rpaphp_slot_head); |
178 | info("Slot [%s](PCI location=%s) registered\n", slot->name, | 180 | info("Slot [%s] registered\n", slot->name); |
179 | slot->location); | ||
180 | return 0; | 181 | return 0; |
181 | 182 | ||
182 | sysfs_fail: | 183 | sysfs_fail: |