From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jon Smirl Date: Tue, 14 Jun 2005 15:02:43 +0000 Subject: Re: Input sysbsystema and hotplug Message-Id: <9e473391050614080230ae359d@mail.gmail.com> List-Id: References: <200506131607.51736.dtor_core@ameritech.net> <20050613221657.GB15381@suse.de> <9e473391050613232170f57ea3@mail.gmail.com> <20050614063851.GA19620@suse.de> In-Reply-To: <20050614063851.GA19620@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Greg KH Cc: Dmitry Torokhov , linux-hotplug-devel@lists.sourceforge.net, Vojtech Pavlik , Kay Sievers , LKML On 6/14/05, Greg KH wrote: > Heh, yes, sorry, you did. > > Hm, I don't even remember why I didn't like it anymore, last I remember, > I think you got the parent reference counting correct, right? Care to > dig out the patch and send it again? I brought this forward from a kernel a couple of months old so it may need some checking. diff --git a/drivers/base/class.c b/drivers/base/class.c --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -406,8 +406,9 @@ int class_device_add(struct class_device /* first, register with generic layer. */ kobject_set_name(&class_dev->kobj, "%s", class_dev->class_id); - if (parent) + if (parent && !class_dev->kobj.parent) class_dev->kobj.parent = &parent->subsys.kset.kobj; + class_dev->kobj.parent = kobject_get(class_dev->kobj.parent); if ((error = kobject_add(&class_dev->kobj))) goto register_done; @@ -438,6 +439,12 @@ int class_device_add(struct class_device return error; } +int class_device_add_child(struct class_device *class_dev, struct class_device *parent) +{ + class_dev->kobj.parent = &class_dev->kobj; + return class_device_add(class_dev); +} + int class_device_register(struct class_device *class_dev) { class_device_initialize(class_dev); @@ -463,6 +470,7 @@ void class_device_del(struct class_devic class_device_remove_attrs(class_dev); kobject_hotplug(&class_dev->kobj, KOBJ_REMOVE); + kobject_put(class_dev->kobj.parent); kobject_del(&class_dev->kobj); if (parent) @@ -581,6 +589,7 @@ EXPORT_SYMBOL_GPL(class_device_register) EXPORT_SYMBOL_GPL(class_device_unregister); EXPORT_SYMBOL_GPL(class_device_initialize); EXPORT_SYMBOL_GPL(class_device_add); +EXPORT_SYMBOL_GPL(class_device_add_child); EXPORT_SYMBOL_GPL(class_device_del); EXPORT_SYMBOL_GPL(class_device_get); EXPORT_SYMBOL_GPL(class_device_put); diff --git a/include/linux/device.h b/include/linux/device.h --- a/include/linux/device.h +++ b/include/linux/device.h @@ -208,6 +208,7 @@ extern int class_device_register(struct extern void class_device_unregister(struct class_device *); extern void class_device_initialize(struct class_device *); extern int class_device_add(struct class_device *); +extern int class_device_add_child(struct class_device *, struct class_device *); extern void class_device_del(struct class_device *); extern int class_device_rename(struct class_device *, char *); -- Jon Smirl jonsmirl@gmail.com ------------------------------------------------------- This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput a projector? How fast can you ride your desk chair down the office luge track? If you want to score the big prize, get to know the little guy. Play to win an NEC 61" plasma display: http://www.necitguy.com/?r _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel