diff options
author | Alan Cox <alan@redhat.com> | 2008-07-22 06:14:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-22 16:03:25 -0400 |
commit | 0c265f4e8598e251108759685dbb3789868086b2 (patch) | |
tree | d969fb7c2bd6da07264b8a2ceb5a58db5e54185f /drivers/usb | |
parent | 8dd03a5b2b775b0932c1705dc19298ccda19167d (diff) |
tty-usb-kl5kusb105: Coding style
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/serial/kl5kusb105.c | 389 |
1 files changed, 188 insertions, 201 deletions
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index 4a38ec8f5fe3..b84dddc71124 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c | |||
@@ -15,12 +15,12 @@ | |||
15 | * Neither Palm, nor their contractor (MCCI) or their supplier (KLSI) provided | 15 | * Neither Palm, nor their contractor (MCCI) or their supplier (KLSI) provided |
16 | * information that was not already available. | 16 | * information that was not already available. |
17 | * | 17 | * |
18 | * It seems that KLSI bought some silicon-design information from ScanLogic, | 18 | * It seems that KLSI bought some silicon-design information from ScanLogic, |
19 | * whose SL11R processor is at the core of the KL5KUSB chipset from KLSI. | 19 | * whose SL11R processor is at the core of the KL5KUSB chipset from KLSI. |
20 | * KLSI has firmware available for their devices; it is probable that the | 20 | * KLSI has firmware available for their devices; it is probable that the |
21 | * firmware differs from that used by KLSI in their products. If you have an | 21 | * firmware differs from that used by KLSI in their products. If you have an |
22 | * original KLSI device and can provide some information on it, I would be | 22 | * original KLSI device and can provide some information on it, I would be |
23 | * most interested in adding support for it here. If you have any information | 23 | * most interested in adding support for it here. If you have any information |
24 | * on the protocol used (or find errors in my reverse-engineered stuff), please | 24 | * on the protocol used (or find errors in my reverse-engineered stuff), please |
25 | * let me know. | 25 | * let me know. |
26 | * | 26 | * |
@@ -40,7 +40,7 @@ | |||
40 | * 0.2 - TIOCMGET works, so autopilot(1) can be used! | 40 | * 0.2 - TIOCMGET works, so autopilot(1) can be used! |
41 | * 0.1 - can be used to to pilot-xfer -p /dev/ttyUSB0 -l | 41 | * 0.1 - can be used to to pilot-xfer -p /dev/ttyUSB0 -l |
42 | * | 42 | * |
43 | * The driver skeleton is mainly based on mct_u232.c and various other | 43 | * The driver skeleton is mainly based on mct_u232.c and various other |
44 | * pieces of code shamelessly copied from the drivers/usb/serial/ directory. | 44 | * pieces of code shamelessly copied from the drivers/usb/serial/ directory. |
45 | */ | 45 | */ |
46 | 46 | ||
@@ -53,7 +53,7 @@ | |||
53 | #include <linux/tty_driver.h> | 53 | #include <linux/tty_driver.h> |
54 | #include <linux/tty_flip.h> | 54 | #include <linux/tty_flip.h> |
55 | #include <linux/module.h> | 55 | #include <linux/module.h> |
56 | #include <asm/uaccess.h> | 56 | #include <linux/uaccess.h> |
57 | #include <asm/unaligned.h> | 57 | #include <asm/unaligned.h> |
58 | #include <linux/usb.h> | 58 | #include <linux/usb.h> |
59 | #include <linux/usb/serial.h> | 59 | #include <linux/usb/serial.h> |
@@ -72,37 +72,25 @@ static int debug; | |||
72 | /* | 72 | /* |
73 | * Function prototypes | 73 | * Function prototypes |
74 | */ | 74 | */ |
75 | static int klsi_105_startup (struct usb_serial *serial); | 75 | static int klsi_105_startup(struct usb_serial *serial); |
76 | static void klsi_105_shutdown (struct usb_serial *serial); | 76 | static void klsi_105_shutdown(struct usb_serial *serial); |
77 | static int klsi_105_open (struct tty_struct *tty, | 77 | static int klsi_105_open(struct tty_struct *tty, |
78 | struct usb_serial_port *port, | 78 | struct usb_serial_port *port, struct file *filp); |
79 | struct file *filp); | 79 | static void klsi_105_close(struct tty_struct *tty, |
80 | static void klsi_105_close (struct tty_struct *tty, | 80 | struct usb_serial_port *port, struct file *filp); |
81 | struct usb_serial_port *port, | 81 | static int klsi_105_write(struct tty_struct *tty, |
82 | struct file *filp); | 82 | struct usb_serial_port *port, const unsigned char *buf, int count); |
83 | static int klsi_105_write (struct tty_struct *tty, | 83 | static void klsi_105_write_bulk_callback(struct urb *urb); |
84 | struct usb_serial_port *port, | 84 | static int klsi_105_chars_in_buffer(struct tty_struct *tty); |
85 | const unsigned char *buf, | 85 | static int klsi_105_write_room(struct tty_struct *tty); |
86 | int count); | 86 | static void klsi_105_read_bulk_callback(struct urb *urb); |
87 | static void klsi_105_write_bulk_callback (struct urb *urb); | 87 | static void klsi_105_set_termios(struct tty_struct *tty, |
88 | static int klsi_105_chars_in_buffer (struct tty_struct *tty); | 88 | struct usb_serial_port *port, struct ktermios *old); |
89 | static int klsi_105_write_room (struct tty_struct *tty); | 89 | static void klsi_105_throttle(struct tty_struct *tty); |
90 | 90 | static void klsi_105_unthrottle(struct tty_struct *tty); | |
91 | static void klsi_105_read_bulk_callback (struct urb *urb); | 91 | static int klsi_105_tiocmget(struct tty_struct *tty, struct file *file); |
92 | static void klsi_105_set_termios (struct tty_struct *tty, | 92 | static int klsi_105_tiocmset(struct tty_struct *tty, struct file *file, |
93 | struct usb_serial_port *port, | 93 | unsigned int set, unsigned int clear); |
94 | struct ktermios *old); | ||
95 | static void klsi_105_throttle (struct tty_struct *tty); | ||
96 | static void klsi_105_unthrottle (struct tty_struct *tty); | ||
97 | /* | ||
98 | static void klsi_105_break_ctl (struct tty_struct *tty, | ||
99 | int break_state ); | ||
100 | */ | ||
101 | static int klsi_105_tiocmget (struct tty_struct *tty, | ||
102 | struct file *file); | ||
103 | static int klsi_105_tiocmset (struct tty_struct *tty, | ||
104 | struct file *file, unsigned int set, | ||
105 | unsigned int clear); | ||
106 | 94 | ||
107 | /* | 95 | /* |
108 | * All of the device info needed for the KLSI converters. | 96 | * All of the device info needed for the KLSI converters. |
@@ -113,7 +101,7 @@ static struct usb_device_id id_table [] = { | |||
113 | { } /* Terminating entry */ | 101 | { } /* Terminating entry */ |
114 | }; | 102 | }; |
115 | 103 | ||
116 | MODULE_DEVICE_TABLE (usb, id_table); | 104 | MODULE_DEVICE_TABLE(usb, id_table); |
117 | 105 | ||
118 | static struct usb_driver kl5kusb105d_driver = { | 106 | static struct usb_driver kl5kusb105d_driver = { |
119 | .name = "kl5kusb105d", | 107 | .name = "kl5kusb105d", |
@@ -138,7 +126,7 @@ static struct usb_serial_driver kl5kusb105d_device = { | |||
138 | .write_bulk_callback = klsi_105_write_bulk_callback, | 126 | .write_bulk_callback = klsi_105_write_bulk_callback, |
139 | .chars_in_buffer = klsi_105_chars_in_buffer, | 127 | .chars_in_buffer = klsi_105_chars_in_buffer, |
140 | .write_room = klsi_105_write_room, | 128 | .write_room = klsi_105_write_room, |
141 | .read_bulk_callback =klsi_105_read_bulk_callback, | 129 | .read_bulk_callback = klsi_105_read_bulk_callback, |
142 | .set_termios = klsi_105_set_termios, | 130 | .set_termios = klsi_105_set_termios, |
143 | /*.break_ctl = klsi_105_break_ctl,*/ | 131 | /*.break_ctl = klsi_105_break_ctl,*/ |
144 | .tiocmget = klsi_105_tiocmget, | 132 | .tiocmget = klsi_105_tiocmget, |
@@ -165,7 +153,7 @@ struct klsi_105_private { | |||
165 | struct ktermios termios; | 153 | struct ktermios termios; |
166 | unsigned long line_state; /* modem line settings */ | 154 | unsigned long line_state; /* modem line settings */ |
167 | /* write pool */ | 155 | /* write pool */ |
168 | struct urb * write_urb_pool[NUM_URBS]; | 156 | struct urb *write_urb_pool[NUM_URBS]; |
169 | spinlock_t lock; | 157 | spinlock_t lock; |
170 | unsigned long bytes_in; | 158 | unsigned long bytes_in; |
171 | unsigned long bytes_out; | 159 | unsigned long bytes_out; |
@@ -184,15 +172,15 @@ static int klsi_105_chg_port_settings(struct usb_serial_port *port, | |||
184 | { | 172 | { |
185 | int rc; | 173 | int rc; |
186 | 174 | ||
187 | rc = usb_control_msg(port->serial->dev, | 175 | rc = usb_control_msg(port->serial->dev, |
188 | usb_sndctrlpipe(port->serial->dev, 0), | 176 | usb_sndctrlpipe(port->serial->dev, 0), |
189 | KL5KUSB105A_SIO_SET_DATA, | 177 | KL5KUSB105A_SIO_SET_DATA, |
190 | USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_INTERFACE, | 178 | USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_INTERFACE, |
191 | 0, /* value */ | 179 | 0, /* value */ |
192 | 0, /* index */ | 180 | 0, /* index */ |
193 | settings, | 181 | settings, |
194 | sizeof(struct klsi_105_port_settings), | 182 | sizeof(struct klsi_105_port_settings), |
195 | KLSI_TIMEOUT); | 183 | KLSI_TIMEOUT); |
196 | if (rc < 0) | 184 | if (rc < 0) |
197 | err("Change port settings failed (error = %d)", rc); | 185 | err("Change port settings failed (error = %d)", rc); |
198 | info("%s - %d byte block, baudrate %x, databits %d, u1 %d, u2 %d", | 186 | info("%s - %d byte block, baudrate %x, databits %d, u1 %d, u2 %d", |
@@ -200,7 +188,7 @@ static int klsi_105_chg_port_settings(struct usb_serial_port *port, | |||
200 | settings->pktlen, | 188 | settings->pktlen, |
201 | settings->baudrate, settings->databits, | 189 | settings->baudrate, settings->databits, |
202 | settings->unknown1, settings->unknown2); | 190 | settings->unknown1, settings->unknown2); |
203 | return rc; | 191 | return rc; |
204 | } /* klsi_105_chg_port_settings */ | 192 | } /* klsi_105_chg_port_settings */ |
205 | 193 | ||
206 | /* translate a 16-bit status value from the device to linux's TIO bits */ | 194 | /* translate a 16-bit status value from the device to linux's TIO bits */ |
@@ -214,9 +202,9 @@ static unsigned long klsi_105_status2linestate(const __u16 status) | |||
214 | 202 | ||
215 | return res; | 203 | return res; |
216 | } | 204 | } |
217 | /* | 205 | /* |
218 | * Read line control via vendor command and return result through | 206 | * Read line control via vendor command and return result through |
219 | * *line_state_p | 207 | * *line_state_p |
220 | */ | 208 | */ |
221 | /* It seems that the status buffer has always only 2 bytes length */ | 209 | /* It seems that the status buffer has always only 2 bytes length */ |
222 | #define KLSI_STATUSBUF_LEN 2 | 210 | #define KLSI_STATUSBUF_LEN 2 |
@@ -224,14 +212,14 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, | |||
224 | unsigned long *line_state_p) | 212 | unsigned long *line_state_p) |
225 | { | 213 | { |
226 | int rc; | 214 | int rc; |
227 | __u8 status_buf[KLSI_STATUSBUF_LEN] = { -1,-1}; | 215 | __u8 status_buf[KLSI_STATUSBUF_LEN] = { -1, -1}; |
228 | __u16 status; | 216 | __u16 status; |
229 | 217 | ||
230 | info("%s - sending SIO Poll request", __func__); | 218 | info("%s - sending SIO Poll request", __func__); |
231 | rc = usb_control_msg(port->serial->dev, | 219 | rc = usb_control_msg(port->serial->dev, |
232 | usb_rcvctrlpipe(port->serial->dev, 0), | 220 | usb_rcvctrlpipe(port->serial->dev, 0), |
233 | KL5KUSB105A_SIO_POLL, | 221 | KL5KUSB105A_SIO_POLL, |
234 | USB_TYPE_VENDOR | USB_DIR_IN, | 222 | USB_TYPE_VENDOR | USB_DIR_IN, |
235 | 0, /* value */ | 223 | 0, /* value */ |
236 | 0, /* index */ | 224 | 0, /* index */ |
237 | status_buf, KLSI_STATUSBUF_LEN, | 225 | status_buf, KLSI_STATUSBUF_LEN, |
@@ -247,8 +235,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, | |||
247 | 235 | ||
248 | *line_state_p = klsi_105_status2linestate(status); | 236 | *line_state_p = klsi_105_status2linestate(status); |
249 | } | 237 | } |
250 | 238 | return rc; | |
251 | return rc; | ||
252 | } | 239 | } |
253 | 240 | ||
254 | 241 | ||
@@ -256,7 +243,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, | |||
256 | * Driver's tty interface functions | 243 | * Driver's tty interface functions |
257 | */ | 244 | */ |
258 | 245 | ||
259 | static int klsi_105_startup (struct usb_serial *serial) | 246 | static int klsi_105_startup(struct usb_serial *serial) |
260 | { | 247 | { |
261 | struct klsi_105_private *priv; | 248 | struct klsi_105_private *priv; |
262 | int i, j; | 249 | int i, j; |
@@ -266,7 +253,7 @@ static int klsi_105_startup (struct usb_serial *serial) | |||
266 | */ | 253 | */ |
267 | 254 | ||
268 | /* allocate the private data structure */ | 255 | /* allocate the private data structure */ |
269 | for (i=0; i<serial->num_ports; i++) { | 256 | for (i = 0; i < serial->num_ports; i++) { |
270 | priv = kmalloc(sizeof(struct klsi_105_private), | 257 | priv = kmalloc(sizeof(struct klsi_105_private), |
271 | GFP_KERNEL); | 258 | GFP_KERNEL); |
272 | if (!priv) { | 259 | if (!priv) { |
@@ -287,9 +274,9 @@ static int klsi_105_startup (struct usb_serial *serial) | |||
287 | priv->bytes_out = 0; | 274 | priv->bytes_out = 0; |
288 | usb_set_serial_port_data(serial->port[i], priv); | 275 | usb_set_serial_port_data(serial->port[i], priv); |
289 | 276 | ||
290 | spin_lock_init (&priv->lock); | 277 | spin_lock_init(&priv->lock); |
291 | for (j=0; j<NUM_URBS; j++) { | 278 | for (j = 0; j < NUM_URBS; j++) { |
292 | struct urb* urb = usb_alloc_urb(0, GFP_KERNEL); | 279 | struct urb *urb = usb_alloc_urb(0, GFP_KERNEL); |
293 | 280 | ||
294 | priv->write_urb_pool[j] = urb; | 281 | priv->write_urb_pool[j] = urb; |
295 | if (urb == NULL) { | 282 | if (urb == NULL) { |
@@ -297,10 +284,11 @@ static int klsi_105_startup (struct usb_serial *serial) | |||
297 | goto err_cleanup; | 284 | goto err_cleanup; |
298 | } | 285 | } |
299 | 286 | ||
300 | urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, | 287 | urb->transfer_buffer = |
301 | GFP_KERNEL); | 288 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); |
302 | if (!urb->transfer_buffer) { | 289 | if (!urb->transfer_buffer) { |
303 | err("%s - out of memory for urb buffers.", __func__); | 290 | err("%s - out of memory for urb buffers.", |
291 | __func__); | ||
304 | goto err_cleanup; | 292 | goto err_cleanup; |
305 | } | 293 | } |
306 | } | 294 | } |
@@ -308,13 +296,13 @@ static int klsi_105_startup (struct usb_serial *serial) | |||
308 | /* priv->termios is left uninitalized until port opening */ | 296 | /* priv->termios is left uninitalized until port opening */ |
309 | init_waitqueue_head(&serial->port[i]->write_wait); | 297 | init_waitqueue_head(&serial->port[i]->write_wait); |
310 | } | 298 | } |
311 | 299 | ||
312 | return 0; | 300 | return 0; |
313 | 301 | ||
314 | err_cleanup: | 302 | err_cleanup: |
315 | for (; i >= 0; i--) { | 303 | for (; i >= 0; i--) { |
316 | priv = usb_get_serial_port_data(serial->port[i]); | 304 | priv = usb_get_serial_port_data(serial->port[i]); |
317 | for (j=0; j < NUM_URBS; j++) { | 305 | for (j = 0; j < NUM_URBS; j++) { |
318 | if (priv->write_urb_pool[j]) { | 306 | if (priv->write_urb_pool[j]) { |
319 | kfree(priv->write_urb_pool[j]->transfer_buffer); | 307 | kfree(priv->write_urb_pool[j]->transfer_buffer); |
320 | usb_free_urb(priv->write_urb_pool[j]); | 308 | usb_free_urb(priv->write_urb_pool[j]); |
@@ -326,22 +314,23 @@ err_cleanup: | |||
326 | } /* klsi_105_startup */ | 314 | } /* klsi_105_startup */ |
327 | 315 | ||
328 | 316 | ||
329 | static void klsi_105_shutdown (struct usb_serial *serial) | 317 | static void klsi_105_shutdown(struct usb_serial *serial) |
330 | { | 318 | { |
331 | int i; | 319 | int i; |
332 | 320 | ||
333 | dbg("%s", __func__); | 321 | dbg("%s", __func__); |
334 | 322 | ||
335 | /* stop reads and writes on all ports */ | 323 | /* stop reads and writes on all ports */ |
336 | for (i=0; i < serial->num_ports; ++i) { | 324 | for (i = 0; i < serial->num_ports; ++i) { |
337 | struct klsi_105_private *priv = usb_get_serial_port_data(serial->port[i]); | 325 | struct klsi_105_private *priv = |
326 | usb_get_serial_port_data(serial->port[i]); | ||
338 | unsigned long flags; | 327 | unsigned long flags; |
339 | 328 | ||
340 | if (priv) { | 329 | if (priv) { |
341 | /* kill our write urb pool */ | 330 | /* kill our write urb pool */ |
342 | int j; | 331 | int j; |
343 | struct urb **write_urbs = priv->write_urb_pool; | 332 | struct urb **write_urbs = priv->write_urb_pool; |
344 | spin_lock_irqsave(&priv->lock,flags); | 333 | spin_lock_irqsave(&priv->lock, flags); |
345 | 334 | ||
346 | for (j = 0; j < NUM_URBS; j++) { | 335 | for (j = 0; j < NUM_URBS; j++) { |
347 | if (write_urbs[j]) { | 336 | if (write_urbs[j]) { |
@@ -353,12 +342,10 @@ static void klsi_105_shutdown (struct usb_serial *serial) | |||
353 | * oopses. */ | 342 | * oopses. */ |
354 | /* usb_kill_urb(write_urbs[j]); */ | 343 | /* usb_kill_urb(write_urbs[j]); */ |
355 | kfree(write_urbs[j]->transfer_buffer); | 344 | kfree(write_urbs[j]->transfer_buffer); |
356 | usb_free_urb (write_urbs[j]); | 345 | usb_free_urb(write_urbs[j]); |
357 | } | 346 | } |
358 | } | 347 | } |
359 | 348 | spin_unlock_irqrestore(&priv->lock, flags); | |
360 | spin_unlock_irqrestore (&priv->lock, flags); | ||
361 | |||
362 | kfree(priv); | 349 | kfree(priv); |
363 | usb_set_serial_port_data(serial->port[i], NULL); | 350 | usb_set_serial_port_data(serial->port[i], NULL); |
364 | } | 351 | } |
@@ -384,7 +371,7 @@ static int klsi_105_open(struct tty_struct *tty, | |||
384 | 371 | ||
385 | /* Do a defined restart: | 372 | /* Do a defined restart: |
386 | * Set up sane default baud rate and send the 'READ_ON' | 373 | * Set up sane default baud rate and send the 'READ_ON' |
387 | * vendor command. | 374 | * vendor command. |
388 | * FIXME: set modem line control (how?) | 375 | * FIXME: set modem line control (how?) |
389 | * Then read the modem line control and store values in | 376 | * Then read the modem line control and store values in |
390 | * priv->line_state. | 377 | * priv->line_state. |
@@ -395,24 +382,24 @@ static int klsi_105_open(struct tty_struct *tty, | |||
395 | cfg.unknown1 = 0; | 382 | cfg.unknown1 = 0; |
396 | cfg.unknown2 = 1; | 383 | cfg.unknown2 = 1; |
397 | klsi_105_chg_port_settings(port, &cfg); | 384 | klsi_105_chg_port_settings(port, &cfg); |
398 | 385 | ||
399 | /* set up termios structure */ | 386 | /* set up termios structure */ |
400 | spin_lock_irqsave (&priv->lock, flags); | 387 | spin_lock_irqsave(&priv->lock, flags); |
401 | priv->termios.c_iflag = tty->termios->c_iflag; | 388 | priv->termios.c_iflag = tty->termios->c_iflag; |
402 | priv->termios.c_oflag = tty->termios->c_oflag; | 389 | priv->termios.c_oflag = tty->termios->c_oflag; |
403 | priv->termios.c_cflag = tty->termios->c_cflag; | 390 | priv->termios.c_cflag = tty->termios->c_cflag; |
404 | priv->termios.c_lflag = tty->termios->c_lflag; | 391 | priv->termios.c_lflag = tty->termios->c_lflag; |
405 | for (i=0; i<NCCS; i++) | 392 | for (i = 0; i < NCCS; i++) |
406 | priv->termios.c_cc[i] = tty->termios->c_cc[i]; | 393 | priv->termios.c_cc[i] = tty->termios->c_cc[i]; |
407 | priv->cfg.pktlen = cfg.pktlen; | 394 | priv->cfg.pktlen = cfg.pktlen; |
408 | priv->cfg.baudrate = cfg.baudrate; | 395 | priv->cfg.baudrate = cfg.baudrate; |
409 | priv->cfg.databits = cfg.databits; | 396 | priv->cfg.databits = cfg.databits; |
410 | priv->cfg.unknown1 = cfg.unknown1; | 397 | priv->cfg.unknown1 = cfg.unknown1; |
411 | priv->cfg.unknown2 = cfg.unknown2; | 398 | priv->cfg.unknown2 = cfg.unknown2; |
412 | spin_unlock_irqrestore (&priv->lock, flags); | 399 | spin_unlock_irqrestore(&priv->lock, flags); |
413 | 400 | ||
414 | /* READ_ON and urb submission */ | 401 | /* READ_ON and urb submission */ |
415 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, | 402 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, |
416 | usb_rcvbulkpipe(port->serial->dev, | 403 | usb_rcvbulkpipe(port->serial->dev, |
417 | port->bulk_in_endpointAddress), | 404 | port->bulk_in_endpointAddress), |
418 | port->read_urb->transfer_buffer, | 405 | port->read_urb->transfer_buffer, |
@@ -428,7 +415,7 @@ static int klsi_105_open(struct tty_struct *tty, | |||
428 | } | 415 | } |
429 | 416 | ||
430 | rc = usb_control_msg(port->serial->dev, | 417 | rc = usb_control_msg(port->serial->dev, |
431 | usb_sndctrlpipe(port->serial->dev,0), | 418 | usb_sndctrlpipe(port->serial->dev, 0), |
432 | KL5KUSB105A_SIO_CONFIGURE, | 419 | KL5KUSB105A_SIO_CONFIGURE, |
433 | USB_TYPE_VENDOR|USB_DIR_OUT|USB_RECIP_INTERFACE, | 420 | USB_TYPE_VENDOR|USB_DIR_OUT|USB_RECIP_INTERFACE, |
434 | KL5KUSB105A_SIO_CONFIGURE_READ_ON, | 421 | KL5KUSB105A_SIO_CONFIGURE_READ_ON, |
@@ -439,14 +426,14 @@ static int klsi_105_open(struct tty_struct *tty, | |||
439 | if (rc < 0) { | 426 | if (rc < 0) { |
440 | err("Enabling read failed (error = %d)", rc); | 427 | err("Enabling read failed (error = %d)", rc); |
441 | retval = rc; | 428 | retval = rc; |
442 | } else | 429 | } else |
443 | dbg("%s - enabled reading", __func__); | 430 | dbg("%s - enabled reading", __func__); |
444 | 431 | ||
445 | rc = klsi_105_get_line_state(port, &line_state); | 432 | rc = klsi_105_get_line_state(port, &line_state); |
446 | if (rc >= 0) { | 433 | if (rc >= 0) { |
447 | spin_lock_irqsave (&priv->lock, flags); | 434 | spin_lock_irqsave(&priv->lock, flags); |
448 | priv->line_state = line_state; | 435 | priv->line_state = line_state; |
449 | spin_unlock_irqrestore (&priv->lock, flags); | 436 | spin_unlock_irqrestore(&priv->lock, flags); |
450 | dbg("%s - read line state 0x%lx", __func__, line_state); | 437 | dbg("%s - read line state 0x%lx", __func__, line_state); |
451 | retval = 0; | 438 | retval = 0; |
452 | } else | 439 | } else |
@@ -468,14 +455,14 @@ static void klsi_105_close(struct tty_struct *tty, | |||
468 | mutex_lock(&port->serial->disc_mutex); | 455 | mutex_lock(&port->serial->disc_mutex); |
469 | if (!port->serial->disconnected) { | 456 | if (!port->serial->disconnected) { |
470 | /* send READ_OFF */ | 457 | /* send READ_OFF */ |
471 | rc = usb_control_msg (port->serial->dev, | 458 | rc = usb_control_msg(port->serial->dev, |
472 | usb_sndctrlpipe(port->serial->dev, 0), | 459 | usb_sndctrlpipe(port->serial->dev, 0), |
473 | KL5KUSB105A_SIO_CONFIGURE, | 460 | KL5KUSB105A_SIO_CONFIGURE, |
474 | USB_TYPE_VENDOR | USB_DIR_OUT, | 461 | USB_TYPE_VENDOR | USB_DIR_OUT, |
475 | KL5KUSB105A_SIO_CONFIGURE_READ_OFF, | 462 | KL5KUSB105A_SIO_CONFIGURE_READ_OFF, |
476 | 0, /* index */ | 463 | 0, /* index */ |
477 | NULL, 0, | 464 | NULL, 0, |
478 | KLSI_TIMEOUT); | 465 | KLSI_TIMEOUT); |
479 | if (rc < 0) | 466 | if (rc < 0) |
480 | err("Disabling read failed (error = %d)", rc); | 467 | err("Disabling read failed (error = %d)", rc); |
481 | } | 468 | } |
@@ -488,12 +475,13 @@ static void klsi_105_close(struct tty_struct *tty, | |||
488 | /* FIXME */ | 475 | /* FIXME */ |
489 | /* wgg - do I need this? I think so. */ | 476 | /* wgg - do I need this? I think so. */ |
490 | usb_kill_urb(port->interrupt_in_urb); | 477 | usb_kill_urb(port->interrupt_in_urb); |
491 | info("kl5kusb105 port stats: %ld bytes in, %ld bytes out", priv->bytes_in, priv->bytes_out); | 478 | info("kl5kusb105 port stats: %ld bytes in, %ld bytes out", |
479 | priv->bytes_in, priv->bytes_out); | ||
492 | } /* klsi_105_close */ | 480 | } /* klsi_105_close */ |
493 | 481 | ||
494 | 482 | ||
495 | /* We need to write a complete 64-byte data block and encode the | 483 | /* We need to write a complete 64-byte data block and encode the |
496 | * number actually sent in the first double-byte, LSB-order. That | 484 | * number actually sent in the first double-byte, LSB-order. That |
497 | * leaves at most 62 bytes of payload. | 485 | * leaves at most 62 bytes of payload. |
498 | */ | 486 | */ |
499 | #define KLSI_105_DATA_OFFSET 2 /* in the bulk urb data block */ | 487 | #define KLSI_105_DATA_OFFSET 2 /* in the bulk urb data block */ |
@@ -504,7 +492,7 @@ static int klsi_105_write(struct tty_struct *tty, | |||
504 | { | 492 | { |
505 | struct klsi_105_private *priv = usb_get_serial_port_data(port); | 493 | struct klsi_105_private *priv = usb_get_serial_port_data(port); |
506 | int result, size; | 494 | int result, size; |
507 | int bytes_sent=0; | 495 | int bytes_sent = 0; |
508 | 496 | ||
509 | dbg("%s - port %d", __func__, port->number); | 497 | dbg("%s - port %d", __func__, port->number); |
510 | 498 | ||
@@ -513,34 +501,37 @@ static int klsi_105_write(struct tty_struct *tty, | |||
513 | struct urb *urb = NULL; | 501 | struct urb *urb = NULL; |
514 | unsigned long flags; | 502 | unsigned long flags; |
515 | int i; | 503 | int i; |
516 | /* since the pool is per-port we might not need the spin lock !? */ | 504 | /* since the pool is per-port we might not need |
517 | spin_lock_irqsave (&priv->lock, flags); | 505 | the spin lock !? */ |
518 | for (i=0; i<NUM_URBS; i++) { | 506 | spin_lock_irqsave(&priv->lock, flags); |
507 | for (i = 0; i < NUM_URBS; i++) { | ||
519 | if (priv->write_urb_pool[i]->status != -EINPROGRESS) { | 508 | if (priv->write_urb_pool[i]->status != -EINPROGRESS) { |
520 | urb = priv->write_urb_pool[i]; | 509 | urb = priv->write_urb_pool[i]; |
521 | dbg("%s - using pool URB %d", __func__, i); | 510 | dbg("%s - using pool URB %d", __func__, i); |
522 | break; | 511 | break; |
523 | } | 512 | } |
524 | } | 513 | } |
525 | spin_unlock_irqrestore (&priv->lock, flags); | 514 | spin_unlock_irqrestore(&priv->lock, flags); |
526 | 515 | ||
527 | if (urb==NULL) { | 516 | if (urb == NULL) { |
528 | dbg("%s - no more free urbs", __func__); | 517 | dbg("%s - no more free urbs", __func__); |
529 | goto exit; | 518 | goto exit; |
530 | } | 519 | } |
531 | 520 | ||
532 | if (urb->transfer_buffer == NULL) { | 521 | if (urb->transfer_buffer == NULL) { |
533 | urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC); | 522 | urb->transfer_buffer = |
523 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC); | ||
534 | if (urb->transfer_buffer == NULL) { | 524 | if (urb->transfer_buffer == NULL) { |
535 | err("%s - no more kernel memory...", __func__); | 525 | err("%s - no more kernel memory...", __func__); |
536 | goto exit; | 526 | goto exit; |
537 | } | 527 | } |
538 | } | 528 | } |
539 | 529 | ||
540 | size = min (count, port->bulk_out_size - KLSI_105_DATA_OFFSET); | 530 | size = min(count, port->bulk_out_size - KLSI_105_DATA_OFFSET); |
541 | size = min (size, URB_TRANSFER_BUFFER_SIZE - KLSI_105_DATA_OFFSET); | 531 | size = min(size, URB_TRANSFER_BUFFER_SIZE - |
532 | KLSI_105_DATA_OFFSET); | ||
542 | 533 | ||
543 | memcpy (urb->transfer_buffer + KLSI_105_DATA_OFFSET, buf, size); | 534 | memcpy(urb->transfer_buffer + KLSI_105_DATA_OFFSET, buf, size); |
544 | 535 | ||
545 | /* write payload size into transfer buffer */ | 536 | /* write payload size into transfer buffer */ |
546 | ((__u8 *)urb->transfer_buffer)[0] = (__u8) (size & 0xFF); | 537 | ((__u8 *)urb->transfer_buffer)[0] = (__u8) (size & 0xFF); |
@@ -558,7 +549,8 @@ static int klsi_105_write(struct tty_struct *tty, | |||
558 | /* send the data out the bulk port */ | 549 | /* send the data out the bulk port */ |
559 | result = usb_submit_urb(urb, GFP_ATOMIC); | 550 | result = usb_submit_urb(urb, GFP_ATOMIC); |
560 | if (result) { | 551 | if (result) { |
561 | err("%s - failed submitting write urb, error %d", __func__, result); | 552 | err("%s - failed submitting write urb, error %d", |
553 | __func__, result); | ||
562 | goto exit; | 554 | goto exit; |
563 | } | 555 | } |
564 | buf += size; | 556 | buf += size; |
@@ -567,12 +559,12 @@ static int klsi_105_write(struct tty_struct *tty, | |||
567 | } | 559 | } |
568 | exit: | 560 | exit: |
569 | /* lockless, but it's for debug info only... */ | 561 | /* lockless, but it's for debug info only... */ |
570 | priv->bytes_out+=bytes_sent; | 562 | priv->bytes_out += bytes_sent; |
571 | 563 | ||
572 | return bytes_sent; /* that's how much we wrote */ | 564 | return bytes_sent; /* that's how much we wrote */ |
573 | } /* klsi_105_write */ | 565 | } /* klsi_105_write */ |
574 | 566 | ||
575 | static void klsi_105_write_bulk_callback ( struct urb *urb) | 567 | static void klsi_105_write_bulk_callback(struct urb *urb) |
576 | { | 568 | { |
577 | struct usb_serial_port *port = urb->context; | 569 | struct usb_serial_port *port = urb->context; |
578 | int status = urb->status; | 570 | int status = urb->status; |
@@ -590,7 +582,7 @@ static void klsi_105_write_bulk_callback ( struct urb *urb) | |||
590 | 582 | ||
591 | 583 | ||
592 | /* return number of characters currently in the writing process */ | 584 | /* return number of characters currently in the writing process */ |
593 | static int klsi_105_chars_in_buffer (struct tty_struct *tty) | 585 | static int klsi_105_chars_in_buffer(struct tty_struct *tty) |
594 | { | 586 | { |
595 | struct usb_serial_port *port = tty->driver_data; | 587 | struct usb_serial_port *port = tty->driver_data; |
596 | int chars = 0; | 588 | int chars = 0; |
@@ -598,21 +590,20 @@ static int klsi_105_chars_in_buffer (struct tty_struct *tty) | |||
598 | unsigned long flags; | 590 | unsigned long flags; |
599 | struct klsi_105_private *priv = usb_get_serial_port_data(port); | 591 | struct klsi_105_private *priv = usb_get_serial_port_data(port); |
600 | 592 | ||
601 | spin_lock_irqsave (&priv->lock, flags); | 593 | spin_lock_irqsave(&priv->lock, flags); |
602 | 594 | ||
603 | for (i = 0; i < NUM_URBS; ++i) { | 595 | for (i = 0; i < NUM_URBS; ++i) { |
604 | if (priv->write_urb_pool[i]->status == -EINPROGRESS) { | 596 | if (priv->write_urb_pool[i]->status == -EINPROGRESS) |
605 | chars += URB_TRANSFER_BUFFER_SIZE; | 597 | chars += URB_TRANSFER_BUFFER_SIZE; |
606 | } | ||
607 | } | 598 | } |
608 | 599 | ||
609 | spin_unlock_irqrestore (&priv->lock, flags); | 600 | spin_unlock_irqrestore(&priv->lock, flags); |
610 | 601 | ||
611 | dbg("%s - returns %d", __func__, chars); | 602 | dbg("%s - returns %d", __func__, chars); |
612 | return (chars); | 603 | return chars; |
613 | } | 604 | } |
614 | 605 | ||
615 | static int klsi_105_write_room (struct tty_struct *tty) | 606 | static int klsi_105_write_room(struct tty_struct *tty) |
616 | { | 607 | { |
617 | struct usb_serial_port *port = tty->driver_data; | 608 | struct usb_serial_port *port = tty->driver_data; |
618 | unsigned long flags; | 609 | unsigned long flags; |
@@ -620,22 +611,21 @@ static int klsi_105_write_room (struct tty_struct *tty) | |||
620 | int room = 0; | 611 | int room = 0; |
621 | struct klsi_105_private *priv = usb_get_serial_port_data(port); | 612 | struct klsi_105_private *priv = usb_get_serial_port_data(port); |
622 | 613 | ||
623 | spin_lock_irqsave (&priv->lock, flags); | 614 | spin_lock_irqsave(&priv->lock, flags); |
624 | for (i = 0; i < NUM_URBS; ++i) { | 615 | for (i = 0; i < NUM_URBS; ++i) { |
625 | if (priv->write_urb_pool[i]->status != -EINPROGRESS) { | 616 | if (priv->write_urb_pool[i]->status != -EINPROGRESS) |
626 | room += URB_TRANSFER_BUFFER_SIZE; | 617 | room += URB_TRANSFER_BUFFER_SIZE; |
627 | } | ||
628 | } | 618 | } |
629 | 619 | ||
630 | spin_unlock_irqrestore (&priv->lock, flags); | 620 | spin_unlock_irqrestore(&priv->lock, flags); |
631 | 621 | ||
632 | dbg("%s - returns %d", __func__, room); | 622 | dbg("%s - returns %d", __func__, room); |
633 | return (room); | 623 | return room; |
634 | } | 624 | } |
635 | 625 | ||
636 | 626 | ||
637 | 627 | ||
638 | static void klsi_105_read_bulk_callback (struct urb *urb) | 628 | static void klsi_105_read_bulk_callback(struct urb *urb) |
639 | { | 629 | { |
640 | struct usb_serial_port *port = urb->context; | 630 | struct usb_serial_port *port = urb->context; |
641 | struct klsi_105_private *priv = usb_get_serial_port_data(port); | 631 | struct klsi_105_private *priv = usb_get_serial_port_data(port); |
@@ -674,7 +664,7 @@ static void klsi_105_read_bulk_callback (struct urb *urb) | |||
674 | * against re-entry an then mixed-up data because of | 664 | * against re-entry an then mixed-up data because of |
675 | * intermixed tty_flip_buffer_push()s | 665 | * intermixed tty_flip_buffer_push()s |
676 | * FIXME | 666 | * FIXME |
677 | */ | 667 | */ |
678 | usb_serial_debug_data(debug, &port->dev, __func__, | 668 | usb_serial_debug_data(debug, &port->dev, __func__, |
679 | urb->actual_length, data); | 669 | urb->actual_length, data); |
680 | 670 | ||
@@ -694,7 +684,7 @@ static void klsi_105_read_bulk_callback (struct urb *urb) | |||
694 | priv->bytes_in += bytes_sent; | 684 | priv->bytes_in += bytes_sent; |
695 | } | 685 | } |
696 | /* Continue trying to always read */ | 686 | /* Continue trying to always read */ |
697 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, | 687 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, |
698 | usb_rcvbulkpipe(port->serial->dev, | 688 | usb_rcvbulkpipe(port->serial->dev, |
699 | port->bulk_in_endpointAddress), | 689 | port->bulk_in_endpointAddress), |
700 | port->read_urb->transfer_buffer, | 690 | port->read_urb->transfer_buffer, |
@@ -703,13 +693,14 @@ static void klsi_105_read_bulk_callback (struct urb *urb) | |||
703 | port); | 693 | port); |
704 | rc = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 694 | rc = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
705 | if (rc) | 695 | if (rc) |
706 | err("%s - failed resubmitting read urb, error %d", __func__, rc); | 696 | err("%s - failed resubmitting read urb, error %d", |
697 | __func__, rc); | ||
707 | } /* klsi_105_read_bulk_callback */ | 698 | } /* klsi_105_read_bulk_callback */ |
708 | 699 | ||
709 | 700 | ||
710 | static void klsi_105_set_termios (struct tty_struct *tty, | 701 | static void klsi_105_set_termios(struct tty_struct *tty, |
711 | struct usb_serial_port *port, | 702 | struct usb_serial_port *port, |
712 | struct ktermios *old_termios) | 703 | struct ktermios *old_termios) |
713 | { | 704 | { |
714 | struct klsi_105_private *priv = usb_get_serial_port_data(port); | 705 | struct klsi_105_private *priv = usb_get_serial_port_data(port); |
715 | unsigned int iflag = tty->termios->c_iflag; | 706 | unsigned int iflag = tty->termios->c_iflag; |
@@ -719,65 +710,63 @@ static void klsi_105_set_termios (struct tty_struct *tty, | |||
719 | struct klsi_105_port_settings cfg; | 710 | struct klsi_105_port_settings cfg; |
720 | unsigned long flags; | 711 | unsigned long flags; |
721 | speed_t baud; | 712 | speed_t baud; |
722 | 713 | ||
723 | /* lock while we are modifying the settings */ | 714 | /* lock while we are modifying the settings */ |
724 | spin_lock_irqsave (&priv->lock, flags); | 715 | spin_lock_irqsave(&priv->lock, flags); |
725 | 716 | ||
726 | /* | 717 | /* |
727 | * Update baud rate | 718 | * Update baud rate |
728 | */ | 719 | */ |
729 | baud = tty_get_baud_rate(tty); | 720 | baud = tty_get_baud_rate(tty); |
730 | 721 | ||
731 | if( (cflag & CBAUD) != (old_cflag & CBAUD) ) { | 722 | if ((cflag & CBAUD) != (old_cflag & CBAUD)) { |
732 | /* reassert DTR and (maybe) RTS on transition from B0 */ | 723 | /* reassert DTR and (maybe) RTS on transition from B0 */ |
733 | if( (old_cflag & CBAUD) == B0 ) { | 724 | if ((old_cflag & CBAUD) == B0) { |
734 | dbg("%s: baud was B0", __func__); | 725 | dbg("%s: baud was B0", __func__); |
735 | #if 0 | 726 | #if 0 |
736 | priv->control_state |= TIOCM_DTR; | 727 | priv->control_state |= TIOCM_DTR; |
737 | /* don't set RTS if using hardware flow control */ | 728 | /* don't set RTS if using hardware flow control */ |
738 | if (!(old_cflag & CRTSCTS)) { | 729 | if (!(old_cflag & CRTSCTS)) |
739 | priv->control_state |= TIOCM_RTS; | 730 | priv->control_state |= TIOCM_RTS; |
740 | } | ||
741 | mct_u232_set_modem_ctrl(serial, priv->control_state); | 731 | mct_u232_set_modem_ctrl(serial, priv->control_state); |
742 | #endif | 732 | #endif |
743 | } | 733 | } |
744 | } | 734 | } |
745 | switch(baud) { | 735 | switch (baud) { |
746 | case 0: /* handled below */ | 736 | case 0: /* handled below */ |
747 | break; | 737 | break; |
748 | case 1200: | 738 | case 1200: |
749 | priv->cfg.baudrate = kl5kusb105a_sio_b1200; | 739 | priv->cfg.baudrate = kl5kusb105a_sio_b1200; |
750 | break; | 740 | break; |
751 | case 2400: | 741 | case 2400: |
752 | priv->cfg.baudrate = kl5kusb105a_sio_b2400; | 742 | priv->cfg.baudrate = kl5kusb105a_sio_b2400; |
753 | break; | 743 | break; |
754 | case 4800: | 744 | case 4800: |
755 | priv->cfg.baudrate = kl5kusb105a_sio_b4800; | 745 | priv->cfg.baudrate = kl5kusb105a_sio_b4800; |
756 | break; | 746 | break; |
757 | case 9600: | 747 | case 9600: |
748 | priv->cfg.baudrate = kl5kusb105a_sio_b9600; | ||
749 | break; | ||
750 | case 19200: | ||
751 | priv->cfg.baudrate = kl5kusb105a_sio_b19200; | ||
752 | break; | ||
753 | case 38400: | ||
754 | priv->cfg.baudrate = kl5kusb105a_sio_b38400; | ||
755 | break; | ||
756 | case 57600: | ||
757 | priv->cfg.baudrate = kl5kusb105a_sio_b57600; | ||
758 | break; | ||
759 | case 115200: | ||
760 | priv->cfg.baudrate = kl5kusb105a_sio_b115200; | ||
761 | break; | ||
762 | default: | ||
763 | dbg("KLSI USB->Serial converter:" | ||
764 | " unsupported baudrate request, using default of 9600"); | ||
758 | priv->cfg.baudrate = kl5kusb105a_sio_b9600; | 765 | priv->cfg.baudrate = kl5kusb105a_sio_b9600; |
759 | break; | 766 | baud = 9600; |
760 | case 19200: | 767 | break; |
761 | priv->cfg.baudrate = kl5kusb105a_sio_b19200; | ||
762 | break; | ||
763 | case 38400: | ||
764 | priv->cfg.baudrate = kl5kusb105a_sio_b38400; | ||
765 | break; | ||
766 | case 57600: | ||
767 | priv->cfg.baudrate = kl5kusb105a_sio_b57600; | ||
768 | break; | ||
769 | case 115200: | ||
770 | priv->cfg.baudrate = kl5kusb105a_sio_b115200; | ||
771 | break; | ||
772 | default: | ||
773 | dbg("KLSI USB->Serial converter:" | ||
774 | " unsupported baudrate request, using default" | ||
775 | " of 9600"); | ||
776 | priv->cfg.baudrate = kl5kusb105a_sio_b9600; | ||
777 | baud = 9600; | ||
778 | break; | ||
779 | } | 768 | } |
780 | if ((cflag & CBAUD) == B0 ) { | 769 | if ((cflag & CBAUD) == B0) { |
781 | dbg("%s: baud is B0", __func__); | 770 | dbg("%s: baud is B0", __func__); |
782 | /* Drop RTS and DTR */ | 771 | /* Drop RTS and DTR */ |
783 | /* maybe this should be simulated by sending read | 772 | /* maybe this should be simulated by sending read |
@@ -786,7 +775,7 @@ static void klsi_105_set_termios (struct tty_struct *tty, | |||
786 | ; | 775 | ; |
787 | #if 0 | 776 | #if 0 |
788 | priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); | 777 | priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); |
789 | mct_u232_set_modem_ctrl(serial, priv->control_state); | 778 | mct_u232_set_modem_ctrl(serial, priv->control_state); |
790 | #endif | 779 | #endif |
791 | } | 780 | } |
792 | tty_encode_baud_rate(tty, baud, baud); | 781 | tty_encode_baud_rate(tty, baud, baud); |
@@ -796,11 +785,11 @@ static void klsi_105_set_termios (struct tty_struct *tty, | |||
796 | switch (cflag & CSIZE) { | 785 | switch (cflag & CSIZE) { |
797 | case CS5: | 786 | case CS5: |
798 | dbg("%s - 5 bits/byte not supported", __func__); | 787 | dbg("%s - 5 bits/byte not supported", __func__); |
799 | spin_unlock_irqrestore (&priv->lock, flags); | 788 | spin_unlock_irqrestore(&priv->lock, flags); |
800 | return ; | 789 | return ; |
801 | case CS6: | 790 | case CS6: |
802 | dbg("%s - 6 bits/byte not supported", __func__); | 791 | dbg("%s - 6 bits/byte not supported", __func__); |
803 | spin_unlock_irqrestore (&priv->lock, flags); | 792 | spin_unlock_irqrestore(&priv->lock, flags); |
804 | return ; | 793 | return ; |
805 | case CS7: | 794 | case CS7: |
806 | priv->cfg.databits = kl5kusb105a_dtb_7; | 795 | priv->cfg.databits = kl5kusb105a_dtb_7; |
@@ -819,8 +808,7 @@ static void klsi_105_set_termios (struct tty_struct *tty, | |||
819 | * Update line control register (LCR) | 808 | * Update line control register (LCR) |
820 | */ | 809 | */ |
821 | if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD)) | 810 | if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD)) |
822 | || (cflag & CSTOPB) != (old_cflag & CSTOPB) ) { | 811 | || (cflag & CSTOPB) != (old_cflag & CSTOPB)) { |
823 | |||
824 | /* Not currently supported */ | 812 | /* Not currently supported */ |
825 | tty->termios->c_cflag &= ~(PARENB|PARODD|CSTOPB); | 813 | tty->termios->c_cflag &= ~(PARENB|PARODD|CSTOPB); |
826 | #if 0 | 814 | #if 0 |
@@ -841,20 +829,18 @@ static void klsi_105_set_termios (struct tty_struct *tty, | |||
841 | #endif | 829 | #endif |
842 | ; | 830 | ; |
843 | } | 831 | } |
844 | |||
845 | /* | 832 | /* |
846 | * Set flow control: well, I do not really now how to handle DTR/RTS. | 833 | * Set flow control: well, I do not really now how to handle DTR/RTS. |
847 | * Just do what we have seen with SniffUSB on Win98. | 834 | * Just do what we have seen with SniffUSB on Win98. |
848 | */ | 835 | */ |
849 | if( (iflag & IXOFF) != (old_iflag & IXOFF) | 836 | if ((iflag & IXOFF) != (old_iflag & IXOFF) |
850 | || (iflag & IXON) != (old_iflag & IXON) | 837 | || (iflag & IXON) != (old_iflag & IXON) |
851 | || (cflag & CRTSCTS) != (old_cflag & CRTSCTS) ) { | 838 | || (cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { |
852 | |||
853 | /* Not currently supported */ | 839 | /* Not currently supported */ |
854 | tty->termios->c_cflag &= ~CRTSCTS; | 840 | tty->termios->c_cflag &= ~CRTSCTS; |
855 | /* Drop DTR/RTS if no flow control otherwise assert */ | 841 | /* Drop DTR/RTS if no flow control otherwise assert */ |
856 | #if 0 | 842 | #if 0 |
857 | if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS) ) | 843 | if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS)) |
858 | priv->control_state |= TIOCM_DTR | TIOCM_RTS; | 844 | priv->control_state |= TIOCM_DTR | TIOCM_RTS; |
859 | else | 845 | else |
860 | priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); | 846 | priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); |
@@ -862,20 +848,21 @@ static void klsi_105_set_termios (struct tty_struct *tty, | |||
862 | #endif | 848 | #endif |
863 | ; | 849 | ; |
864 | } | 850 | } |
865 | memcpy (&cfg, &priv->cfg, sizeof(cfg)); | 851 | memcpy(&cfg, &priv->cfg, sizeof(cfg)); |
866 | spin_unlock_irqrestore (&priv->lock, flags); | 852 | spin_unlock_irqrestore(&priv->lock, flags); |
867 | 853 | ||
868 | /* now commit changes to device */ | 854 | /* now commit changes to device */ |
869 | klsi_105_chg_port_settings(port, &cfg); | 855 | klsi_105_chg_port_settings(port, &cfg); |
870 | } /* klsi_105_set_termios */ | 856 | } /* klsi_105_set_termios */ |
871 | 857 | ||
872 | 858 | ||
873 | #if 0 | 859 | #if 0 |
874 | static void mct_u232_break_ctl( struct tty_struct *tty, int break_state ) | 860 | static void mct_u232_break_ctl(struct tty_struct *tty, int break_state) |
875 | { | 861 | { |
876 | struct usb_serial_port *port = tty->driver_data; | 862 | struct usb_serial_port *port = tty->driver_data; |
877 | struct usb_serial *serial = port->serial; | 863 | struct usb_serial *serial = port->serial; |
878 | struct mct_u232_private *priv = (struct mct_u232_private *)port->private; | 864 | struct mct_u232_private *priv = |
865 | (struct mct_u232_private *)port->private; | ||
879 | unsigned char lcr = priv->last_lcr; | 866 | unsigned char lcr = priv->last_lcr; |
880 | 867 | ||
881 | dbg("%sstate=%d", __func__, break_state); | 868 | dbg("%sstate=%d", __func__, break_state); |
@@ -887,7 +874,7 @@ static void mct_u232_break_ctl( struct tty_struct *tty, int break_state ) | |||
887 | } /* mct_u232_break_ctl */ | 874 | } /* mct_u232_break_ctl */ |
888 | #endif | 875 | #endif |
889 | 876 | ||
890 | static int klsi_105_tiocmget (struct tty_struct *tty, struct file *file) | 877 | static int klsi_105_tiocmget(struct tty_struct *tty, struct file *file) |
891 | { | 878 | { |
892 | struct usb_serial_port *port = tty->driver_data; | 879 | struct usb_serial_port *port = tty->driver_data; |
893 | struct klsi_105_private *priv = usb_get_serial_port_data(port); | 880 | struct klsi_105_private *priv = usb_get_serial_port_data(port); |
@@ -903,18 +890,18 @@ static int klsi_105_tiocmget (struct tty_struct *tty, struct file *file) | |||
903 | return rc; | 890 | return rc; |
904 | } | 891 | } |
905 | 892 | ||
906 | spin_lock_irqsave (&priv->lock, flags); | 893 | spin_lock_irqsave(&priv->lock, flags); |
907 | priv->line_state = line_state; | 894 | priv->line_state = line_state; |
908 | spin_unlock_irqrestore (&priv->lock, flags); | 895 | spin_unlock_irqrestore(&priv->lock, flags); |
909 | dbg("%s - read line state 0x%lx", __func__, line_state); | 896 | dbg("%s - read line state 0x%lx", __func__, line_state); |
910 | return (int)line_state; | 897 | return (int)line_state; |
911 | } | 898 | } |
912 | 899 | ||
913 | static int klsi_105_tiocmset (struct tty_struct *tty, struct file *file, | 900 | static int klsi_105_tiocmset(struct tty_struct *tty, struct file *file, |
914 | unsigned int set, unsigned int clear) | 901 | unsigned int set, unsigned int clear) |
915 | { | 902 | { |
916 | int retval = -EINVAL; | 903 | int retval = -EINVAL; |
917 | 904 | ||
918 | dbg("%s", __func__); | 905 | dbg("%s", __func__); |
919 | 906 | ||
920 | /* if this ever gets implemented, it should be done something like this: | 907 | /* if this ever gets implemented, it should be done something like this: |
@@ -939,14 +926,14 @@ static int klsi_105_tiocmset (struct tty_struct *tty, struct file *file, | |||
939 | return retval; | 926 | return retval; |
940 | } | 927 | } |
941 | 928 | ||
942 | static void klsi_105_throttle (struct tty_struct *tty) | 929 | static void klsi_105_throttle(struct tty_struct *tty) |
943 | { | 930 | { |
944 | struct usb_serial_port *port = tty->driver_data; | 931 | struct usb_serial_port *port = tty->driver_data; |
945 | dbg("%s - port %d", __func__, port->number); | 932 | dbg("%s - port %d", __func__, port->number); |
946 | usb_kill_urb(port->read_urb); | 933 | usb_kill_urb(port->read_urb); |
947 | } | 934 | } |
948 | 935 | ||
949 | static void klsi_105_unthrottle (struct tty_struct *tty) | 936 | static void klsi_105_unthrottle(struct tty_struct *tty) |
950 | { | 937 | { |
951 | struct usb_serial_port *port = tty->driver_data; | 938 | struct usb_serial_port *port = tty->driver_data; |
952 | int result; | 939 | int result; |
@@ -962,7 +949,7 @@ static void klsi_105_unthrottle (struct tty_struct *tty) | |||
962 | 949 | ||
963 | 950 | ||
964 | 951 | ||
965 | static int __init klsi_105_init (void) | 952 | static int __init klsi_105_init(void) |
966 | { | 953 | { |
967 | int retval; | 954 | int retval; |
968 | retval = usb_serial_register(&kl5kusb105d_device); | 955 | retval = usb_serial_register(&kl5kusb105d_device); |
@@ -981,19 +968,19 @@ failed_usb_serial_register: | |||
981 | } | 968 | } |
982 | 969 | ||
983 | 970 | ||
984 | static void __exit klsi_105_exit (void) | 971 | static void __exit klsi_105_exit(void) |
985 | { | 972 | { |
986 | usb_deregister (&kl5kusb105d_driver); | 973 | usb_deregister(&kl5kusb105d_driver); |
987 | usb_serial_deregister (&kl5kusb105d_device); | 974 | usb_serial_deregister(&kl5kusb105d_device); |
988 | } | 975 | } |
989 | 976 | ||
990 | 977 | ||
991 | module_init (klsi_105_init); | 978 | module_init(klsi_105_init); |
992 | module_exit (klsi_105_exit); | 979 | module_exit(klsi_105_exit); |
993 | 980 | ||
994 | MODULE_AUTHOR( DRIVER_AUTHOR ); | 981 | MODULE_AUTHOR(DRIVER_AUTHOR); |
995 | MODULE_DESCRIPTION( DRIVER_DESC ); | 982 | MODULE_DESCRIPTION(DRIVER_DESC); |
996 | MODULE_LICENSE("GPL"); | 983 | MODULE_LICENSE("GPL"); |
997 | 984 | ||
998 | 985 | ||
999 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 986 | module_param(debug, bool, S_IRUGO | S_IWUSR); |