diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
commit | ada47b5fe13d89735805b566185f4885f5a3f750 (patch) | |
tree | 644b88f8a71896307d71438e9b3af49126ffb22b /drivers/usb/serial/ch341.c | |
parent | 43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff) | |
parent | 3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff) |
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/usb/serial/ch341.c')
-rw-r--r-- | drivers/usb/serial/ch341.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c index 59eff721fcc5..7e8e39818414 100644 --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c | |||
@@ -19,9 +19,11 @@ | |||
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/tty.h> | 20 | #include <linux/tty.h> |
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | #include <linux/slab.h> | ||
22 | #include <linux/usb.h> | 23 | #include <linux/usb.h> |
23 | #include <linux/usb/serial.h> | 24 | #include <linux/usb/serial.h> |
24 | #include <linux/serial.h> | 25 | #include <linux/serial.h> |
26 | #include <asm/unaligned.h> | ||
25 | 27 | ||
26 | #define DEFAULT_BAUD_RATE 9600 | 28 | #define DEFAULT_BAUD_RATE 9600 |
27 | #define DEFAULT_TIMEOUT 1000 | 29 | #define DEFAULT_TIMEOUT 1000 |
@@ -70,7 +72,7 @@ | |||
70 | 72 | ||
71 | static int debug; | 73 | static int debug; |
72 | 74 | ||
73 | static struct usb_device_id id_table [] = { | 75 | static const struct usb_device_id id_table[] = { |
74 | { USB_DEVICE(0x4348, 0x5523) }, | 76 | { USB_DEVICE(0x4348, 0x5523) }, |
75 | { USB_DEVICE(0x1a86, 0x7523) }, | 77 | { USB_DEVICE(0x1a86, 0x7523) }, |
76 | { }, | 78 | { }, |
@@ -392,16 +394,22 @@ static void ch341_break_ctl(struct tty_struct *tty, int break_state) | |||
392 | struct usb_serial_port *port = tty->driver_data; | 394 | struct usb_serial_port *port = tty->driver_data; |
393 | int r; | 395 | int r; |
394 | uint16_t reg_contents; | 396 | uint16_t reg_contents; |
395 | uint8_t break_reg[2]; | 397 | uint8_t *break_reg; |
396 | 398 | ||
397 | dbg("%s()", __func__); | 399 | dbg("%s()", __func__); |
398 | 400 | ||
401 | break_reg = kmalloc(2, GFP_KERNEL); | ||
402 | if (!break_reg) { | ||
403 | dev_err(&port->dev, "%s - kmalloc failed\n", __func__); | ||
404 | return; | ||
405 | } | ||
406 | |||
399 | r = ch341_control_in(port->serial->dev, CH341_REQ_READ_REG, | 407 | r = ch341_control_in(port->serial->dev, CH341_REQ_READ_REG, |
400 | ch341_break_reg, 0, break_reg, sizeof(break_reg)); | 408 | ch341_break_reg, 0, break_reg, 2); |
401 | if (r < 0) { | 409 | if (r < 0) { |
402 | printk(KERN_WARNING "%s: USB control read error whilst getting" | 410 | dev_err(&port->dev, "%s - USB control read error (%d)\n", |
403 | " break register contents.\n", __FILE__); | 411 | __func__, r); |
404 | return; | 412 | goto out; |
405 | } | 413 | } |
406 | dbg("%s - initial ch341 break register contents - reg1: %x, reg2: %x", | 414 | dbg("%s - initial ch341 break register contents - reg1: %x, reg2: %x", |
407 | __func__, break_reg[0], break_reg[1]); | 415 | __func__, break_reg[0], break_reg[1]); |
@@ -416,12 +424,14 @@ static void ch341_break_ctl(struct tty_struct *tty, int break_state) | |||
416 | } | 424 | } |
417 | dbg("%s - New ch341 break register contents - reg1: %x, reg2: %x", | 425 | dbg("%s - New ch341 break register contents - reg1: %x, reg2: %x", |
418 | __func__, break_reg[0], break_reg[1]); | 426 | __func__, break_reg[0], break_reg[1]); |
419 | reg_contents = (uint16_t)break_reg[0] | ((uint16_t)break_reg[1] << 8); | 427 | reg_contents = get_unaligned_le16(break_reg); |
420 | r = ch341_control_out(port->serial->dev, CH341_REQ_WRITE_REG, | 428 | r = ch341_control_out(port->serial->dev, CH341_REQ_WRITE_REG, |
421 | ch341_break_reg, reg_contents); | 429 | ch341_break_reg, reg_contents); |
422 | if (r < 0) | 430 | if (r < 0) |
423 | printk(KERN_WARNING "%s: USB control write error whilst setting" | 431 | dev_err(&port->dev, "%s - USB control write error (%d)\n", |
424 | " break register contents.\n", __FILE__); | 432 | __func__, r); |
433 | out: | ||
434 | kfree(break_reg); | ||
425 | } | 435 | } |
426 | 436 | ||
427 | static int ch341_tiocmset(struct tty_struct *tty, struct file *file, | 437 | static int ch341_tiocmset(struct tty_struct *tty, struct file *file, |