Commit b989f180 authored by Dmitry Torokhov's avatar Dmitry Torokhov

[PATCH] kobject: make kobject hotplug function public

make kobject hotplug mechanism public so that others may call it.
parent 0010bc50
...@@ -56,6 +56,7 @@ extern void kobject_unregister(struct kobject *); ...@@ -56,6 +56,7 @@ extern void kobject_unregister(struct kobject *);
extern struct kobject * kobject_get(struct kobject *); extern struct kobject * kobject_get(struct kobject *);
extern void kobject_put(struct kobject *); extern void kobject_put(struct kobject *);
extern void kobject_hotplug(const char *action, struct kobject *);
struct kobj_type { struct kobj_type {
void (*release)(struct kobject *); void (*release)(struct kobject *);
......
...@@ -198,9 +198,24 @@ static void kset_hotplug(const char *action, struct kset *kset, ...@@ -198,9 +198,24 @@ static void kset_hotplug(const char *action, struct kset *kset,
kfree(envp); kfree(envp);
return; return;
} }
void kobject_hotplug(const char *action, struct kobject *kobj)
{
struct kobject * top_kobj = kobj;
/* If this kobj does not belong to a kset,
try to find a parent that does. */
if (!top_kobj->kset && top_kobj->parent) {
do {
top_kobj = top_kobj->parent;
} while (!top_kobj->kset && top_kobj->parent);
}
if (top_kobj->kset && top_kobj->kset->hotplug_ops)
kset_hotplug(action, top_kobj->kset, kobj);
}
#else #else
static void kset_hotplug(const char *action, struct kset *kset, void kobject_hotplug(const char *action, struct kobject *kobj)
struct kobject *kobj)
{ {
return; return;
} }
...@@ -248,7 +263,6 @@ int kobject_add(struct kobject * kobj) ...@@ -248,7 +263,6 @@ int kobject_add(struct kobject * kobj)
{ {
int error = 0; int error = 0;
struct kobject * parent; struct kobject * parent;
struct kobject * top_kobj;
if (!(kobj = kobject_get(kobj))) if (!(kobj = kobject_get(kobj)))
return -ENOENT; return -ENOENT;
...@@ -277,18 +291,9 @@ int kobject_add(struct kobject * kobj) ...@@ -277,18 +291,9 @@ int kobject_add(struct kobject * kobj)
if (parent) if (parent)
kobject_put(parent); kobject_put(parent);
} else { } else {
/* If this kobj does not belong to a kset, kobject_hotplug("add", kobj);
try to find a parent that does. */
top_kobj = kobj;
if (!top_kobj->kset && top_kobj->parent) {
do {
top_kobj = top_kobj->parent;
} while (!top_kobj->kset && top_kobj->parent);
} }
if (top_kobj->kset && top_kobj->kset->hotplug_ops)
kset_hotplug("add", top_kobj->kset, kobj);
}
return error; return error;
} }
...@@ -396,20 +401,7 @@ void kobject_rename(struct kobject * kobj, char *new_name) ...@@ -396,20 +401,7 @@ void kobject_rename(struct kobject * kobj, char *new_name)
void kobject_del(struct kobject * kobj) void kobject_del(struct kobject * kobj)
{ {
struct kobject * top_kobj; kobject_hotplug("remove", kobj);
/* If this kobj does not belong to a kset,
try to find a parent that does. */
top_kobj = kobj;
if (!top_kobj->kset && top_kobj->parent) {
do {
top_kobj = top_kobj->parent;
} while (!top_kobj->kset && top_kobj->parent);
}
if (top_kobj->kset && top_kobj->kset->hotplug_ops)
kset_hotplug("remove", top_kobj->kset, kobj);
sysfs_remove_dir(kobj); sysfs_remove_dir(kobj);
unlink(kobj); unlink(kobj);
} }
...@@ -638,6 +630,7 @@ EXPORT_SYMBOL(kobject_register); ...@@ -638,6 +630,7 @@ EXPORT_SYMBOL(kobject_register);
EXPORT_SYMBOL(kobject_unregister); EXPORT_SYMBOL(kobject_unregister);
EXPORT_SYMBOL(kobject_get); EXPORT_SYMBOL(kobject_get);
EXPORT_SYMBOL(kobject_put); EXPORT_SYMBOL(kobject_put);
EXPORT_SYMBOL(kobject_hotplug);
EXPORT_SYMBOL(kset_register); EXPORT_SYMBOL(kset_register);
EXPORT_SYMBOL(kset_unregister); EXPORT_SYMBOL(kset_unregister);
......
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