diff options
author | Logan Gunthorpe <logang@deltatee.com> | 2017-03-17 19:48:18 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-03-21 06:44:33 +0100 |
commit | 857313e51006ff51524579bcd8808b70f9a80812 (patch) | |
tree | 49844bbb9fdb8f66005c13505b4f98f0367b38a7 /drivers/media/cec | |
parent | iio:core: utilize new cdev_device_add helper function (diff) | |
download | linux-857313e51006ff51524579bcd8808b70f9a80812.tar.xz linux-857313e51006ff51524579bcd8808b70f9a80812.zip |
media: utilize new cdev_device_add helper function
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.
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/media/cec')
-rw-r--r-- | drivers/media/cec/cec-core.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/media/cec/cec-core.c b/drivers/media/cec/cec-core.c index 37217e205040..3163e038a364 100644 --- a/drivers/media/cec/cec-core.c +++ b/drivers/media/cec/cec-core.c @@ -137,24 +137,17 @@ static int __must_check cec_devnode_register(struct cec_devnode *devnode, /* Part 2: Initialize and register the character device */ cdev_init(&devnode->cdev, &cec_devnode_fops); - devnode->cdev.kobj.parent = &devnode->dev.kobj; devnode->cdev.owner = owner; - ret = cdev_add(&devnode->cdev, devnode->dev.devt, 1); - if (ret < 0) { - pr_err("%s: cdev_add failed\n", __func__); + ret = cdev_device_add(&devnode->cdev, &devnode->dev); + if (ret) { + pr_err("%s: cdev_device_add failed\n", __func__); goto clr_bit; } - ret = device_add(&devnode->dev); - if (ret) - goto cdev_del; - devnode->registered = true; return 0; -cdev_del: - cdev_del(&devnode->cdev); clr_bit: mutex_lock(&cec_devnode_lock); clear_bit(devnode->minor, cec_devnode_nums); @@ -190,8 +183,7 @@ static void cec_devnode_unregister(struct cec_devnode *devnode) devnode->unregistered = true; mutex_unlock(&devnode->lock); - device_del(&devnode->dev); - cdev_del(&devnode->cdev); + cdev_device_del(&devnode->cdev, &devnode->dev); put_device(&devnode->dev); } |