diff options
Diffstat (limited to 'drivers/usb/serial/ch341.c')
| -rw-r--r-- | drivers/usb/serial/ch341.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c index e9c7046ae355..d255f66e708e 100644 --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c | |||
| @@ -242,13 +242,11 @@ out: kfree(buffer); | |||
| 242 | return r; | 242 | return r; |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | /* allocate private data */ | 245 | static int ch341_port_probe(struct usb_serial_port *port) |
| 246 | static int ch341_attach(struct usb_serial *serial) | ||
| 247 | { | 246 | { |
| 248 | struct ch341_private *priv; | 247 | struct ch341_private *priv; |
| 249 | int r; | 248 | int r; |
| 250 | 249 | ||
| 251 | /* private data */ | ||
| 252 | priv = kzalloc(sizeof(struct ch341_private), GFP_KERNEL); | 250 | priv = kzalloc(sizeof(struct ch341_private), GFP_KERNEL); |
| 253 | if (!priv) | 251 | if (!priv) |
| 254 | return -ENOMEM; | 252 | return -ENOMEM; |
| @@ -258,17 +256,27 @@ static int ch341_attach(struct usb_serial *serial) | |||
| 258 | priv->baud_rate = DEFAULT_BAUD_RATE; | 256 | priv->baud_rate = DEFAULT_BAUD_RATE; |
| 259 | priv->line_control = CH341_BIT_RTS | CH341_BIT_DTR; | 257 | priv->line_control = CH341_BIT_RTS | CH341_BIT_DTR; |
| 260 | 258 | ||
| 261 | r = ch341_configure(serial->dev, priv); | 259 | r = ch341_configure(port->serial->dev, priv); |
| 262 | if (r < 0) | 260 | if (r < 0) |
| 263 | goto error; | 261 | goto error; |
| 264 | 262 | ||
| 265 | usb_set_serial_port_data(serial->port[0], priv); | 263 | usb_set_serial_port_data(port, priv); |
| 266 | return 0; | 264 | return 0; |
| 267 | 265 | ||
| 268 | error: kfree(priv); | 266 | error: kfree(priv); |
| 269 | return r; | 267 | return r; |
| 270 | } | 268 | } |
| 271 | 269 | ||
| 270 | static int ch341_port_remove(struct usb_serial_port *port) | ||
| 271 | { | ||
| 272 | struct ch341_private *priv; | ||
| 273 | |||
| 274 | priv = usb_get_serial_port_data(port); | ||
| 275 | kfree(priv); | ||
| 276 | |||
| 277 | return 0; | ||
| 278 | } | ||
| 279 | |||
| 272 | static int ch341_carrier_raised(struct usb_serial_port *port) | 280 | static int ch341_carrier_raised(struct usb_serial_port *port) |
| 273 | { | 281 | { |
| 274 | struct ch341_private *priv = usb_get_serial_port_data(port); | 282 | struct ch341_private *priv = usb_get_serial_port_data(port); |
| @@ -304,7 +312,7 @@ static void ch341_close(struct usb_serial_port *port) | |||
| 304 | static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port) | 312 | static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port) |
| 305 | { | 313 | { |
| 306 | struct usb_serial *serial = port->serial; | 314 | struct usb_serial *serial = port->serial; |
| 307 | struct ch341_private *priv = usb_get_serial_port_data(serial->port[0]); | 315 | struct ch341_private *priv = usb_get_serial_port_data(port); |
| 308 | int r; | 316 | int r; |
| 309 | 317 | ||
| 310 | priv->baud_rate = DEFAULT_BAUD_RATE; | 318 | priv->baud_rate = DEFAULT_BAUD_RATE; |
| @@ -608,7 +616,8 @@ static struct usb_serial_driver ch341_device = { | |||
| 608 | .tiocmget = ch341_tiocmget, | 616 | .tiocmget = ch341_tiocmget, |
| 609 | .tiocmset = ch341_tiocmset, | 617 | .tiocmset = ch341_tiocmset, |
| 610 | .read_int_callback = ch341_read_int_callback, | 618 | .read_int_callback = ch341_read_int_callback, |
| 611 | .attach = ch341_attach, | 619 | .port_probe = ch341_port_probe, |
| 620 | .port_remove = ch341_port_remove, | ||
| 612 | .reset_resume = ch341_reset_resume, | 621 | .reset_resume = ch341_reset_resume, |
| 613 | }; | 622 | }; |
| 614 | 623 | ||
