Commit bbf210d9 authored by Andrew Morton's avatar Andrew Morton Committed by Greg Kroah-Hartman

[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: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent dcde404f
...@@ -187,6 +187,8 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action) ...@@ -187,6 +187,8 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action)
u64 seq; u64 seq;
struct kobject *top_kobj = kobj; struct kobject *top_kobj = kobj;
struct kset *kset; 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) { if (!top_kobj->kset && top_kobj->parent) {
do { do {
...@@ -194,15 +196,18 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action) ...@@ -194,15 +196,18 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action)
} while (!top_kobj->kset && top_kobj->parent); } while (!top_kobj->kset && top_kobj->parent);
} }
if (top_kobj->kset && top_kobj->kset->hotplug_ops) if (top_kobj->kset)
kset = top_kobj->kset; kset = top_kobj->kset;
else else
return; return;
if (kset->hotplug_ops)
hotplug_ops = kset->hotplug_ops;
/* If the kset has a filter operation, call it. /* If the kset has a filter operation, call it.
Skip the event, if the filter returns zero. */ Skip the event, if the filter returns zero. */
if (kset->hotplug_ops->filter) { if (hotplug_ops->filter) {
if (!kset->hotplug_ops->filter(kset, kobj)) if (!hotplug_ops->filter(kset, kobj))
return; return;
} }
...@@ -221,8 +226,8 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action) ...@@ -221,8 +226,8 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action)
if (!buffer) if (!buffer)
goto exit; goto exit;
if (kset->hotplug_ops->name) if (hotplug_ops->name)
name = kset->hotplug_ops->name(kset, kobj); name = hotplug_ops->name(kset, kobj);
if (name == NULL) if (name == NULL)
name = kset->kobj.name; name = kset->kobj.name;
...@@ -256,9 +261,9 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action) ...@@ -256,9 +261,9 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action)
envp [i++] = scratch; envp [i++] = scratch;
scratch += sprintf(scratch, "SUBSYSTEM=%s", name) + 1; scratch += sprintf(scratch, "SUBSYSTEM=%s", name) + 1;
if (kset->hotplug_ops->hotplug) { if (hotplug_ops->hotplug) {
/* have the kset specific function add its stuff */ /* 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, &envp[i], NUM_ENVP - i, scratch,
BUFFER_SIZE - (scratch - buffer)); BUFFER_SIZE - (scratch - buffer));
if (retval) { if (retval) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment