aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-10-28 16:09:47 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-28 16:09:47 -0400
commit84860bf0644d7c45afe7ddbd30731c3e3c371fae (patch)
treed6c4b98a9c3fd9981e7fcc5d7729c9e01e327767 /include
parent8caf89157d64f1eedba37113afb4b303b2b3e301 (diff)
parent6fbfddcb52d8d9fa2cd209f5ac2a1c87497d55b5 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
Diffstat (limited to 'include')
-rw-r--r--include/linux/device.h115
-rw-r--r--include/linux/genhd.h1
-rw-r--r--include/linux/i2o.h4
-rw-r--r--include/linux/input.h26
-rw-r--r--include/linux/pm.h26
5 files changed, 117 insertions, 55 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index 95d607a48f06..a9e72ac3fb9f 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -28,19 +28,6 @@
28#define BUS_ID_SIZE KOBJ_NAME_LEN 28#define BUS_ID_SIZE KOBJ_NAME_LEN
29 29
30 30
31enum {
32 SUSPEND_NOTIFY,
33 SUSPEND_SAVE_STATE,
34 SUSPEND_DISABLE,
35 SUSPEND_POWER_DOWN,
36};
37
38enum {
39 RESUME_POWER_ON,
40 RESUME_RESTORE_STATE,
41 RESUME_ENABLE,
42};
43
44struct device; 31struct device;
45struct device_driver; 32struct device_driver;
46struct class; 33struct class;
@@ -115,8 +102,8 @@ struct device_driver {
115 int (*probe) (struct device * dev); 102 int (*probe) (struct device * dev);
116 int (*remove) (struct device * dev); 103 int (*remove) (struct device * dev);
117 void (*shutdown) (struct device * dev); 104 void (*shutdown) (struct device * dev);
118 int (*suspend) (struct device * dev, pm_message_t state, u32 level); 105 int (*suspend) (struct device * dev, pm_message_t state);
119 int (*resume) (struct device * dev, u32 level); 106 int (*resume) (struct device * dev);
120}; 107};
121 108
122 109
@@ -190,7 +177,43 @@ struct class_attribute class_attr_##_name = __ATTR(_name,_mode,_show,_store)
190extern int class_create_file(struct class *, const struct class_attribute *); 177extern int class_create_file(struct class *, const struct class_attribute *);
191extern void class_remove_file(struct class *, const struct class_attribute *); 178extern void class_remove_file(struct class *, const struct class_attribute *);
192 179
180struct class_device_attribute {
181 struct attribute attr;
182 ssize_t (*show)(struct class_device *, char * buf);
183 ssize_t (*store)(struct class_device *, const char * buf, size_t count);
184};
185
186#define CLASS_DEVICE_ATTR(_name,_mode,_show,_store) \
187struct class_device_attribute class_device_attr_##_name = \
188 __ATTR(_name,_mode,_show,_store)
189
190extern int class_device_create_file(struct class_device *,
191 const struct class_device_attribute *);
193 192
193/**
194 * struct class_device - class devices
195 * @class: pointer to the parent class for this class device. This is required.
196 * @devt: for internal use by the driver core only.
197 * @node: for internal use by the driver core only.
198 * @kobj: for internal use by the driver core only.
199 * @devt_attr: for internal use by the driver core only.
200 * @dev: if set, a symlink to the struct device is created in the sysfs
201 * directory for this struct class device.
202 * @class_data: pointer to whatever you want to store here for this struct
203 * class_device. Use class_get_devdata() and class_set_devdata() to get and
204 * set this pointer.
205 * @parent: pointer to a struct class_device that is the parent of this struct
206 * class_device. If NULL, this class_device will show up at the root of the
207 * struct class in sysfs (which is probably what you want to have happen.)
208 * @release: pointer to a release function for this struct class_device. If
209 * set, this will be called instead of the class specific release function.
210 * Only use this if you want to override the default release function, like
211 * when you are nesting class_device structures.
212 * @hotplug: pointer to a hotplug function for this struct class_device. If
213 * set, this will be called instead of the class specific hotplug function.
214 * Only use this if you want to override the default hotplug function, like
215 * when you are nesting class_device structures.
216 */
194struct class_device { 217struct class_device {
195 struct list_head node; 218 struct list_head node;
196 219
@@ -198,9 +221,14 @@ struct class_device {
198 struct class * class; /* required */ 221 struct class * class; /* required */
199 dev_t devt; /* dev_t, creates the sysfs "dev" */ 222 dev_t devt; /* dev_t, creates the sysfs "dev" */
200 struct class_device_attribute *devt_attr; 223 struct class_device_attribute *devt_attr;
224 struct class_device_attribute uevent_attr;
201 struct device * dev; /* not necessary, but nice to have */ 225 struct device * dev; /* not necessary, but nice to have */
202 void * class_data; /* class-specific data */ 226 void * class_data; /* class-specific data */
227 struct class_device *parent; /* parent of this child device, if there is one */
203 228
229 void (*release)(struct class_device *dev);
230 int (*hotplug)(struct class_device *dev, char **envp,
231 int num_envp, char *buffer, int buffer_size);
204 char class_id[BUS_ID_SIZE]; /* unique to this class */ 232 char class_id[BUS_ID_SIZE]; /* unique to this class */
205}; 233};
206 234
@@ -228,18 +256,6 @@ extern int class_device_rename(struct class_device *, char *);
228extern struct class_device * class_device_get(struct class_device *); 256extern struct class_device * class_device_get(struct class_device *);
229extern void class_device_put(struct class_device *); 257extern void class_device_put(struct class_device *);
230 258
231struct class_device_attribute {
232 struct attribute attr;
233 ssize_t (*show)(struct class_device *, char * buf);
234 ssize_t (*store)(struct class_device *, const char * buf, size_t count);
235};
236
237#define CLASS_DEVICE_ATTR(_name,_mode,_show,_store) \
238struct class_device_attribute class_device_attr_##_name = \
239 __ATTR(_name,_mode,_show,_store)
240
241extern int class_device_create_file(struct class_device *,
242 const struct class_device_attribute *);
243extern void class_device_remove_file(struct class_device *, 259extern void class_device_remove_file(struct class_device *,
244 const struct class_device_attribute *); 260 const struct class_device_attribute *);
245extern int class_device_create_bin_file(struct class_device *, 261extern int class_device_create_bin_file(struct class_device *,
@@ -251,8 +267,8 @@ struct class_interface {
251 struct list_head node; 267 struct list_head node;
252 struct class *class; 268 struct class *class;
253 269
254 int (*add) (struct class_device *); 270 int (*add) (struct class_device *, struct class_interface *);
255 void (*remove) (struct class_device *); 271 void (*remove) (struct class_device *, struct class_interface *);
256}; 272};
257 273
258extern int class_interface_register(struct class_interface *); 274extern int class_interface_register(struct class_interface *);
@@ -260,12 +276,29 @@ extern void class_interface_unregister(struct class_interface *);
260 276
261extern struct class *class_create(struct module *owner, char *name); 277extern struct class *class_create(struct module *owner, char *name);
262extern void class_destroy(struct class *cls); 278extern void class_destroy(struct class *cls);
263extern struct class_device *class_device_create(struct class *cls, dev_t devt, 279extern struct class_device *class_device_create(struct class *cls,
264 struct device *device, char *fmt, ...) 280 struct class_device *parent,
265 __attribute__((format(printf,4,5))); 281 dev_t devt,
282 struct device *device,
283 char *fmt, ...)
284 __attribute__((format(printf,5,6)));
266extern void class_device_destroy(struct class *cls, dev_t devt); 285extern void class_device_destroy(struct class *cls, dev_t devt);
267 286
268 287
288/* interface for exporting device attributes */
289struct device_attribute {
290 struct attribute attr;
291 ssize_t (*show)(struct device *dev, struct device_attribute *attr,
292 char *buf);
293 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
294 const char *buf, size_t count);
295};
296
297#define DEVICE_ATTR(_name,_mode,_show,_store) \
298struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store)
299
300extern int device_create_file(struct device *device, struct device_attribute * entry);
301extern void device_remove_file(struct device * dev, struct device_attribute * attr);
269struct device { 302struct device {
270 struct klist klist_children; 303 struct klist klist_children;
271 struct klist_node knode_parent; /* node in sibling list */ 304 struct klist_node knode_parent; /* node in sibling list */
@@ -275,6 +308,7 @@ struct device {
275 308
276 struct kobject kobj; 309 struct kobject kobj;
277 char bus_id[BUS_ID_SIZE]; /* position on parent bus */ 310 char bus_id[BUS_ID_SIZE]; /* position on parent bus */
311 struct device_attribute uevent_attr;
278 312
279 struct semaphore sem; /* semaphore to synchronize calls to 313 struct semaphore sem; /* semaphore to synchronize calls to
280 * its driver. 314 * its driver.
@@ -343,23 +377,6 @@ extern int device_attach(struct device * dev);
343extern void driver_attach(struct device_driver * drv); 377extern void driver_attach(struct device_driver * drv);
344 378
345 379
346/* driverfs interface for exporting device attributes */
347
348struct device_attribute {
349 struct attribute attr;
350 ssize_t (*show)(struct device *dev, struct device_attribute *attr,
351 char *buf);
352 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
353 const char *buf, size_t count);
354};
355
356#define DEVICE_ATTR(_name,_mode,_show,_store) \
357struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store)
358
359
360extern int device_create_file(struct device *device, struct device_attribute * entry);
361extern void device_remove_file(struct device * dev, struct device_attribute * attr);
362
363/* 380/*
364 * Platform "fixup" functions - allow the platform to have their say 381 * Platform "fixup" functions - allow the platform to have their say
365 * about devices and actions that the general device layer doesn't 382 * about devices and actions that the general device layer doesn't
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 142e1c1e0689..eabdb5cce357 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -132,6 +132,7 @@ struct gendisk {
132struct disk_attribute { 132struct disk_attribute {
133 struct attribute attr; 133 struct attribute attr;
134 ssize_t (*show)(struct gendisk *, char *); 134 ssize_t (*show)(struct gendisk *, char *);
135 ssize_t (*store)(struct gendisk *, const char *, size_t);
135}; 136};
136 137
137/* 138/*
diff --git a/include/linux/i2o.h b/include/linux/i2o.h
index b4af45aad25d..92300325dbcd 100644
--- a/include/linux/i2o.h
+++ b/include/linux/i2o.h
@@ -66,8 +66,6 @@ struct i2o_device {
66 struct device device; 66 struct device device;
67 67
68 struct semaphore lock; /* device lock */ 68 struct semaphore lock; /* device lock */
69
70 struct class_device classdev; /* i2o device class */
71}; 69};
72 70
73/* 71/*
@@ -194,7 +192,7 @@ struct i2o_controller {
194 struct resource mem_resource; /* Mem resource allocated to the IOP */ 192 struct resource mem_resource; /* Mem resource allocated to the IOP */
195 193
196 struct device device; 194 struct device device;
197 struct class_device classdev; /* I2O controller class */ 195 struct class_device *classdev; /* I2O controller class device */
198 struct i2o_device *exec; /* Executive */ 196 struct i2o_device *exec; /* Executive */
199#if BITS_PER_LONG == 64 197#if BITS_PER_LONG == 64
200 spinlock_t context_list_lock; /* lock for context_list */ 198 spinlock_t context_list_lock; /* lock for context_list */
diff --git a/include/linux/input.h b/include/linux/input.h
index d7836311ada9..f623c745c21c 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -12,6 +12,7 @@
12#ifdef __KERNEL__ 12#ifdef __KERNEL__
13#include <linux/time.h> 13#include <linux/time.h>
14#include <linux/list.h> 14#include <linux/list.h>
15#include <linux/device.h>
15#else 16#else
16#include <sys/time.h> 17#include <sys/time.h>
17#include <sys/ioctl.h> 18#include <sys/ioctl.h>
@@ -890,11 +891,15 @@ struct input_dev {
890 struct semaphore sem; /* serializes open and close operations */ 891 struct semaphore sem; /* serializes open and close operations */
891 unsigned int users; 892 unsigned int users;
892 893
893 struct device *dev; 894 struct class_device cdev;
895 struct device *dev; /* will be removed soon */
896
897 int dynalloc; /* temporarily */
894 898
895 struct list_head h_list; 899 struct list_head h_list;
896 struct list_head node; 900 struct list_head node;
897}; 901};
902#define to_input_dev(d) container_of(d, struct input_dev, cdev)
898 903
899/* 904/*
900 * Structure for hotplug & device<->driver matching. 905 * Structure for hotplug & device<->driver matching.
@@ -985,6 +990,23 @@ static inline void init_input_dev(struct input_dev *dev)
985 INIT_LIST_HEAD(&dev->node); 990 INIT_LIST_HEAD(&dev->node);
986} 991}
987 992
993struct input_dev *input_allocate_device(void);
994
995static inline void input_free_device(struct input_dev *dev)
996{
997 kfree(dev);
998}
999
1000static inline struct input_dev *input_get_device(struct input_dev *dev)
1001{
1002 return to_input_dev(class_device_get(&dev->cdev));
1003}
1004
1005static inline void input_put_device(struct input_dev *dev)
1006{
1007 class_device_put(&dev->cdev);
1008}
1009
988void input_register_device(struct input_dev *); 1010void input_register_device(struct input_dev *);
989void input_unregister_device(struct input_dev *); 1011void input_unregister_device(struct input_dev *);
990 1012
@@ -1053,7 +1075,7 @@ static inline void input_set_abs_params(struct input_dev *dev, int axis, int min
1053 dev->absbit[LONG(axis)] |= BIT(axis); 1075 dev->absbit[LONG(axis)] |= BIT(axis);
1054} 1076}
1055 1077
1056extern struct class *input_class; 1078extern struct class input_class;
1057 1079
1058#endif 1080#endif
1059#endif 1081#endif
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 5cfb07648eca..7897cf500c51 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -219,7 +219,9 @@ typedef struct pm_message {
219 219
220struct dev_pm_info { 220struct dev_pm_info {
221 pm_message_t power_state; 221 pm_message_t power_state;
222 unsigned can_wakeup:1;
222#ifdef CONFIG_PM 223#ifdef CONFIG_PM
224 unsigned should_wakeup:1;
223 pm_message_t prev_state; 225 pm_message_t prev_state;
224 void * saved_state; 226 void * saved_state;
225 atomic_t pm_users; 227 atomic_t pm_users;
@@ -236,13 +238,35 @@ extern void device_resume(void);
236 238
237#ifdef CONFIG_PM 239#ifdef CONFIG_PM
238extern int device_suspend(pm_message_t state); 240extern int device_suspend(pm_message_t state);
239#else 241
242#define device_set_wakeup_enable(dev,val) \
243 ((dev)->power.should_wakeup = !!(val))
244#define device_may_wakeup(dev) \
245 (device_can_wakeup(dev) && (dev)->power.should_wakeup)
246
247#else /* !CONFIG_PM */
248
240static inline int device_suspend(pm_message_t state) 249static inline int device_suspend(pm_message_t state)
241{ 250{
242 return 0; 251 return 0;
243} 252}
253
254#define device_set_wakeup_enable(dev,val) do{}while(0)
255#define device_may_wakeup(dev) (0)
256
244#endif 257#endif
245 258
259/* changes to device_may_wakeup take effect on the next pm state change.
260 * by default, devices should wakeup if they can.
261 */
262#define device_can_wakeup(dev) \
263 ((dev)->power.can_wakeup)
264#define device_init_wakeup(dev,val) \
265 do { \
266 device_can_wakeup(dev) = !!(val); \
267 device_set_wakeup_enable(dev,val); \
268 } while(0)
269
246#endif /* __KERNEL__ */ 270#endif /* __KERNEL__ */
247 271
248#endif /* _LINUX_PM_H */ 272#endif /* _LINUX_PM_H */