summaryrefslogtreecommitdiff
path: root/include/linux/kobject.h
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <greg@kroah.com>2003-04-04 01:06:13 -0800
committerGreg Kroah-Hartman <greg@kroah.com>2003-04-04 01:06:13 -0800
commitac6ecad34952822e7f85fae561fdb9c9229d5f4a (patch)
tree8df6a271a9664b603f81c89cda3a70d65164c7a3 /include/linux/kobject.h
parentcb8d68097e3de5187ca370214782e381d04d12a7 (diff)
kobject: cause /sbin/hotplug to be called when kobjects are added and removed
This only happens if a kobject belongs to a subsystem that has specified a set of hotplug operations. Based on work done by Kevin Fleming <kpfleming@cox.net>
Diffstat (limited to 'include/linux/kobject.h')
-rw-r--r--include/linux/kobject.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index e9cfa0dc3d24..8c84e7bce42e 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -57,12 +57,24 @@ struct kobj_type {
* of object; multiple ksets can belong to one subsystem. All
* ksets of a subsystem share the subsystem's lock.
*
+ * Each kset can support hotplugging; if it does, it will be given
+ * the opportunity to filter out specific kobjects from being
+ * reported, as well as to add its own "data" elements to the
+ * environment being passed to the hotplug helper.
*/
+struct kset_hotplug_ops {
+ int (*filter)(struct kset *kset, struct kobject *kobj);
+ char *(*name)(struct kset *kset, struct kobject *kobj);
+ int (*hotplug)(struct kset *kset, struct kobject *kobj, char **envp,
+ int num_envp, char *buffer, int buffer_size);
+};
+
struct kset {
struct subsystem * subsys;
struct kobj_type * ktype;
struct list_head list;
struct kobject kobj;
+ struct kset_hotplug_ops * hotplug_ops;
};
@@ -86,6 +98,13 @@ static inline void kset_put(struct kset * k)
kobject_put(&k->kobj);
}
+static inline struct kobj_type * get_ktype(struct kobject * k)
+{
+ if (k->kset && k->kset->ktype)
+ return k->kset->ktype;
+ else
+ return k->ktype;
+}
extern struct kobject * kset_find_obj(struct kset *, const char *);
@@ -95,11 +114,12 @@ struct subsystem {
struct rw_semaphore rwsem;
};
-#define decl_subsys(_name,_type) \
+#define decl_subsys(_name,_type,_hotplug_ops) \
struct subsystem _name##_subsys = { \
.kset = { \
.kobj = { .name = __stringify(_name) }, \
.ktype = _type, \
+ .hotplug_ops =_hotplug_ops, \
} \
}