diff options
-rw-r--r-- | drivers/usb/serial/kl5kusb105.c | 68 |
1 files changed, 24 insertions, 44 deletions
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index 3f6d7376c02d..1f4517864cd2 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c | |||
@@ -60,8 +60,8 @@ | |||
60 | /* | 60 | /* |
61 | * Function prototypes | 61 | * Function prototypes |
62 | */ | 62 | */ |
63 | static int klsi_105_startup(struct usb_serial *serial); | 63 | static int klsi_105_port_probe(struct usb_serial_port *port); |
64 | static void klsi_105_release(struct usb_serial *serial); | 64 | static int klsi_105_port_remove(struct usb_serial_port *port); |
65 | static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port); | 65 | static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port); |
66 | static void klsi_105_close(struct usb_serial_port *port); | 66 | static void klsi_105_close(struct usb_serial_port *port); |
67 | static void klsi_105_set_termios(struct tty_struct *tty, | 67 | static void klsi_105_set_termios(struct tty_struct *tty, |
@@ -99,8 +99,8 @@ static struct usb_serial_driver kl5kusb105d_device = { | |||
99 | /*.break_ctl = klsi_105_break_ctl,*/ | 99 | /*.break_ctl = klsi_105_break_ctl,*/ |
100 | .tiocmget = klsi_105_tiocmget, | 100 | .tiocmget = klsi_105_tiocmget, |
101 | .tiocmset = klsi_105_tiocmset, | 101 | .tiocmset = klsi_105_tiocmset, |
102 | .attach = klsi_105_startup, | 102 | .port_probe = klsi_105_port_probe, |
103 | .release = klsi_105_release, | 103 | .port_remove = klsi_105_port_remove, |
104 | .throttle = usb_serial_generic_throttle, | 104 | .throttle = usb_serial_generic_throttle, |
105 | .unthrottle = usb_serial_generic_unthrottle, | 105 | .unthrottle = usb_serial_generic_unthrottle, |
106 | .process_read_urb = klsi_105_process_read_urb, | 106 | .process_read_urb = klsi_105_process_read_urb, |
@@ -223,60 +223,40 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, | |||
223 | * Driver's tty interface functions | 223 | * Driver's tty interface functions |
224 | */ | 224 | */ |
225 | 225 | ||
226 | static int klsi_105_startup(struct usb_serial *serial) | 226 | static int klsi_105_port_probe(struct usb_serial_port *port) |
227 | { | 227 | { |
228 | struct klsi_105_private *priv; | 228 | struct klsi_105_private *priv; |
229 | int i; | ||
230 | 229 | ||
231 | /* check if we support the product id (see keyspan.c) | 230 | priv = kmalloc(sizeof(*priv), GFP_KERNEL); |
232 | * FIXME | 231 | if (!priv) |
233 | */ | 232 | return -ENOMEM; |
234 | 233 | ||
235 | /* allocate the private data structure */ | 234 | /* set initial values for control structures */ |
236 | for (i = 0; i < serial->num_ports; i++) { | 235 | priv->cfg.pktlen = 5; |
237 | priv = kmalloc(sizeof(struct klsi_105_private), | 236 | priv->cfg.baudrate = kl5kusb105a_sio_b9600; |
238 | GFP_KERNEL); | 237 | priv->cfg.databits = kl5kusb105a_dtb_8; |
239 | if (!priv) { | 238 | priv->cfg.unknown1 = 0; |
240 | dev_dbg(&serial->interface->dev, | 239 | priv->cfg.unknown2 = 1; |
241 | "%s - kmalloc for klsi_105_private failed.\n", | ||
242 | __func__); | ||
243 | i--; | ||
244 | goto err_cleanup; | ||
245 | } | ||
246 | /* set initial values for control structures */ | ||
247 | priv->cfg.pktlen = 5; | ||
248 | priv->cfg.baudrate = kl5kusb105a_sio_b9600; | ||
249 | priv->cfg.databits = kl5kusb105a_dtb_8; | ||
250 | priv->cfg.unknown1 = 0; | ||
251 | priv->cfg.unknown2 = 1; | ||
252 | 240 | ||
253 | priv->line_state = 0; | 241 | priv->line_state = 0; |
254 | 242 | ||
255 | usb_set_serial_port_data(serial->port[i], priv); | 243 | spin_lock_init(&priv->lock); |
256 | 244 | ||
257 | spin_lock_init(&priv->lock); | 245 | /* priv->termios is left uninitialized until port opening */ |
258 | 246 | ||
259 | /* priv->termios is left uninitialized until port opening */ | 247 | usb_set_serial_port_data(port, priv); |
260 | init_waitqueue_head(&serial->port[i]->write_wait); | ||
261 | } | ||
262 | 248 | ||
263 | return 0; | 249 | return 0; |
264 | |||
265 | err_cleanup: | ||
266 | for (; i >= 0; i--) { | ||
267 | priv = usb_get_serial_port_data(serial->port[i]); | ||
268 | kfree(priv); | ||
269 | usb_set_serial_port_data(serial->port[i], NULL); | ||
270 | } | ||
271 | return -ENOMEM; | ||
272 | } | 250 | } |
273 | 251 | ||
274 | static void klsi_105_release(struct usb_serial *serial) | 252 | static int klsi_105_port_remove(struct usb_serial_port *port) |
275 | { | 253 | { |
276 | int i; | 254 | struct klsi_105_private *priv; |
255 | |||
256 | priv = usb_get_serial_port_data(port); | ||
257 | kfree(priv); | ||
277 | 258 | ||
278 | for (i = 0; i < serial->num_ports; ++i) | 259 | return 0; |
279 | kfree(usb_get_serial_port_data(serial->port[i])); | ||
280 | } | 260 | } |
281 | 261 | ||
282 | static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port) | 262 | static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port) |