diff options
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/of/platform.c | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 500436f9be7f..0197725e033a 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c | |||
| @@ -422,6 +422,7 @@ static int of_platform_bus_create(struct device_node *bus, | |||
| 422 | break; | 422 | break; |
| 423 | } | 423 | } |
| 424 | } | 424 | } |
| 425 | of_node_set_flag(bus, OF_POPULATED_BUS); | ||
| 425 | return rc; | 426 | return rc; |
| 426 | } | 427 | } |
| 427 | 428 | ||
| @@ -508,19 +509,13 @@ EXPORT_SYMBOL_GPL(of_platform_populate); | |||
| 508 | 509 | ||
| 509 | static int of_platform_device_destroy(struct device *dev, void *data) | 510 | static int of_platform_device_destroy(struct device *dev, void *data) |
| 510 | { | 511 | { |
| 511 | bool *children_left = data; | ||
| 512 | |||
| 513 | /* Do not touch devices not populated from the device tree */ | 512 | /* Do not touch devices not populated from the device tree */ |
| 514 | if (!dev->of_node || !of_node_check_flag(dev->of_node, OF_POPULATED)) { | 513 | if (!dev->of_node || !of_node_check_flag(dev->of_node, OF_POPULATED)) |
| 515 | *children_left = true; | ||
| 516 | return 0; | 514 | return 0; |
| 517 | } | ||
| 518 | 515 | ||
| 519 | /* Recurse, but don't touch this device if it has any children left */ | 516 | /* Recurse for any nodes that were treated as busses */ |
| 520 | if (of_platform_depopulate(dev) != 0) { | 517 | if (of_node_check_flag(dev->of_node, OF_POPULATED_BUS)) |
| 521 | *children_left = true; | 518 | device_for_each_child(dev, NULL, of_platform_device_destroy); |
| 522 | return 0; | ||
| 523 | } | ||
| 524 | 519 | ||
| 525 | if (dev->bus == &platform_bus_type) | 520 | if (dev->bus == &platform_bus_type) |
| 526 | platform_device_unregister(to_platform_device(dev)); | 521 | platform_device_unregister(to_platform_device(dev)); |
| @@ -528,19 +523,15 @@ static int of_platform_device_destroy(struct device *dev, void *data) | |||
| 528 | else if (dev->bus == &amba_bustype) | 523 | else if (dev->bus == &amba_bustype) |
| 529 | amba_device_unregister(to_amba_device(dev)); | 524 | amba_device_unregister(to_amba_device(dev)); |
| 530 | #endif | 525 | #endif |
| 531 | else { | ||
| 532 | *children_left = true; | ||
| 533 | return 0; | ||
| 534 | } | ||
| 535 | 526 | ||
| 536 | of_node_clear_flag(dev->of_node, OF_POPULATED); | 527 | of_node_clear_flag(dev->of_node, OF_POPULATED); |
| 537 | 528 | of_node_clear_flag(dev->of_node, OF_POPULATED_BUS); | |
| 538 | return 0; | 529 | return 0; |
| 539 | } | 530 | } |
| 540 | 531 | ||
| 541 | /** | 532 | /** |
| 542 | * of_platform_depopulate() - Remove devices populated from device tree | 533 | * of_platform_depopulate() - Remove devices populated from device tree |
| 543 | * @parent: device which childred will be removed | 534 | * @parent: device which children will be removed |
| 544 | * | 535 | * |
| 545 | * Complementary to of_platform_populate(), this function removes children | 536 | * Complementary to of_platform_populate(), this function removes children |
| 546 | * of the given device (and, recurrently, their children) that have been | 537 | * of the given device (and, recurrently, their children) that have been |
| @@ -550,14 +541,9 @@ static int of_platform_device_destroy(struct device *dev, void *data) | |||
| 550 | * Returns 0 when all children devices have been removed or | 541 | * Returns 0 when all children devices have been removed or |
| 551 | * -EBUSY when some children remained. | 542 | * -EBUSY when some children remained. |
| 552 | */ | 543 | */ |
| 553 | int of_platform_depopulate(struct device *parent) | 544 | void of_platform_depopulate(struct device *parent) |
| 554 | { | 545 | { |
| 555 | bool children_left = false; | 546 | device_for_each_child(parent, NULL, of_platform_device_destroy); |
| 556 | |||
| 557 | device_for_each_child(parent, &children_left, | ||
| 558 | of_platform_device_destroy); | ||
| 559 | |||
| 560 | return children_left ? -EBUSY : 0; | ||
| 561 | } | 547 | } |
| 562 | EXPORT_SYMBOL_GPL(of_platform_depopulate); | 548 | EXPORT_SYMBOL_GPL(of_platform_depopulate); |
| 563 | 549 | ||
