diff options
author | Johan Hovold <jhovold@gmail.com> | 2010-05-13 15:33:10 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-20 16:21:46 -0400 |
commit | b2c573790381720e8b0aca1f392b4063f84cfcb6 (patch) | |
tree | 099ec1822ba42bbac8f4367315b7928b42172b50 /drivers/usb | |
parent | 55c6d85cabb33461139e430f48b9dea794d46f67 (diff) |
USB: ipw: reimplement using generic framework
Compile-only tested.
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/serial/ipw.c | 128 |
1 files changed, 4 insertions, 124 deletions
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c index 585ec1e237b6..ca77e88836bd 100644 --- a/drivers/usb/serial/ipw.c +++ b/drivers/usb/serial/ipw.c | |||
@@ -34,7 +34,6 @@ | |||
34 | * DCD, DTR, RTS, CTS which are currently faked. | 34 | * DCD, DTR, RTS, CTS which are currently faked. |
35 | * It's good enough for PPP at this point. It's based off all kinds of | 35 | * It's good enough for PPP at this point. It's based off all kinds of |
36 | * code found in usb/serial and usb/class | 36 | * code found in usb/serial and usb/class |
37 | * | ||
38 | */ | 37 | */ |
39 | 38 | ||
40 | #include <linux/kernel.h> | 39 | #include <linux/kernel.h> |
@@ -52,7 +51,7 @@ | |||
52 | /* | 51 | /* |
53 | * Version Information | 52 | * Version Information |
54 | */ | 53 | */ |
55 | #define DRIVER_VERSION "v0.3" | 54 | #define DRIVER_VERSION "v0.4" |
56 | #define DRIVER_AUTHOR "Roelf Diedericks" | 55 | #define DRIVER_AUTHOR "Roelf Diedericks" |
57 | #define DRIVER_DESC "IPWireless tty driver" | 56 | #define DRIVER_DESC "IPWireless tty driver" |
58 | 57 | ||
@@ -65,8 +64,6 @@ | |||
65 | /* Message sizes */ | 64 | /* Message sizes */ |
66 | #define EVENT_BUFFER_SIZE 0xFF | 65 | #define EVENT_BUFFER_SIZE 0xFF |
67 | #define CHAR2INT16(c1, c0) (((u32)((c1) & 0xff) << 8) + (u32)((c0) & 0xff)) | 66 | #define CHAR2INT16(c1, c0) (((u32)((c1) & 0xff) << 8) + (u32)((c0) & 0xff)) |
68 | #define NUM_BULK_URBS 24 | ||
69 | #define NUM_CONTROL_URBS 16 | ||
70 | 67 | ||
71 | /* vendor/product pairs that are known work with this driver*/ | 68 | /* vendor/product pairs that are known work with this driver*/ |
72 | #define IPW_VID 0x0bc3 | 69 | #define IPW_VID 0x0bc3 |
@@ -151,47 +148,6 @@ static struct usb_driver usb_ipw_driver = { | |||
151 | 148 | ||
152 | static int debug; | 149 | static int debug; |
153 | 150 | ||
154 | static void ipw_read_bulk_callback(struct urb *urb) | ||
155 | { | ||
156 | struct usb_serial_port *port = urb->context; | ||
157 | unsigned char *data = urb->transfer_buffer; | ||
158 | struct tty_struct *tty; | ||
159 | int result; | ||
160 | int status = urb->status; | ||
161 | |||
162 | dbg("%s - port %d", __func__, port->number); | ||
163 | |||
164 | if (status) { | ||
165 | dbg("%s - nonzero read bulk status received: %d", | ||
166 | __func__, status); | ||
167 | return; | ||
168 | } | ||
169 | |||
170 | usb_serial_debug_data(debug, &port->dev, __func__, | ||
171 | urb->actual_length, data); | ||
172 | |||
173 | tty = tty_port_tty_get(&port->port); | ||
174 | if (tty && urb->actual_length) { | ||
175 | tty_insert_flip_string(tty, data, urb->actual_length); | ||
176 | tty_flip_buffer_push(tty); | ||
177 | } | ||
178 | tty_kref_put(tty); | ||
179 | |||
180 | /* Continue trying to always read */ | ||
181 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, | ||
182 | usb_rcvbulkpipe(port->serial->dev, | ||
183 | port->bulk_in_endpointAddress), | ||
184 | port->read_urb->transfer_buffer, | ||
185 | port->read_urb->transfer_buffer_length, | ||
186 | ipw_read_bulk_callback, port); | ||
187 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | ||
188 | if (result) | ||
189 | dev_err(&port->dev, | ||
190 | "%s - failed resubmitting read urb, error %d\n", | ||
191 | __func__, result); | ||
192 | return; | ||
193 | } | ||
194 | |||
195 | static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port) | 151 | static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port) |
196 | { | 152 | { |
197 | struct usb_device *dev = port->serial->dev; | 153 | struct usb_device *dev = port->serial->dev; |
@@ -229,15 +185,7 @@ static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
229 | 185 | ||
230 | /*--2: Start reading from the device */ | 186 | /*--2: Start reading from the device */ |
231 | dbg("%s: setting up bulk read callback", __func__); | 187 | dbg("%s: setting up bulk read callback", __func__); |
232 | usb_fill_bulk_urb(port->read_urb, dev, | 188 | usb_serial_generic_open(tty, port); |
233 | usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress), | ||
234 | port->bulk_in_buffer, | ||
235 | port->bulk_in_size, | ||
236 | ipw_read_bulk_callback, port); | ||
237 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); | ||
238 | if (result < 0) | ||
239 | dbg("%s - usb_submit_urb(read bulk) failed with status %d", | ||
240 | __func__, result); | ||
241 | 189 | ||
242 | /*--3: Tell the modem to open the floodgates on the rx bulk channel */ | 190 | /*--3: Tell the modem to open the floodgates on the rx bulk channel */ |
243 | dbg("%s:asking modem for RxRead (RXBULK_ON)", __func__); | 191 | dbg("%s:asking modem for RxRead (RXBULK_ON)", __func__); |
@@ -337,72 +285,7 @@ static void ipw_close(struct usb_serial_port *port) | |||
337 | dev_err(&port->dev, | 285 | dev_err(&port->dev, |
338 | "Disabling bulk RxRead failed (error = %d)\n", result); | 286 | "Disabling bulk RxRead failed (error = %d)\n", result); |
339 | 287 | ||
340 | /* shutdown any in-flight urbs that we know about */ | 288 | usb_serial_generic_close(port); |
341 | usb_kill_urb(port->read_urb); | ||
342 | usb_kill_urb(port->write_urb); | ||
343 | } | ||
344 | |||
345 | static void ipw_write_bulk_callback(struct urb *urb) | ||
346 | { | ||
347 | struct usb_serial_port *port = urb->context; | ||
348 | int status = urb->status; | ||
349 | |||
350 | dbg("%s", __func__); | ||
351 | |||
352 | port->write_urb_busy = 0; | ||
353 | |||
354 | if (status) | ||
355 | dbg("%s - nonzero write bulk status received: %d", | ||
356 | __func__, status); | ||
357 | |||
358 | usb_serial_port_softint(port); | ||
359 | } | ||
360 | |||
361 | static int ipw_write(struct tty_struct *tty, struct usb_serial_port *port, | ||
362 | const unsigned char *buf, int count) | ||
363 | { | ||
364 | struct usb_device *dev = port->serial->dev; | ||
365 | int ret; | ||
366 | |||
367 | dbg("%s: TOP: count=%d, in_interrupt=%ld", __func__, | ||
368 | count, in_interrupt()); | ||
369 | |||
370 | if (count == 0) { | ||
371 | dbg("%s - write request of 0 bytes", __func__); | ||
372 | return 0; | ||
373 | } | ||
374 | |||
375 | spin_lock_bh(&port->lock); | ||
376 | if (port->write_urb_busy) { | ||
377 | spin_unlock_bh(&port->lock); | ||
378 | dbg("%s - already writing", __func__); | ||
379 | return 0; | ||
380 | } | ||
381 | port->write_urb_busy = 1; | ||
382 | spin_unlock_bh(&port->lock); | ||
383 | |||
384 | count = min(count, port->bulk_out_size); | ||
385 | memcpy(port->bulk_out_buffer, buf, count); | ||
386 | |||
387 | dbg("%s count now:%d", __func__, count); | ||
388 | |||
389 | usb_fill_bulk_urb(port->write_urb, dev, | ||
390 | usb_sndbulkpipe(dev, port->bulk_out_endpointAddress), | ||
391 | port->write_urb->transfer_buffer, | ||
392 | count, | ||
393 | ipw_write_bulk_callback, | ||
394 | port); | ||
395 | |||
396 | ret = usb_submit_urb(port->write_urb, GFP_ATOMIC); | ||
397 | if (ret != 0) { | ||
398 | port->write_urb_busy = 0; | ||
399 | dbg("%s - usb_submit_urb(write bulk) failed with error = %d", | ||
400 | __func__, ret); | ||
401 | return ret; | ||
402 | } | ||
403 | |||
404 | dbg("%s returning %d", __func__, count); | ||
405 | return count; | ||
406 | } | 289 | } |
407 | 290 | ||
408 | static struct usb_serial_driver ipw_device = { | 291 | static struct usb_serial_driver ipw_device = { |
@@ -411,15 +294,12 @@ static struct usb_serial_driver ipw_device = { | |||
411 | .name = "ipw", | 294 | .name = "ipw", |
412 | }, | 295 | }, |
413 | .description = "IPWireless converter", | 296 | .description = "IPWireless converter", |
414 | .usb_driver = &usb_ipw_driver, | 297 | .usb_driver = &usb_ipw_driver, |
415 | .id_table = usb_ipw_ids, | 298 | .id_table = usb_ipw_ids, |
416 | .num_ports = 1, | 299 | .num_ports = 1, |
417 | .open = ipw_open, | 300 | .open = ipw_open, |
418 | .close = ipw_close, | 301 | .close = ipw_close, |
419 | .dtr_rts = ipw_dtr_rts, | 302 | .dtr_rts = ipw_dtr_rts, |
420 | .write = ipw_write, | ||
421 | .write_bulk_callback = ipw_write_bulk_callback, | ||
422 | .read_bulk_callback = ipw_read_bulk_callback, | ||
423 | }; | 303 | }; |
424 | 304 | ||
425 | 305 | ||