aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug
diff options
context:
space:
mode:
authorLinas Vepstas <linas@austin.ibm.com>2007-11-26 02:51:37 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2008-02-01 18:04:22 -0500
commit1b7c9fcaa147662628078c83ecaf1ef2c5c9c9d0 (patch)
treeb563e65c2caf1d095c7352d1db1b4e47a014496d /drivers/pci/hotplug
parent677cc6443b28508bb1a34d4d0d6a9b9a20179369 (diff)
pci hotplug: fix rpaphp directory naming
Fix presentation of the slot number in the /sys/bus/pci/slots directory to match that used in the majority of other drivers. > Greg said: > How is anyone supposed to write sane managability tools in the > presence > of such anarchy? > > > ~ # cat /sys/bus/pci/slots/0000:00:02.2/phy_location > > U787A.001.DNZ00Z5-P1-C2 > > Right. This should look like: > > # cat /sys/bus/pci/slots/U787A.001.DNZ00Z5-P1-C2/address > 0000:00:02 This patch implements exactly what you describe. Boot tested. I assume you really mean it -- if so, then please review and ack the patch !? I have absolutely no clue if this breaks any existing IBM tools. I'm pretty sure it doesn't ... but attention Mike Strosaker! does it? Signed-off-by: Linas Vepstas <linas@austin.ibm.com> Cc: Kristen Carlson Accardi <kristen.c.accardi@intel.com> Cc: <strosake@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci/hotplug')
-rw-r--r--drivers/pci/hotplug/rpaphp.h1
-rw-r--r--drivers/pci/hotplug/rpaphp_pci.c14
-rw-r--r--drivers/pci/hotplug/rpaphp_slot.c47
3 files changed, 24 insertions, 38 deletions
diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h
index c822a779653f..7d5921b1ee78 100644
--- a/drivers/pci/hotplug/rpaphp.h
+++ b/drivers/pci/hotplug/rpaphp.h
@@ -74,7 +74,6 @@ struct slot {
74 u32 type; 74 u32 type;
75 u32 power_domain; 75 u32 power_domain;
76 char *name; 76 char *name;
77 char *location;
78 struct device_node *dn; 77 struct device_node *dn;
79 struct pci_bus *bus; 78 struct pci_bus *bus;
80 struct list_head *pci_devs; 79 struct list_head *pci_devs;
diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c
index 0de84533cd80..6571e9b4c2ec 100644
--- a/drivers/pci/hotplug/rpaphp_pci.c
+++ b/drivers/pci/hotplug/rpaphp_pci.c
@@ -64,19 +64,6 @@ int rpaphp_get_sensor_state(struct slot *slot, int *state)
64 return rc; 64 return rc;
65} 65}
66 66
67static void set_slot_name(struct slot *slot)
68{
69 struct pci_bus *bus = slot->bus;
70 struct pci_dev *bridge;
71
72 bridge = bus->self;
73 if (bridge)
74 strcpy(slot->name, pci_name(bridge));
75 else
76 sprintf(slot->name, "%04x:%02x:00.0", pci_domain_nr(bus),
77 bus->number);
78}
79
80/** 67/**
81 * rpaphp_enable_slot - record slot state, config pci device 68 * rpaphp_enable_slot - record slot state, config pci device
82 * @slot: target &slot 69 * @slot: target &slot
@@ -115,7 +102,6 @@ int rpaphp_enable_slot(struct slot *slot)
115 info->adapter_status = EMPTY; 102 info->adapter_status = EMPTY;
116 slot->bus = bus; 103 slot->bus = bus;
117 slot->pci_devs = &bus->devices; 104 slot->pci_devs = &bus->devices;
118 set_slot_name(slot);
119 105
120 /* if there's an adapter in the slot, go add the pci devices */ 106 /* if there's an adapter in the slot, go add the pci devices */
121 if (state == PRESENT) { 107 if (state == PRESENT) {
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
36static ssize_t location_read_file (struct hotplug_slot *php_slot, char *buf) 36static 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
50static struct hotplug_slot_attribute php_attr_location = { 58static 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
103error_name:
104 kfree(slot->hotplug_slot->name);
105error_info: 107error_info:
106 kfree(slot->hotplug_slot->info); 108 kfree(slot->hotplug_slot->info);
107error_hpslot: 109error_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
182sysfs_fail: 183sysfs_fail: