Skip to content

Commit

Permalink
iio: exynos_adc: use indio_dev->dev structure to handle child nodes
Browse files Browse the repository at this point in the history
Using pdev->dev with device_for_each_child() would iterate over all
of the children of the platform device and delete them.
Thus, causing crashes during module unload.

We should be using the indio_dev->dev structure for
registering/unregistering child nodes.

Reported-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Naveen Krishna Ch <ch.naveen@samsung.com>
Reviewed-by: Doug Anderson <dianders@chromium.org>
Tested-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
  • Loading branch information
Naveen Krishna Ch authored and Jonathan Cameron committed Apr 26, 2014
1 parent b9b3a41 commit 3d821a1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/iio/adc/exynos_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ static int exynos_adc_probe(struct platform_device *pdev)

exynos_adc_hw_init(info);

ret = of_platform_populate(np, exynos_adc_match, NULL, &pdev->dev);
ret = of_platform_populate(np, exynos_adc_match, NULL, &indio_dev->dev);
if (ret < 0) {
dev_err(&pdev->dev, "failed adding child nodes\n");
goto err_of_populate;
Expand All @@ -353,7 +353,7 @@ static int exynos_adc_probe(struct platform_device *pdev)
return 0;

err_of_populate:
device_for_each_child(&pdev->dev, NULL,
device_for_each_child(&indio_dev->dev, NULL,
exynos_adc_remove_devices);
regulator_disable(info->vdd);
clk_disable_unprepare(info->clk);
Expand All @@ -369,7 +369,7 @@ static int exynos_adc_remove(struct platform_device *pdev)
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
struct exynos_adc *info = iio_priv(indio_dev);

device_for_each_child(&pdev->dev, NULL,
device_for_each_child(&indio_dev->dev, NULL,
exynos_adc_remove_devices);
regulator_disable(info->vdd);
clk_disable_unprepare(info->clk);
Expand Down

0 comments on commit 3d821a1

Please sign in to comment.