diff options
author | MUNEDA Takahiro <muneda.takahiro@jp.fujitsu.com> | 2006-02-23 20:56:08 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-03-23 17:35:15 -0500 |
commit | e27da3814170385a4d2797397d706e554635812d (patch) | |
tree | 67d9b838c79ebb6d1bba4a2c3bc85f3a7c3e9798 /drivers/pci/hotplug/acpiphp_core.c | |
parent | 63e5f248c4b748690b5180aa1b4b10eac51bb0e1 (diff) |
[PATCH] acpiphp - slot management fix - V4
o This patch removes IDs (for slots management).
o This patch removes the slot register/unregister processes
from the init/exit phases. Instead, adds these processes
in the bridge add/cleanup phases.
o Currently, this change doesn't have any meanings. But
these changes are needed to support p2p bridge(with
hotplug slot)
Signed-off-by: MUNEDA Takahiro <muneda.takahiro@jp.fujitsu.com>
Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci/hotplug/acpiphp_core.c')
-rw-r--r-- | drivers/pci/hotplug/acpiphp_core.c | 129 |
1 files changed, 61 insertions, 68 deletions
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c index bce71c933478..4f1b0da8e47e 100644 --- a/drivers/pci/hotplug/acpiphp_core.c +++ b/drivers/pci/hotplug/acpiphp_core.c | |||
@@ -44,8 +44,6 @@ | |||
44 | #include "pci_hotplug.h" | 44 | #include "pci_hotplug.h" |
45 | #include "acpiphp.h" | 45 | #include "acpiphp.h" |
46 | 46 | ||
47 | static LIST_HEAD(slot_list); | ||
48 | |||
49 | #define MY_NAME "acpiphp" | 47 | #define MY_NAME "acpiphp" |
50 | 48 | ||
51 | static int debug; | 49 | static int debug; |
@@ -341,62 +339,53 @@ static void release_slot(struct hotplug_slot *hotplug_slot) | |||
341 | kfree(slot); | 339 | kfree(slot); |
342 | } | 340 | } |
343 | 341 | ||
344 | /** | 342 | /* callback routine to initialize 'struct slot' for each slot */ |
345 | * init_slots - initialize 'struct slot' structures for each slot | 343 | int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot) |
346 | * | ||
347 | */ | ||
348 | static int __init init_slots(void) | ||
349 | { | 344 | { |
350 | struct slot *slot; | 345 | struct slot *slot; |
346 | struct hotplug_slot *hotplug_slot; | ||
347 | struct hotplug_slot_info *hotplug_slot_info; | ||
351 | int retval = -ENOMEM; | 348 | int retval = -ENOMEM; |
352 | int i; | 349 | |
353 | 350 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); | |
354 | for (i = 0; i < num_slots; ++i) { | 351 | if (!slot) |
355 | slot = kmalloc(sizeof(struct slot), GFP_KERNEL); | 352 | goto error; |
356 | if (!slot) | 353 | |
357 | goto error; | 354 | slot->hotplug_slot = kzalloc(sizeof(*hotplug_slot), GFP_KERNEL); |
358 | memset(slot, 0, sizeof(struct slot)); | 355 | if (!slot->hotplug_slot) |
359 | 356 | goto error_slot; | |
360 | slot->hotplug_slot = kmalloc(sizeof(struct hotplug_slot), GFP_KERNEL); | 357 | |
361 | if (!slot->hotplug_slot) | 358 | slot->hotplug_slot->info = kzalloc(sizeof(*hotplug_slot_info), |
362 | goto error_slot; | 359 | GFP_KERNEL); |
363 | memset(slot->hotplug_slot, 0, sizeof(struct hotplug_slot)); | 360 | if (!slot->hotplug_slot->info) |
364 | 361 | goto error_hpslot; | |
365 | slot->hotplug_slot->info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); | 362 | |
366 | if (!slot->hotplug_slot->info) | 363 | slot->hotplug_slot->name = kzalloc(SLOT_NAME_SIZE, GFP_KERNEL); |
367 | goto error_hpslot; | 364 | if (!slot->hotplug_slot->name) |
368 | memset(slot->hotplug_slot->info, 0, sizeof(struct hotplug_slot_info)); | 365 | goto error_info; |
369 | 366 | ||
370 | slot->hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); | 367 | slot->hotplug_slot->private = slot; |
371 | if (!slot->hotplug_slot->name) | 368 | slot->hotplug_slot->release = &release_slot; |
372 | goto error_info; | 369 | slot->hotplug_slot->ops = &acpi_hotplug_slot_ops; |
373 | 370 | ||
374 | slot->number = i; | 371 | slot->acpi_slot = acpiphp_slot; |
375 | 372 | slot->hotplug_slot->info->power_status = acpiphp_get_power_status(slot->acpi_slot); | |
376 | slot->hotplug_slot->private = slot; | 373 | slot->hotplug_slot->info->attention_status = 0; |
377 | slot->hotplug_slot->release = &release_slot; | 374 | slot->hotplug_slot->info->latch_status = acpiphp_get_latch_status(slot->acpi_slot); |
378 | slot->hotplug_slot->ops = &acpi_hotplug_slot_ops; | 375 | slot->hotplug_slot->info->adapter_status = acpiphp_get_adapter_status(slot->acpi_slot); |
379 | 376 | slot->hotplug_slot->info->max_bus_speed = PCI_SPEED_UNKNOWN; | |
380 | slot->acpi_slot = get_slot_from_id(i); | 377 | slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN; |
381 | slot->hotplug_slot->info->power_status = acpiphp_get_power_status(slot->acpi_slot); | 378 | |
382 | slot->hotplug_slot->info->attention_status = 0; | 379 | acpiphp_slot->slot = slot; |
383 | slot->hotplug_slot->info->latch_status = acpiphp_get_latch_status(slot->acpi_slot); | 380 | make_slot_name(slot); |
384 | slot->hotplug_slot->info->adapter_status = acpiphp_get_adapter_status(slot->acpi_slot); | 381 | |
385 | slot->hotplug_slot->info->max_bus_speed = PCI_SPEED_UNKNOWN; | 382 | retval = pci_hp_register(slot->hotplug_slot); |
386 | slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN; | 383 | if (retval) { |
387 | 384 | err("pci_hp_register failed with error %d\n", retval); | |
388 | make_slot_name(slot); | 385 | goto error_name; |
389 | 386 | } | |
390 | retval = pci_hp_register(slot->hotplug_slot); | 387 | |
391 | if (retval) { | 388 | info("Slot [%s] registered\n", slot->hotplug_slot->name); |
392 | err("pci_hp_register failed with error %d\n", retval); | ||
393 | goto error_name; | ||
394 | } | ||
395 | |||
396 | /* add slot to our internal list */ | ||
397 | list_add(&slot->slot_list, &slot_list); | ||
398 | info("Slot [%s] registered\n", slot->hotplug_slot->name); | ||
399 | } | ||
400 | 389 | ||
401 | return 0; | 390 | return 0; |
402 | error_name: | 391 | error_name: |
@@ -412,17 +401,16 @@ error: | |||
412 | } | 401 | } |
413 | 402 | ||
414 | 403 | ||
415 | static void __exit cleanup_slots (void) | 404 | void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *acpiphp_slot) |
416 | { | 405 | { |
417 | struct list_head *tmp, *n; | 406 | struct slot *slot = acpiphp_slot->slot; |
418 | struct slot *slot; | 407 | int retval = 0; |
419 | 408 | ||
420 | list_for_each_safe (tmp, n, &slot_list) { | 409 | info ("Slot [%s] unregistered\n", slot->hotplug_slot->name); |
421 | /* memory will be freed in release_slot callback */ | 410 | |
422 | slot = list_entry(tmp, struct slot, slot_list); | 411 | retval = pci_hp_deregister(slot->hotplug_slot); |
423 | list_del(&slot->slot_list); | 412 | if (retval) |
424 | pci_hp_deregister(slot->hotplug_slot); | 413 | err("pci_hp_deregister failed with error %d\n", retval); |
425 | } | ||
426 | } | 414 | } |
427 | 415 | ||
428 | 416 | ||
@@ -439,16 +427,21 @@ static int __init acpiphp_init(void) | |||
439 | 427 | ||
440 | /* read all the ACPI info from the system */ | 428 | /* read all the ACPI info from the system */ |
441 | retval = init_acpi(); | 429 | retval = init_acpi(); |
442 | if (retval && !(docking_station)) | ||
443 | return retval; | ||
444 | 430 | ||
445 | return init_slots(); | 431 | /* if we have found a docking station, we should |
432 | * go ahead and load even if init_acpi has found | ||
433 | * no slots. This handles the case when the _DCK | ||
434 | * method not defined under the actual dock bridge | ||
435 | */ | ||
436 | if (docking_station) | ||
437 | return 0; | ||
438 | else | ||
439 | return retval; | ||
446 | } | 440 | } |
447 | 441 | ||
448 | 442 | ||
449 | static void __exit acpiphp_exit(void) | 443 | static void __exit acpiphp_exit(void) |
450 | { | 444 | { |
451 | cleanup_slots(); | ||
452 | /* deallocate internal data structures etc. */ | 445 | /* deallocate internal data structures etc. */ |
453 | acpiphp_glue_exit(); | 446 | acpiphp_glue_exit(); |
454 | 447 | ||