aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb/serial.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/usb/serial.h')
-rw-r--r--include/linux/usb/serial.h160
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 */
63struct usb_serial_port { 64struct 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 */
100static inline void *usb_get_serial_port_data (struct usb_serial_port *port) 102static 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
105static inline void usb_set_serial_port_data (struct usb_serial_port *port, void *data) 107static 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 */
127struct usb_serial { 130struct 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 */
147static inline void *usb_get_serial_data (struct usb_serial *serial) 152static inline void *usb_get_serial_data(struct usb_serial *serial)
148{ 153{
149 return serial->private; 154 return serial->private;
150} 155}
151 156
152static inline void usb_set_serial_data (struct usb_serial *serial, void *data) 157static 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
254extern int usb_serial_register(struct usb_serial_driver *driver); 263extern int usb_serial_register(struct usb_serial_driver *driver);
255extern void usb_serial_deregister(struct usb_serial_driver *driver); 264extern void usb_serial_deregister(struct usb_serial_driver *driver);
256extern void usb_serial_port_softint(struct usb_serial_port *port); 265extern void usb_serial_port_softint(struct usb_serial_port *port);
257 266
258extern int usb_serial_probe(struct usb_interface *iface, const struct usb_device_id *id); 267extern int usb_serial_probe(struct usb_interface *iface,
268 const struct usb_device_id *id);
259extern void usb_serial_disconnect(struct usb_interface *iface); 269extern void usb_serial_disconnect(struct usb_interface *iface);
260 270
261extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message); 271extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message);
262extern int usb_serial_resume(struct usb_interface *intf); 272extern int usb_serial_resume(struct usb_interface *intf);
263 273
264extern int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *data, int length, __u8 bRequest); 274extern int ezusb_writememory(struct usb_serial *serial, int address,
265extern int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit); 275 unsigned char *data, int length, __u8 bRequest);
276extern 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
269extern void usb_serial_console_init (int debug, int minor); 280extern void usb_serial_console_init(int debug, int minor);
270extern void usb_serial_console_exit (void); 281extern void usb_serial_console_exit(void);
271extern void usb_serial_console_disconnect(struct usb_serial *serial); 282extern void usb_serial_console_disconnect(struct usb_serial *serial);
272#else 283#else
273static inline void usb_serial_console_init (int debug, int minor) { } 284static inline void usb_serial_console_init(int debug, int minor) { }
274static inline void usb_serial_console_exit (void) { } 285static inline void usb_serial_console_exit(void) { }
275static inline void usb_serial_console_disconnect(struct usb_serial *serial) {} 286static 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 */
279extern struct usb_serial *usb_serial_get_by_index (unsigned int minor); 290extern struct usb_serial *usb_serial_get_by_index(unsigned int minor);
280extern void usb_serial_put(struct usb_serial *serial); 291extern void usb_serial_put(struct usb_serial *serial);
281extern int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp); 292extern int usb_serial_generic_open(struct usb_serial_port *port,
282extern int usb_serial_generic_write (struct usb_serial_port *port, const unsigned char *buf, int count); 293 struct file *filp);
283extern void usb_serial_generic_close (struct usb_serial_port *port, struct file *filp); 294extern int usb_serial_generic_write(struct usb_serial_port *port,
284extern int usb_serial_generic_resume (struct usb_serial *serial); 295 const unsigned char *buf, int count);
285extern int usb_serial_generic_write_room (struct usb_serial_port *port); 296extern void usb_serial_generic_close(struct usb_serial_port *port,
286extern int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port); 297 struct file *filp);
287extern void usb_serial_generic_read_bulk_callback (struct urb *urb); 298extern int usb_serial_generic_resume(struct usb_serial *serial);
288extern void usb_serial_generic_write_bulk_callback (struct urb *urb); 299extern int usb_serial_generic_write_room(struct usb_serial_port *port);
289extern void usb_serial_generic_throttle (struct usb_serial_port *port); 300extern int usb_serial_generic_chars_in_buffer(struct usb_serial_port *port);
290extern void usb_serial_generic_unthrottle (struct usb_serial_port *port); 301extern void usb_serial_generic_read_bulk_callback(struct urb *urb);
291extern void usb_serial_generic_shutdown (struct usb_serial *serial); 302extern void usb_serial_generic_write_bulk_callback(struct urb *urb);
292extern int usb_serial_generic_register (int debug); 303extern void usb_serial_generic_throttle(struct usb_serial_port *port);
293extern void usb_serial_generic_deregister (void); 304extern void usb_serial_generic_unthrottle(struct usb_serial_port *port);
294 305extern void usb_serial_generic_shutdown(struct usb_serial *serial);
295extern int usb_serial_bus_register (struct usb_serial_driver *device); 306extern int usb_serial_generic_register(int debug);
296extern void usb_serial_bus_deregister (struct usb_serial_driver *device); 307extern void usb_serial_generic_deregister(void);
308
309extern int usb_serial_bus_register(struct usb_serial_driver *device);
310extern void usb_serial_bus_deregister(struct usb_serial_driver *device);
297 311
298extern struct usb_serial_driver usb_serial_generic_device; 312extern struct usb_serial_driver usb_serial_generic_device;
299extern struct bus_type usb_serial_bus_type; 313extern 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