diff options
Diffstat (limited to 'include/linux/usb/serial.h')
| -rw-r--r-- | include/linux/usb/serial.h | 157 |
1 files changed, 87 insertions, 70 deletions
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h index 63b29b5332e6..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 | ||
| @@ -98,12 +99,13 @@ struct usb_serial_port { | |||
| 98 | #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) |
| 99 | 100 | ||
| 100 | /* get and set the port private data pointer helper functions */ | 101 | /* get and set the port private data pointer helper functions */ |
| 101 | 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) |
| 102 | { | 103 | { |
| 103 | return dev_get_drvdata(&port->dev); | 104 | return dev_get_drvdata(&port->dev); |
| 104 | } | 105 | } |
| 105 | 106 | ||
| 106 | 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) | ||
| 107 | { | 109 | { |
| 108 | dev_set_drvdata(&port->dev, data); | 110 | dev_set_drvdata(&port->dev, data); |
| 109 | } | 111 | } |
| @@ -126,9 +128,9 @@ static inline void usb_set_serial_port_data (struct usb_serial_port *port, void | |||
| 126 | * usb_set_serial_data() to access this. | 128 | * usb_set_serial_data() to access this. |
| 127 | */ | 129 | */ |
| 128 | struct usb_serial { | 130 | struct usb_serial { |
| 129 | struct usb_device * dev; | 131 | struct usb_device *dev; |
| 130 | struct usb_serial_driver * type; | 132 | struct usb_serial_driver *type; |
| 131 | struct usb_interface * interface; | 133 | struct usb_interface *interface; |
| 132 | unsigned char disconnected; | 134 | unsigned char disconnected; |
| 133 | unsigned char minor; | 135 | unsigned char minor; |
| 134 | unsigned char num_ports; | 136 | unsigned char num_ports; |
| @@ -137,30 +139,30 @@ struct usb_serial { | |||
| 137 | char num_interrupt_out; | 139 | char num_interrupt_out; |
| 138 | char num_bulk_in; | 140 | char num_bulk_in; |
| 139 | char num_bulk_out; | 141 | char num_bulk_out; |
| 140 | struct usb_serial_port * port[MAX_NUM_PORTS]; | 142 | struct usb_serial_port *port[MAX_NUM_PORTS]; |
| 141 | struct kref kref; | 143 | struct kref kref; |
| 142 | struct mutex disc_mutex; | 144 | struct mutex disc_mutex; |
| 143 | void * private; | 145 | void *private; |
| 144 | }; | 146 | }; |
| 145 | #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) |
| 146 | 148 | ||
| 147 | #define NUM_DONT_CARE 99 | 149 | #define NUM_DONT_CARE 99 |
| 148 | 150 | ||
| 149 | /* get and set the serial private data pointer helper functions */ | 151 | /* get and set the serial private data pointer helper functions */ |
| 150 | static inline void *usb_get_serial_data (struct usb_serial *serial) | 152 | static inline void *usb_get_serial_data(struct usb_serial *serial) |
| 151 | { | 153 | { |
| 152 | return serial->private; | 154 | return serial->private; |
| 153 | } | 155 | } |
| 154 | 156 | ||
| 155 | 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) |
| 156 | { | 158 | { |
| 157 | serial->private = data; | 159 | serial->private = data; |
| 158 | } | 160 | } |
| 159 | 161 | ||
| 160 | /** | 162 | /** |
| 161 | * usb_serial_driver - describes a usb serial driver | 163 | * usb_serial_driver - describes a usb serial driver |
| 162 | * @description: pointer to a string that describes this driver. This string used | 164 | * @description: pointer to a string that describes this driver. This string |
| 163 | * in the syslog messages when a device is inserted or removed. | 165 | * used in the syslog messages when a device is inserted or removed. |
| 164 | * @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 |
| 165 | * of the devices this structure can support. | 167 | * of the devices this structure can support. |
| 166 | * @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 |
| @@ -221,82 +223,91 @@ struct usb_serial_driver { | |||
| 221 | struct usb_driver *usb_driver; | 223 | struct usb_driver *usb_driver; |
| 222 | struct usb_dynids dynids; | 224 | struct usb_dynids dynids; |
| 223 | 225 | ||
| 224 | 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); |
| 225 | int (*attach) (struct usb_serial *serial); | 227 | int (*attach)(struct usb_serial *serial); |
| 226 | int (*calc_num_ports) (struct usb_serial *serial); | 228 | int (*calc_num_ports) (struct usb_serial *serial); |
| 227 | 229 | ||
| 228 | void (*shutdown) (struct usb_serial *serial); | 230 | void (*shutdown)(struct usb_serial *serial); |
| 229 | 231 | ||
| 230 | int (*port_probe) (struct usb_serial_port *port); | 232 | int (*port_probe)(struct usb_serial_port *port); |
| 231 | int (*port_remove) (struct usb_serial_port *port); | 233 | int (*port_remove)(struct usb_serial_port *port); |
| 232 | 234 | ||
| 233 | int (*suspend) (struct usb_serial *serial, pm_message_t message); | 235 | int (*suspend)(struct usb_serial *serial, pm_message_t message); |
| 234 | int (*resume) (struct usb_serial *serial); | 236 | int (*resume)(struct usb_serial *serial); |
| 235 | 237 | ||
| 236 | /* serial function calls */ | 238 | /* serial function calls */ |
| 237 | int (*open) (struct usb_serial_port *port, struct file * filp); | 239 | int (*open)(struct usb_serial_port *port, struct file *filp); |
| 238 | void (*close) (struct usb_serial_port *port, struct file * filp); | 240 | void (*close)(struct usb_serial_port *port, struct file *filp); |
| 239 | 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, |
| 240 | int (*write_room) (struct usb_serial_port *port); | 242 | int count); |
| 241 | 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); |
| 242 | void (*set_termios) (struct usb_serial_port *port, struct ktermios * old); | 244 | int (*ioctl)(struct usb_serial_port *port, struct file *file, |
| 243 | void (*break_ctl) (struct usb_serial_port *port, int break_state); | 245 | unsigned int cmd, unsigned long arg); |
| 244 | int (*chars_in_buffer) (struct usb_serial_port *port); | 246 | void (*set_termios)(struct usb_serial_port *port, struct ktermios *old); |
| 245 | void (*throttle) (struct usb_serial_port *port); | 247 | void (*break_ctl)(struct usb_serial_port *port, int break_state); |
| 246 | void (*unthrottle) (struct usb_serial_port *port); | 248 | int (*chars_in_buffer)(struct usb_serial_port *port); |
| 247 | int (*tiocmget) (struct usb_serial_port *port, struct file *file); | 249 | void (*throttle)(struct usb_serial_port *port); |
| 248 | 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); | ||
| 249 | 254 | ||
| 250 | void (*read_int_callback)(struct urb *urb); | 255 | void (*read_int_callback)(struct urb *urb); |
| 251 | void (*write_int_callback)(struct urb *urb); | 256 | void (*write_int_callback)(struct urb *urb); |
| 252 | void (*read_bulk_callback)(struct urb *urb); | 257 | void (*read_bulk_callback)(struct urb *urb); |
| 253 | void (*write_bulk_callback)(struct urb *urb); | 258 | void (*write_bulk_callback)(struct urb *urb); |
| 254 | }; | 259 | }; |
| 255 | #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) | ||
| 256 | 262 | ||
| 257 | extern int usb_serial_register(struct usb_serial_driver *driver); | 263 | extern int usb_serial_register(struct usb_serial_driver *driver); |
| 258 | extern void usb_serial_deregister(struct usb_serial_driver *driver); | 264 | extern void usb_serial_deregister(struct usb_serial_driver *driver); |
| 259 | extern void usb_serial_port_softint(struct usb_serial_port *port); | 265 | extern void usb_serial_port_softint(struct usb_serial_port *port); |
| 260 | 266 | ||
| 261 | 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); | ||
| 262 | extern void usb_serial_disconnect(struct usb_interface *iface); | 269 | extern void usb_serial_disconnect(struct usb_interface *iface); |
| 263 | 270 | ||
| 264 | 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); |
| 265 | extern int usb_serial_resume(struct usb_interface *intf); | 272 | extern int usb_serial_resume(struct usb_interface *intf); |
| 266 | 273 | ||
| 267 | 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, |
| 268 | 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); | ||
| 269 | 277 | ||
| 270 | /* USB Serial console functions */ | 278 | /* USB Serial console functions */ |
| 271 | #ifdef CONFIG_USB_SERIAL_CONSOLE | 279 | #ifdef CONFIG_USB_SERIAL_CONSOLE |
| 272 | extern void usb_serial_console_init (int debug, int minor); | 280 | extern void usb_serial_console_init(int debug, int minor); |
| 273 | extern void usb_serial_console_exit (void); | 281 | extern void usb_serial_console_exit(void); |
| 274 | extern void usb_serial_console_disconnect(struct usb_serial *serial); | 282 | extern void usb_serial_console_disconnect(struct usb_serial *serial); |
| 275 | #else | 283 | #else |
| 276 | static inline void usb_serial_console_init (int debug, int minor) { } | 284 | static inline void usb_serial_console_init(int debug, int minor) { } |
| 277 | static inline void usb_serial_console_exit (void) { } | 285 | static inline void usb_serial_console_exit(void) { } |
| 278 | static inline void usb_serial_console_disconnect(struct usb_serial *serial) {} | 286 | static inline void usb_serial_console_disconnect(struct usb_serial *serial) {} |
| 279 | #endif | 287 | #endif |
| 280 | 288 | ||
| 281 | /* Functions needed by other parts of the usbserial core */ | 289 | /* Functions needed by other parts of the usbserial core */ |
| 282 | 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); |
| 283 | extern void usb_serial_put(struct usb_serial *serial); | 291 | extern void usb_serial_put(struct usb_serial *serial); |
| 284 | 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, |
| 285 | extern int usb_serial_generic_write (struct usb_serial_port *port, const unsigned char *buf, int count); | 293 | struct file *filp); |
| 286 | 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, |
| 287 | extern int usb_serial_generic_resume (struct usb_serial *serial); | 295 | const unsigned char *buf, int count); |
| 288 | extern int usb_serial_generic_write_room (struct usb_serial_port *port); | 296 | extern void usb_serial_generic_close(struct usb_serial_port *port, |
| 289 | extern int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port); | 297 | struct file *filp); |
| 290 | extern void usb_serial_generic_read_bulk_callback (struct urb *urb); | 298 | extern int usb_serial_generic_resume(struct usb_serial *serial); |
| 291 | extern void usb_serial_generic_write_bulk_callback (struct urb *urb); | 299 | extern int usb_serial_generic_write_room(struct usb_serial_port *port); |
| 292 | 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); |
| 293 | extern void usb_serial_generic_unthrottle (struct usb_serial_port *port); | 301 | extern void usb_serial_generic_read_bulk_callback(struct urb *urb); |
| 294 | extern void usb_serial_generic_shutdown (struct usb_serial *serial); | 302 | extern void usb_serial_generic_write_bulk_callback(struct urb *urb); |
| 295 | extern int usb_serial_generic_register (int debug); | 303 | extern void usb_serial_generic_throttle(struct usb_serial_port *port); |
| 296 | extern void usb_serial_generic_deregister (void); | 304 | extern void usb_serial_generic_unthrottle(struct usb_serial_port *port); |
| 297 | 305 | extern void usb_serial_generic_shutdown(struct usb_serial *serial); | |
| 298 | extern int usb_serial_bus_register (struct usb_serial_driver *device); | 306 | extern int usb_serial_generic_register(int debug); |
| 299 | 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); | ||
| 300 | 311 | ||
| 301 | extern struct usb_serial_driver usb_serial_generic_device; | 312 | extern struct usb_serial_driver usb_serial_generic_device; |
| 302 | extern struct bus_type usb_serial_bus_type; | 313 | extern struct bus_type usb_serial_bus_type; |
| @@ -310,16 +321,22 @@ static inline void usb_serial_debug_data(int debug, | |||
| 310 | int i; | 321 | int i; |
| 311 | 322 | ||
| 312 | if (debug) { | 323 | if (debug) { |
| 313 | dev_printk(KERN_DEBUG, dev, "%s - length = %d, data = ", function, size); | 324 | dev_printk(KERN_DEBUG, dev, "%s - length = %d, data = ", |
| 325 | function, size); | ||
| 314 | for (i = 0; i < size; ++i) | 326 | for (i = 0; i < size; ++i) |
| 315 | printk ("%.2x ", data[i]); | 327 | printk("%.2x ", data[i]); |
| 316 | printk ("\n"); | 328 | printk("\n"); |
| 317 | } | 329 | } |
| 318 | } | 330 | } |
| 319 | 331 | ||
| 320 | /* Use our own dbg macro */ | 332 | /* Use our own dbg macro */ |
| 321 | #undef dbg | 333 | #undef dbg |
| 322 | #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) | ||
| 323 | 340 | ||
| 324 | 341 | ||
| 325 | 342 | ||
