Commit 461a1c79 authored by Alexandru Ardelean's avatar Alexandru Ardelean Committed by Jonathan Cameron

iio: adc: berlin2-adc: convert probe to device-managed only

This driver requires only a devm_add_action_or_reset() hook for the
power-down of the device, and then devm_iio_device_register() can be used
directly.
Signed-off-by: default avatarAlexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210926192642.4051329-1-aardelean@deviqon.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent bdf48481
...@@ -280,6 +280,13 @@ static const struct iio_info berlin2_adc_info = { ...@@ -280,6 +280,13 @@ static const struct iio_info berlin2_adc_info = {
.read_raw = berlin2_adc_read_raw, .read_raw = berlin2_adc_read_raw,
}; };
static void berlin2_adc_powerdown(void *regmap)
{
regmap_update_bits(regmap, BERLIN2_SM_CTRL,
BERLIN2_SM_CTRL_ADC_POWER, 0);
}
static int berlin2_adc_probe(struct platform_device *pdev) static int berlin2_adc_probe(struct platform_device *pdev)
{ {
struct iio_dev *indio_dev; struct iio_dev *indio_dev;
...@@ -293,7 +300,6 @@ static int berlin2_adc_probe(struct platform_device *pdev) ...@@ -293,7 +300,6 @@ static int berlin2_adc_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
priv = iio_priv(indio_dev); priv = iio_priv(indio_dev);
platform_set_drvdata(pdev, indio_dev);
priv->regmap = syscon_node_to_regmap(parent_np); priv->regmap = syscon_node_to_regmap(parent_np);
of_node_put(parent_np); of_node_put(parent_np);
...@@ -333,29 +339,12 @@ static int berlin2_adc_probe(struct platform_device *pdev) ...@@ -333,29 +339,12 @@ static int berlin2_adc_probe(struct platform_device *pdev)
BERLIN2_SM_CTRL_ADC_POWER, BERLIN2_SM_CTRL_ADC_POWER,
BERLIN2_SM_CTRL_ADC_POWER); BERLIN2_SM_CTRL_ADC_POWER);
ret = iio_device_register(indio_dev); ret = devm_add_action_or_reset(&pdev->dev, berlin2_adc_powerdown,
if (ret) { priv->regmap);
/* Power down the ADC */ if (ret)
regmap_update_bits(priv->regmap, BERLIN2_SM_CTRL,
BERLIN2_SM_CTRL_ADC_POWER, 0);
return ret; return ret;
}
return 0;
}
static int berlin2_adc_remove(struct platform_device *pdev)
{
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
struct berlin2_adc_priv *priv = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
/* Power down the ADC */
regmap_update_bits(priv->regmap, BERLIN2_SM_CTRL,
BERLIN2_SM_CTRL_ADC_POWER, 0);
return 0; return devm_iio_device_register(&pdev->dev, indio_dev);
} }
static const struct of_device_id berlin2_adc_match[] = { static const struct of_device_id berlin2_adc_match[] = {
...@@ -370,7 +359,6 @@ static struct platform_driver berlin2_adc_driver = { ...@@ -370,7 +359,6 @@ static struct platform_driver berlin2_adc_driver = {
.of_match_table = berlin2_adc_match, .of_match_table = berlin2_adc_match,
}, },
.probe = berlin2_adc_probe, .probe = berlin2_adc_probe,
.remove = berlin2_adc_remove,
}; };
module_platform_driver(berlin2_adc_driver); module_platform_driver(berlin2_adc_driver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment