[char-misc-next v3 1/5] mei: set parent for char device

Alexander Usyskin posted 5 patches 2 months, 4 weeks ago
There is a newer version of this series
[char-misc-next v3 1/5] mei: set parent for char device
Posted by Alexander Usyskin 2 months, 4 weeks ago
Connect char device to parent device to avoid
parent device unload while char device is
still held open by user-space.

Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
---
 drivers/misc/mei/main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 1f5aaf16e300..95d4c1d8e4e6 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -1225,6 +1225,7 @@ int mei_register(struct mei_device *dev, struct device *parent)
 	devno = MKDEV(MAJOR(mei_devt), dev->minor);
 	cdev_init(&dev->cdev, &mei_fops);
 	dev->cdev.owner = parent->driver->owner;
+	cdev_set_parent(&dev->cdev, &parent->kobj);
 
 	/* Add the device */
 	ret = cdev_add(&dev->cdev, devno, 1);
-- 
2.43.0
Re: [char-misc-next v3 1/5] mei: set parent for char device
Posted by Greg Kroah-Hartman 2 months, 3 weeks ago
On Wed, Jul 09, 2025 at 06:13:40PM +0300, Alexander Usyskin wrote:
> Connect char device to parent device to avoid
> parent device unload while char device is
> still held open by user-space.

Again, this changelog text is not right.  The parent pointer has nothing
to do with "unloading" anything.  It has everything to do with placing
the device in the proper place in sysfs.  So please show a before/after
location of what happens when this patch is applied to make it more
obvious what is happening here.

thanks,

greg k-h
Re: [char-misc-next v3 1/5] mei: set parent for char device
Posted by Greg Kroah-Hartman 2 months, 4 weeks ago
On Wed, Jul 09, 2025 at 06:13:40PM +0300, Alexander Usyskin wrote:
> Connect char device to parent device to avoid
> parent device unload while char device is
> still held open by user-space.

Again, you have 72 columns to use, please use them :(