Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: adc: exynos_adc: fix OF populate on driver rebind

Since commit c6e126de43e7 ("of: Keep track of populated platform
devices") child devices will not be created by of_platform_populate()
if the devices had previously been deregistered individually so that the
OF_POPULATED flag is still set in the corresponding OF nodes.

Switch to using of_platform_depopulate() instead of open coding so that
the child devices are created if the driver is rebound.

Fixes: c6e126de43e7 ("of: Keep track of populated platform devices")
Cc: stable@vger.kernel.org # 3.16
Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Johan Hovold and committed by
Jonathan Cameron
ea6b4feb 441ac299

+2 -13
+2 -13
drivers/iio/adc/exynos_adc.c
··· 540 540 ADC_CHANNEL(9, "adc9"), 541 541 }; 542 542 543 - static int exynos_adc_remove_devices(struct device *dev, void *c) 544 - { 545 - struct platform_device *pdev = to_platform_device(dev); 546 - 547 - platform_device_unregister(pdev); 548 - 549 - return 0; 550 - } 551 - 552 543 static int exynos_adc_probe(struct platform_device *pdev) 553 544 { 554 545 struct exynos_adc *info = NULL; ··· 651 660 return 0; 652 661 653 662 err_of_populate: 654 - device_for_each_child(&indio_dev->dev, NULL, 655 - exynos_adc_remove_devices); 663 + of_platform_depopulate(&indio_dev->dev); 656 664 iio_device_unregister(indio_dev); 657 665 err_irq: 658 666 free_irq(info->irq, info); ··· 671 681 struct iio_dev *indio_dev = platform_get_drvdata(pdev); 672 682 struct exynos_adc *info = iio_priv(indio_dev); 673 683 674 - device_for_each_child(&indio_dev->dev, NULL, 675 - exynos_adc_remove_devices); 684 + of_platform_depopulate(&indio_dev->dev); 676 685 iio_device_unregister(indio_dev); 677 686 free_irq(info->irq, info); 678 687 if (info->data->exit_hw)