diff options
| author | Andrew Morton <akpm@osdl.org> | 2004-10-22 00:29:19 -0700 |
|---|---|---|
| committer | Greg Kroah-Hartman <greg@kroah.com> | 2004-10-22 00:29:19 -0700 |
| commit | bbf210d9acfc3d8c75369e8a74111a44784f4d1d (patch) | |
| tree | ebe32c430563555bc66ac5fa392675f8fb4d1817 | |
| parent | dcde404f44f1d7266ab25c35f1ea29c7ddb47548 (diff) | |
[PATCH] kobject_hotplug: permit no hotplug_ops
Make kobject_hotplug() work even if the kobject's kset doesn't implement any
hotplug_ops.
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
| -rw-r--r-- | lib/kobject_uevent.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index a5ea77096670..1ee5e302c76a 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c @@ -187,6 +187,8 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action) u64 seq; struct kobject *top_kobj = kobj; struct kset *kset; + static struct kset_hotplug_ops null_hotplug_ops; + struct kset_hotplug_ops *hotplug_ops = &null_hotplug_ops; if (!top_kobj->kset && top_kobj->parent) { do { @@ -194,15 +196,18 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action) } while (!top_kobj->kset && top_kobj->parent); } - if (top_kobj->kset && top_kobj->kset->hotplug_ops) + if (top_kobj->kset) kset = top_kobj->kset; else return; + if (kset->hotplug_ops) + hotplug_ops = kset->hotplug_ops; + /* If the kset has a filter operation, call it. Skip the event, if the filter returns zero. */ - if (kset->hotplug_ops->filter) { - if (!kset->hotplug_ops->filter(kset, kobj)) + if (hotplug_ops->filter) { + if (!hotplug_ops->filter(kset, kobj)) return; } @@ -221,8 +226,8 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action) if (!buffer) goto exit; - if (kset->hotplug_ops->name) - name = kset->hotplug_ops->name(kset, kobj); + if (hotplug_ops->name) + name = hotplug_ops->name(kset, kobj); if (name == NULL) name = kset->kobj.name; @@ -256,9 +261,9 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action) envp [i++] = scratch; scratch += sprintf(scratch, "SUBSYSTEM=%s", name) + 1; - if (kset->hotplug_ops->hotplug) { + if (hotplug_ops->hotplug) { /* have the kset specific function add its stuff */ - retval = kset->hotplug_ops->hotplug (kset, kobj, + retval = hotplug_ops->hotplug (kset, kobj, &envp[i], NUM_ENVP - i, scratch, BUFFER_SIZE - (scratch - buffer)); if (retval) { |
