.. | .. |
---|
52 | 52 | static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 value) |
---|
53 | 53 | { |
---|
54 | 54 | int rc; |
---|
55 | | - struct slot *slot = (struct slot *)hotplug_slot->private; |
---|
| 55 | + struct slot *slot = to_slot(hotplug_slot); |
---|
56 | 56 | |
---|
57 | 57 | switch (value) { |
---|
58 | 58 | case 0: |
---|
.. | .. |
---|
66 | 66 | |
---|
67 | 67 | rc = rtas_set_indicator(DR_INDICATOR, slot->index, value); |
---|
68 | 68 | if (!rc) |
---|
69 | | - hotplug_slot->info->attention_status = value; |
---|
| 69 | + slot->attention_status = value; |
---|
70 | 70 | |
---|
71 | 71 | return rc; |
---|
72 | 72 | } |
---|
.. | .. |
---|
79 | 79 | static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value) |
---|
80 | 80 | { |
---|
81 | 81 | int retval, level; |
---|
82 | | - struct slot *slot = (struct slot *)hotplug_slot->private; |
---|
| 82 | + struct slot *slot = to_slot(hotplug_slot); |
---|
83 | 83 | |
---|
84 | 84 | retval = rtas_get_power_level(slot->power_domain, &level); |
---|
85 | 85 | if (!retval) |
---|
.. | .. |
---|
94 | 94 | */ |
---|
95 | 95 | static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value) |
---|
96 | 96 | { |
---|
97 | | - struct slot *slot = (struct slot *)hotplug_slot->private; |
---|
98 | | - *value = slot->hotplug_slot->info->attention_status; |
---|
| 97 | + struct slot *slot = to_slot(hotplug_slot); |
---|
| 98 | + *value = slot->attention_status; |
---|
99 | 99 | return 0; |
---|
100 | 100 | } |
---|
101 | 101 | |
---|
102 | 102 | static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value) |
---|
103 | 103 | { |
---|
104 | | - struct slot *slot = (struct slot *)hotplug_slot->private; |
---|
| 104 | + struct slot *slot = to_slot(hotplug_slot); |
---|
105 | 105 | int rc, state; |
---|
106 | 106 | |
---|
107 | 107 | rc = rpaphp_get_sensor_state(slot, &state); |
---|
.. | .. |
---|
185 | 185 | |
---|
186 | 186 | |
---|
187 | 187 | /* Verify the existence of 'drc_name' and/or 'drc_type' within the |
---|
188 | | - * current node. First obtain it's my-drc-index property. Next, |
---|
189 | | - * obtain the DRC info from it's parent. Use the my-drc-index for |
---|
| 188 | + * current node. First obtain its my-drc-index property. Next, |
---|
| 189 | + * obtain the DRC info from its parent. Use the my-drc-index for |
---|
190 | 190 | * correlation, and obtain/validate the requested properties. |
---|
191 | 191 | */ |
---|
192 | 192 | |
---|
.. | .. |
---|
288 | 288 | |
---|
289 | 289 | static int is_php_type(char *drc_type) |
---|
290 | 290 | { |
---|
291 | | - unsigned long value; |
---|
292 | 291 | char *endptr; |
---|
293 | 292 | |
---|
294 | 293 | /* PCI Hotplug nodes have an integer for drc_type */ |
---|
295 | | - value = simple_strtoul(drc_type, &endptr, 10); |
---|
| 294 | + simple_strtoul(drc_type, &endptr, 10); |
---|
296 | 295 | if (endptr == drc_type) |
---|
297 | 296 | return 0; |
---|
298 | 297 | |
---|
.. | .. |
---|
330 | 329 | return 1; |
---|
331 | 330 | } |
---|
332 | 331 | |
---|
333 | | -/** |
---|
334 | | - * rpaphp_add_slot -- declare a hotplug slot to the hotplug subsystem. |
---|
335 | | - * @dn: device node of slot |
---|
336 | | - * |
---|
337 | | - * This subroutine will register a hotpluggable slot with the |
---|
338 | | - * PCI hotplug infrastructure. This routine is typically called |
---|
339 | | - * during boot time, if the hotplug slots are present at boot time, |
---|
340 | | - * or is called later, by the dlpar add code, if the slot is |
---|
341 | | - * being dynamically added during runtime. |
---|
342 | | - * |
---|
343 | | - * If the device node points at an embedded (built-in) slot, this |
---|
344 | | - * routine will just return without doing anything, since embedded |
---|
345 | | - * slots cannot be hotplugged. |
---|
346 | | - * |
---|
347 | | - * To remove a slot, it suffices to call rpaphp_deregister_slot(). |
---|
348 | | - */ |
---|
349 | | -int rpaphp_add_slot(struct device_node *dn) |
---|
| 332 | +static int rpaphp_drc_info_add_slot(struct device_node *dn) |
---|
| 333 | +{ |
---|
| 334 | + struct slot *slot; |
---|
| 335 | + struct property *info; |
---|
| 336 | + struct of_drc_info drc; |
---|
| 337 | + char drc_name[MAX_DRC_NAME_LEN]; |
---|
| 338 | + const __be32 *cur; |
---|
| 339 | + u32 count; |
---|
| 340 | + int retval = 0; |
---|
| 341 | + |
---|
| 342 | + info = of_find_property(dn, "ibm,drc-info", NULL); |
---|
| 343 | + if (!info) |
---|
| 344 | + return 0; |
---|
| 345 | + |
---|
| 346 | + cur = of_prop_next_u32(info, NULL, &count); |
---|
| 347 | + if (cur) |
---|
| 348 | + cur++; |
---|
| 349 | + else |
---|
| 350 | + return 0; |
---|
| 351 | + |
---|
| 352 | + of_read_drc_info_cell(&info, &cur, &drc); |
---|
| 353 | + if (!is_php_type(drc.drc_type)) |
---|
| 354 | + return 0; |
---|
| 355 | + |
---|
| 356 | + sprintf(drc_name, "%s%d", drc.drc_name_prefix, drc.drc_name_suffix_start); |
---|
| 357 | + |
---|
| 358 | + slot = alloc_slot_struct(dn, drc.drc_index_start, drc_name, drc.drc_power_domain); |
---|
| 359 | + if (!slot) |
---|
| 360 | + return -ENOMEM; |
---|
| 361 | + |
---|
| 362 | + slot->type = simple_strtoul(drc.drc_type, NULL, 10); |
---|
| 363 | + retval = rpaphp_enable_slot(slot); |
---|
| 364 | + if (!retval) |
---|
| 365 | + retval = rpaphp_register_slot(slot); |
---|
| 366 | + |
---|
| 367 | + if (retval) |
---|
| 368 | + dealloc_slot_struct(slot); |
---|
| 369 | + |
---|
| 370 | + return retval; |
---|
| 371 | +} |
---|
| 372 | + |
---|
| 373 | +static int rpaphp_drc_add_slot(struct device_node *dn) |
---|
350 | 374 | { |
---|
351 | 375 | struct slot *slot; |
---|
352 | 376 | int retval = 0; |
---|
353 | 377 | int i; |
---|
354 | 378 | const __be32 *indexes, *names, *types, *power_domains; |
---|
355 | 379 | char *name, *type; |
---|
356 | | - |
---|
357 | | - if (!dn->name || strcmp(dn->name, "pci")) |
---|
358 | | - return 0; |
---|
359 | 380 | |
---|
360 | 381 | /* If this is not a hotplug slot, return without doing anything. */ |
---|
361 | 382 | if (!is_php_dn(dn, &indexes, &names, &types, &power_domains)) |
---|
.. | .. |
---|
395 | 416 | /* XXX FIXME: reports a failure only if last entry in loop failed */ |
---|
396 | 417 | return retval; |
---|
397 | 418 | } |
---|
| 419 | + |
---|
| 420 | +/** |
---|
| 421 | + * rpaphp_add_slot -- declare a hotplug slot to the hotplug subsystem. |
---|
| 422 | + * @dn: device node of slot |
---|
| 423 | + * |
---|
| 424 | + * This subroutine will register a hotpluggable slot with the |
---|
| 425 | + * PCI hotplug infrastructure. This routine is typically called |
---|
| 426 | + * during boot time, if the hotplug slots are present at boot time, |
---|
| 427 | + * or is called later, by the dlpar add code, if the slot is |
---|
| 428 | + * being dynamically added during runtime. |
---|
| 429 | + * |
---|
| 430 | + * If the device node points at an embedded (built-in) slot, this |
---|
| 431 | + * routine will just return without doing anything, since embedded |
---|
| 432 | + * slots cannot be hotplugged. |
---|
| 433 | + * |
---|
| 434 | + * To remove a slot, it suffices to call rpaphp_deregister_slot(). |
---|
| 435 | + */ |
---|
| 436 | +int rpaphp_add_slot(struct device_node *dn) |
---|
| 437 | +{ |
---|
| 438 | + if (!of_node_name_eq(dn, "pci")) |
---|
| 439 | + return 0; |
---|
| 440 | + |
---|
| 441 | + if (of_find_property(dn, "ibm,drc-info", NULL)) |
---|
| 442 | + return rpaphp_drc_info_add_slot(dn); |
---|
| 443 | + else |
---|
| 444 | + return rpaphp_drc_add_slot(dn); |
---|
| 445 | +} |
---|
398 | 446 | EXPORT_SYMBOL_GPL(rpaphp_add_slot); |
---|
399 | 447 | |
---|
400 | 448 | static void __exit cleanup_slots(void) |
---|
.. | .. |
---|
409 | 457 | list_for_each_entry_safe(slot, next, &rpaphp_slot_head, |
---|
410 | 458 | rpaphp_slot_list) { |
---|
411 | 459 | list_del(&slot->rpaphp_slot_list); |
---|
412 | | - pci_hp_deregister(slot->hotplug_slot); |
---|
| 460 | + pci_hp_deregister(&slot->hotplug_slot); |
---|
413 | 461 | dealloc_slot_struct(slot); |
---|
414 | 462 | } |
---|
415 | | - return; |
---|
416 | 463 | } |
---|
417 | 464 | |
---|
418 | 465 | static int __init rpaphp_init(void) |
---|
.. | .. |
---|
434 | 481 | |
---|
435 | 482 | static int enable_slot(struct hotplug_slot *hotplug_slot) |
---|
436 | 483 | { |
---|
437 | | - struct slot *slot = (struct slot *)hotplug_slot->private; |
---|
| 484 | + struct slot *slot = to_slot(hotplug_slot); |
---|
438 | 485 | int state; |
---|
439 | 486 | int retval; |
---|
440 | 487 | |
---|
.. | .. |
---|
446 | 493 | return retval; |
---|
447 | 494 | |
---|
448 | 495 | if (state == PRESENT) { |
---|
| 496 | + pseries_eeh_init_edev_recursive(PCI_DN(slot->dn)); |
---|
| 497 | + |
---|
449 | 498 | pci_lock_rescan_remove(); |
---|
450 | 499 | pci_hp_add_devices(slot->bus); |
---|
451 | 500 | pci_unlock_rescan_remove(); |
---|
.. | .. |
---|
464 | 513 | |
---|
465 | 514 | static int disable_slot(struct hotplug_slot *hotplug_slot) |
---|
466 | 515 | { |
---|
467 | | - struct slot *slot = (struct slot *)hotplug_slot->private; |
---|
| 516 | + struct slot *slot = to_slot(hotplug_slot); |
---|
468 | 517 | if (slot->state == NOT_CONFIGURED) |
---|
469 | 518 | return -EINVAL; |
---|
470 | 519 | |
---|
.. | .. |
---|
477 | 526 | return 0; |
---|
478 | 527 | } |
---|
479 | 528 | |
---|
480 | | -struct hotplug_slot_ops rpaphp_hotplug_slot_ops = { |
---|
| 529 | +const struct hotplug_slot_ops rpaphp_hotplug_slot_ops = { |
---|
481 | 530 | .enable_slot = enable_slot, |
---|
482 | 531 | .disable_slot = disable_slot, |
---|
483 | 532 | .set_attention_status = set_attention_status, |
---|