diff options
Diffstat (limited to 'include/linux/usb/serial.h')
-rw-r--r-- | include/linux/usb/serial.h | 160 |
1 files changed, 90 insertions, 70 deletions
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h index 488ce128885c..21b4a1c6f585 100644 --- a/include/linux/usb/serial.h +++ b/include/linux/usb/serial.h | |||
@@ -20,7 +20,8 @@ | |||
20 | #define SERIAL_TTY_MAJOR 188 /* Nice legal number now */ | 20 | #define SERIAL_TTY_MAJOR 188 /* Nice legal number now */ |
21 | #define SERIAL_TTY_MINORS 255 /* loads of devices :) */ | 21 | #define SERIAL_TTY_MINORS 255 /* loads of devices :) */ |
22 | 22 | ||
23 | #define MAX_NUM_PORTS 8 /* The maximum number of ports one device can grab at once */ | 23 | /* The maximum number of ports one device can grab at once */ |
24 | #define MAX_NUM_PORTS 8 | ||
24 | 25 | ||
25 | /* parity check flag */ | 26 | /* parity check flag */ |
26 | #define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK)) | 27 | #define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK)) |
@@ -61,29 +62,29 @@ | |||
61 | * ports of a device. | 62 | * ports of a device. |
62 | */ | 63 | */ |
63 | struct usb_serial_port { | 64 | struct usb_serial_port { |
64 | struct usb_serial * serial; | 65 | struct usb_serial *serial; |
65 | struct tty_struct * tty; | 66 | struct tty_struct *tty; |
66 | spinlock_t lock; | 67 | spinlock_t lock; |
67 | struct mutex mutex; | 68 | struct mutex mutex; |
68 | unsigned char number; | 69 | unsigned char number; |
69 | 70 | ||
70 | unsigned char * interrupt_in_buffer; | 71 | unsigned char *interrupt_in_buffer; |
71 | struct urb * interrupt_in_urb; | 72 | struct urb *interrupt_in_urb; |
72 | __u8 interrupt_in_endpointAddress; | 73 | __u8 interrupt_in_endpointAddress; |
73 | 74 | ||
74 | unsigned char * interrupt_out_buffer; | 75 | unsigned char *interrupt_out_buffer; |
75 | int interrupt_out_size; | 76 | int interrupt_out_size; |
76 | struct urb * interrupt_out_urb; | 77 | struct urb *interrupt_out_urb; |
77 | __u8 interrupt_out_endpointAddress; | 78 | __u8 interrupt_out_endpointAddress; |
78 | 79 | ||
79 | unsigned char * bulk_in_buffer; | 80 | unsigned char *bulk_in_buffer; |
80 | int bulk_in_size; | 81 | int bulk_in_size; |
81 | struct urb * read_urb; | 82 | struct urb *read_urb; |
82 | __u8 bulk_in_endpointAddress; | 83 | __u8 bulk_in_endpointAddress; |
83 | 84 | ||
84 | unsigned char * bulk_out_buffer; | 85 | unsigned char *bulk_out_buffer; |
85 | int bulk_out_size; | 86 | int bulk_out_size; |
86 | struct urb * write_urb; | 87 | struct urb *write_urb; |
87 | int write_urb_busy; | 88 | int write_urb_busy; |
88 | __u8 bulk_out_endpointAddress; | 89 | __u8 bulk_out_endpointAddress; |
89 | 90 | ||
@@ -92,17 +93,19 @@ struct usb_serial_port { | |||
92 | int open_count; | 93 | int open_count; |
93 | char throttled; | 94 | char throttled; |
94 | char throttle_req; | 95 | char throttle_req; |
96 | char console; | ||
95 | struct device dev; | 97 | struct device dev; |
96 | }; | 98 | }; |
97 | #define to_usb_serial_port(d) container_of(d, struct usb_serial_port, dev) | 99 | #define to_usb_serial_port(d) container_of(d, struct usb_serial_port, dev) |
98 | 100 | ||
99 | /* get and set the port private data pointer helper functions */ | 101 | /* get and set the port private data pointer helper functions */ |
100 | static inline void *usb_get_serial_port_data (struct usb_serial_port *port) | 102 | static inline void *usb_get_serial_port_data(struct usb_serial_port *port) |
101 | { | 103 | { |
102 | return dev_get_drvdata(&port->dev); | 104 | return dev_get_drvdata(&port->dev); |
103 | } | 105 | } |
104 | 106 | ||
105 | static inline void usb_set_serial_port_data (struct usb_serial_port *port, void *data) | 107 | static inline void usb_set_serial_port_data(struct usb_serial_port *port, |
108 | void *data) | ||
106 | { | 109 | { |
107 | dev_set_drvdata(&port->dev, data); | 110 | dev_set_drvdata(&port->dev, data); |
108 | } | 111 | } |
@@ -125,9 +128,10 @@ static inline void usb_set_serial_port_data (struct usb_serial_port *port, void | |||
125 | * usb_set_serial_data() to access this. | 128 | * usb_set_serial_data() to access this. |
126 | */ | 129 | */ |
127 | struct usb_serial { | 130 | struct usb_serial { |
128 | struct usb_device * dev; | 131 | struct usb_device *dev; |
129 | struct usb_serial_driver * type; | 132 | struct usb_serial_driver *type; |
130 | struct usb_interface * interface; | 133 | struct usb_interface *interface; |
134 | unsigned char disconnected; | ||
131 | unsigned char minor; | 135 | unsigned char minor; |
132 | unsigned char num_ports; | 136 | unsigned char num_ports; |
133 | unsigned char num_port_pointers; | 137 | unsigned char num_port_pointers; |
@@ -135,29 +139,30 @@ struct usb_serial { | |||
135 | char num_interrupt_out; | 139 | char num_interrupt_out; |
136 | char num_bulk_in; | 140 | char num_bulk_in; |
137 | char num_bulk_out; | 141 | char num_bulk_out; |
138 | struct usb_serial_port * port[MAX_NUM_PORTS]; | 142 | struct usb_serial_port *port[MAX_NUM_PORTS]; |
139 | struct kref kref; | 143 | struct kref kref; |
140 | void * private; | 144 | struct mutex disc_mutex; |
145 | void *private; | ||
141 | }; | 146 | }; |
142 | #define to_usb_serial(d) container_of(d, struct usb_serial, kref) | 147 | #define to_usb_serial(d) container_of(d, struct usb_serial, kref) |
143 | 148 | ||
144 | #define NUM_DONT_CARE 99 | 149 | #define NUM_DONT_CARE 99 |
145 | 150 | ||
146 | /* get and set the serial private data pointer helper functions */ | 151 | /* get and set the serial private data pointer helper functions */ |
147 | static inline void *usb_get_serial_data (struct usb_serial *serial) | 152 | static inline void *usb_get_serial_data(struct usb_serial *serial) |
148 | { | 153 | { |
149 | return serial->private; | 154 | return serial->private; |
150 | } | 155 | } |
151 | 156 | ||
152 | static inline void usb_set_serial_data (struct usb_serial *serial, void *data) | 157 | static inline void usb_set_serial_data(struct usb_serial *serial, void *data) |
153 | { | 158 | { |
154 | serial->private = data; | 159 | serial->private = data; |
155 | } | 160 | } |
156 | 161 | ||
157 | /** | 162 | /** |
158 | * usb_serial_driver - describes a usb serial driver | 163 | * usb_serial_driver - describes a usb serial driver |
159 | * @description: pointer to a string that describes this driver. This string used | 164 | * @description: pointer to a string that describes this driver. This string |
160 | * in the syslog messages when a device is inserted or removed. | 165 | * used in the syslog messages when a device is inserted or removed. |
161 | * @id_table: pointer to a list of usb_device_id structures that define all | 166 | * @id_table: pointer to a list of usb_device_id structures that define all |
162 | * of the devices this structure can support. | 167 | * of the devices this structure can support. |
163 | * @num_interrupt_in: If a device doesn't have this many interrupt-in | 168 | * @num_interrupt_in: If a device doesn't have this many interrupt-in |
@@ -218,82 +223,91 @@ struct usb_serial_driver { | |||
218 | struct usb_driver *usb_driver; | 223 | struct usb_driver *usb_driver; |
219 | struct usb_dynids dynids; | 224 | struct usb_dynids dynids; |
220 | 225 | ||
221 | int (*probe) (struct usb_serial *serial, const struct usb_device_id *id); | 226 | int (*probe)(struct usb_serial *serial, const struct usb_device_id *id); |
222 | int (*attach) (struct usb_serial *serial); | 227 | int (*attach)(struct usb_serial *serial); |
223 | int (*calc_num_ports) (struct usb_serial *serial); | 228 | int (*calc_num_ports) (struct usb_serial *serial); |
224 | 229 | ||
225 | void (*shutdown) (struct usb_serial *serial); | 230 | void (*shutdown)(struct usb_serial *serial); |
226 | 231 | ||
227 | int (*port_probe) (struct usb_serial_port *port); | 232 | int (*port_probe)(struct usb_serial_port *port); |
228 | int (*port_remove) (struct usb_serial_port *port); | 233 | int (*port_remove)(struct usb_serial_port *port); |
229 | 234 | ||
230 | int (*suspend) (struct usb_serial *serial, pm_message_t message); | 235 | int (*suspend)(struct usb_serial *serial, pm_message_t message); |
231 | int (*resume) (struct usb_serial *serial); | 236 | int (*resume)(struct usb_serial *serial); |
232 | 237 | ||
233 | /* serial function calls */ | 238 | /* serial function calls */ |
234 | int (*open) (struct usb_serial_port *port, struct file * filp); | 239 | int (*open)(struct usb_serial_port *port, struct file *filp); |
235 | void (*close) (struct usb_serial_port *port, struct file * filp); | 240 | void (*close)(struct usb_serial_port *port, struct file *filp); |
236 | int (*write) (struct usb_serial_port *port, const unsigned char *buf, int count); | 241 | int (*write)(struct usb_serial_port *port, const unsigned char *buf, |
237 | int (*write_room) (struct usb_serial_port *port); | 242 | int count); |
238 | int (*ioctl) (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); | 243 | int (*write_room)(struct usb_serial_port *port); |
239 | void (*set_termios) (struct usb_serial_port *port, struct ktermios * old); | 244 | int (*ioctl)(struct usb_serial_port *port, struct file *file, |
240 | void (*break_ctl) (struct usb_serial_port *port, int break_state); | 245 | unsigned int cmd, unsigned long arg); |
241 | int (*chars_in_buffer) (struct usb_serial_port *port); | 246 | void (*set_termios)(struct usb_serial_port *port, struct ktermios *old); |
242 | void (*throttle) (struct usb_serial_port *port); | 247 | void (*break_ctl)(struct usb_serial_port *port, int break_state); |
243 | void (*unthrottle) (struct usb_serial_port *port); | 248 | int (*chars_in_buffer)(struct usb_serial_port *port); |
244 | int (*tiocmget) (struct usb_serial_port *port, struct file *file); | 249 | void (*throttle)(struct usb_serial_port *port); |
245 | int (*tiocmset) (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear); | 250 | void (*unthrottle)(struct usb_serial_port *port); |
251 | int (*tiocmget)(struct usb_serial_port *port, struct file *file); | ||
252 | int (*tiocmset)(struct usb_serial_port *port, struct file *file, | ||
253 | unsigned int set, unsigned int clear); | ||
246 | 254 | ||
247 | void (*read_int_callback)(struct urb *urb); | 255 | void (*read_int_callback)(struct urb *urb); |
248 | void (*write_int_callback)(struct urb *urb); | 256 | void (*write_int_callback)(struct urb *urb); |
249 | void (*read_bulk_callback)(struct urb *urb); | 257 | void (*read_bulk_callback)(struct urb *urb); |
250 | void (*write_bulk_callback)(struct urb *urb); | 258 | void (*write_bulk_callback)(struct urb *urb); |
251 | }; | 259 | }; |
252 | #define to_usb_serial_driver(d) container_of(d, struct usb_serial_driver, driver) | 260 | #define to_usb_serial_driver(d) \ |
261 | container_of(d, struct usb_serial_driver, driver) | ||
253 | 262 | ||
254 | extern int usb_serial_register(struct usb_serial_driver *driver); | 263 | extern int usb_serial_register(struct usb_serial_driver *driver); |
255 | extern void usb_serial_deregister(struct usb_serial_driver *driver); | 264 | extern void usb_serial_deregister(struct usb_serial_driver *driver); |
256 | extern void usb_serial_port_softint(struct usb_serial_port *port); | 265 | extern void usb_serial_port_softint(struct usb_serial_port *port); |
257 | 266 | ||
258 | extern int usb_serial_probe(struct usb_interface *iface, const struct usb_device_id *id); | 267 | extern int usb_serial_probe(struct usb_interface *iface, |
268 | const struct usb_device_id *id); | ||
259 | extern void usb_serial_disconnect(struct usb_interface *iface); | 269 | extern void usb_serial_disconnect(struct usb_interface *iface); |
260 | 270 | ||
261 | extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message); | 271 | extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message); |
262 | extern int usb_serial_resume(struct usb_interface *intf); | 272 | extern int usb_serial_resume(struct usb_interface *intf); |
263 | 273 | ||
264 | extern int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *data, int length, __u8 bRequest); | 274 | extern int ezusb_writememory(struct usb_serial *serial, int address, |
265 | extern int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit); | 275 | unsigned char *data, int length, __u8 bRequest); |
276 | extern int ezusb_set_reset(struct usb_serial *serial, unsigned char reset_bit); | ||
266 | 277 | ||
267 | /* USB Serial console functions */ | 278 | /* USB Serial console functions */ |
268 | #ifdef CONFIG_USB_SERIAL_CONSOLE | 279 | #ifdef CONFIG_USB_SERIAL_CONSOLE |
269 | extern void usb_serial_console_init (int debug, int minor); | 280 | extern void usb_serial_console_init(int debug, int minor); |
270 | extern void usb_serial_console_exit (void); | 281 | extern void usb_serial_console_exit(void); |
271 | extern void usb_serial_console_disconnect(struct usb_serial *serial); | 282 | extern void usb_serial_console_disconnect(struct usb_serial *serial); |
272 | #else | 283 | #else |
273 | static inline void usb_serial_console_init (int debug, int minor) { } | 284 | static inline void usb_serial_console_init(int debug, int minor) { } |
274 | static inline void usb_serial_console_exit (void) { } | 285 | static inline void usb_serial_console_exit(void) { } |
275 | static inline void usb_serial_console_disconnect(struct usb_serial *serial) {} | 286 | static inline void usb_serial_console_disconnect(struct usb_serial *serial) {} |
276 | #endif | 287 | #endif |
277 | 288 | ||
278 | /* Functions needed by other parts of the usbserial core */ | 289 | /* Functions needed by other parts of the usbserial core */ |
279 | extern struct usb_serial *usb_serial_get_by_index (unsigned int minor); | 290 | extern struct usb_serial *usb_serial_get_by_index(unsigned int minor); |
280 | extern void usb_serial_put(struct usb_serial *serial); | 291 | extern void usb_serial_put(struct usb_serial *serial); |
281 | extern int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp); | 292 | extern int usb_serial_generic_open(struct usb_serial_port *port, |
282 | extern int usb_serial_generic_write (struct usb_serial_port *port, const unsigned char *buf, int count); | 293 | struct file *filp); |
283 | extern void usb_serial_generic_close (struct usb_serial_port *port, struct file *filp); | 294 | extern int usb_serial_generic_write(struct usb_serial_port *port, |
284 | extern int usb_serial_generic_resume (struct usb_serial *serial); | 295 | const unsigned char *buf, int count); |
285 | extern int usb_serial_generic_write_room (struct usb_serial_port *port); | 296 | extern void usb_serial_generic_close(struct usb_serial_port *port, |
286 | extern int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port); | 297 | struct file *filp); |
287 | extern void usb_serial_generic_read_bulk_callback (struct urb *urb); | 298 | extern int usb_serial_generic_resume(struct usb_serial *serial); |
288 | extern void usb_serial_generic_write_bulk_callback (struct urb *urb); | 299 | extern int usb_serial_generic_write_room(struct usb_serial_port *port); |
289 | extern void usb_serial_generic_throttle (struct usb_serial_port *port); | 300 | extern int usb_serial_generic_chars_in_buffer(struct usb_serial_port *port); |
290 | extern void usb_serial_generic_unthrottle (struct usb_serial_port *port); | 301 | extern void usb_serial_generic_read_bulk_callback(struct urb *urb); |
291 | extern void usb_serial_generic_shutdown (struct usb_serial *serial); | 302 | extern void usb_serial_generic_write_bulk_callback(struct urb *urb); |
292 | extern int usb_serial_generic_register (int debug); | 303 | extern void usb_serial_generic_throttle(struct usb_serial_port *port); |
293 | extern void usb_serial_generic_deregister (void); | 304 | extern void usb_serial_generic_unthrottle(struct usb_serial_port *port); |
294 | 305 | extern void usb_serial_generic_shutdown(struct usb_serial *serial); | |
295 | extern int usb_serial_bus_register (struct usb_serial_driver *device); | 306 | extern int usb_serial_generic_register(int debug); |
296 | extern void usb_serial_bus_deregister (struct usb_serial_driver *device); | 307 | extern void usb_serial_generic_deregister(void); |
308 | |||
309 | extern int usb_serial_bus_register(struct usb_serial_driver *device); | ||
310 | extern void usb_serial_bus_deregister(struct usb_serial_driver *device); | ||
297 | 311 | ||
298 | extern struct usb_serial_driver usb_serial_generic_device; | 312 | extern struct usb_serial_driver usb_serial_generic_device; |
299 | extern struct bus_type usb_serial_bus_type; | 313 | extern struct bus_type usb_serial_bus_type; |
@@ -307,16 +321,22 @@ static inline void usb_serial_debug_data(int debug, | |||
307 | int i; | 321 | int i; |
308 | 322 | ||
309 | if (debug) { | 323 | if (debug) { |
310 | dev_printk(KERN_DEBUG, dev, "%s - length = %d, data = ", function, size); | 324 | dev_printk(KERN_DEBUG, dev, "%s - length = %d, data = ", |
325 | function, size); | ||
311 | for (i = 0; i < size; ++i) | 326 | for (i = 0; i < size; ++i) |
312 | printk ("%.2x ", data[i]); | 327 | printk("%.2x ", data[i]); |
313 | printk ("\n"); | 328 | printk("\n"); |
314 | } | 329 | } |
315 | } | 330 | } |
316 | 331 | ||
317 | /* Use our own dbg macro */ | 332 | /* Use our own dbg macro */ |
318 | #undef dbg | 333 | #undef dbg |
319 | #define dbg(format, arg...) do { if (debug) printk(KERN_DEBUG "%s: " format "\n" , __FILE__ , ## arg); } while (0) | 334 | #define dbg(format, arg...) \ |
335 | do { \ | ||
336 | if (debug) \ | ||
337 | printk(KERN_DEBUG "%s: " format "\n" , __FILE__ , \ | ||
338 | ## arg); \ | ||
339 | } while (0) | ||
320 | 340 | ||
321 | 341 | ||
322 | 342 | ||