Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1603567
| From | Logan Gunthorpe <logang@deltatee.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v5 10/16] iio:core: utilize new cdev_device_add helper function |
| Date | 2017-03-17 20:00 +0100 |
| Message-ID | <tm5gv-2nQ-43@gated-at.bofh.it> (permalink) |
| References | <tm5gt-2nQ-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Replace the open coded registration of the cdev and dev with the
new device_add_cdev() helper. The helper replaces a common pattern by
taking the proper reference against the parent device and adding both
the cdev and the device.
In doing so we have to remove a guard statement from cdev_del,
but this doesn't appear to be required in any way.
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
---
drivers/iio/industrialio-core.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index d18ded4..26a03c6 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -1720,18 +1720,13 @@ int iio_device_register(struct iio_dev *indio_dev)
cdev_init(&indio_dev->chrdev, &iio_buffer_fileops);
indio_dev->chrdev.owner = indio_dev->info->driver_module;
- indio_dev->chrdev.kobj.parent = &indio_dev->dev.kobj;
- ret = cdev_add(&indio_dev->chrdev, indio_dev->dev.devt, 1);
- if (ret < 0)
- goto error_unreg_eventset;
- ret = device_add(&indio_dev->dev);
+ ret = cdev_device_add(&indio_dev->chrdev, &indio_dev->dev);
if (ret < 0)
- goto error_cdev_del;
+ goto error_unreg_eventset;
return 0;
-error_cdev_del:
- cdev_del(&indio_dev->chrdev);
+
error_unreg_eventset:
iio_device_unregister_eventset(indio_dev);
error_free_sysfs:
@@ -1752,10 +1747,8 @@ void iio_device_unregister(struct iio_dev *indio_dev)
{
mutex_lock(&indio_dev->info_exist_lock);
- device_del(&indio_dev->dev);
+ cdev_device_del(&indio_dev->chrdev, &indio_dev->dev);
- if (indio_dev->chrdev.dev)
- cdev_del(&indio_dev->chrdev);
iio_device_unregister_debugfs(indio_dev);
iio_disable_all_buffers(indio_dev);
--
2.1.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v5 00/16] Cleanup chardev instances with helper function Logan Gunthorpe <logang@deltatee.com> - 2017-03-17 20:00 +0100 [PATCH v5 08/16] IB/ucm: utilize new cdev_device_add helper function Logan Gunthorpe <logang@deltatee.com> - 2017-03-17 20:00 +0100 [PATCH v5 15/16] scsi: utilize new cdev_device_add helper function Logan Gunthorpe <logang@deltatee.com> - 2017-03-17 20:00 +0100 [PATCH v5 02/16] device-dax: fix cdev leak Logan Gunthorpe <logang@deltatee.com> - 2017-03-17 20:00 +0100 [PATCH v5 01/16] chardev: add helper function to register char devs with a struct device Logan Gunthorpe <logang@deltatee.com> - 2017-03-17 20:00 +0100 [PATCH v5 03/16] device-dax: utilize new cdev_device_add helper function Logan Gunthorpe <logang@deltatee.com> - 2017-03-17 20:00 +0100 [PATCH v5 10/16] iio:core: utilize new cdev_device_add helper function Logan Gunthorpe <logang@deltatee.com> - 2017-03-17 20:00 +0100 [PATCH v5 09/16] infiniband: utilize the new cdev_set_parent function Logan Gunthorpe <logang@deltatee.com> - 2017-03-17 20:00 +0100 [PATCH v5 11/16] media: utilize new cdev_device_add helper function Logan Gunthorpe <logang@deltatee.com> - 2017-03-17 20:00 +0100 [PATCH v5 14/16] rtc: utilize new cdev_device_add helper function Logan Gunthorpe <logang@deltatee.com> - 2017-03-17 20:00 +0100 [PATCH v5 05/16] gpiolib: utilize new cdev_device_add helper function Logan Gunthorpe <logang@deltatee.com> - 2017-03-17 20:00 +0100
csiph-web