aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Breathitt Gray <vilhelm.gray@gmail.com>2017-01-24 15:26:17 -0500
committerJonathan Cameron <jic23@kernel.org>2017-01-28 07:44:05 -0500
commitb2d226caecfc2dbf85b2abd2814b42627c5dde0a (patch)
tree6fe5e8c114df4446a71f54f7091dd64f3945ae9a
parent75de5546100e27a88e8d13067a4335f61d334ba2 (diff)
iio: stx104: Utilize devm_ functions in driver probe callback
The devm_ resource manager functions allow memory to be automatically released when a device is unbound. This patch takes advantage of the resource manager functions and replaces the gpiochip_add_data call and iio_device_register call with the devm_gpiochip_add_data call and devm_iio_device_register call respectively. In addition, the stx104_remove function has been removed as no longer necessary due to the use of the relevant devm_ resource manager functions. Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/iio/adc/stx104.c22
1 files changed, 2 insertions, 20 deletions
diff --git a/drivers/iio/adc/stx104.c b/drivers/iio/adc/stx104.c
index 7e3645749eaf..c56ff286695d 100644
--- a/drivers/iio/adc/stx104.c
+++ b/drivers/iio/adc/stx104.c
@@ -339,30 +339,13 @@ static int stx104_probe(struct device *dev, unsigned int id)
339 stx104dev->chip = &stx104gpio->chip; 339 stx104dev->chip = &stx104gpio->chip;
340 dev_set_drvdata(dev, stx104dev); 340 dev_set_drvdata(dev, stx104dev);
341 341
342 err = gpiochip_add_data(&stx104gpio->chip, stx104gpio); 342 err = devm_gpiochip_add_data(dev, &stx104gpio->chip, stx104gpio);
343 if (err) { 343 if (err) {
344 dev_err(dev, "GPIO registering failed (%d)\n", err); 344 dev_err(dev, "GPIO registering failed (%d)\n", err);
345 return err; 345 return err;
346 } 346 }
347 347
348 err = iio_device_register(indio_dev); 348 return devm_iio_device_register(dev, indio_dev);
349 if (err) {
350 dev_err(dev, "IIO device registering failed (%d)\n", err);
351 gpiochip_remove(&stx104gpio->chip);
352 return err;
353 }
354
355 return 0;
356}
357
358static int stx104_remove(struct device *dev, unsigned int id)
359{
360 struct stx104_dev *const stx104dev = dev_get_drvdata(dev);
361
362 iio_device_unregister(stx104dev->indio_dev);
363 gpiochip_remove(stx104dev->chip);
364
365 return 0;
366} 349}
367 350
368static struct isa_driver stx104_driver = { 351static struct isa_driver stx104_driver = {
@@ -370,7 +353,6 @@ static struct isa_driver stx104_driver = {
370 .driver = { 353 .driver = {
371 .name = "stx104" 354 .name = "stx104"
372 }, 355 },
373 .remove = stx104_remove
374}; 356};
375 357
376module_isa_driver(stx104_driver, num_stx104); 358module_isa_driver(stx104_driver, num_stx104);