Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 289640
b: refs/heads/master
c: a5360a5
h: refs/heads/master
v: v3
  • Loading branch information
Preston Fick authored and Greg Kroah-Hartman committed Mar 3, 2012
1 parent 0137f13 commit 8c38133
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3d71769014c55e05b2342b6d9c1464f7fb383322
refs/heads/master: a5360a53a7ccad5ed9ccef210b94fef13c6e5529
44 changes: 41 additions & 3 deletions trunk/drivers/usb/serial/cp210x.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ static int cp210x_tiocmset_port(struct usb_serial_port *port,
unsigned int, unsigned int);
static void cp210x_break_ctl(struct tty_struct *, int);
static int cp210x_startup(struct usb_serial *);
static void cp210x_release(struct usb_serial *);
static void cp210x_dtr_rts(struct usb_serial_port *p, int on);

static bool debug;
Expand Down Expand Up @@ -121,6 +122,8 @@ static const struct usb_device_id id_table[] = {
{ USB_DEVICE(0x10C4, 0x8665) }, /* AC-Services OBD-IF */
{ USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
{ USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
{ USB_DEVICE(0x10C4, 0xEA70) }, /* Silicon Labs factory default */
{ USB_DEVICE(0x10C4, 0xEA80) }, /* Silicon Labs factory default */
{ USB_DEVICE(0x10C4, 0xEA71) }, /* Infinity GPS-MIC-1 Radio Monophone */
{ USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */
{ USB_DEVICE(0x10C4, 0xF002) }, /* Elan Digital Systems USBwave12 */
Expand Down Expand Up @@ -149,6 +152,10 @@ static const struct usb_device_id id_table[] = {

MODULE_DEVICE_TABLE(usb, id_table);

struct cp210x_port_private {
__u8 bInterfaceNumber;
};

static struct usb_driver cp210x_driver = {
.name = "cp210x",
.probe = usb_serial_probe,
Expand All @@ -172,6 +179,7 @@ static struct usb_serial_driver cp210x_device = {
.tiocmget = cp210x_tiocmget,
.tiocmset = cp210x_tiocmset,
.attach = cp210x_startup,
.release = cp210x_release,
.dtr_rts = cp210x_dtr_rts
};

Expand Down Expand Up @@ -263,6 +271,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request,
unsigned int *data, int size)
{
struct usb_serial *serial = port->serial;
struct cp210x_port_private *port_priv = usb_get_serial_port_data(port);
__le32 *buf;
int result, i, length;

Expand All @@ -278,7 +287,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request,
/* Issue the request, attempting to read 'size' bytes */
result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
request, REQTYPE_DEVICE_TO_HOST, 0x0000,
0, buf, size, 300);
port_priv->bInterfaceNumber, buf, size, 300);

/* Convert data into an array of integers */
for (i = 0; i < length; i++)
Expand Down Expand Up @@ -309,6 +318,7 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request,
unsigned int *data, int size)
{
struct usb_serial *serial = port->serial;
struct cp210x_port_private *port_priv = usb_get_serial_port_data(port);
__le32 *buf;
int result, i, length;

Expand All @@ -330,12 +340,12 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request,
result = usb_control_msg(serial->dev,
usb_sndctrlpipe(serial->dev, 0),
request, REQTYPE_HOST_TO_DEVICE, 0x0000,
0, buf, size, 300);
port_priv->bInterfaceNumber, buf, size, 300);
} else {
result = usb_control_msg(serial->dev,
usb_sndctrlpipe(serial->dev, 0),
request, REQTYPE_HOST_TO_DEVICE, data[0],
0, NULL, 0, 300);
port_priv->bInterfaceNumber, NULL, 0, 300);
}

kfree(buf);
Expand Down Expand Up @@ -845,11 +855,39 @@ static void cp210x_break_ctl (struct tty_struct *tty, int break_state)

static int cp210x_startup(struct usb_serial *serial)
{
struct cp210x_port_private *port_priv;
int i;

/* cp210x buffers behave strangely unless device is reset */
usb_reset_device(serial->dev);

for (i = 0; i < serial->num_ports; i++) {
port_priv = kzalloc(sizeof(*port_priv), GFP_KERNEL);
if (!port_priv)
return -ENOMEM;

memset(port_priv, 0x00, sizeof(*port_priv));
port_priv->bInterfaceNumber =
serial->interface->cur_altsetting->desc.bInterfaceNumber;

usb_set_serial_port_data(serial->port[i], port_priv);
}

return 0;
}

static void cp210x_release(struct usb_serial *serial)
{
struct cp210x_port_private *port_priv;
int i;

for (i = 0; i < serial->num_ports; i++) {
port_priv = usb_get_serial_port_data(serial->port[i]);
kfree(port_priv);
usb_set_serial_port_data(serial->port[i], NULL);
}
}

module_usb_serial_driver(cp210x_driver, serial_drivers);

MODULE_DESCRIPTION(DRIVER_DESC);
Expand Down

0 comments on commit 8c38133

Please sign in to comment.