mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 13:55:32 +00:00
iio: adc: ad7124: Use devm_ managed calls for all of probe() + drop remove()
As not many steps were not already devm_ managed, use devm_add_action_or_reset() to handle the rest. This also uses the new devm_ad_sd_setup_buffer_and_trigger() function. Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210513120752.90074-12-aardelean@deviqon.com
This commit is contained in:
parent
bd5dcdeb3f
commit
c066ca1464
1 changed files with 15 additions and 33 deletions
|
@ -862,6 +862,11 @@ static void ad7124_reg_disable(void *r)
|
||||||
regulator_disable(r);
|
regulator_disable(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ad7124_clk_disable(void *c)
|
||||||
|
{
|
||||||
|
clk_disable_unprepare(c);
|
||||||
|
}
|
||||||
|
|
||||||
static int ad7124_probe(struct spi_device *spi)
|
static int ad7124_probe(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
const struct ad7124_chip_info *info;
|
const struct ad7124_chip_info *info;
|
||||||
|
@ -883,8 +888,6 @@ static int ad7124_probe(struct spi_device *spi)
|
||||||
|
|
||||||
ad_sd_init(&st->sd, indio_dev, spi, &ad7124_sigma_delta_info);
|
ad_sd_init(&st->sd, indio_dev, spi, &ad7124_sigma_delta_info);
|
||||||
|
|
||||||
spi_set_drvdata(spi, indio_dev);
|
|
||||||
|
|
||||||
indio_dev->name = st->chip_info->name;
|
indio_dev->name = st->chip_info->name;
|
||||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||||
indio_dev->info = &ad7124_info;
|
indio_dev->info = &ad7124_info;
|
||||||
|
@ -922,48 +925,28 @@ static int ad7124_probe(struct spi_device *spi)
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
ret = devm_add_action_or_reset(&spi->dev, ad7124_clk_disable, st->mclk);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
ret = ad7124_soft_reset(st);
|
ret = ad7124_soft_reset(st);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto error_clk_disable_unprepare;
|
return ret;
|
||||||
|
|
||||||
ret = ad7124_check_chip_id(st);
|
ret = ad7124_check_chip_id(st);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto error_clk_disable_unprepare;
|
return ret;
|
||||||
|
|
||||||
ret = ad7124_setup(st);
|
ret = ad7124_setup(st);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto error_clk_disable_unprepare;
|
return ret;
|
||||||
|
|
||||||
ret = ad_sd_setup_buffer_and_trigger(indio_dev);
|
ret = devm_ad_sd_setup_buffer_and_trigger(&spi->dev, indio_dev);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto error_clk_disable_unprepare;
|
return ret;
|
||||||
|
|
||||||
ret = iio_device_register(indio_dev);
|
return devm_iio_device_register(&spi->dev, indio_dev);
|
||||||
if (ret < 0) {
|
|
||||||
dev_err(&spi->dev, "Failed to register iio device\n");
|
|
||||||
goto error_remove_trigger;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
error_remove_trigger:
|
|
||||||
ad_sd_cleanup_buffer_and_trigger(indio_dev);
|
|
||||||
error_clk_disable_unprepare:
|
|
||||||
clk_disable_unprepare(st->mclk);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ad7124_remove(struct spi_device *spi)
|
|
||||||
{
|
|
||||||
struct iio_dev *indio_dev = spi_get_drvdata(spi);
|
|
||||||
struct ad7124_state *st = iio_priv(indio_dev);
|
|
||||||
|
|
||||||
iio_device_unregister(indio_dev);
|
|
||||||
ad_sd_cleanup_buffer_and_trigger(indio_dev);
|
|
||||||
clk_disable_unprepare(st->mclk);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct of_device_id ad7124_of_match[] = {
|
static const struct of_device_id ad7124_of_match[] = {
|
||||||
|
@ -981,7 +964,6 @@ static struct spi_driver ad71124_driver = {
|
||||||
.of_match_table = ad7124_of_match,
|
.of_match_table = ad7124_of_match,
|
||||||
},
|
},
|
||||||
.probe = ad7124_probe,
|
.probe = ad7124_probe,
|
||||||
.remove = ad7124_remove,
|
|
||||||
};
|
};
|
||||||
module_spi_driver(ad71124_driver);
|
module_spi_driver(ad71124_driver);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue