bonding: process the err returned by dev_set_allmulti properly in bond_enslave
[pandora-kernel.git] / include / linux / serio.h
1 #ifndef _SERIO_H
2 #define _SERIO_H
3
4 /*
5  * Copyright (C) 1999-2002 Vojtech Pavlik
6 *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License version 2 as published by
9  * the Free Software Foundation.
10  */
11
12 #include <linux/ioctl.h>
13
14 #define SPIOCSTYPE      _IOW('q', 0x01, unsigned long)
15
16 #ifdef __KERNEL__
17
18 #include <linux/types.h>
19 #include <linux/interrupt.h>
20 #include <linux/list.h>
21 #include <linux/spinlock.h>
22 #include <linux/mutex.h>
23 #include <linux/device.h>
24 #include <linux/mod_devicetable.h>
25
26 struct serio {
27         void *port_data;
28
29         char name[32];
30         char phys[32];
31
32         bool manual_bind;
33
34         struct serio_device_id id;
35
36         /* Protects critical sections from port's interrupt handler */
37         spinlock_t lock;
38
39         int (*write)(struct serio *, unsigned char);
40         int (*open)(struct serio *);
41         void (*close)(struct serio *);
42         int (*start)(struct serio *);
43         void (*stop)(struct serio *);
44
45         struct serio *parent;
46         /* Entry in parent->children list */
47         struct list_head child_node;
48         struct list_head children;
49         /* Level of nesting in serio hierarchy */
50         unsigned int depth;
51
52         /*
53          * serio->drv is accessed from interrupt handlers; when modifying
54          * caller should acquire serio->drv_mutex and serio->lock.
55          */
56         struct serio_driver *drv;
57         /* Protects serio->drv so attributes can pin current driver */
58         struct mutex drv_mutex;
59
60         struct device dev;
61
62         struct list_head node;
63
64         /*
65          * For use by PS/2 layer when several ports share hardware and
66          * may get indigestion when exposed to concurrent access (i8042).
67          */
68         struct mutex *ps2_cmd_mutex;
69 };
70 #define to_serio_port(d)        container_of(d, struct serio, dev)
71
72 struct serio_driver {
73         const char *description;
74
75         const struct serio_device_id *id_table;
76         bool manual_bind;
77
78         void (*write_wakeup)(struct serio *);
79         irqreturn_t (*interrupt)(struct serio *, unsigned char, unsigned int);
80         int  (*connect)(struct serio *, struct serio_driver *drv);
81         int  (*reconnect)(struct serio *);
82         void (*disconnect)(struct serio *);
83         void (*cleanup)(struct serio *);
84
85         struct device_driver driver;
86 };
87 #define to_serio_driver(d)      container_of(d, struct serio_driver, driver)
88
89 int serio_open(struct serio *serio, struct serio_driver *drv);
90 void serio_close(struct serio *serio);
91 void serio_rescan(struct serio *serio);
92 void serio_reconnect(struct serio *serio);
93 irqreturn_t serio_interrupt(struct serio *serio, unsigned char data, unsigned int flags);
94
95 void __serio_register_port(struct serio *serio, struct module *owner);
96
97 /* use a define to avoid include chaining to get THIS_MODULE */
98 #define serio_register_port(serio) \
99         __serio_register_port(serio, THIS_MODULE)
100
101 void serio_unregister_port(struct serio *serio);
102 void serio_unregister_child_port(struct serio *serio);
103
104 int __must_check __serio_register_driver(struct serio_driver *drv,
105                                 struct module *owner, const char *mod_name);
106
107 /* use a define to avoid include chaining to get THIS_MODULE & friends */
108 #define serio_register_driver(drv) \
109         __serio_register_driver(drv, THIS_MODULE, KBUILD_MODNAME)
110
111 void serio_unregister_driver(struct serio_driver *drv);
112
113 static inline int serio_write(struct serio *serio, unsigned char data)
114 {
115         if (serio->write)
116                 return serio->write(serio, data);
117         else
118                 return -1;
119 }
120
121 static inline void serio_drv_write_wakeup(struct serio *serio)
122 {
123         if (serio->drv && serio->drv->write_wakeup)
124                 serio->drv->write_wakeup(serio);
125 }
126
127 /*
128  * Use the following functions to manipulate serio's per-port
129  * driver-specific data.
130  */
131 static inline void *serio_get_drvdata(struct serio *serio)
132 {
133         return dev_get_drvdata(&serio->dev);
134 }
135
136 static inline void serio_set_drvdata(struct serio *serio, void *data)
137 {
138         dev_set_drvdata(&serio->dev, data);
139 }
140
141 /*
142  * Use the following functions to protect critical sections in
143  * driver code from port's interrupt handler
144  */
145 static inline void serio_pause_rx(struct serio *serio)
146 {
147         spin_lock_irq(&serio->lock);
148 }
149
150 static inline void serio_continue_rx(struct serio *serio)
151 {
152         spin_unlock_irq(&serio->lock);
153 }
154
155 #endif
156
157 /*
158  * bit masks for use in "interrupt" flags (3rd argument)
159  */
160 #define SERIO_TIMEOUT   1
161 #define SERIO_PARITY    2
162 #define SERIO_FRAME     4
163
164 /*
165  * Serio types
166  */
167 #define SERIO_XT        0x00
168 #define SERIO_8042      0x01
169 #define SERIO_RS232     0x02
170 #define SERIO_HIL_MLC   0x03
171 #define SERIO_PS_PSTHRU 0x05
172 #define SERIO_8042_XL   0x06
173
174 /*
175  * Serio protocols
176  */
177 #define SERIO_UNKNOWN   0x00
178 #define SERIO_MSC       0x01
179 #define SERIO_SUN       0x02
180 #define SERIO_MS        0x03
181 #define SERIO_MP        0x04
182 #define SERIO_MZ        0x05
183 #define SERIO_MZP       0x06
184 #define SERIO_MZPP      0x07
185 #define SERIO_VSXXXAA   0x08
186 #define SERIO_SUNKBD    0x10
187 #define SERIO_WARRIOR   0x18
188 #define SERIO_SPACEORB  0x19
189 #define SERIO_MAGELLAN  0x1a
190 #define SERIO_SPACEBALL 0x1b
191 #define SERIO_GUNZE     0x1c
192 #define SERIO_IFORCE    0x1d
193 #define SERIO_STINGER   0x1e
194 #define SERIO_NEWTON    0x1f
195 #define SERIO_STOWAWAY  0x20
196 #define SERIO_H3600     0x21
197 #define SERIO_PS2SER    0x22
198 #define SERIO_TWIDKBD   0x23
199 #define SERIO_TWIDJOY   0x24
200 #define SERIO_HIL       0x25
201 #define SERIO_SNES232   0x26
202 #define SERIO_SEMTECH   0x27
203 #define SERIO_LKKBD     0x28
204 #define SERIO_ELO       0x29
205 #define SERIO_MICROTOUCH        0x30
206 #define SERIO_PENMOUNT  0x31
207 #define SERIO_TOUCHRIGHT        0x32
208 #define SERIO_TOUCHWIN  0x33
209 #define SERIO_TAOSEVM   0x34
210 #define SERIO_FUJITSU   0x35
211 #define SERIO_ZHENHUA   0x36
212 #define SERIO_INEXIO    0x37
213 #define SERIO_TOUCHIT213        0x38
214 #define SERIO_W8001     0x39
215 #define SERIO_DYNAPRO   0x3a
216 #define SERIO_HAMPSHIRE 0x3b
217 #define SERIO_PS2MULT   0x3c
218 #define SERIO_TSC40     0x3d
219
220 #endif