aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kobject.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/kobject.h')
-rw-r--r--include/linux/kobject.h58
1 files changed, 25 insertions, 33 deletions
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index eb0e63ef297f..c288e41ba331 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -124,7 +124,6 @@ struct kset_uevent_ops {
124}; 124};
125 125
126struct kset { 126struct kset {
127 struct subsystem * subsys;
128 struct kobj_type * ktype; 127 struct kobj_type * ktype;
129 struct list_head list; 128 struct list_head list;
130 spinlock_t list_lock; 129 spinlock_t list_lock;
@@ -171,32 +170,23 @@ extern struct kobject * kset_find_obj(struct kset *, const char *);
171#define set_kset_name(str) .kset = { .kobj = { .name = str } } 170#define set_kset_name(str) .kset = { .kobj = { .name = str } }
172 171
173 172
174
175struct subsystem {
176 struct kset kset;
177};
178
179#define decl_subsys(_name,_type,_uevent_ops) \ 173#define decl_subsys(_name,_type,_uevent_ops) \
180struct subsystem _name##_subsys = { \ 174struct kset _name##_subsys = { \
181 .kset = { \ 175 .kobj = { .name = __stringify(_name) }, \
182 .kobj = { .name = __stringify(_name) }, \ 176 .ktype = _type, \
183 .ktype = _type, \ 177 .uevent_ops =_uevent_ops, \
184 .uevent_ops =_uevent_ops, \
185 } \
186} 178}
187#define decl_subsys_name(_varname,_name,_type,_uevent_ops) \ 179#define decl_subsys_name(_varname,_name,_type,_uevent_ops) \
188struct subsystem _varname##_subsys = { \ 180struct kset _varname##_subsys = { \
189 .kset = { \ 181 .kobj = { .name = __stringify(_name) }, \
190 .kobj = { .name = __stringify(_name) }, \ 182 .ktype = _type, \
191 .ktype = _type, \ 183 .uevent_ops =_uevent_ops, \
192 .uevent_ops =_uevent_ops, \
193 } \
194} 184}
195 185
196/* The global /sys/kernel/ subsystem for people to chain off of */ 186/* The global /sys/kernel/ subsystem for people to chain off of */
197extern struct subsystem kernel_subsys; 187extern struct kset kernel_subsys;
198/* The global /sys/hypervisor/ subsystem */ 188/* The global /sys/hypervisor/ subsystem */
199extern struct subsystem hypervisor_subsys; 189extern struct kset hypervisor_subsys;
200 190
201/** 191/**
202 * Helpers for setting the kset of registered objects. 192 * Helpers for setting the kset of registered objects.
@@ -214,7 +204,7 @@ extern struct subsystem hypervisor_subsys;
214 */ 204 */
215 205
216#define kobj_set_kset_s(obj,subsys) \ 206#define kobj_set_kset_s(obj,subsys) \
217 (obj)->kobj.kset = &(subsys).kset 207 (obj)->kobj.kset = &(subsys)
218 208
219/** 209/**
220 * kset_set_kset_s(obj,subsys) - set kset for embedded kset. 210 * kset_set_kset_s(obj,subsys) - set kset for embedded kset.
@@ -228,7 +218,7 @@ extern struct subsystem hypervisor_subsys;
228 */ 218 */
229 219
230#define kset_set_kset_s(obj,subsys) \ 220#define kset_set_kset_s(obj,subsys) \
231 (obj)->kset.kobj.kset = &(subsys).kset 221 (obj)->kset.kobj.kset = &(subsys)
232 222
233/** 223/**
234 * subsys_set_kset(obj,subsys) - set kset for subsystem 224 * subsys_set_kset(obj,subsys) - set kset for subsystem
@@ -241,29 +231,31 @@ extern struct subsystem hypervisor_subsys;
241 */ 231 */
242 232
243#define subsys_set_kset(obj,_subsys) \ 233#define subsys_set_kset(obj,_subsys) \
244 (obj)->subsys.kset.kobj.kset = &(_subsys).kset 234 (obj)->subsys.kobj.kset = &(_subsys)
245 235
246extern void subsystem_init(struct subsystem *); 236extern void subsystem_init(struct kset *);
247extern int __must_check subsystem_register(struct subsystem *); 237extern int __must_check subsystem_register(struct kset *);
248extern void subsystem_unregister(struct subsystem *); 238extern void subsystem_unregister(struct kset *);
249 239
250static inline struct subsystem * subsys_get(struct subsystem * s) 240static inline struct kset *subsys_get(struct kset *s)
251{ 241{
252 return s ? container_of(kset_get(&s->kset),struct subsystem,kset) : NULL; 242 if (s)
243 return kset_get(s);
244 return NULL;
253} 245}
254 246
255static inline void subsys_put(struct subsystem * s) 247static inline void subsys_put(struct kset *s)
256{ 248{
257 kset_put(&s->kset); 249 kset_put(s);
258} 250}
259 251
260struct subsys_attribute { 252struct subsys_attribute {
261 struct attribute attr; 253 struct attribute attr;
262 ssize_t (*show)(struct subsystem *, char *); 254 ssize_t (*show)(struct kset *, char *);
263 ssize_t (*store)(struct subsystem *, const char *, size_t); 255 ssize_t (*store)(struct kset *, const char *, size_t);
264}; 256};
265 257
266extern int __must_check subsys_create_file(struct subsystem * , 258extern int __must_check subsys_create_file(struct kset *,
267 struct subsys_attribute *); 259 struct subsys_attribute *);
268 260
269#if defined(CONFIG_HOTPLUG) 261#if defined(CONFIG_HOTPLUG)