diff options
author | John Rose <johnrose@austin.ibm.com> | 2005-07-25 11:17:03 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-09-08 17:57:23 -0400 |
commit | 56d8456b06ad1316bff3c75caed5e06e786f20d8 (patch) | |
tree | f7a17c2e66c548b5172bebd07a01437ff78a9447 /drivers/pci/hotplug | |
parent | 940903c5a5a906c622a79b3101586deb1a1b3480 (diff) |
[PATCH] PCI Hotplug: rpaphp: Purify hotplug
Currently rpaphp registers the following bus types as hotplug slots:
1) Actual PCI Hotplug slots
2) Embedded/Internal PCI slots
3) PCI Host Bridges
The second and third bus types are not actually direct parents of
removable adapters. As such, the rpaphp has special case code to fake
results for attributes like power, adapter status, etc. This patch
removes types 2 and 3 from the rpaphp module.
This patch also changes the DLPAR module so that slots can be
DLPAR-added/removed without having been designated as hotplug-capable.
Signed-off-by: John Rose <johnrose@austin.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci/hotplug')
-rw-r--r-- | drivers/pci/hotplug/rpadlpar_core.c | 154 | ||||
-rw-r--r-- | drivers/pci/hotplug/rpaphp.h | 6 | ||||
-rw-r--r-- | drivers/pci/hotplug/rpaphp_core.c | 69 | ||||
-rw-r--r-- | drivers/pci/hotplug/rpaphp_pci.c | 11 | ||||
-rw-r--r-- | drivers/pci/hotplug/rpaphp_slot.c | 57 |
5 files changed, 104 insertions, 193 deletions
diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c index f2a73f70e58c..4ada15111af0 100644 --- a/drivers/pci/hotplug/rpadlpar_core.c +++ b/drivers/pci/hotplug/rpadlpar_core.c | |||
@@ -26,6 +26,8 @@ | |||
26 | 26 | ||
27 | static DECLARE_MUTEX(rpadlpar_sem); | 27 | static DECLARE_MUTEX(rpadlpar_sem); |
28 | 28 | ||
29 | #define DLPAR_MODULE_NAME "rpadlpar_io" | ||
30 | |||
29 | #define NODE_TYPE_VIO 1 | 31 | #define NODE_TYPE_VIO 1 |
30 | #define NODE_TYPE_SLOT 2 | 32 | #define NODE_TYPE_SLOT 2 |
31 | #define NODE_TYPE_PHB 3 | 33 | #define NODE_TYPE_PHB 3 |
@@ -93,14 +95,14 @@ static struct device_node *find_dlpar_node(char *drc_name, int *node_type) | |||
93 | return NULL; | 95 | return NULL; |
94 | } | 96 | } |
95 | 97 | ||
96 | static struct slot *find_slot(char *drc_name) | 98 | static struct slot *find_slot(struct device_node *dn) |
97 | { | 99 | { |
98 | struct list_head *tmp, *n; | 100 | struct list_head *tmp, *n; |
99 | struct slot *slot; | 101 | struct slot *slot; |
100 | 102 | ||
101 | list_for_each_safe(tmp, n, &rpaphp_slot_head) { | 103 | list_for_each_safe(tmp, n, &rpaphp_slot_head) { |
102 | slot = list_entry(tmp, struct slot, rpaphp_slot_list); | 104 | slot = list_entry(tmp, struct slot, rpaphp_slot_list); |
103 | if (strcmp(slot->location, drc_name) == 0) | 105 | if (slot->dn == dn) |
104 | return slot; | 106 | return slot; |
105 | } | 107 | } |
106 | 108 | ||
@@ -214,6 +216,9 @@ static int dlpar_add_pci_slot(char *drc_name, struct device_node *dn) | |||
214 | struct pci_dev *dev; | 216 | struct pci_dev *dev; |
215 | int rc; | 217 | int rc; |
216 | 218 | ||
219 | if (rpaphp_find_pci_bus(dn)) | ||
220 | return -EINVAL; | ||
221 | |||
217 | /* Add pci bus */ | 222 | /* Add pci bus */ |
218 | dev = dlpar_pci_add_bus(dn); | 223 | dev = dlpar_pci_add_bus(dn); |
219 | if (!dev) { | 224 | if (!dev) { |
@@ -261,36 +266,32 @@ static int dlpar_remove_root_bus(struct pci_controller *phb) | |||
261 | return 0; | 266 | return 0; |
262 | } | 267 | } |
263 | 268 | ||
264 | static int dlpar_remove_phb(struct slot *slot) | 269 | static int dlpar_remove_phb(char *drc_name, struct device_node *dn) |
265 | { | 270 | { |
266 | struct pci_controller *phb; | 271 | struct slot *slot; |
267 | struct device_node *dn; | ||
268 | int rc = 0; | 272 | int rc = 0; |
269 | 273 | ||
270 | dn = slot->dn; | 274 | if (!rpaphp_find_pci_bus(dn)) |
271 | if (!dn) { | 275 | return -EINVAL; |
272 | printk(KERN_ERR "%s: unexpected NULL slot device node\n", | ||
273 | __FUNCTION__); | ||
274 | return -EIO; | ||
275 | } | ||
276 | |||
277 | phb = dn->phb; | ||
278 | if (!phb) { | ||
279 | printk(KERN_ERR "%s: unexpected NULL phb pointer\n", | ||
280 | __FUNCTION__); | ||
281 | return -EIO; | ||
282 | } | ||
283 | 276 | ||
284 | if (rpaphp_remove_slot(slot)) { | 277 | slot = find_slot(dn); |
285 | printk(KERN_ERR "%s: unable to remove hotplug slot %s\n", | 278 | if (slot) { |
286 | __FUNCTION__, slot->location); | 279 | /* Remove hotplug slot */ |
287 | return -EIO; | 280 | if (rpaphp_remove_slot(slot)) { |
281 | printk(KERN_ERR | ||
282 | "%s: unable to remove hotplug slot %s\n", | ||
283 | __FUNCTION__, drc_name); | ||
284 | return -EIO; | ||
285 | } | ||
288 | } | 286 | } |
289 | 287 | ||
290 | rc = dlpar_remove_root_bus(phb); | 288 | BUG_ON(!dn->phb); |
289 | rc = dlpar_remove_root_bus(dn->phb); | ||
291 | if (rc < 0) | 290 | if (rc < 0) |
292 | return rc; | 291 | return rc; |
293 | 292 | ||
293 | dn->phb = NULL; | ||
294 | |||
294 | return 0; | 295 | return 0; |
295 | } | 296 | } |
296 | 297 | ||
@@ -298,9 +299,14 @@ static int dlpar_add_phb(char *drc_name, struct device_node *dn) | |||
298 | { | 299 | { |
299 | struct pci_controller *phb; | 300 | struct pci_controller *phb; |
300 | 301 | ||
302 | if (dn->phb) { | ||
303 | /* PHB already exists */ | ||
304 | return -EINVAL; | ||
305 | } | ||
306 | |||
301 | phb = init_phb_dynamic(dn); | 307 | phb = init_phb_dynamic(dn); |
302 | if (!phb) | 308 | if (!phb) |
303 | return -EINVAL; | 309 | return -EIO; |
304 | 310 | ||
305 | if (rpaphp_add_slot(dn)) { | 311 | if (rpaphp_add_slot(dn)) { |
306 | printk(KERN_ERR "%s: unable to add hotplug slot %s\n", | 312 | printk(KERN_ERR "%s: unable to add hotplug slot %s\n", |
@@ -310,6 +316,20 @@ static int dlpar_add_phb(char *drc_name, struct device_node *dn) | |||
310 | return 0; | 316 | return 0; |
311 | } | 317 | } |
312 | 318 | ||
319 | static int dlpar_add_vio_slot(char *drc_name, struct device_node *dn) | ||
320 | { | ||
321 | if (vio_find_node(dn)) | ||
322 | return -EINVAL; | ||
323 | |||
324 | if (!vio_register_device_node(dn)) { | ||
325 | printk(KERN_ERR | ||
326 | "%s: failed to register vio node %s\n", | ||
327 | __FUNCTION__, drc_name); | ||
328 | return -EIO; | ||
329 | } | ||
330 | return 0; | ||
331 | } | ||
332 | |||
313 | /** | 333 | /** |
314 | * dlpar_add_slot - DLPAR add an I/O Slot | 334 | * dlpar_add_slot - DLPAR add an I/O Slot |
315 | * @drc_name: drc-name of newly added slot | 335 | * @drc_name: drc-name of newly added slot |
@@ -327,17 +347,11 @@ int dlpar_add_slot(char *drc_name) | |||
327 | { | 347 | { |
328 | struct device_node *dn = NULL; | 348 | struct device_node *dn = NULL; |
329 | int node_type; | 349 | int node_type; |
330 | int rc; | 350 | int rc = -EIO; |
331 | 351 | ||
332 | if (down_interruptible(&rpadlpar_sem)) | 352 | if (down_interruptible(&rpadlpar_sem)) |
333 | return -ERESTARTSYS; | 353 | return -ERESTARTSYS; |
334 | 354 | ||
335 | /* Check for existing hotplug slot */ | ||
336 | if (find_slot(drc_name)) { | ||
337 | rc = -EINVAL; | ||
338 | goto exit; | ||
339 | } | ||
340 | |||
341 | /* Find newly added node */ | 355 | /* Find newly added node */ |
342 | dn = find_dlpar_node(drc_name, &node_type); | 356 | dn = find_dlpar_node(drc_name, &node_type); |
343 | if (!dn) { | 357 | if (!dn) { |
@@ -345,32 +359,19 @@ int dlpar_add_slot(char *drc_name) | |||
345 | goto exit; | 359 | goto exit; |
346 | } | 360 | } |
347 | 361 | ||
348 | rc = -EIO; | ||
349 | switch (node_type) { | 362 | switch (node_type) { |
350 | case NODE_TYPE_VIO: | 363 | case NODE_TYPE_VIO: |
351 | if (!vio_register_device_node(dn)) { | 364 | rc = dlpar_add_vio_slot(drc_name, dn); |
352 | printk(KERN_ERR | ||
353 | "%s: failed to register vio node %s\n", | ||
354 | __FUNCTION__, drc_name); | ||
355 | goto exit; | ||
356 | } | ||
357 | break; | 365 | break; |
358 | case NODE_TYPE_SLOT: | 366 | case NODE_TYPE_SLOT: |
359 | rc = dlpar_add_pci_slot(drc_name, dn); | 367 | rc = dlpar_add_pci_slot(drc_name, dn); |
360 | if (rc) | ||
361 | goto exit; | ||
362 | break; | 368 | break; |
363 | case NODE_TYPE_PHB: | 369 | case NODE_TYPE_PHB: |
364 | rc = dlpar_add_phb(drc_name, dn); | 370 | rc = dlpar_add_phb(drc_name, dn); |
365 | if (rc) | ||
366 | goto exit; | ||
367 | break; | 371 | break; |
368 | default: | ||
369 | printk("%s: unexpected node type\n", __FUNCTION__); | ||
370 | goto exit; | ||
371 | } | 372 | } |
372 | 373 | ||
373 | rc = 0; | 374 | printk(KERN_INFO "%s: slot %s added\n", DLPAR_MODULE_NAME, drc_name); |
374 | exit: | 375 | exit: |
375 | up(&rpadlpar_sem); | 376 | up(&rpadlpar_sem); |
376 | return rc; | 377 | return rc; |
@@ -384,18 +385,15 @@ exit: | |||
384 | * of an I/O Slot. | 385 | * of an I/O Slot. |
385 | * Return Codes: | 386 | * Return Codes: |
386 | * 0 Success | 387 | * 0 Success |
387 | * -EIO Internal Error | 388 | * -EINVAL Vio dev doesn't exist |
388 | */ | 389 | */ |
389 | static int dlpar_remove_vio_slot(struct device_node *dn, char *drc_name) | 390 | static int dlpar_remove_vio_slot(char *drc_name, struct device_node *dn) |
390 | { | 391 | { |
391 | struct vio_dev *vio_dev; | 392 | struct vio_dev *vio_dev; |
392 | 393 | ||
393 | vio_dev = vio_find_node(dn); | 394 | vio_dev = vio_find_node(dn); |
394 | if (!vio_dev) { | 395 | if (!vio_dev) |
395 | printk(KERN_ERR "%s: %s does not correspond to a vio dev\n", | 396 | return -EINVAL; |
396 | __FUNCTION__, drc_name); | ||
397 | return -EIO; | ||
398 | } | ||
399 | 397 | ||
400 | vio_unregister_device(vio_dev); | 398 | vio_unregister_device(vio_dev); |
401 | return 0; | 399 | return 0; |
@@ -412,15 +410,24 @@ static int dlpar_remove_vio_slot(struct device_node *dn, char *drc_name) | |||
412 | * -ENODEV Not a valid drc_name | 410 | * -ENODEV Not a valid drc_name |
413 | * -EIO Internal PCI Error | 411 | * -EIO Internal PCI Error |
414 | */ | 412 | */ |
415 | int dlpar_remove_pci_slot(struct slot *slot, char *drc_name) | 413 | int dlpar_remove_pci_slot(char *drc_name, struct device_node *dn) |
416 | { | 414 | { |
417 | struct pci_bus *bus = slot->bus; | 415 | struct pci_bus *bus; |
416 | struct slot *slot; | ||
418 | 417 | ||
419 | /* Remove hotplug slot */ | 418 | bus = rpaphp_find_pci_bus(dn); |
420 | if (rpaphp_remove_slot(slot)) { | 419 | if (!bus) |
421 | printk(KERN_ERR "%s: unable to remove hotplug slot %s\n", | 420 | return -EINVAL; |
422 | __FUNCTION__, drc_name); | 421 | |
423 | return -EIO; | 422 | slot = find_slot(dn); |
423 | if (slot) { | ||
424 | /* Remove hotplug slot */ | ||
425 | if (rpaphp_remove_slot(slot)) { | ||
426 | printk(KERN_ERR | ||
427 | "%s: unable to remove hotplug slot %s\n", | ||
428 | __FUNCTION__, drc_name); | ||
429 | return -EIO; | ||
430 | } | ||
424 | } | 431 | } |
425 | 432 | ||
426 | if (unmap_bus_range(bus)) { | 433 | if (unmap_bus_range(bus)) { |
@@ -450,7 +457,6 @@ int dlpar_remove_pci_slot(struct slot *slot, char *drc_name) | |||
450 | int dlpar_remove_slot(char *drc_name) | 457 | int dlpar_remove_slot(char *drc_name) |
451 | { | 458 | { |
452 | struct device_node *dn; | 459 | struct device_node *dn; |
453 | struct slot *slot; | ||
454 | int node_type; | 460 | int node_type; |
455 | int rc = 0; | 461 | int rc = 0; |
456 | 462 | ||
@@ -463,22 +469,18 @@ int dlpar_remove_slot(char *drc_name) | |||
463 | goto exit; | 469 | goto exit; |
464 | } | 470 | } |
465 | 471 | ||
466 | if (node_type == NODE_TYPE_VIO) { | 472 | switch (node_type) { |
467 | rc = dlpar_remove_vio_slot(dn, drc_name); | 473 | case NODE_TYPE_VIO: |
468 | } else { | 474 | rc = dlpar_remove_vio_slot(drc_name, dn); |
469 | slot = find_slot(drc_name); | 475 | break; |
470 | if (!slot) { | 476 | case NODE_TYPE_PHB: |
471 | rc = -EINVAL; | 477 | rc = dlpar_remove_phb(drc_name, dn); |
472 | goto exit; | 478 | break; |
473 | } | 479 | case NODE_TYPE_SLOT: |
474 | 480 | rc = dlpar_remove_pci_slot(drc_name, dn); | |
475 | if (node_type == NODE_TYPE_PHB) | 481 | break; |
476 | rc = dlpar_remove_phb(slot); | ||
477 | else { | ||
478 | /* NODE_TYPE_SLOT */ | ||
479 | rc = dlpar_remove_pci_slot(slot, drc_name); | ||
480 | } | ||
481 | } | 482 | } |
483 | printk(KERN_INFO "%s: slot %s removed\n", DLPAR_MODULE_NAME, drc_name); | ||
482 | exit: | 484 | exit: |
483 | up(&rpadlpar_sem); | 485 | up(&rpadlpar_sem); |
484 | return rc; | 486 | return rc; |
diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h index 064a0d66e3c5..61d94d1e29cb 100644 --- a/drivers/pci/hotplug/rpaphp.h +++ b/drivers/pci/hotplug/rpaphp.h | |||
@@ -30,10 +30,6 @@ | |||
30 | #include <linux/pci.h> | 30 | #include <linux/pci.h> |
31 | #include "pci_hotplug.h" | 31 | #include "pci_hotplug.h" |
32 | 32 | ||
33 | #define PHB 2 | ||
34 | #define HOTPLUG 1 | ||
35 | #define EMBEDDED 0 | ||
36 | |||
37 | #define DR_INDICATOR 9002 | 33 | #define DR_INDICATOR 9002 |
38 | #define DR_ENTITY_SENSE 9003 | 34 | #define DR_ENTITY_SENSE 9003 |
39 | 35 | ||
@@ -79,7 +75,6 @@ struct slot { | |||
79 | u32 power_domain; | 75 | u32 power_domain; |
80 | char *name; | 76 | char *name; |
81 | char *location; | 77 | char *location; |
82 | u8 removable; | ||
83 | struct device_node *dn; | 78 | struct device_node *dn; |
84 | struct pci_bus *bus; | 79 | struct pci_bus *bus; |
85 | struct list_head *pci_devs; | 80 | struct list_head *pci_devs; |
@@ -93,6 +88,7 @@ extern int num_slots; | |||
93 | /* function prototypes */ | 88 | /* function prototypes */ |
94 | 89 | ||
95 | /* rpaphp_pci.c */ | 90 | /* rpaphp_pci.c */ |
91 | extern struct pci_bus *rpaphp_find_pci_bus(struct device_node *dn); | ||
96 | extern int rpaphp_claim_resource(struct pci_dev *dev, int resource); | 92 | extern int rpaphp_claim_resource(struct pci_dev *dev, int resource); |
97 | extern int rpaphp_enable_pci_slot(struct slot *slot); | 93 | extern int rpaphp_enable_pci_slot(struct slot *slot); |
98 | extern int register_pci_slot(struct slot *slot); | 94 | extern int register_pci_slot(struct slot *slot); |
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c index 22ec0993cf89..c830ff0acdc3 100644 --- a/drivers/pci/hotplug/rpaphp_core.c +++ b/drivers/pci/hotplug/rpaphp_core.c | |||
@@ -307,34 +307,6 @@ static int is_php_dn(struct device_node *dn, int **indexes, int **names, | |||
307 | return 0; | 307 | return 0; |
308 | } | 308 | } |
309 | 309 | ||
310 | static int is_dr_dn(struct device_node *dn, int **indexes, int **names, | ||
311 | int **types, int **power_domains, int **my_drc_index) | ||
312 | { | ||
313 | int rc; | ||
314 | |||
315 | *my_drc_index = (int *) get_property(dn, "ibm,my-drc-index", NULL); | ||
316 | if(!*my_drc_index) | ||
317 | return (0); | ||
318 | |||
319 | if (!dn->parent) | ||
320 | return (0); | ||
321 | |||
322 | rc = get_children_props(dn->parent, indexes, names, types, | ||
323 | power_domains); | ||
324 | return (rc >= 0); | ||
325 | } | ||
326 | |||
327 | static inline int is_vdevice_root(struct device_node *dn) | ||
328 | { | ||
329 | return !strcmp(dn->name, "vdevice"); | ||
330 | } | ||
331 | |||
332 | int is_dlpar_type(const char *type_str) | ||
333 | { | ||
334 | /* Only register DLPAR-capable nodes of drc-type PHB or SLOT */ | ||
335 | return (!strcmp(type_str, "PHB") || !strcmp(type_str, "SLOT")); | ||
336 | } | ||
337 | |||
338 | /**************************************************************** | 310 | /**************************************************************** |
339 | * rpaphp not only registers PCI hotplug slots(HOTPLUG), | 311 | * rpaphp not only registers PCI hotplug slots(HOTPLUG), |
340 | * but also logical DR slots(EMBEDDED). | 312 | * but also logical DR slots(EMBEDDED). |
@@ -346,7 +318,7 @@ int rpaphp_add_slot(struct device_node *dn) | |||
346 | { | 318 | { |
347 | struct slot *slot; | 319 | struct slot *slot; |
348 | int retval = 0; | 320 | int retval = 0; |
349 | int i, *my_drc_index, slot_type; | 321 | int i; |
350 | int *indexes, *names, *types, *power_domains; | 322 | int *indexes, *names, *types, *power_domains; |
351 | char *name, *type; | 323 | char *name, *type; |
352 | 324 | ||
@@ -354,40 +326,25 @@ int rpaphp_add_slot(struct device_node *dn) | |||
354 | 326 | ||
355 | /* register PCI devices */ | 327 | /* register PCI devices */ |
356 | if (dn->name != 0 && strcmp(dn->name, "pci") == 0) { | 328 | if (dn->name != 0 && strcmp(dn->name, "pci") == 0) { |
357 | if (is_php_dn(dn, &indexes, &names, &types, &power_domains)) | 329 | if (!is_php_dn(dn, &indexes, &names, &types, &power_domains)) |
358 | slot_type = HOTPLUG; | 330 | goto exit; |
359 | else if (is_dr_dn(dn, &indexes, &names, &types, &power_domains, &my_drc_index)) | ||
360 | slot_type = EMBEDDED; | ||
361 | else goto exit; | ||
362 | 331 | ||
363 | name = (char *) &names[1]; | 332 | name = (char *) &names[1]; |
364 | type = (char *) &types[1]; | 333 | type = (char *) &types[1]; |
365 | for (i = 0; i < indexes[0]; i++, | 334 | for (i = 0; i < indexes[0]; i++, |
366 | name += (strlen(name) + 1), type += (strlen(type) + 1)) { | 335 | name += (strlen(name) + 1), type += (strlen(type) + 1)) { |
367 | 336 | ||
368 | if (slot_type == HOTPLUG || | 337 | if (!(slot = alloc_slot_struct(dn, indexes[i + 1], name, |
369 | (slot_type == EMBEDDED && | 338 | power_domains[i + 1]))) { |
370 | indexes[i + 1] == my_drc_index[0] && | 339 | retval = -ENOMEM; |
371 | is_dlpar_type(type))) { | 340 | goto exit; |
372 | if (!(slot = alloc_slot_struct(dn, indexes[i + 1], name, | 341 | } |
373 | power_domains[i + 1]))) { | 342 | slot->type = simple_strtoul(type, NULL, 10); |
374 | retval = -ENOMEM; | ||
375 | goto exit; | ||
376 | } | ||
377 | if (!strcmp(type, "PHB")) | ||
378 | slot->type = PHB; | ||
379 | else if (slot_type == EMBEDDED) | ||
380 | slot->type = EMBEDDED; | ||
381 | else | ||
382 | slot->type = simple_strtoul(type, NULL, 10); | ||
383 | 343 | ||
384 | dbg(" Found drc-index:0x%x drc-name:%s drc-type:%s\n", | 344 | dbg("Found drc-index:0x%x drc-name:%s drc-type:%s\n", |
385 | indexes[i + 1], name, type); | 345 | indexes[i + 1], name, type); |
386 | 346 | ||
387 | retval = register_pci_slot(slot); | 347 | retval = register_pci_slot(slot); |
388 | if (slot_type == EMBEDDED) | ||
389 | goto exit; | ||
390 | } | ||
391 | } | 348 | } |
392 | } | 349 | } |
393 | exit: | 350 | exit: |
diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c index f2f1cd0f941a..17a0279ebcb9 100644 --- a/drivers/pci/hotplug/rpaphp_pci.c +++ b/drivers/pci/hotplug/rpaphp_pci.c | |||
@@ -49,13 +49,14 @@ static struct pci_bus *find_bus_among_children(struct pci_bus *bus, | |||
49 | return child; | 49 | return child; |
50 | } | 50 | } |
51 | 51 | ||
52 | static struct pci_bus *rpaphp_find_pci_bus(struct device_node *dn) | 52 | struct pci_bus *rpaphp_find_pci_bus(struct device_node *dn) |
53 | { | 53 | { |
54 | if (!dn->phb || !dn->phb->bus) | 54 | if (!dn->phb || !dn->phb->bus) |
55 | return NULL; | 55 | return NULL; |
56 | 56 | ||
57 | return find_bus_among_children(dn->phb->bus, dn); | 57 | return find_bus_among_children(dn->phb->bus, dn); |
58 | } | 58 | } |
59 | EXPORT_SYMBOL_GPL(rpaphp_find_pci_bus); | ||
59 | 60 | ||
60 | int rpaphp_claim_resource(struct pci_dev *dev, int resource) | 61 | int rpaphp_claim_resource(struct pci_dev *dev, int resource) |
61 | { | 62 | { |
@@ -129,10 +130,8 @@ int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value) | |||
129 | if (rc) | 130 | if (rc) |
130 | goto exit; | 131 | goto exit; |
131 | 132 | ||
132 | if ((state == EMPTY) || (slot->type == PHB)) { | 133 | if (state == EMPTY) |
133 | dbg("slot is empty\n"); | ||
134 | *value = EMPTY; | 134 | *value = EMPTY; |
135 | } | ||
136 | else if (state == PRESENT) { | 135 | else if (state == PRESENT) { |
137 | if (!is_init) { | 136 | if (!is_init) { |
138 | /* at run-time slot->state can be changed by */ | 137 | /* at run-time slot->state can be changed by */ |
@@ -423,10 +422,6 @@ int register_pci_slot(struct slot *slot) | |||
423 | { | 422 | { |
424 | int rc = -EINVAL; | 423 | int rc = -EINVAL; |
425 | 424 | ||
426 | if ((slot->type == EMBEDDED) || (slot->type == PHB)) | ||
427 | slot->removable = 0; | ||
428 | else | ||
429 | slot->removable = 1; | ||
430 | if (setup_pci_hotplug_slot_info(slot)) | 425 | if (setup_pci_hotplug_slot_info(slot)) |
431 | goto exit_rc; | 426 | goto exit_rc; |
432 | if (setup_pci_slot(slot)) | 427 | if (setup_pci_slot(slot)) |
diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c index 80402027c015..0e8815495083 100644 --- a/drivers/pci/hotplug/rpaphp_slot.c +++ b/drivers/pci/hotplug/rpaphp_slot.c | |||
@@ -30,35 +30,6 @@ | |||
30 | #include <asm/rtas.h> | 30 | #include <asm/rtas.h> |
31 | #include "rpaphp.h" | 31 | #include "rpaphp.h" |
32 | 32 | ||
33 | static ssize_t removable_read_file (struct hotplug_slot *php_slot, char *buf) | ||
34 | { | ||
35 | u8 value; | ||
36 | int retval = -ENOENT; | ||
37 | struct slot *slot = (struct slot *)php_slot->private; | ||
38 | |||
39 | if (!slot) | ||
40 | return retval; | ||
41 | |||
42 | value = slot->removable; | ||
43 | retval = sprintf (buf, "%d\n", value); | ||
44 | return retval; | ||
45 | } | ||
46 | |||
47 | static struct hotplug_slot_attribute hotplug_slot_attr_removable = { | ||
48 | .attr = {.name = "phy_removable", .mode = S_IFREG | S_IRUGO}, | ||
49 | .show = removable_read_file, | ||
50 | }; | ||
51 | |||
52 | static void rpaphp_sysfs_add_attr_removable (struct hotplug_slot *slot) | ||
53 | { | ||
54 | sysfs_create_file(&slot->kobj, &hotplug_slot_attr_removable.attr); | ||
55 | } | ||
56 | |||
57 | static void rpaphp_sysfs_remove_attr_removable (struct hotplug_slot *slot) | ||
58 | { | ||
59 | sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_removable.attr); | ||
60 | } | ||
61 | |||
62 | static ssize_t location_read_file (struct hotplug_slot *php_slot, char *buf) | 33 | static ssize_t location_read_file (struct hotplug_slot *php_slot, char *buf) |
63 | { | 34 | { |
64 | char *value; | 35 | char *value; |
@@ -176,9 +147,6 @@ int deregister_slot(struct slot *slot) | |||
176 | /* remove "phy_location" file */ | 147 | /* remove "phy_location" file */ |
177 | rpaphp_sysfs_remove_attr_location(php_slot); | 148 | rpaphp_sysfs_remove_attr_location(php_slot); |
178 | 149 | ||
179 | /* remove "phy_removable" file */ | ||
180 | rpaphp_sysfs_remove_attr_removable(php_slot); | ||
181 | |||
182 | retval = pci_hp_deregister(php_slot); | 150 | retval = pci_hp_deregister(php_slot); |
183 | if (retval) | 151 | if (retval) |
184 | err("Problem unregistering a slot %s\n", slot->name); | 152 | err("Problem unregistering a slot %s\n", slot->name); |
@@ -212,9 +180,6 @@ int register_slot(struct slot *slot) | |||
212 | /* create "phy_locatoin" file */ | 180 | /* create "phy_locatoin" file */ |
213 | rpaphp_sysfs_add_attr_location(slot->hotplug_slot); | 181 | rpaphp_sysfs_add_attr_location(slot->hotplug_slot); |
214 | 182 | ||
215 | /* create "phy_removable" file */ | ||
216 | rpaphp_sysfs_add_attr_removable(slot->hotplug_slot); | ||
217 | |||
218 | /* add slot to our internal list */ | 183 | /* add slot to our internal list */ |
219 | dbg("%s adding slot[%s] to rpaphp_slot_list\n", | 184 | dbg("%s adding slot[%s] to rpaphp_slot_list\n", |
220 | __FUNCTION__, slot->name); | 185 | __FUNCTION__, slot->name); |
@@ -230,21 +195,17 @@ int rpaphp_get_power_status(struct slot *slot, u8 * value) | |||
230 | { | 195 | { |
231 | int rc = 0, level; | 196 | int rc = 0, level; |
232 | 197 | ||
233 | if (slot->type == HOTPLUG) { | 198 | rc = rtas_get_power_level(slot->power_domain, &level); |
234 | rc = rtas_get_power_level(slot->power_domain, &level); | 199 | if (rc < 0) { |
235 | if (!rc) { | 200 | err("failed to get power-level for slot(%s), rc=0x%x\n", |
236 | dbg("%s the power level of slot %s(pwd-domain:0x%x) is %d\n", | 201 | slot->location, rc); |
237 | __FUNCTION__, slot->name, slot->power_domain, level); | 202 | return rc; |
238 | *value = level; | ||
239 | } else | ||
240 | err("failed to get power-level for slot(%s), rc=0x%x\n", | ||
241 | slot->location, rc); | ||
242 | } else { | ||
243 | dbg("%s report POWER_ON for EMBEDDED or PHB slot %s\n", | ||
244 | __FUNCTION__, slot->location); | ||
245 | *value = (u8) POWER_ON; | ||
246 | } | 203 | } |
247 | 204 | ||
205 | dbg("%s the power level of slot %s(pwd-domain:0x%x) is %d\n", | ||
206 | __FUNCTION__, slot->name, slot->power_domain, level); | ||
207 | *value = level; | ||
208 | |||
248 | return rc; | 209 | return rc; |
249 | } | 210 | } |
250 | 211 | ||