Re: Input sysbsystema and hotplug

From: Jon Smirl (jonsmirl_at_gmail.com)
Date: 06/14/05

  • Next message: Kylene Jo Hall: "Re: [PATCH] tpm: improve output in sysfs files when the TPM fails"
    Date:	Tue, 14 Jun 2005 11:02:43 -0400
    To: Greg KH <gregkh@suse.de>
    
    

    On 6/14/05, Greg KH <gregkh@suse.de> 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
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: Kylene Jo Hall: "Re: [PATCH] tpm: improve output in sysfs files when the TPM fails"

    Relevant Pages

    • Re: Catching NForce2 lockup with NMI watchdog
      ... > machine freezes doing hdparm, the cursor still blinks, but I can't do ... > anything anymore. ... If you're worried about your filesystem, just boot the patched kernel in ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [RFC][PATCH] filesystem auditing by location+name
      ... Also, could drop some of that extra debugging code (heh, like that MKDEV ... > +config AUDITFILESYSTEM ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: 2.6.11-rc2-mm1
      ... >> Binary searching shows that the bug was introduced by ... Heh, on my system, I get no cursor, and no letters, either (this is ... Letters are present for a while during boot; ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: console remains blanked
      ... > (due to inactivity for example) doesn't get unblanked ... > anymore when new output is written to it. ... blank/unblank time. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: dpm_runtime_suspend and _resume()
      ... Break them anymore than they currently are? ... I wouldn't recommend using those functions. ... of existing poorly-designed infrastructure in the process. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)