1/****************************************************************************
2 ****************************************************************************
3 ***
4 ***   This header was automatically generated from a Linux kernel header
5 ***   of the same name, to make information necessary for userspace to
6 ***   call into the kernel available to libc.  It contains only constants,
7 ***   structures, and macros generated from the original header, and thus,
8 ***   contains no copyrightable information.
9 ***
10 ****************************************************************************
11 ****************************************************************************/
12#ifndef _DEVICE_H_
13#define _DEVICE_H_
14
15#include <linux/ioport.h>
16#include <linux/kobject.h>
17#include <linux/klist.h>
18#include <linux/list.h>
19#include <linux/types.h>
20#include <linux/module.h>
21#include <linux/pm.h>
22#include <asm/semaphore.h>
23#include <asm/atomic.h>
24
25#define DEVICE_NAME_SIZE 50
26#define DEVICE_NAME_HALF __stringify(20)
27#define DEVICE_ID_SIZE 32
28#define BUS_ID_SIZE KOBJ_NAME_LEN
29
30struct device;
31struct device_driver;
32struct class;
33struct class_device;
34
35struct bus_type {
36 const char * name;
37
38 struct subsystem subsys;
39 struct kset drivers;
40 struct kset devices;
41 struct klist klist_devices;
42 struct klist klist_drivers;
43
44 struct bus_attribute * bus_attrs;
45 struct device_attribute * dev_attrs;
46 struct driver_attribute * drv_attrs;
47
48 int (*match)(struct device * dev, struct device_driver * drv);
49 int (*uevent)(struct device *dev, char **envp,
50 int num_envp, char *buffer, int buffer_size);
51 int (*probe)(struct device * dev);
52 int (*remove)(struct device * dev);
53 void (*shutdown)(struct device * dev);
54 int (*suspend)(struct device * dev, pm_message_t state);
55 int (*resume)(struct device * dev);
56};
57
58struct device * bus_find_device(struct bus_type *bus, struct device *start,
59 void *data, int (*match)(struct device *, void *));
60
61struct bus_attribute {
62 struct attribute attr;
63 ssize_t (*show)(struct bus_type *, char * buf);
64 ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
65};
66
67#define BUS_ATTR(_name,_mode,_show,_store)  struct bus_attribute bus_attr_##_name = __ATTR(_name,_mode,_show,_store)
68
69struct device_driver {
70 const char * name;
71 struct bus_type * bus;
72
73 struct completion unloaded;
74 struct kobject kobj;
75 struct klist klist_devices;
76 struct klist_node knode_bus;
77
78 struct module * owner;
79
80 int (*probe) (struct device * dev);
81 int (*remove) (struct device * dev);
82 void (*shutdown) (struct device * dev);
83 int (*suspend) (struct device * dev, pm_message_t state);
84 int (*resume) (struct device * dev);
85};
86
87struct driver_attribute {
88 struct attribute attr;
89 ssize_t (*show)(struct device_driver *, char * buf);
90 ssize_t (*store)(struct device_driver *, const char * buf, size_t count);
91};
92
93#define DRIVER_ATTR(_name,_mode,_show,_store)  struct driver_attribute driver_attr_##_name = __ATTR(_name,_mode,_show,_store)
94
95struct device * driver_find_device(struct device_driver *drv,
96 struct device *start, void *data,
97 int (*match)(struct device *, void *));
98
99struct class {
100 const char * name;
101 struct module * owner;
102
103 struct subsystem subsys;
104 struct list_head children;
105 struct list_head devices;
106 struct list_head interfaces;
107 struct semaphore sem;
108
109 struct class_attribute * class_attrs;
110 struct class_device_attribute * class_dev_attrs;
111
112 int (*uevent)(struct class_device *dev, char **envp,
113 int num_envp, char *buffer, int buffer_size);
114
115 void (*release)(struct class_device *dev);
116 void (*class_release)(struct class *class);
117};
118
119struct class_attribute {
120 struct attribute attr;
121 ssize_t (*show)(struct class *, char * buf);
122 ssize_t (*store)(struct class *, const char * buf, size_t count);
123};
124
125#define CLASS_ATTR(_name,_mode,_show,_store)  struct class_attribute class_attr_##_name = __ATTR(_name,_mode,_show,_store)
126
127struct class_device_attribute {
128 struct attribute attr;
129 ssize_t (*show)(struct class_device *, char * buf);
130 ssize_t (*store)(struct class_device *, const char * buf, size_t count);
131};
132
133#define CLASS_DEVICE_ATTR(_name,_mode,_show,_store)  struct class_device_attribute class_device_attr_##_name =   __ATTR(_name,_mode,_show,_store)
134
135struct class_device {
136 struct list_head node;
137
138 struct kobject kobj;
139 struct class * class;
140 dev_t devt;
141 struct class_device_attribute *devt_attr;
142 struct class_device_attribute uevent_attr;
143 struct device * dev;
144 void * class_data;
145 struct class_device *parent;
146 struct attribute_group ** groups;
147
148 void (*release)(struct class_device *dev);
149 int (*uevent)(struct class_device *dev, char **envp,
150 int num_envp, char *buffer, int buffer_size);
151 char class_id[BUS_ID_SIZE];
152};
153
154struct class_interface {
155 struct list_head node;
156 struct class *class;
157
158 int (*add) (struct class_device *, struct class_interface *);
159 void (*remove) (struct class_device *, struct class_interface *);
160};
161
162struct device_attribute {
163 struct attribute attr;
164 ssize_t (*show)(struct device *dev, struct device_attribute *attr,
165 char *buf);
166 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
167 const char *buf, size_t count);
168};
169
170#define DEVICE_ATTR(_name,_mode,_show,_store)  struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store)
171
172struct device {
173 struct klist klist_children;
174 struct klist_node knode_parent;
175 struct klist_node knode_driver;
176 struct klist_node knode_bus;
177 struct device * parent;
178
179 struct kobject kobj;
180 char bus_id[BUS_ID_SIZE];
181 struct device_attribute uevent_attr;
182 struct device_attribute *devt_attr;
183
184 struct semaphore sem;
185
186 struct bus_type * bus;
187 struct device_driver *driver;
188 void *driver_data;
189 void *platform_data;
190 void *firmware_data;
191 struct dev_pm_info power;
192
193 u64 *dma_mask;
194 u64 coherent_dma_mask;
195
196 struct list_head dma_pools;
197
198 struct dma_coherent_mem *dma_mem;
199
200 struct list_head node;
201 struct class *class;
202 dev_t devt;
203
204 void (*release)(struct device * dev);
205};
206
207#define dev_printk(level, dev, format, arg...)   printk(level "%s %s: " format , dev_driver_string(dev) , (dev)->bus_id , ## arg)
208
209#ifdef DEBUG
210#define dev_dbg(dev, format, arg...)   dev_printk(KERN_DEBUG , dev , format , ## arg)
211#else
212#define dev_dbg(dev, format, arg...) do { (void)(dev); } while (0)
213#endif
214
215#define dev_err(dev, format, arg...)   dev_printk(KERN_ERR , dev , format , ## arg)
216#define dev_info(dev, format, arg...)   dev_printk(KERN_INFO , dev , format , ## arg)
217#define dev_warn(dev, format, arg...)   dev_printk(KERN_WARNING , dev , format , ## arg)
218#define dev_notice(dev, format, arg...)   dev_printk(KERN_NOTICE , dev , format , ## arg)
219
220#define MODULE_ALIAS_CHARDEV(major,minor)   MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
221#define MODULE_ALIAS_CHARDEV_MAJOR(major)   MODULE_ALIAS("char-major-" __stringify(major) "-*")
222#endif
223