aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-01-25 11:34:42 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-01-25 11:35:13 -0500
commitdf8dc74e8a383eaf2d9b44b80a71ec6f0e52b42e (patch)
treebc3799a43e8b94fa84b32e37b1c124d5e4868f50 /include/linux
parent556a169dab38b5100df6f4a45b655dddd3db94c1 (diff)
parent4a3ad20ccd8f4d2a0535cf98fa83f7b561ba59a9 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6
This can be broken down into these major areas: - Documentation updates (language translations and fixes, as well as kobject and kset documenatation updates.) - major kset/kobject/ktype rework and fixes. This cleans up the kset and kobject and ktype relationship and architecture, making sense of things now, and good documenation and samples are provided for others to use. Also the attributes for kobjects are much easier to handle now. This cleaned up a LOT of code all through the kernel, making kobjects easier to use if you want to. - struct bus_type has been reworked to now handle the lifetime rules properly, as the kobject is properly dynamic. - struct driver has also been reworked, and now the lifetime issues are resolved. - the block subsystem has been converted to use struct device now, and not "raw" kobjects. This patch has been in the -mm tree for over a year now, and finally all the issues are worked out with it. Older distros now properly work with new kernels, and no userspace updates are needed at all. - nozomi driver is added. This has also been in -mm for a long time, and many people have asked for it to go in. It is now in good enough shape to do so. - lots of class_device conversions to use struct device instead. The tree is almost all cleaned up now, only SCSI and IB is the remaining code to fix up... * git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6: (196 commits) Driver core: coding style fixes Kobject: fix coding style issues in kobject c files Kobject: fix coding style issues in kobject.h Driver core: fix coding style issues in device.h spi: use class iteration api scsi: use class iteration api rtc: use class iteration api power supply : use class iteration api ieee1394: use class iteration api Driver Core: add class iteration api Driver core: Cleanup get_device_parent() in device_add() and device_move() UIO: constify function pointer tables Driver Core: constify the name passed to platform_device_register_simple driver core: fix build with SYSFS=n sysfs: make SYSFS_DEPRECATED depend on SYSFS Driver core: use LIST_HEAD instead of call to INIT_LIST_HEAD in __init kobject: add sample code for how to use ksets/ktypes/kobjects kobject: add sample code for how to use kobjects in a simple manner. kobject: update the kobject/kset documentation kobject: remove old, outdated documentation. ...
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/device.h360
-rw-r--r--include/linux/dmaengine.h3
-rw-r--r--include/linux/fs.h2
-rw-r--r--include/linux/genhd.h37
-rw-r--r--include/linux/kobject.h184
-rw-r--r--include/linux/kref.h1
-rw-r--r--include/linux/module.h19
-rw-r--r--include/linux/pci_hotplug.h2
-rw-r--r--include/linux/pktcdvd.h2
-rw-r--r--include/linux/platform_device.h2
-rw-r--r--include/linux/sched.h9
-rw-r--r--include/linux/sysdev.h1
-rw-r--r--include/linux/tifm.h2
-rw-r--r--include/linux/uio_driver.h6
14 files changed, 305 insertions, 325 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index 2e15822fe409..1880208964d6 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -25,75 +25,69 @@
25#include <asm/device.h> 25#include <asm/device.h>
26 26
27#define DEVICE_NAME_SIZE 50 27#define DEVICE_NAME_SIZE 50
28#define DEVICE_NAME_HALF __stringify(20) /* Less than half to accommodate slop */ 28/* DEVICE_NAME_HALF is really less than half to accommodate slop */
29#define DEVICE_NAME_HALF __stringify(20)
29#define DEVICE_ID_SIZE 32 30#define DEVICE_ID_SIZE 32
30#define BUS_ID_SIZE KOBJ_NAME_LEN 31#define BUS_ID_SIZE KOBJ_NAME_LEN
31 32
32 33
33struct device; 34struct device;
34struct device_driver; 35struct device_driver;
36struct driver_private;
35struct class; 37struct class;
36struct class_device; 38struct class_device;
37struct bus_type; 39struct bus_type;
40struct bus_type_private;
38 41
39struct bus_attribute { 42struct bus_attribute {
40 struct attribute attr; 43 struct attribute attr;
41 ssize_t (*show)(struct bus_type *, char * buf); 44 ssize_t (*show)(struct bus_type *bus, char *buf);
42 ssize_t (*store)(struct bus_type *, const char * buf, size_t count); 45 ssize_t (*store)(struct bus_type *bus, const char *buf, size_t count);
43}; 46};
44 47
45#define BUS_ATTR(_name,_mode,_show,_store) \ 48#define BUS_ATTR(_name, _mode, _show, _store) \
46struct bus_attribute bus_attr_##_name = __ATTR(_name,_mode,_show,_store) 49struct bus_attribute bus_attr_##_name = __ATTR(_name, _mode, _show, _store)
47 50
48extern int __must_check bus_create_file(struct bus_type *, 51extern int __must_check bus_create_file(struct bus_type *,
49 struct bus_attribute *); 52 struct bus_attribute *);
50extern void bus_remove_file(struct bus_type *, struct bus_attribute *); 53extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
51 54
52struct bus_type { 55struct bus_type {
53 const char * name; 56 const char *name;
54 struct module * owner; 57 struct bus_attribute *bus_attrs;
58 struct device_attribute *dev_attrs;
59 struct driver_attribute *drv_attrs;
55 60
56 struct kset subsys; 61 int (*match)(struct device *dev, struct device_driver *drv);
57 struct kset drivers; 62 int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
58 struct kset devices; 63 int (*probe)(struct device *dev);
59 struct klist klist_devices; 64 int (*remove)(struct device *dev);
60 struct klist klist_drivers; 65 void (*shutdown)(struct device *dev);
61
62 struct blocking_notifier_head bus_notifier;
63
64 struct bus_attribute * bus_attrs;
65 struct device_attribute * dev_attrs;
66 struct driver_attribute * drv_attrs;
67
68 int (*match)(struct device * dev, struct device_driver * drv);
69 int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
70 int (*probe)(struct device * dev);
71 int (*remove)(struct device * dev);
72 void (*shutdown)(struct device * dev);
73 66
74 int (*suspend)(struct device * dev, pm_message_t state); 67 int (*suspend)(struct device *dev, pm_message_t state);
75 int (*suspend_late)(struct device * dev, pm_message_t state); 68 int (*suspend_late)(struct device *dev, pm_message_t state);
76 int (*resume_early)(struct device * dev); 69 int (*resume_early)(struct device *dev);
77 int (*resume)(struct device * dev); 70 int (*resume)(struct device *dev);
78 71
79 unsigned int drivers_autoprobe:1; 72 struct bus_type_private *p;
80}; 73};
81 74
82extern int __must_check bus_register(struct bus_type * bus); 75extern int __must_check bus_register(struct bus_type *bus);
83extern void bus_unregister(struct bus_type * bus); 76extern void bus_unregister(struct bus_type *bus);
84 77
85extern int __must_check bus_rescan_devices(struct bus_type * bus); 78extern int __must_check bus_rescan_devices(struct bus_type *bus);
86 79
87/* iterator helpers for buses */ 80/* iterator helpers for buses */
88 81
89int bus_for_each_dev(struct bus_type * bus, struct device * start, void * data, 82int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
90 int (*fn)(struct device *, void *)); 83 int (*fn)(struct device *dev, void *data));
91struct device * bus_find_device(struct bus_type *bus, struct device *start, 84struct device *bus_find_device(struct bus_type *bus, struct device *start,
92 void *data, int (*match)(struct device *, void *)); 85 void *data,
86 int (*match)(struct device *dev, void *data));
93 87
94int __must_check bus_for_each_drv(struct bus_type *bus, 88int __must_check bus_for_each_drv(struct bus_type *bus,
95 struct device_driver *start, void *data, 89 struct device_driver *start, void *data,
96 int (*fn)(struct device_driver *, void *)); 90 int (*fn)(struct device_driver *, void *));
97 91
98/* 92/*
99 * Bus notifiers: Get notified of addition/removal of devices 93 * Bus notifiers: Get notified of addition/removal of devices
@@ -118,111 +112,128 @@ extern int bus_unregister_notifier(struct bus_type *bus,
118#define BUS_NOTIFY_UNBIND_DRIVER 0x00000004 /* driver about to be 112#define BUS_NOTIFY_UNBIND_DRIVER 0x00000004 /* driver about to be
119 unbound */ 113 unbound */
120 114
115extern struct kset *bus_get_kset(struct bus_type *bus);
116extern struct klist *bus_get_device_klist(struct bus_type *bus);
117
121struct device_driver { 118struct device_driver {
122 const char * name; 119 const char *name;
123 struct bus_type * bus; 120 struct bus_type *bus;
124 121
125 struct kobject kobj; 122 struct module *owner;
126 struct klist klist_devices; 123 const char *mod_name; /* used for built-in modules */
127 struct klist_node knode_bus;
128 124
129 struct module * owner; 125 int (*probe) (struct device *dev);
130 const char * mod_name; /* used for built-in modules */ 126 int (*remove) (struct device *dev);
131 struct module_kobject * mkobj; 127 void (*shutdown) (struct device *dev);
128 int (*suspend) (struct device *dev, pm_message_t state);
129 int (*resume) (struct device *dev);
130 struct attribute_group **groups;
132 131
133 int (*probe) (struct device * dev); 132 struct driver_private *p;
134 int (*remove) (struct device * dev);
135 void (*shutdown) (struct device * dev);
136 int (*suspend) (struct device * dev, pm_message_t state);
137 int (*resume) (struct device * dev);
138}; 133};
139 134
140 135
141extern int __must_check driver_register(struct device_driver * drv); 136extern int __must_check driver_register(struct device_driver *drv);
142extern void driver_unregister(struct device_driver * drv); 137extern void driver_unregister(struct device_driver *drv);
143 138
144extern struct device_driver * get_driver(struct device_driver * drv); 139extern struct device_driver *get_driver(struct device_driver *drv);
145extern void put_driver(struct device_driver * drv); 140extern void put_driver(struct device_driver *drv);
146extern struct device_driver *driver_find(const char *name, struct bus_type *bus); 141extern struct device_driver *driver_find(const char *name,
142 struct bus_type *bus);
147extern int driver_probe_done(void); 143extern int driver_probe_done(void);
148 144
149/* sysfs interface for exporting driver attributes */ 145/* sysfs interface for exporting driver attributes */
150 146
151struct driver_attribute { 147struct driver_attribute {
152 struct attribute attr; 148 struct attribute attr;
153 ssize_t (*show)(struct device_driver *, char * buf); 149 ssize_t (*show)(struct device_driver *driver, char *buf);
154 ssize_t (*store)(struct device_driver *, const char * buf, size_t count); 150 ssize_t (*store)(struct device_driver *driver, const char *buf,
151 size_t count);
155}; 152};
156 153
157#define DRIVER_ATTR(_name,_mode,_show,_store) \ 154#define DRIVER_ATTR(_name, _mode, _show, _store) \
158struct driver_attribute driver_attr_##_name = __ATTR(_name,_mode,_show,_store) 155struct driver_attribute driver_attr_##_name = \
156 __ATTR(_name, _mode, _show, _store)
159 157
160extern int __must_check driver_create_file(struct device_driver *, 158extern int __must_check driver_create_file(struct device_driver *driver,
161 struct driver_attribute *); 159 struct driver_attribute *attr);
162extern void driver_remove_file(struct device_driver *, struct driver_attribute *); 160extern void driver_remove_file(struct device_driver *driver,
161 struct driver_attribute *attr);
163 162
164extern int __must_check driver_for_each_device(struct device_driver * drv, 163extern int __must_check driver_add_kobj(struct device_driver *drv,
165 struct device *start, void *data, 164 struct kobject *kobj,
166 int (*fn)(struct device *, void *)); 165 const char *fmt, ...);
167struct device * driver_find_device(struct device_driver *drv, 166
168 struct device *start, void *data, 167extern int __must_check driver_for_each_device(struct device_driver *drv,
169 int (*match)(struct device *, void *)); 168 struct device *start,
169 void *data,
170 int (*fn)(struct device *dev,
171 void *));
172struct device *driver_find_device(struct device_driver *drv,
173 struct device *start, void *data,
174 int (*match)(struct device *dev, void *data));
170 175
171/* 176/*
172 * device classes 177 * device classes
173 */ 178 */
174struct class { 179struct class {
175 const char * name; 180 const char *name;
176 struct module * owner; 181 struct module *owner;
177 182
178 struct kset subsys; 183 struct kset subsys;
179 struct list_head children; 184 struct list_head children;
180 struct list_head devices; 185 struct list_head devices;
181 struct list_head interfaces; 186 struct list_head interfaces;
182 struct kset class_dirs; 187 struct kset class_dirs;
183 struct semaphore sem; /* locks both the children and interfaces lists */ 188 struct semaphore sem; /* locks children, devices, interfaces */
184 189 struct class_attribute *class_attrs;
185 struct class_attribute * class_attrs; 190 struct class_device_attribute *class_dev_attrs;
186 struct class_device_attribute * class_dev_attrs; 191 struct device_attribute *dev_attrs;
187 struct device_attribute * dev_attrs;
188 192
189 int (*uevent)(struct class_device *dev, struct kobj_uevent_env *env); 193 int (*uevent)(struct class_device *dev, struct kobj_uevent_env *env);
190 int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); 194 int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env);
191 195
192 void (*release)(struct class_device *dev); 196 void (*release)(struct class_device *dev);
193 void (*class_release)(struct class *class); 197 void (*class_release)(struct class *class);
194 void (*dev_release)(struct device *dev); 198 void (*dev_release)(struct device *dev);
195 199
196 int (*suspend)(struct device *, pm_message_t state); 200 int (*suspend)(struct device *dev, pm_message_t state);
197 int (*resume)(struct device *); 201 int (*resume)(struct device *dev);
198}; 202};
199 203
200extern int __must_check class_register(struct class *); 204extern int __must_check class_register(struct class *class);
201extern void class_unregister(struct class *); 205extern void class_unregister(struct class *class);
206extern int class_for_each_device(struct class *class, void *data,
207 int (*fn)(struct device *dev, void *data));
208extern struct device *class_find_device(struct class *class, void *data,
209 int (*match)(struct device *, void *));
210extern struct class_device *class_find_child(struct class *class, void *data,
211 int (*match)(struct class_device *, void *));
202 212
203 213
204struct class_attribute { 214struct class_attribute {
205 struct attribute attr; 215 struct attribute attr;
206 ssize_t (*show)(struct class *, char * buf); 216 ssize_t (*show)(struct class *class, char *buf);
207 ssize_t (*store)(struct class *, const char * buf, size_t count); 217 ssize_t (*store)(struct class *class, const char *buf, size_t count);
208}; 218};
209 219
210#define CLASS_ATTR(_name,_mode,_show,_store) \ 220#define CLASS_ATTR(_name, _mode, _show, _store) \
211struct class_attribute class_attr_##_name = __ATTR(_name,_mode,_show,_store) 221struct class_attribute class_attr_##_name = __ATTR(_name, _mode, _show, _store)
212 222
213extern int __must_check class_create_file(struct class *, 223extern int __must_check class_create_file(struct class *class,
214 const struct class_attribute *); 224 const struct class_attribute *attr);
215extern void class_remove_file(struct class *, const struct class_attribute *); 225extern void class_remove_file(struct class *class,
226 const struct class_attribute *attr);
216 227
217struct class_device_attribute { 228struct class_device_attribute {
218 struct attribute attr; 229 struct attribute attr;
219 ssize_t (*show)(struct class_device *, char * buf); 230 ssize_t (*show)(struct class_device *, char *buf);
220 ssize_t (*store)(struct class_device *, const char * buf, size_t count); 231 ssize_t (*store)(struct class_device *, const char *buf, size_t count);
221}; 232};
222 233
223#define CLASS_DEVICE_ATTR(_name,_mode,_show,_store) \ 234#define CLASS_DEVICE_ATTR(_name, _mode, _show, _store) \
224struct class_device_attribute class_device_attr_##_name = \ 235struct class_device_attribute class_device_attr_##_name = \
225 __ATTR(_name,_mode,_show,_store) 236 __ATTR(_name, _mode, _show, _store)
226 237
227extern int __must_check class_device_create_file(struct class_device *, 238extern int __must_check class_device_create_file(struct class_device *,
228 const struct class_device_attribute *); 239 const struct class_device_attribute *);
@@ -255,26 +266,24 @@ struct class_device {
255 struct list_head node; 266 struct list_head node;
256 267
257 struct kobject kobj; 268 struct kobject kobj;
258 struct class * class; /* required */ 269 struct class *class;
259 dev_t devt; /* dev_t, creates the sysfs "dev" */ 270 dev_t devt;
260 struct device * dev; /* not necessary, but nice to have */ 271 struct device *dev;
261 void * class_data; /* class-specific data */ 272 void *class_data;
262 struct class_device *parent; /* parent of this child device, if there is one */ 273 struct class_device *parent;
263 struct attribute_group ** groups; /* optional groups */ 274 struct attribute_group **groups;
264 275
265 void (*release)(struct class_device *dev); 276 void (*release)(struct class_device *dev);
266 int (*uevent)(struct class_device *dev, struct kobj_uevent_env *env); 277 int (*uevent)(struct class_device *dev, struct kobj_uevent_env *env);
267 char class_id[BUS_ID_SIZE]; /* unique to this class */ 278 char class_id[BUS_ID_SIZE];
268}; 279};
269 280
270static inline void * 281static inline void *class_get_devdata(struct class_device *dev)
271class_get_devdata (struct class_device *dev)
272{ 282{
273 return dev->class_data; 283 return dev->class_data;
274} 284}
275 285
276static inline void 286static inline void class_set_devdata(struct class_device *dev, void *data)
277class_set_devdata (struct class_device *dev, void *data)
278{ 287{
279 dev->class_data = data; 288 dev->class_data = data;
280} 289}
@@ -286,10 +295,10 @@ extern void class_device_initialize(struct class_device *);
286extern int __must_check class_device_add(struct class_device *); 295extern int __must_check class_device_add(struct class_device *);
287extern void class_device_del(struct class_device *); 296extern void class_device_del(struct class_device *);
288 297
289extern struct class_device * class_device_get(struct class_device *); 298extern struct class_device *class_device_get(struct class_device *);
290extern void class_device_put(struct class_device *); 299extern void class_device_put(struct class_device *);
291 300
292extern void class_device_remove_file(struct class_device *, 301extern void class_device_remove_file(struct class_device *,
293 const struct class_device_attribute *); 302 const struct class_device_attribute *);
294extern int __must_check class_device_create_bin_file(struct class_device *, 303extern int __must_check class_device_create_bin_file(struct class_device *,
295 struct bin_attribute *); 304 struct bin_attribute *);
@@ -316,7 +325,7 @@ extern struct class_device *class_device_create(struct class *cls,
316 dev_t devt, 325 dev_t devt,
317 struct device *device, 326 struct device *device,
318 const char *fmt, ...) 327 const char *fmt, ...)
319 __attribute__((format(printf,5,6))); 328 __attribute__((format(printf, 5, 6)));
320extern void class_device_destroy(struct class *cls, dev_t devt); 329extern void class_device_destroy(struct class *cls, dev_t devt);
321 330
322/* 331/*
@@ -333,8 +342,8 @@ struct device_type {
333 struct attribute_group **groups; 342 struct attribute_group **groups;
334 int (*uevent)(struct device *dev, struct kobj_uevent_env *env); 343 int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
335 void (*release)(struct device *dev); 344 void (*release)(struct device *dev);
336 int (*suspend)(struct device * dev, pm_message_t state); 345 int (*suspend)(struct device *dev, pm_message_t state);
337 int (*resume)(struct device * dev); 346 int (*resume)(struct device *dev);
338}; 347};
339 348
340/* interface for exporting device attributes */ 349/* interface for exporting device attributes */
@@ -346,18 +355,19 @@ struct device_attribute {
346 const char *buf, size_t count); 355 const char *buf, size_t count);
347}; 356};
348 357
349#define DEVICE_ATTR(_name,_mode,_show,_store) \ 358#define DEVICE_ATTR(_name, _mode, _show, _store) \
350struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store) 359struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store)
351 360
352extern int __must_check device_create_file(struct device *device, 361extern int __must_check device_create_file(struct device *device,
353 struct device_attribute * entry); 362 struct device_attribute *entry);
354extern void device_remove_file(struct device * dev, struct device_attribute * attr); 363extern void device_remove_file(struct device *dev,
364 struct device_attribute *attr);
355extern int __must_check device_create_bin_file(struct device *dev, 365extern int __must_check device_create_bin_file(struct device *dev,
356 struct bin_attribute *attr); 366 struct bin_attribute *attr);
357extern void device_remove_bin_file(struct device *dev, 367extern void device_remove_bin_file(struct device *dev,
358 struct bin_attribute *attr); 368 struct bin_attribute *attr);
359extern int device_schedule_callback_owner(struct device *dev, 369extern int device_schedule_callback_owner(struct device *dev,
360 void (*func)(struct device *), struct module *owner); 370 void (*func)(struct device *dev), struct module *owner);
361 371
362/* This is a macro to avoid include problems with THIS_MODULE */ 372/* This is a macro to avoid include problems with THIS_MODULE */
363#define device_schedule_callback(dev, func) \ 373#define device_schedule_callback(dev, func) \
@@ -368,21 +378,21 @@ typedef void (*dr_release_t)(struct device *dev, void *res);
368typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data); 378typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data);
369 379
370#ifdef CONFIG_DEBUG_DEVRES 380#ifdef CONFIG_DEBUG_DEVRES
371extern void * __devres_alloc(dr_release_t release, size_t size, gfp_t gfp, 381extern void *__devres_alloc(dr_release_t release, size_t size, gfp_t gfp,
372 const char *name); 382 const char *name);
373#define devres_alloc(release, size, gfp) \ 383#define devres_alloc(release, size, gfp) \
374 __devres_alloc(release, size, gfp, #release) 384 __devres_alloc(release, size, gfp, #release)
375#else 385#else
376extern void * devres_alloc(dr_release_t release, size_t size, gfp_t gfp); 386extern void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp);
377#endif 387#endif
378extern void devres_free(void *res); 388extern void devres_free(void *res);
379extern void devres_add(struct device *dev, void *res); 389extern void devres_add(struct device *dev, void *res);
380extern void * devres_find(struct device *dev, dr_release_t release, 390extern void *devres_find(struct device *dev, dr_release_t release,
381 dr_match_t match, void *match_data);
382extern void * devres_get(struct device *dev, void *new_res,
383 dr_match_t match, void *match_data); 391 dr_match_t match, void *match_data);
384extern void * devres_remove(struct device *dev, dr_release_t release, 392extern void *devres_get(struct device *dev, void *new_res,
385 dr_match_t match, void *match_data); 393 dr_match_t match, void *match_data);
394extern void *devres_remove(struct device *dev, dr_release_t release,
395 dr_match_t match, void *match_data);
386extern int devres_destroy(struct device *dev, dr_release_t release, 396extern int devres_destroy(struct device *dev, dr_release_t release,
387 dr_match_t match, void *match_data); 397 dr_match_t match, void *match_data);
388 398
@@ -399,7 +409,7 @@ extern void devm_kfree(struct device *dev, void *p);
399 409
400struct device { 410struct device {
401 struct klist klist_children; 411 struct klist klist_children;
402 struct klist_node knode_parent; /* node in sibling list */ 412 struct klist_node knode_parent; /* node in sibling list */
403 struct klist_node knode_driver; 413 struct klist_node knode_driver;
404 struct klist_node knode_bus; 414 struct klist_node knode_bus;
405 struct device *parent; 415 struct device *parent;
@@ -414,7 +424,7 @@ struct device {
414 * its driver. 424 * its driver.
415 */ 425 */
416 426
417 struct bus_type * bus; /* type of bus device is on */ 427 struct bus_type *bus; /* type of bus device is on */
418 struct device_driver *driver; /* which driver has allocated this 428 struct device_driver *driver; /* which driver has allocated this
419 device */ 429 device */
420 void *driver_data; /* data private to the driver */ 430 void *driver_data; /* data private to the driver */
@@ -445,10 +455,10 @@ struct device {
445 /* class_device migration path */ 455 /* class_device migration path */
446 struct list_head node; 456 struct list_head node;
447 struct class *class; 457 struct class *class;
448 dev_t devt; /* dev_t, creates the sysfs "dev" */ 458 dev_t devt; /* dev_t, creates the sysfs "dev" */
449 struct attribute_group **groups; /* optional groups */ 459 struct attribute_group **groups; /* optional groups */
450 460
451 void (*release)(struct device * dev); 461 void (*release)(struct device *dev);
452}; 462};
453 463
454#ifdef CONFIG_NUMA 464#ifdef CONFIG_NUMA
@@ -470,14 +480,12 @@ static inline void set_dev_node(struct device *dev, int node)
470} 480}
471#endif 481#endif
472 482
473static inline void * 483static inline void *dev_get_drvdata(struct device *dev)
474dev_get_drvdata (struct device *dev)
475{ 484{
476 return dev->driver_data; 485 return dev->driver_data;
477} 486}
478 487
479static inline void 488static inline void dev_set_drvdata(struct device *dev, void *data)
480dev_set_drvdata (struct device *dev, void *data)
481{ 489{
482 dev->driver_data = data; 490 dev->driver_data = data;
483} 491}
@@ -492,15 +500,15 @@ void driver_init(void);
492/* 500/*
493 * High level routines for use by the bus drivers 501 * High level routines for use by the bus drivers
494 */ 502 */
495extern int __must_check device_register(struct device * dev); 503extern int __must_check device_register(struct device *dev);
496extern void device_unregister(struct device * dev); 504extern void device_unregister(struct device *dev);
497extern void device_initialize(struct device * dev); 505extern void device_initialize(struct device *dev);
498extern int __must_check device_add(struct device * dev); 506extern int __must_check device_add(struct device *dev);
499extern void device_del(struct device * dev); 507extern void device_del(struct device *dev);
500extern int device_for_each_child(struct device *, void *, 508extern int device_for_each_child(struct device *dev, void *data,
501 int (*fn)(struct device *, void *)); 509 int (*fn)(struct device *dev, void *data));
502extern struct device *device_find_child(struct device *, void *data, 510extern struct device *device_find_child(struct device *dev, void *data,
503 int (*match)(struct device *, void *)); 511 int (*match)(struct device *dev, void *data));
504extern int device_rename(struct device *dev, char *new_name); 512extern int device_rename(struct device *dev, char *new_name);
505extern int device_move(struct device *dev, struct device *new_parent); 513extern int device_move(struct device *dev, struct device *new_parent);
506 514
@@ -509,8 +517,8 @@ extern int device_move(struct device *dev, struct device *new_parent);
509 * for information on use. 517 * for information on use.
510 */ 518 */
511extern int __must_check device_bind_driver(struct device *dev); 519extern int __must_check device_bind_driver(struct device *dev);
512extern void device_release_driver(struct device * dev); 520extern void device_release_driver(struct device *dev);
513extern int __must_check device_attach(struct device * dev); 521extern int __must_check device_attach(struct device *dev);
514extern int __must_check driver_attach(struct device_driver *drv); 522extern int __must_check driver_attach(struct device_driver *drv);
515extern int __must_check device_reprobe(struct device *dev); 523extern int __must_check device_reprobe(struct device *dev);
516 524
@@ -519,8 +527,16 @@ extern int __must_check device_reprobe(struct device *dev);
519 */ 527 */
520extern struct device *device_create(struct class *cls, struct device *parent, 528extern struct device *device_create(struct class *cls, struct device *parent,
521 dev_t devt, const char *fmt, ...) 529 dev_t devt, const char *fmt, ...)
522 __attribute__((format(printf,4,5))); 530 __attribute__((format(printf, 4, 5)));
523extern void device_destroy(struct class *cls, dev_t devt); 531extern void device_destroy(struct class *cls, dev_t devt);
532#ifdef CONFIG_PM_SLEEP
533extern void destroy_suspended_device(struct class *cls, dev_t devt);
534#else /* !CONFIG_PM_SLEEP */
535static inline void destroy_suspended_device(struct class *cls, dev_t devt)
536{
537 device_destroy(cls, devt);
538}
539#endif /* !CONFIG_PM_SLEEP */
524 540
525/* 541/*
526 * Platform "fixup" functions - allow the platform to have their say 542 * Platform "fixup" functions - allow the platform to have their say
@@ -528,17 +544,17 @@ extern void device_destroy(struct class *cls, dev_t devt);
528 * know about. 544 * know about.
529 */ 545 */
530/* Notify platform of device discovery */ 546/* Notify platform of device discovery */
531extern int (*platform_notify)(struct device * dev); 547extern int (*platform_notify)(struct device *dev);
532 548
533extern int (*platform_notify_remove)(struct device * dev); 549extern int (*platform_notify_remove)(struct device *dev);
534 550
535 551
536/** 552/**
537 * get_device - atomically increment the reference count for the device. 553 * get_device - atomically increment the reference count for the device.
538 * 554 *
539 */ 555 */
540extern struct device * get_device(struct device * dev); 556extern struct device *get_device(struct device *dev);
541extern void put_device(struct device * dev); 557extern void put_device(struct device *dev);
542 558
543 559
544/* drivers/base/power/shutdown.c */ 560/* drivers/base/power/shutdown.c */
@@ -547,22 +563,33 @@ extern void device_shutdown(void);
547/* drivers/base/sys.c */ 563/* drivers/base/sys.c */
548extern void sysdev_shutdown(void); 564extern void sysdev_shutdown(void);
549 565
550
551/* drivers/base/firmware.c */
552extern int __must_check firmware_register(struct kset *);
553extern void firmware_unregister(struct kset *);
554
555/* debugging and troubleshooting/diagnostic helpers. */ 566/* debugging and troubleshooting/diagnostic helpers. */
556extern const char *dev_driver_string(struct device *dev); 567extern const char *dev_driver_string(struct device *dev);
557#define dev_printk(level, dev, format, arg...) \ 568#define dev_printk(level, dev, format, arg...) \
558 printk(level "%s %s: " format , dev_driver_string(dev) , (dev)->bus_id , ## arg) 569 printk(level "%s %s: " format , dev_driver_string(dev) , \
570 (dev)->bus_id , ## arg)
571
572#define dev_emerg(dev, format, arg...) \
573 dev_printk(KERN_EMERG , dev , format , ## arg)
574#define dev_alert(dev, format, arg...) \
575 dev_printk(KERN_ALERT , dev , format , ## arg)
576#define dev_crit(dev, format, arg...) \
577 dev_printk(KERN_CRIT , dev , format , ## arg)
578#define dev_err(dev, format, arg...) \
579 dev_printk(KERN_ERR , dev , format , ## arg)
580#define dev_warn(dev, format, arg...) \
581 dev_printk(KERN_WARNING , dev , format , ## arg)
582#define dev_notice(dev, format, arg...) \
583 dev_printk(KERN_NOTICE , dev , format , ## arg)
584#define dev_info(dev, format, arg...) \
585 dev_printk(KERN_INFO , dev , format , ## arg)
559 586
560#ifdef DEBUG 587#ifdef DEBUG
561#define dev_dbg(dev, format, arg...) \ 588#define dev_dbg(dev, format, arg...) \
562 dev_printk(KERN_DEBUG , dev , format , ## arg) 589 dev_printk(KERN_DEBUG , dev , format , ## arg)
563#else 590#else
564static inline int __attribute__ ((format (printf, 2, 3))) 591static inline int __attribute__ ((format (printf, 2, 3)))
565dev_dbg(struct device * dev, const char * fmt, ...) 592dev_dbg(struct device *dev, const char *fmt, ...)
566{ 593{
567 return 0; 594 return 0;
568} 595}
@@ -572,21 +599,12 @@ dev_dbg(struct device * dev, const char * fmt, ...)
572#define dev_vdbg dev_dbg 599#define dev_vdbg dev_dbg
573#else 600#else
574static inline int __attribute__ ((format (printf, 2, 3))) 601static inline int __attribute__ ((format (printf, 2, 3)))
575dev_vdbg(struct device * dev, const char * fmt, ...) 602dev_vdbg(struct device *dev, const char *fmt, ...)
576{ 603{
577 return 0; 604 return 0;
578} 605}
579#endif 606#endif
580 607
581#define dev_err(dev, format, arg...) \
582 dev_printk(KERN_ERR , dev , format , ## arg)
583#define dev_info(dev, format, arg...) \
584 dev_printk(KERN_INFO , dev , format , ## arg)
585#define dev_warn(dev, format, arg...) \
586 dev_printk(KERN_WARNING , dev , format , ## arg)
587#define dev_notice(dev, format, arg...) \
588 dev_printk(KERN_NOTICE , dev , format , ## arg)
589
590/* Create alias, so I can be autoloaded. */ 608/* Create alias, so I can be autoloaded. */
591#define MODULE_ALIAS_CHARDEV(major,minor) \ 609#define MODULE_ALIAS_CHARDEV(major,minor) \
592 MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor)) 610 MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index a3b6035b6c86..55c9a6952f44 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -132,7 +132,7 @@ struct dma_chan {
132 132
133 /* sysfs */ 133 /* sysfs */
134 int chan_id; 134 int chan_id;
135 struct class_device class_dev; 135 struct device dev;
136 136
137 struct kref refcount; 137 struct kref refcount;
138 int slow_ref; 138 int slow_ref;
@@ -142,6 +142,7 @@ struct dma_chan {
142 struct dma_chan_percpu *local; 142 struct dma_chan_percpu *local;
143}; 143};
144 144
145#define to_dma_chan(p) container_of(p, struct dma_chan, dev)
145 146
146void dma_chan_cleanup(struct kref *kref); 147void dma_chan_cleanup(struct kref *kref);
147 148
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b3ec4a496d64..21398a5d688d 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1476,7 +1476,7 @@ extern void drop_collected_mounts(struct vfsmount *);
1476extern int vfs_statfs(struct dentry *, struct kstatfs *); 1476extern int vfs_statfs(struct dentry *, struct kstatfs *);
1477 1477
1478/* /sys/fs */ 1478/* /sys/fs */
1479extern struct kset fs_subsys; 1479extern struct kobject *fs_kobj;
1480 1480
1481#define FLOCK_VERIFY_READ 1 1481#define FLOCK_VERIFY_READ 1
1482#define FLOCK_VERIFY_WRITE 2 1482#define FLOCK_VERIFY_WRITE 2
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index a47b8025d399..1dbea0ac5693 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -10,9 +10,19 @@
10 */ 10 */
11 11
12#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/kdev_t.h>
13 14
14#ifdef CONFIG_BLOCK 15#ifdef CONFIG_BLOCK
15 16
17#define kobj_to_dev(k) container_of(k, struct device, kobj)
18#define dev_to_disk(device) container_of(device, struct gendisk, dev)
19#define dev_to_part(device) container_of(device, struct hd_struct, dev)
20
21extern struct device_type disk_type;
22extern struct device_type part_type;
23extern struct kobject *block_depr;
24extern struct class block_class;
25
16enum { 26enum {
17/* These three have identical behaviour; use the second one if DOS FDISK gets 27/* These three have identical behaviour; use the second one if DOS FDISK gets
18 confused about extended/logical partitions starting past cylinder 1023. */ 28 confused about extended/logical partitions starting past cylinder 1023. */
@@ -84,7 +94,7 @@ struct partition {
84struct hd_struct { 94struct hd_struct {
85 sector_t start_sect; 95 sector_t start_sect;
86 sector_t nr_sects; 96 sector_t nr_sects;
87 struct kobject kobj; 97 struct device dev;
88 struct kobject *holder_dir; 98 struct kobject *holder_dir;
89 unsigned ios[2], sectors[2]; /* READs and WRITEs */ 99 unsigned ios[2], sectors[2]; /* READs and WRITEs */
90 int policy, partno; 100 int policy, partno;
@@ -117,15 +127,14 @@ struct gendisk {
117 * disks that can't be partitioned. */ 127 * disks that can't be partitioned. */
118 char disk_name[32]; /* name of major driver */ 128 char disk_name[32]; /* name of major driver */
119 struct hd_struct **part; /* [indexed by minor] */ 129 struct hd_struct **part; /* [indexed by minor] */
120 int part_uevent_suppress;
121 struct block_device_operations *fops; 130 struct block_device_operations *fops;
122 struct request_queue *queue; 131 struct request_queue *queue;
123 void *private_data; 132 void *private_data;
124 sector_t capacity; 133 sector_t capacity;
125 134
126 int flags; 135 int flags;
127 struct device *driverfs_dev; 136 struct device *driverfs_dev; // FIXME: remove
128 struct kobject kobj; 137 struct device dev;
129 struct kobject *holder_dir; 138 struct kobject *holder_dir;
130 struct kobject *slave_dir; 139 struct kobject *slave_dir;
131 140
@@ -143,13 +152,6 @@ struct gendisk {
143 struct work_struct async_notify; 152 struct work_struct async_notify;
144}; 153};
145 154
146/* Structure for sysfs attributes on block devices */
147struct disk_attribute {
148 struct attribute attr;
149 ssize_t (*show)(struct gendisk *, char *);
150 ssize_t (*store)(struct gendisk *, const char *, size_t);
151};
152
153/* 155/*
154 * Macros to operate on percpu disk statistics: 156 * Macros to operate on percpu disk statistics:
155 * 157 *
@@ -411,7 +413,8 @@ struct unixware_disklabel {
411#define ADDPART_FLAG_RAID 1 413#define ADDPART_FLAG_RAID 1
412#define ADDPART_FLAG_WHOLEDISK 2 414#define ADDPART_FLAG_WHOLEDISK 2
413 415
414char *disk_name (struct gendisk *hd, int part, char *buf); 416extern dev_t blk_lookup_devt(const char *name);
417extern char *disk_name (struct gendisk *hd, int part, char *buf);
415 418
416extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); 419extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev);
417extern void add_partition(struct gendisk *, int, sector_t, sector_t, int); 420extern void add_partition(struct gendisk *, int, sector_t, sector_t, int);
@@ -423,12 +426,12 @@ extern struct gendisk *alloc_disk(int minors);
423extern struct kobject *get_disk(struct gendisk *disk); 426extern struct kobject *get_disk(struct gendisk *disk);
424extern void put_disk(struct gendisk *disk); 427extern void put_disk(struct gendisk *disk);
425extern void genhd_media_change_notify(struct gendisk *disk); 428extern void genhd_media_change_notify(struct gendisk *disk);
426extern void blk_register_region(dev_t dev, unsigned long range, 429extern void blk_register_region(dev_t devt, unsigned long range,
427 struct module *module, 430 struct module *module,
428 struct kobject *(*probe)(dev_t, int *, void *), 431 struct kobject *(*probe)(dev_t, int *, void *),
429 int (*lock)(dev_t, void *), 432 int (*lock)(dev_t, void *),
430 void *data); 433 void *data);
431extern void blk_unregister_region(dev_t dev, unsigned long range); 434extern void blk_unregister_region(dev_t devt, unsigned long range);
432 435
433static inline struct block_device *bdget_disk(struct gendisk *disk, int index) 436static inline struct block_device *bdget_disk(struct gendisk *disk, int index)
434{ 437{
@@ -441,6 +444,12 @@ static inline struct block_device *bdget_disk(struct gendisk *disk, int index)
441 444
442static inline void printk_all_partitions(void) { } 445static inline void printk_all_partitions(void) { }
443 446
447static inline dev_t blk_lookup_devt(const char *name)
448{
449 dev_t devt = MKDEV(0, 0);
450 return devt;
451}
452
444#endif /* CONFIG_BLOCK */ 453#endif /* CONFIG_BLOCK */
445 454
446#endif 455#endif
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 4a0d27f475d7..caa3f411f15d 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -3,15 +3,14 @@
3 * 3 *
4 * Copyright (c) 2002-2003 Patrick Mochel 4 * Copyright (c) 2002-2003 Patrick Mochel
5 * Copyright (c) 2002-2003 Open Source Development Labs 5 * Copyright (c) 2002-2003 Open Source Development Labs
6 * Copyright (c) 2006-2007 Greg Kroah-Hartman <greg@kroah.com> 6 * Copyright (c) 2006-2008 Greg Kroah-Hartman <greg@kroah.com>
7 * Copyright (c) 2006-2007 Novell Inc. 7 * Copyright (c) 2006-2008 Novell Inc.
8 * 8 *
9 * This file is released under the GPLv2. 9 * This file is released under the GPLv2.
10 * 10 *
11 *
12 * Please read Documentation/kobject.txt before using the kobject 11 * Please read Documentation/kobject.txt before using the kobject
13 * interface, ESPECIALLY the parts about reference counts and object 12 * interface, ESPECIALLY the parts about reference counts and object
14 * destructors. 13 * destructors.
15 */ 14 */
16 15
17#ifndef _KOBJECT_H_ 16#ifndef _KOBJECT_H_
@@ -61,48 +60,54 @@ enum kobject_action {
61}; 60};
62 61
63struct kobject { 62struct kobject {
64 const char * k_name; 63 const char *name;
65 struct kref kref; 64 struct kref kref;
66 struct list_head entry; 65 struct list_head entry;
67 struct kobject * parent; 66 struct kobject *parent;
68 struct kset * kset; 67 struct kset *kset;
69 struct kobj_type * ktype; 68 struct kobj_type *ktype;
70 struct sysfs_dirent * sd; 69 struct sysfs_dirent *sd;
70 unsigned int state_initialized:1;
71 unsigned int state_in_sysfs:1;
72 unsigned int state_add_uevent_sent:1;
73 unsigned int state_remove_uevent_sent:1;
71}; 74};
72 75
73extern int kobject_set_name(struct kobject *, const char *, ...) 76extern int kobject_set_name(struct kobject *kobj, const char *name, ...)
74 __attribute__((format(printf,2,3))); 77 __attribute__((format(printf, 2, 3)));
75 78
76static inline const char * kobject_name(const struct kobject * kobj) 79static inline const char *kobject_name(const struct kobject *kobj)
77{ 80{
78 return kobj->k_name; 81 return kobj->name;
79} 82}
80 83
81extern void kobject_init(struct kobject *); 84extern void kobject_init(struct kobject *kobj, struct kobj_type *ktype);
82extern void kobject_cleanup(struct kobject *); 85extern int __must_check kobject_add(struct kobject *kobj,
86 struct kobject *parent,
87 const char *fmt, ...);
88extern int __must_check kobject_init_and_add(struct kobject *kobj,
89 struct kobj_type *ktype,
90 struct kobject *parent,
91 const char *fmt, ...);
92
93extern void kobject_del(struct kobject *kobj);
83 94
84extern int __must_check kobject_add(struct kobject *); 95extern struct kobject * __must_check kobject_create(void);
85extern void kobject_del(struct kobject *); 96extern struct kobject * __must_check kobject_create_and_add(const char *name,
97 struct kobject *parent);
86 98
87extern int __must_check kobject_rename(struct kobject *, const char *new_name); 99extern int __must_check kobject_rename(struct kobject *, const char *new_name);
88extern int __must_check kobject_move(struct kobject *, struct kobject *); 100extern int __must_check kobject_move(struct kobject *, struct kobject *);
89 101
90extern int __must_check kobject_register(struct kobject *); 102extern struct kobject *kobject_get(struct kobject *kobj);
91extern void kobject_unregister(struct kobject *); 103extern void kobject_put(struct kobject *kobj);
92
93extern struct kobject * kobject_get(struct kobject *);
94extern void kobject_put(struct kobject *);
95
96extern struct kobject *kobject_kset_add_dir(struct kset *kset,
97 struct kobject *, const char *);
98extern struct kobject *kobject_add_dir(struct kobject *, const char *);
99 104
100extern char * kobject_get_path(struct kobject *, gfp_t); 105extern char *kobject_get_path(struct kobject *kobj, gfp_t flag);
101 106
102struct kobj_type { 107struct kobj_type {
103 void (*release)(struct kobject *); 108 void (*release)(struct kobject *kobj);
104 struct sysfs_ops * sysfs_ops; 109 struct sysfs_ops *sysfs_ops;
105 struct attribute ** default_attrs; 110 struct attribute **default_attrs;
106}; 111};
107 112
108struct kobj_uevent_env { 113struct kobj_uevent_env {
@@ -119,6 +124,16 @@ struct kset_uevent_ops {
119 struct kobj_uevent_env *env); 124 struct kobj_uevent_env *env);
120}; 125};
121 126
127struct kobj_attribute {
128 struct attribute attr;
129 ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,
130 char *buf);
131 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
132 const char *buf, size_t count);
133};
134
135extern struct sysfs_ops kobj_sysfs_ops;
136
122/** 137/**
123 * struct kset - a set of kobjects of a specific type, belonging to a specific subsystem. 138 * struct kset - a set of kobjects of a specific type, belonging to a specific subsystem.
124 * 139 *
@@ -128,7 +143,6 @@ struct kset_uevent_ops {
128 * define the attribute callbacks and other common events that happen to 143 * define the attribute callbacks and other common events that happen to
129 * a kobject. 144 * a kobject.
130 * 145 *
131 * @ktype: the struct kobj_type for this specific kset
132 * @list: the list of all kobjects for this kset 146 * @list: the list of all kobjects for this kset
133 * @list_lock: a lock for iterating over the kobjects 147 * @list_lock: a lock for iterating over the kobjects
134 * @kobj: the embedded kobject for this kset (recursion, isn't it fun...) 148 * @kobj: the embedded kobject for this kset (recursion, isn't it fun...)
@@ -138,99 +152,49 @@ struct kset_uevent_ops {
138 * desired. 152 * desired.
139 */ 153 */
140struct kset { 154struct kset {
141 struct kobj_type *ktype; 155 struct list_head list;
142 struct list_head list; 156 spinlock_t list_lock;
143 spinlock_t list_lock; 157 struct kobject kobj;
144 struct kobject kobj; 158 struct kset_uevent_ops *uevent_ops;
145 struct kset_uevent_ops *uevent_ops;
146}; 159};
147 160
161extern void kset_init(struct kset *kset);
162extern int __must_check kset_register(struct kset *kset);
163extern void kset_unregister(struct kset *kset);
164extern struct kset * __must_check kset_create_and_add(const char *name,
165 struct kset_uevent_ops *u,
166 struct kobject *parent_kobj);
148 167
149extern void kset_init(struct kset * k); 168static inline struct kset *to_kset(struct kobject *kobj)
150extern int __must_check kset_add(struct kset * k);
151extern int __must_check kset_register(struct kset * k);
152extern void kset_unregister(struct kset * k);
153
154static inline struct kset * to_kset(struct kobject * kobj)
155{ 169{
156 return kobj ? container_of(kobj,struct kset,kobj) : NULL; 170 return kobj ? container_of(kobj, struct kset, kobj) : NULL;
157} 171}
158 172
159static inline struct kset * kset_get(struct kset * k) 173static inline struct kset *kset_get(struct kset *k)
160{ 174{
161 return k ? to_kset(kobject_get(&k->kobj)) : NULL; 175 return k ? to_kset(kobject_get(&k->kobj)) : NULL;
162} 176}
163 177
164static inline void kset_put(struct kset * k) 178static inline void kset_put(struct kset *k)
165{ 179{
166 kobject_put(&k->kobj); 180 kobject_put(&k->kobj);
167} 181}
168 182
169static inline struct kobj_type * get_ktype(struct kobject * k) 183static inline struct kobj_type *get_ktype(struct kobject *kobj)
170{ 184{
171 if (k->kset && k->kset->ktype) 185 return kobj->ktype;
172 return k->kset->ktype;
173 else
174 return k->ktype;
175} 186}
176 187
177extern struct kobject * kset_find_obj(struct kset *, const char *); 188extern struct kobject *kset_find_obj(struct kset *, const char *);
178
179
180/*
181 * Use this when initializing an embedded kset with no other
182 * fields to initialize.
183 */
184#define set_kset_name(str) .kset = { .kobj = { .k_name = str } }
185
186
187#define decl_subsys(_name,_type,_uevent_ops) \
188struct kset _name##_subsys = { \
189 .kobj = { .k_name = __stringify(_name) }, \
190 .ktype = _type, \
191 .uevent_ops =_uevent_ops, \
192}
193#define decl_subsys_name(_varname,_name,_type,_uevent_ops) \
194struct kset _varname##_subsys = { \
195 .kobj = { .k_name = __stringify(_name) }, \
196 .ktype = _type, \
197 .uevent_ops =_uevent_ops, \
198}
199
200/* The global /sys/kernel/ subsystem for people to chain off of */
201extern struct kset kernel_subsys;
202/* The global /sys/hypervisor/ subsystem */
203extern struct kset hypervisor_subsys;
204
205/*
206 * Helpers for setting the kset of registered objects.
207 * Often, a registered object belongs to a kset embedded in a
208 * subsystem. These do no magic, just make the resulting code
209 * easier to follow.
210 */
211
212/**
213 * kobj_set_kset_s(obj,subsys) - set kset for embedded kobject.
214 * @obj: ptr to some object type.
215 * @subsys: a subsystem object (not a ptr).
216 *
217 * Can be used for any object type with an embedded ->kobj.
218 */
219
220#define kobj_set_kset_s(obj,subsys) \
221 (obj)->kobj.kset = &(subsys)
222
223extern int __must_check subsystem_register(struct kset *);
224extern void subsystem_unregister(struct kset *);
225
226struct subsys_attribute {
227 struct attribute attr;
228 ssize_t (*show)(struct kset *, char *);
229 ssize_t (*store)(struct kset *, const char *, size_t);
230};
231 189
232extern int __must_check subsys_create_file(struct kset *, 190/* The global /sys/kernel/ kobject for people to chain off of */
233 struct subsys_attribute *); 191extern struct kobject *kernel_kobj;
192/* The global /sys/hypervisor/ kobject for people to chain off of */
193extern struct kobject *hypervisor_kobj;
194/* The global /sys/power/ kobject for people to chain off of */
195extern struct kobject *power_kobj;
196/* The global /sys/firmware/ kobject for people to chain off of */
197extern struct kobject *firmware_kobj;
234 198
235#if defined(CONFIG_HOTPLUG) 199#if defined(CONFIG_HOTPLUG)
236int kobject_uevent(struct kobject *kobj, enum kobject_action action); 200int kobject_uevent(struct kobject *kobj, enum kobject_action action);
@@ -243,18 +207,20 @@ int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...)
243int kobject_action_type(const char *buf, size_t count, 207int kobject_action_type(const char *buf, size_t count,
244 enum kobject_action *type); 208 enum kobject_action *type);
245#else 209#else
246static inline int kobject_uevent(struct kobject *kobj, enum kobject_action action) 210static inline int kobject_uevent(struct kobject *kobj,
211 enum kobject_action action)
247{ return 0; } 212{ return 0; }
248static inline int kobject_uevent_env(struct kobject *kobj, 213static inline int kobject_uevent_env(struct kobject *kobj,
249 enum kobject_action action, 214 enum kobject_action action,
250 char *envp[]) 215 char *envp[])
251{ return 0; } 216{ return 0; }
252 217
253static inline int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...) 218static inline int add_uevent_var(struct kobj_uevent_env *env,
219 const char *format, ...)
254{ return 0; } 220{ return 0; }
255 221
256static inline int kobject_action_type(const char *buf, size_t count, 222static inline int kobject_action_type(const char *buf, size_t count,
257 enum kobject_action *type) 223 enum kobject_action *type)
258{ return -EINVAL; } 224{ return -EINVAL; }
259#endif 225#endif
260 226
diff --git a/include/linux/kref.h b/include/linux/kref.h
index 6fee3539893f..5d185635786e 100644
--- a/include/linux/kref.h
+++ b/include/linux/kref.h
@@ -24,6 +24,7 @@ struct kref {
24 atomic_t refcount; 24 atomic_t refcount;
25}; 25};
26 26
27void kref_set(struct kref *kref, int num);
27void kref_init(struct kref *kref); 28void kref_init(struct kref *kref);
28void kref_get(struct kref *kref); 29void kref_get(struct kref *kref);
29int kref_put(struct kref *kref, void (*release) (struct kref *kref)); 30int kref_put(struct kref *kref, void (*release) (struct kref *kref));
diff --git a/include/linux/module.h b/include/linux/module.h
index 2cbc0b87e329..c97bdb7eb957 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -574,7 +574,9 @@ struct device_driver;
574#ifdef CONFIG_SYSFS 574#ifdef CONFIG_SYSFS
575struct module; 575struct module;
576 576
577extern struct kset module_subsys; 577extern struct kset *module_kset;
578extern struct kobj_type module_ktype;
579extern int module_sysfs_initialized;
578 580
579int mod_sysfs_init(struct module *mod); 581int mod_sysfs_init(struct module *mod);
580int mod_sysfs_setup(struct module *mod, 582int mod_sysfs_setup(struct module *mod,
@@ -607,21 +609,6 @@ static inline void module_remove_modinfo_attrs(struct module *mod)
607 609
608#endif /* CONFIG_SYSFS */ 610#endif /* CONFIG_SYSFS */
609 611
610#if defined(CONFIG_SYSFS) && defined(CONFIG_MODULES)
611
612void module_add_driver(struct module *mod, struct device_driver *drv);
613void module_remove_driver(struct device_driver *drv);
614
615#else /* not both CONFIG_SYSFS && CONFIG_MODULES */
616
617static inline void module_add_driver(struct module *mod, struct device_driver *drv)
618{ }
619
620static inline void module_remove_driver(struct device_driver *drv)
621{ }
622
623#endif
624
625#define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x) 612#define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)
626 613
627/* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */ 614/* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */
diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
index ab4cb6ecd47c..8f67e8f2a3cc 100644
--- a/include/linux/pci_hotplug.h
+++ b/include/linux/pci_hotplug.h
@@ -174,7 +174,7 @@ extern int pci_hp_register (struct hotplug_slot *slot);
174extern int pci_hp_deregister (struct hotplug_slot *slot); 174extern int pci_hp_deregister (struct hotplug_slot *slot);
175extern int __must_check pci_hp_change_slot_info (struct hotplug_slot *slot, 175extern int __must_check pci_hp_change_slot_info (struct hotplug_slot *slot,
176 struct hotplug_slot_info *info); 176 struct hotplug_slot_info *info);
177extern struct kset pci_hotplug_slots_subsys; 177extern struct kset *pci_hotplug_slots_kset;
178 178
179/* PCI Setting Record (Type 0) */ 179/* PCI Setting Record (Type 0) */
180struct hpp_type0 { 180struct hpp_type0 {
diff --git a/include/linux/pktcdvd.h b/include/linux/pktcdvd.h
index 5ea4f05683f6..04b4d7330e6d 100644
--- a/include/linux/pktcdvd.h
+++ b/include/linux/pktcdvd.h
@@ -290,7 +290,7 @@ struct pktcdvd_device
290 int write_congestion_off; 290 int write_congestion_off;
291 int write_congestion_on; 291 int write_congestion_on;
292 292
293 struct class_device *clsdev; /* sysfs pktcdvd[0-7] class dev */ 293 struct device *dev; /* sysfs pktcdvd[0-7] dev */
294 struct pktcdvd_kobj *kobj_stat; /* sysfs pktcdvd[0-7]/stat/ */ 294 struct pktcdvd_kobj *kobj_stat; /* sysfs pktcdvd[0-7]/stat/ */
295 struct pktcdvd_kobj *kobj_wqueue; /* sysfs pktcdvd[0-7]/write_queue/ */ 295 struct pktcdvd_kobj *kobj_wqueue; /* sysfs pktcdvd[0-7]/write_queue/ */
296 296
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index e80804316cdb..3261681c82a4 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -35,7 +35,7 @@ extern struct resource *platform_get_resource_byname(struct platform_device *, u
35extern int platform_get_irq_byname(struct platform_device *, char *); 35extern int platform_get_irq_byname(struct platform_device *, char *);
36extern int platform_add_devices(struct platform_device **, int); 36extern int platform_add_devices(struct platform_device **, int);
37 37
38extern struct platform_device *platform_device_register_simple(char *, int id, 38extern struct platform_device *platform_device_register_simple(const char *, int id,
39 struct resource *, unsigned int); 39 struct resource *, unsigned int);
40 40
41extern struct platform_device *platform_device_alloc(const char *name, int id); 41extern struct platform_device *platform_device_alloc(const char *name, int id);
diff --git a/include/linux/sched.h b/include/linux/sched.h
index cc14656f8682..d6eacda765ca 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -552,18 +552,13 @@ struct user_struct {
552#ifdef CONFIG_FAIR_USER_SCHED 552#ifdef CONFIG_FAIR_USER_SCHED
553 struct task_group *tg; 553 struct task_group *tg;
554#ifdef CONFIG_SYSFS 554#ifdef CONFIG_SYSFS
555 struct kset kset; 555 struct kobject kobj;
556 struct subsys_attribute user_attr;
557 struct work_struct work; 556 struct work_struct work;
558#endif 557#endif
559#endif 558#endif
560}; 559};
561 560
562#ifdef CONFIG_FAIR_USER_SCHED 561extern int uids_sysfs_init(void);
563extern int uids_kobject_init(void);
564#else
565static inline int uids_kobject_init(void) { return 0; }
566#endif
567 562
568extern struct user_struct *find_user(uid_t); 563extern struct user_struct *find_user(uid_t);
569 564
diff --git a/include/linux/sysdev.h b/include/linux/sysdev.h
index e285746588d6..f752e73bf977 100644
--- a/include/linux/sysdev.h
+++ b/include/linux/sysdev.h
@@ -29,6 +29,7 @@
29struct sys_device; 29struct sys_device;
30 30
31struct sysdev_class { 31struct sysdev_class {
32 const char *name;
32 struct list_head drivers; 33 struct list_head drivers;
33 34
34 /* Default operations for these types of devices */ 35 /* Default operations for these types of devices */
diff --git a/include/linux/tifm.h b/include/linux/tifm.h
index 6b3a31805c72..2096b76d0cee 100644
--- a/include/linux/tifm.h
+++ b/include/linux/tifm.h
@@ -120,7 +120,7 @@ struct tifm_adapter {
120 struct completion *finish_me; 120 struct completion *finish_me;
121 121
122 struct work_struct media_switcher; 122 struct work_struct media_switcher;
123 struct class_device cdev; 123 struct device dev;
124 124
125 void (*eject)(struct tifm_adapter *fm, 125 void (*eject)(struct tifm_adapter *fm,
126 struct tifm_dev *sock); 126 struct tifm_dev *sock);
diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
index 44c28e94df50..973386d439da 100644
--- a/include/linux/uio_driver.h
+++ b/include/linux/uio_driver.h
@@ -18,20 +18,22 @@
18#include <linux/fs.h> 18#include <linux/fs.h>
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20 20
21struct uio_map;
22
21/** 23/**
22 * struct uio_mem - description of a UIO memory region 24 * struct uio_mem - description of a UIO memory region
23 * @kobj: kobject for this mapping
24 * @addr: address of the device's memory 25 * @addr: address of the device's memory
25 * @size: size of IO 26 * @size: size of IO
26 * @memtype: type of memory addr points to 27 * @memtype: type of memory addr points to
27 * @internal_addr: ioremap-ped version of addr, for driver internal use 28 * @internal_addr: ioremap-ped version of addr, for driver internal use
29 * @map: for use by the UIO core only.
28 */ 30 */
29struct uio_mem { 31struct uio_mem {
30 struct kobject kobj;
31 unsigned long addr; 32 unsigned long addr;
32 unsigned long size; 33 unsigned long size;
33 int memtype; 34 int memtype;
34 void __iomem *internal_addr; 35 void __iomem *internal_addr;
36 struct uio_map *map;
35}; 37};
36 38
37#define MAX_UIO_MAPS 5 39#define MAX_UIO_MAPS 5