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

iio: adc: axp288_adc: convert probe to full device-managed

This change converts the probe of this driver to use device-managed
functions only, which means that the remove hook can be removed.
The remove hook has only 2 calls to iio_device_unregister() and
iio_map_array_unregister(). Both these can now be done via devm register
functions, now that there's also a devm_iio_map_array_register() function.

The platform_set_drvdata() can also be removed now.

This change also removes the error print for when the iio_device_register()
call fails. This isn't required now.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210903072917.45769-4-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Alexandru Ardelean and committed by
Jonathan Cameron
298fdedc 7a29120c

+4 -24
+4 -24
drivers/iio/adc/axp288_adc.c
··· 259 259 info->irq = platform_get_irq(pdev, 0); 260 260 if (info->irq < 0) 261 261 return info->irq; 262 - platform_set_drvdata(pdev, indio_dev); 262 + 263 263 info->regmap = axp20x->regmap; 264 264 /* 265 265 * Set ADC to enabled state at all time, including system suspend. ··· 276 276 indio_dev->num_channels = ARRAY_SIZE(axp288_adc_channels); 277 277 indio_dev->info = &axp288_adc_iio_info; 278 278 indio_dev->modes = INDIO_DIRECT_MODE; 279 - ret = iio_map_array_register(indio_dev, axp288_adc_default_maps); 279 + 280 + ret = devm_iio_map_array_register(&pdev->dev, indio_dev, axp288_adc_default_maps); 280 281 if (ret < 0) 281 282 return ret; 282 283 283 - ret = iio_device_register(indio_dev); 284 - if (ret < 0) { 285 - dev_err(&pdev->dev, "unable to register iio device\n"); 286 - goto err_array_unregister; 287 - } 288 - return 0; 289 - 290 - err_array_unregister: 291 - iio_map_array_unregister(indio_dev); 292 - 293 - return ret; 294 - } 295 - 296 - static int axp288_adc_remove(struct platform_device *pdev) 297 - { 298 - struct iio_dev *indio_dev = platform_get_drvdata(pdev); 299 - 300 - iio_device_unregister(indio_dev); 301 - iio_map_array_unregister(indio_dev); 302 - 303 - return 0; 284 + return devm_iio_device_register(&pdev->dev, indio_dev); 304 285 } 305 286 306 287 static const struct platform_device_id axp288_adc_id_table[] = { ··· 291 310 292 311 static struct platform_driver axp288_adc_driver = { 293 312 .probe = axp288_adc_probe, 294 - .remove = axp288_adc_remove, 295 313 .id_table = axp288_adc_id_table, 296 314 .driver = { 297 315 .name = "axp288_adc",