aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorAlex Chiang <achiang@hp.com>2008-10-20 19:41:17 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2008-10-22 19:42:39 -0400
commitd6c479e0b777afcd7a26ca62e122e3f878ccc830 (patch)
tree326fa6cb470f4d819582dfaffa33f55e42b7c78f /drivers/pci
parentdf77cd10078e36e1b89964e5e8c206add399a98d (diff)
PCI: cpci_hotplug: stop managing hotplug_slot->name
We no longer need to manage our version of hotplug_slot->name since the PCI and hotplug core manage it on our behalf. Now, we simply advise the PCI core of the name that we would like, and let the core take care of the rest. Cc: kristen.c.accardi@intel.com Cc: scottm@somanetworks.com Acked-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> Signed-off-by: Alex Chiang <achiang@hp.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/hotplug/cpci_hotplug.h6
-rw-r--r--drivers/pci/hotplug/cpci_hotplug_core.c76
-rw-r--r--drivers/pci/hotplug/cpci_hotplug_pci.c4
3 files changed, 37 insertions, 49 deletions
diff --git a/drivers/pci/hotplug/cpci_hotplug.h b/drivers/pci/hotplug/cpci_hotplug.h
index d9769b30be9a..9fff878cf026 100644
--- a/drivers/pci/hotplug/cpci_hotplug.h
+++ b/drivers/pci/hotplug/cpci_hotplug.h
@@ -30,6 +30,7 @@
30 30
31#include <linux/types.h> 31#include <linux/types.h>
32#include <linux/pci.h> 32#include <linux/pci.h>
33#include <linux/pci_hotplug.h>
33 34
34/* PICMG 2.1 R2.0 HS CSR bits: */ 35/* PICMG 2.1 R2.0 HS CSR bits: */
35#define HS_CSR_INS 0x0080 36#define HS_CSR_INS 0x0080
@@ -69,6 +70,11 @@ struct cpci_hp_controller {
69 struct cpci_hp_controller_ops *ops; 70 struct cpci_hp_controller_ops *ops;
70}; 71};
71 72
73static inline const char *slot_name(struct slot *slot)
74{
75 return hotplug_slot_name(slot->hotplug_slot);
76}
77
72extern int cpci_hp_register_controller(struct cpci_hp_controller *controller); 78extern int cpci_hp_register_controller(struct cpci_hp_controller *controller);
73extern int cpci_hp_unregister_controller(struct cpci_hp_controller *controller); 79extern int cpci_hp_unregister_controller(struct cpci_hp_controller *controller);
74extern int cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last); 80extern int cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last);
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
index 5e5dee85763c..de94f4feef8c 100644
--- a/drivers/pci/hotplug/cpci_hotplug_core.c
+++ b/drivers/pci/hotplug/cpci_hotplug_core.c
@@ -108,7 +108,7 @@ enable_slot(struct hotplug_slot *hotplug_slot)
108 struct slot *slot = hotplug_slot->private; 108 struct slot *slot = hotplug_slot->private;
109 int retval = 0; 109 int retval = 0;
110 110
111 dbg("%s - physical_slot = %s", __func__, hotplug_slot->name); 111 dbg("%s - physical_slot = %s", __func__, slot_name(slot));
112 112
113 if (controller->ops->set_power) 113 if (controller->ops->set_power)
114 retval = controller->ops->set_power(slot, 1); 114 retval = controller->ops->set_power(slot, 1);
@@ -121,25 +121,23 @@ disable_slot(struct hotplug_slot *hotplug_slot)
121 struct slot *slot = hotplug_slot->private; 121 struct slot *slot = hotplug_slot->private;
122 int retval = 0; 122 int retval = 0;
123 123
124 dbg("%s - physical_slot = %s", __func__, hotplug_slot->name); 124 dbg("%s - physical_slot = %s", __func__, slot_name(slot));
125 125
126 down_write(&list_rwsem); 126 down_write(&list_rwsem);
127 127
128 /* Unconfigure device */ 128 /* Unconfigure device */
129 dbg("%s - unconfiguring slot %s", 129 dbg("%s - unconfiguring slot %s", __func__, slot_name(slot));
130 __func__, slot->hotplug_slot->name);
131 if ((retval = cpci_unconfigure_slot(slot))) { 130 if ((retval = cpci_unconfigure_slot(slot))) {
132 err("%s - could not unconfigure slot %s", 131 err("%s - could not unconfigure slot %s",
133 __func__, slot->hotplug_slot->name); 132 __func__, slot_name(slot));
134 goto disable_error; 133 goto disable_error;
135 } 134 }
136 dbg("%s - finished unconfiguring slot %s", 135 dbg("%s - finished unconfiguring slot %s", __func__, slot_name(slot));
137 __func__, slot->hotplug_slot->name);
138 136
139 /* Clear EXT (by setting it) */ 137 /* Clear EXT (by setting it) */
140 if (cpci_clear_ext(slot)) { 138 if (cpci_clear_ext(slot)) {
141 err("%s - could not clear EXT for slot %s", 139 err("%s - could not clear EXT for slot %s",
142 __func__, slot->hotplug_slot->name); 140 __func__, slot_name(slot));
143 retval = -ENODEV; 141 retval = -ENODEV;
144 goto disable_error; 142 goto disable_error;
145 } 143 }
@@ -214,7 +212,6 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
214 struct slot *slot = hotplug_slot->private; 212 struct slot *slot = hotplug_slot->private;
215 213
216 kfree(slot->hotplug_slot->info); 214 kfree(slot->hotplug_slot->info);
217 kfree(slot->hotplug_slot->name);
218 kfree(slot->hotplug_slot); 215 kfree(slot->hotplug_slot);
219 if (slot->dev) 216 if (slot->dev)
220 pci_dev_put(slot->dev); 217 pci_dev_put(slot->dev);
@@ -222,12 +219,6 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
222} 219}
223 220
224#define SLOT_NAME_SIZE 6 221#define SLOT_NAME_SIZE 6
225static void
226make_slot_name(struct slot *slot)
227{
228 snprintf(slot->hotplug_slot->name,
229 SLOT_NAME_SIZE, "%02x:%02x", slot->bus->number, slot->number);
230}
231 222
232int 223int
233cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last) 224cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
@@ -235,7 +226,7 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
235 struct slot *slot; 226 struct slot *slot;
236 struct hotplug_slot *hotplug_slot; 227 struct hotplug_slot *hotplug_slot;
237 struct hotplug_slot_info *info; 228 struct hotplug_slot_info *info;
238 char *name; 229 char name[SLOT_NAME_SIZE];
239 int status = -ENOMEM; 230 int status = -ENOMEM;
240 int i; 231 int i;
241 232
@@ -262,35 +253,31 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
262 goto error_hpslot; 253 goto error_hpslot;
263 hotplug_slot->info = info; 254 hotplug_slot->info = info;
264 255
265 name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
266 if (!name)
267 goto error_info;
268 hotplug_slot->name = name;
269
270 slot->bus = bus; 256 slot->bus = bus;
271 slot->number = i; 257 slot->number = i;
272 slot->devfn = PCI_DEVFN(i, 0); 258 slot->devfn = PCI_DEVFN(i, 0);
273 259
260 snprintf(name, SLOT_NAME_SIZE, "%02x:%02x", bus->number, i);
261
274 hotplug_slot->private = slot; 262 hotplug_slot->private = slot;
275 hotplug_slot->release = &release_slot; 263 hotplug_slot->release = &release_slot;
276 make_slot_name(slot);
277 hotplug_slot->ops = &cpci_hotplug_slot_ops; 264 hotplug_slot->ops = &cpci_hotplug_slot_ops;
278 265
279 /* 266 /*
280 * Initialize the slot info structure with some known 267 * Initialize the slot info structure with some known
281 * good values. 268 * good values.
282 */ 269 */
283 dbg("initializing slot %s", slot->hotplug_slot->name); 270 dbg("initializing slot %s", name);
284 info->power_status = cpci_get_power_status(slot); 271 info->power_status = cpci_get_power_status(slot);
285 info->attention_status = cpci_get_attention_status(slot); 272 info->attention_status = cpci_get_attention_status(slot);
286 273
287 dbg("registering slot %s", slot->hotplug_slot->name); 274 dbg("registering slot %s", name);
288 status = pci_hp_register(slot->hotplug_slot, bus, i, 275 status = pci_hp_register(slot->hotplug_slot, bus, i, name);
289 slot->hotplug_slot->name);
290 if (status) { 276 if (status) {
291 err("pci_hp_register failed with error %d", status); 277 err("pci_hp_register failed with error %d", status);
292 goto error_name; 278 goto error_info;
293 } 279 }
280 dbg("slot registered with name: %s", slot_name(slot));
294 281
295 /* Add slot to our internal list */ 282 /* Add slot to our internal list */
296 down_write(&list_rwsem); 283 down_write(&list_rwsem);
@@ -299,8 +286,6 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
299 up_write(&list_rwsem); 286 up_write(&list_rwsem);
300 } 287 }
301 return 0; 288 return 0;
302error_name:
303 kfree(name);
304error_info: 289error_info:
305 kfree(info); 290 kfree(info);
306error_hpslot: 291error_hpslot:
@@ -328,7 +313,7 @@ cpci_hp_unregister_bus(struct pci_bus *bus)
328 list_del(&slot->slot_list); 313 list_del(&slot->slot_list);
329 slots--; 314 slots--;
330 315
331 dbg("deregistering slot %s", slot->hotplug_slot->name); 316 dbg("deregistering slot %s", slot_name(slot));
332 status = pci_hp_deregister(slot->hotplug_slot); 317 status = pci_hp_deregister(slot->hotplug_slot);
333 if (status) { 318 if (status) {
334 err("pci_hp_deregister failed with error %d", 319 err("pci_hp_deregister failed with error %d",
@@ -380,11 +365,10 @@ init_slots(int clear_ins)
380 return -1; 365 return -1;
381 } 366 }
382 list_for_each_entry(slot, &slot_list, slot_list) { 367 list_for_each_entry(slot, &slot_list, slot_list) {
383 dbg("%s - looking at slot %s", 368 dbg("%s - looking at slot %s", __func__, slot_name(slot));
384 __func__, slot->hotplug_slot->name);
385 if (clear_ins && cpci_check_and_clear_ins(slot)) 369 if (clear_ins && cpci_check_and_clear_ins(slot))
386 dbg("%s - cleared INS for slot %s", 370 dbg("%s - cleared INS for slot %s",
387 __func__, slot->hotplug_slot->name); 371 __func__, slot_name(slot));
388 dev = pci_get_slot(slot->bus, PCI_DEVFN(slot->number, 0)); 372 dev = pci_get_slot(slot->bus, PCI_DEVFN(slot->number, 0));
389 if (dev) { 373 if (dev) {
390 if (update_adapter_status(slot->hotplug_slot, 1)) 374 if (update_adapter_status(slot->hotplug_slot, 1))
@@ -415,8 +399,7 @@ check_slots(void)
415 } 399 }
416 extracted = inserted = 0; 400 extracted = inserted = 0;
417 list_for_each_entry(slot, &slot_list, slot_list) { 401 list_for_each_entry(slot, &slot_list, slot_list) {
418 dbg("%s - looking at slot %s", 402 dbg("%s - looking at slot %s", __func__, slot_name(slot));
419 __func__, slot->hotplug_slot->name);
420 if (cpci_check_and_clear_ins(slot)) { 403 if (cpci_check_and_clear_ins(slot)) {
421 /* 404 /*
422 * Some broken hardware (e.g. PLX 9054AB) asserts 405 * Some broken hardware (e.g. PLX 9054AB) asserts
@@ -424,35 +407,34 @@ check_slots(void)
424 */ 407 */
425 if (slot->dev) { 408 if (slot->dev) {
426 warn("slot %s already inserted", 409 warn("slot %s already inserted",
427 slot->hotplug_slot->name); 410 slot_name(slot));
428 inserted++; 411 inserted++;
429 continue; 412 continue;
430 } 413 }
431 414
432 /* Process insertion */ 415 /* Process insertion */
433 dbg("%s - slot %s inserted", 416 dbg("%s - slot %s inserted", __func__, slot_name(slot));
434 __func__, slot->hotplug_slot->name);
435 417
436 /* GSM, debug */ 418 /* GSM, debug */
437 hs_csr = cpci_get_hs_csr(slot); 419 hs_csr = cpci_get_hs_csr(slot);
438 dbg("%s - slot %s HS_CSR (1) = %04x", 420 dbg("%s - slot %s HS_CSR (1) = %04x",
439 __func__, slot->hotplug_slot->name, hs_csr); 421 __func__, slot_name(slot), hs_csr);
440 422
441 /* Configure device */ 423 /* Configure device */
442 dbg("%s - configuring slot %s", 424 dbg("%s - configuring slot %s",
443 __func__, slot->hotplug_slot->name); 425 __func__, slot_name(slot));
444 if (cpci_configure_slot(slot)) { 426 if (cpci_configure_slot(slot)) {
445 err("%s - could not configure slot %s", 427 err("%s - could not configure slot %s",
446 __func__, slot->hotplug_slot->name); 428 __func__, slot_name(slot));
447 continue; 429 continue;
448 } 430 }
449 dbg("%s - finished configuring slot %s", 431 dbg("%s - finished configuring slot %s",
450 __func__, slot->hotplug_slot->name); 432 __func__, slot_name(slot));
451 433
452 /* GSM, debug */ 434 /* GSM, debug */
453 hs_csr = cpci_get_hs_csr(slot); 435 hs_csr = cpci_get_hs_csr(slot);
454 dbg("%s - slot %s HS_CSR (2) = %04x", 436 dbg("%s - slot %s HS_CSR (2) = %04x",
455 __func__, slot->hotplug_slot->name, hs_csr); 437 __func__, slot_name(slot), hs_csr);
456 438
457 if (update_latch_status(slot->hotplug_slot, 1)) 439 if (update_latch_status(slot->hotplug_slot, 1))
458 warn("failure to update latch file"); 440 warn("failure to update latch file");
@@ -465,18 +447,18 @@ check_slots(void)
465 /* GSM, debug */ 447 /* GSM, debug */
466 hs_csr = cpci_get_hs_csr(slot); 448 hs_csr = cpci_get_hs_csr(slot);
467 dbg("%s - slot %s HS_CSR (3) = %04x", 449 dbg("%s - slot %s HS_CSR (3) = %04x",
468 __func__, slot->hotplug_slot->name, hs_csr); 450 __func__, slot_name(slot), hs_csr);
469 451
470 inserted++; 452 inserted++;
471 } else if (cpci_check_ext(slot)) { 453 } else if (cpci_check_ext(slot)) {
472 /* Process extraction request */ 454 /* Process extraction request */
473 dbg("%s - slot %s extracted", 455 dbg("%s - slot %s extracted",
474 __func__, slot->hotplug_slot->name); 456 __func__, slot_name(slot));
475 457
476 /* GSM, debug */ 458 /* GSM, debug */
477 hs_csr = cpci_get_hs_csr(slot); 459 hs_csr = cpci_get_hs_csr(slot);
478 dbg("%s - slot %s HS_CSR = %04x", 460 dbg("%s - slot %s HS_CSR = %04x",
479 __func__, slot->hotplug_slot->name, hs_csr); 461 __func__, slot_name(slot), hs_csr);
480 462
481 if (!slot->extracting) { 463 if (!slot->extracting) {
482 if (update_latch_status(slot->hotplug_slot, 0)) { 464 if (update_latch_status(slot->hotplug_slot, 0)) {
@@ -494,7 +476,7 @@ check_slots(void)
494 * bother trying to tell the driver or not? 476 * bother trying to tell the driver or not?
495 */ 477 */
496 err("card in slot %s was improperly removed", 478 err("card in slot %s was improperly removed",
497 slot->hotplug_slot->name); 479 slot_name(slot));
498 if (update_adapter_status(slot->hotplug_slot, 0)) 480 if (update_adapter_status(slot->hotplug_slot, 0))
499 warn("failure to update adapter file"); 481 warn("failure to update adapter file");
500 slot->extracting = 0; 482 slot->extracting = 0;
diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c
index df82b95e2874..829c327cfb5e 100644
--- a/drivers/pci/hotplug/cpci_hotplug_pci.c
+++ b/drivers/pci/hotplug/cpci_hotplug_pci.c
@@ -209,7 +209,7 @@ int cpci_led_on(struct slot* slot)
209 hs_cap + 2, 209 hs_cap + 2,
210 hs_csr)) { 210 hs_csr)) {
211 err("Could not set LOO for slot %s", 211 err("Could not set LOO for slot %s",
212 slot->hotplug_slot->name); 212 hotplug_slot_name(slot->hotplug_slot));
213 return -ENODEV; 213 return -ENODEV;
214 } 214 }
215 } 215 }
@@ -238,7 +238,7 @@ int cpci_led_off(struct slot* slot)
238 hs_cap + 2, 238 hs_cap + 2,
239 hs_csr)) { 239 hs_csr)) {
240 err("Could not clear LOO for slot %s", 240 err("Could not clear LOO for slot %s",
241 slot->hotplug_slot->name); 241 hotplug_slot_name(slot->hotplug_slot));
242 return -ENODEV; 242 return -ENODEV;
243 } 243 }
244 } 244 }