aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/device.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/device.h')
-rw-r--r--include/linux/device.h64
1 files changed, 34 insertions, 30 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index df94c0de53f2..7b781a72b293 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -14,6 +14,7 @@
14#include <linux/config.h> 14#include <linux/config.h>
15#include <linux/ioport.h> 15#include <linux/ioport.h>
16#include <linux/kobject.h> 16#include <linux/kobject.h>
17#include <linux/klist.h>
17#include <linux/list.h> 18#include <linux/list.h>
18#include <linux/types.h> 19#include <linux/types.h>
19#include <linux/module.h> 20#include <linux/module.h>
@@ -44,14 +45,15 @@ struct device;
44struct device_driver; 45struct device_driver;
45struct class; 46struct class;
46struct class_device; 47struct class_device;
47struct class_simple;
48 48
49struct bus_type { 49struct bus_type {
50 char * name; 50 const char * name;
51 51
52 struct subsystem subsys; 52 struct subsystem subsys;
53 struct kset drivers; 53 struct kset drivers;
54 struct kset devices; 54 struct kset devices;
55 struct klist klist_devices;
56 struct klist klist_drivers;
55 57
56 struct bus_attribute * bus_attrs; 58 struct bus_attribute * bus_attrs;
57 struct device_attribute * dev_attrs; 59 struct device_attribute * dev_attrs;
@@ -98,17 +100,18 @@ extern int bus_create_file(struct bus_type *, struct bus_attribute *);
98extern void bus_remove_file(struct bus_type *, struct bus_attribute *); 100extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
99 101
100struct device_driver { 102struct device_driver {
101 char * name; 103 const char * name;
102 struct bus_type * bus; 104 struct bus_type * bus;
103 105
104 struct completion unloaded; 106 struct completion unloaded;
105 struct kobject kobj; 107 struct kobject kobj;
106 struct list_head devices; 108 struct klist klist_devices;
109 struct klist_node knode_bus;
107 110
108 struct module * owner; 111 struct module * owner;
109 112
110 int (*probe) (struct device * dev); 113 int (*probe) (struct device * dev);
111 int (*remove) (struct device * dev); 114 int (*remove) (struct device * dev);
112 void (*shutdown) (struct device * dev); 115 void (*shutdown) (struct device * dev);
113 int (*suspend) (struct device * dev, pm_message_t state, u32 level); 116 int (*suspend) (struct device * dev, pm_message_t state, u32 level);
114 int (*resume) (struct device * dev, u32 level); 117 int (*resume) (struct device * dev, u32 level);
@@ -137,12 +140,16 @@ struct driver_attribute driver_attr_##_name = __ATTR(_name,_mode,_show,_store)
137extern int driver_create_file(struct device_driver *, struct driver_attribute *); 140extern int driver_create_file(struct device_driver *, struct driver_attribute *);
138extern void driver_remove_file(struct device_driver *, struct driver_attribute *); 141extern void driver_remove_file(struct device_driver *, struct driver_attribute *);
139 142
143extern int driver_for_each_device(struct device_driver * drv, struct device * start,
144 void * data, int (*fn)(struct device *, void *));
145
140 146
141/* 147/*
142 * device classes 148 * device classes
143 */ 149 */
144struct class { 150struct class {
145 char * name; 151 const char * name;
152 struct module * owner;
146 153
147 struct subsystem subsys; 154 struct subsystem subsys;
148 struct list_head children; 155 struct list_head children;
@@ -185,6 +192,7 @@ struct class_device {
185 struct kobject kobj; 192 struct kobject kobj;
186 struct class * class; /* required */ 193 struct class * class; /* required */
187 dev_t devt; /* dev_t, creates the sysfs "dev" */ 194 dev_t devt; /* dev_t, creates the sysfs "dev" */
195 struct class_device_attribute *devt_attr;
188 struct device * dev; /* not necessary, but nice to have */ 196 struct device * dev; /* not necessary, but nice to have */
189 void * class_data; /* class-specific data */ 197 void * class_data; /* class-specific data */
190 198
@@ -245,26 +253,28 @@ struct class_interface {
245extern int class_interface_register(struct class_interface *); 253extern int class_interface_register(struct class_interface *);
246extern void class_interface_unregister(struct class_interface *); 254extern void class_interface_unregister(struct class_interface *);
247 255
248/* interface for class simple stuff */ 256extern struct class *class_create(struct module *owner, char *name);
249extern struct class_simple *class_simple_create(struct module *owner, char *name); 257extern void class_destroy(struct class *cls);
250extern void class_simple_destroy(struct class_simple *cs); 258extern struct class_device *class_device_create(struct class *cls, dev_t devt,
251extern struct class_device *class_simple_device_add(struct class_simple *cs, dev_t dev, struct device *device, const char *fmt, ...) 259 struct device *device, char *fmt, ...)
252 __attribute__((format(printf,4,5))); 260 __attribute__((format(printf,4,5)));
253extern int class_simple_set_hotplug(struct class_simple *, 261extern void class_device_destroy(struct class *cls, dev_t devt);
254 int (*hotplug)(struct class_device *dev, char **envp, int num_envp, char *buffer, int buffer_size));
255extern void class_simple_device_remove(dev_t dev);
256 262
257 263
258struct device { 264struct device {
259 struct list_head node; /* node in sibling list */ 265 struct klist klist_children;
260 struct list_head bus_list; /* node in bus's list */ 266 struct klist_node knode_parent; /* node in sibling list */
261 struct list_head driver_list; 267 struct klist_node knode_driver;
262 struct list_head children; 268 struct klist_node knode_bus;
263 struct device * parent; 269 struct device * parent;
264 270
265 struct kobject kobj; 271 struct kobject kobj;
266 char bus_id[BUS_ID_SIZE]; /* position on parent bus */ 272 char bus_id[BUS_ID_SIZE]; /* position on parent bus */
267 273
274 struct semaphore sem; /* semaphore to synchronize calls to
275 * its driver.
276 */
277
268 struct bus_type * bus; /* type of bus device is on */ 278 struct bus_type * bus; /* type of bus device is on */
269 struct device_driver *driver; /* which driver has allocated this 279 struct device_driver *driver; /* which driver has allocated this
270 device */ 280 device */
@@ -288,12 +298,6 @@ struct device {
288 void (*release)(struct device * dev); 298 void (*release)(struct device * dev);
289}; 299};
290 300
291static inline struct device *
292list_to_dev(struct list_head *node)
293{
294 return list_entry(node, struct device, node);
295}
296
297static inline void * 301static inline void *
298dev_get_drvdata (struct device *dev) 302dev_get_drvdata (struct device *dev)
299{ 303{
@@ -321,7 +325,6 @@ extern int device_for_each_child(struct device *, void *,
321 * Manual binding of a device to driver. See drivers/base/bus.c 325 * Manual binding of a device to driver. See drivers/base/bus.c
322 * for information on use. 326 * for information on use.
323 */ 327 */
324extern int driver_probe_device(struct device_driver * drv, struct device * dev);
325extern void device_bind_driver(struct device * dev); 328extern void device_bind_driver(struct device * dev);
326extern void device_release_driver(struct device * dev); 329extern void device_release_driver(struct device * dev);
327extern int device_attach(struct device * dev); 330extern int device_attach(struct device * dev);
@@ -332,8 +335,10 @@ extern void driver_attach(struct device_driver * drv);
332 335
333struct device_attribute { 336struct device_attribute {
334 struct attribute attr; 337 struct attribute attr;
335 ssize_t (*show)(struct device * dev, char * buf); 338 ssize_t (*show)(struct device *dev, struct device_attribute *attr,
336 ssize_t (*store)(struct device * dev, const char * buf, size_t count); 339 char *buf);
340 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
341 const char *buf, size_t count);
337}; 342};
338 343
339#define DEVICE_ATTR(_name,_mode,_show,_store) \ 344#define DEVICE_ATTR(_name,_mode,_show,_store) \
@@ -360,13 +365,12 @@ extern int (*platform_notify_remove)(struct device * dev);
360 */ 365 */
361extern struct device * get_device(struct device * dev); 366extern struct device * get_device(struct device * dev);
362extern void put_device(struct device * dev); 367extern void put_device(struct device * dev);
363extern struct device *device_find(const char *name, struct bus_type *bus);
364 368
365 369
366/* drivers/base/platform.c */ 370/* drivers/base/platform.c */
367 371
368struct platform_device { 372struct platform_device {
369 char * name; 373 const char * name;
370 u32 id; 374 u32 id;
371 struct device dev; 375 struct device dev;
372 u32 num_resources; 376 u32 num_resources;