Hi Sakari, Thank you for the patch. On Wed, Dec 20, 2023 at 12:36:48PM +0200, Sakari Ailus wrote: > From: Logan Gunthorpe <logang@xxxxxxxxxxxx> > > 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@xxxxxxxxxxxx> > Acked-by: Hans Verkuil <hans.verkuil@xxxxxxxxx> > Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> This reapplies a commit you've reverted in 02/29 in this series. I understand this is done to be able to apply the revert in 03/29 cleanly. Given that those three patches are consecutive, wouldn't it be better to squash 02/29, 03/29 and 04/29, with the commit message of 03/29 ? Otherwise, I would at least drop the Acked-by and Reviewed-by tags in the patches you reapply, as they've been reviewed in a different context. The same applies to patches 05/29, 06/29 and 07/29. > --- > drivers/media/cec/core/cec-core.c | 16 ++++------------ > drivers/media/mc/mc-devnode.c | 23 +++++++++-------------- > 2 files changed, 13 insertions(+), 26 deletions(-) > > diff --git a/drivers/media/cec/core/cec-core.c b/drivers/media/cec/core/cec-core.c > index 0645e68411fb..15494b46458a 100644 > --- a/drivers/media/cec/core/cec-core.c > +++ b/drivers/media/cec/core/cec-core.c > @@ -137,26 +137,19 @@ 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; > kobject_set_name(&devnode->cdev.kobj, "cec%d", devnode->minor); > > devnode->registered = true; > - 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__); > devnode->registered = false; > goto clr_bit; > } > > - ret = device_add(&devnode->dev); > - if (ret) > - goto cdev_del; > - > return 0; > > -cdev_del: > - cdev_del(&devnode->cdev); > clr_bit: > mutex_lock(&cec_devnode_lock); > clear_bit(devnode->minor, cec_devnode_nums); > @@ -202,8 +195,7 @@ static void cec_devnode_unregister(struct cec_adapter *adap) > cec_adap_enable(adap); > mutex_unlock(&adap->lock); > > - device_del(&devnode->dev); > - cdev_del(&devnode->cdev); > + cdev_device_del(&devnode->cdev, &devnode->dev); > put_device(&devnode->dev); > } > > diff --git a/drivers/media/mc/mc-devnode.c b/drivers/media/mc/mc-devnode.c > index 1e1792c3ae3f..fabcd646679b 100644 > --- a/drivers/media/mc/mc-devnode.c > +++ b/drivers/media/mc/mc-devnode.c > @@ -232,29 +232,24 @@ int __must_check media_devnode_register(struct media_device *mdev, > devnode->minor = minor; > devnode->media_dev = mdev; > > - /* Part 2: Initialize and register the character device */ > + /* Part 2: Initialize the media and character devices */ > cdev_init(&devnode->cdev, &media_devnode_fops); > devnode->cdev.owner = owner; > kobject_set_name(&devnode->cdev.kobj, "media%d", devnode->minor); > > - ret = cdev_add(&devnode->cdev, MKDEV(MAJOR(media_dev_t), > - devnode->minor), 1); > - if (ret < 0) { > - pr_err("%s: cdev_add failed\n", __func__); > - goto error; > - } > - > - /* Part 3: Register the media device */ > devnode->dev.bus = &media_bus_type; > devnode->dev.devt = MKDEV(MAJOR(media_dev_t), devnode->minor); > devnode->dev.release = media_devnode_release; > if (devnode->parent) > devnode->dev.parent = devnode->parent; > dev_set_name(&devnode->dev, "media%d", devnode->minor); > - ret = device_register(&devnode->dev); > + device_initialize(&devnode->dev); > + > + /* Part 3: Add the media and character devices */ > + ret = cdev_device_add(&devnode->cdev, &devnode->dev); > if (ret < 0) { > - pr_err("%s: device_register failed\n", __func__); > - goto error; > + pr_err("%s: cdev_device_add failed\n", __func__); > + goto cdev_add_error; > } > > /* Part 4: Activate this minor. The char device can now be used. */ > @@ -262,9 +257,9 @@ int __must_check media_devnode_register(struct media_device *mdev, > > return 0; > > -error: > +cdev_add_error: > mutex_lock(&media_devnode_lock); > - cdev_del(&devnode->cdev); > + cdev_device_del(&devnode->cdev, &devnode->dev); > clear_bit(devnode->minor, media_devnode_nums); > mutex_unlock(&media_devnode_lock); > -- Regards, Laurent Pinchart