aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/safe_serial.c
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2010-05-18 18:01:31 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-05-20 16:21:49 -0400
commit12e2e52cc578714d5824a27dd1a131a5418d636b (patch)
treec191a5a9006fd7a097fc474097e021614dcb20c4 /drivers/usb/serial/safe_serial.c
parent241c80ea72be4828c63f5dd44b142e54d0a12f5d (diff)
USB: safe_serial: reimplement read using generic framework
Use process_read_urb to implement read processing. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/safe_serial.c')
-rw-r--r--drivers/usb/serial/safe_serial.c47
1 files changed, 8 insertions, 39 deletions
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
index 915c094ef92c..d9af5c5ed9e8 100644
--- a/drivers/usb/serial/safe_serial.c
+++ b/drivers/usb/serial/safe_serial.c
@@ -213,38 +213,20 @@ static __u16 __inline__ fcs_compute10(unsigned char *sp, int len, __u16 fcs)
213 return fcs; 213 return fcs;
214} 214}
215 215
216static void safe_read_bulk_callback(struct urb *urb) 216static void safe_process_read_urb(struct urb *urb)
217{ 217{
218 struct usb_serial_port *port = urb->context; 218 struct usb_serial_port *port = urb->context;
219 unsigned char *data = urb->transfer_buffer; 219 unsigned char *data = urb->transfer_buffer;
220 unsigned char length = urb->actual_length; 220 unsigned char length = urb->actual_length;
221 struct tty_struct *tty; 221 struct tty_struct *tty;
222 int result;
223 int status = urb->status;
224 222
225 dbg("%s", __func__); 223 if (!length)
226
227 if (status) {
228 dbg("%s - nonzero read bulk status received: %d",
229 __func__, status);
230 return; 224 return;
231 }
232 225
233 dbg("safe_read_bulk_callback length: %d",
234 port->read_urb->actual_length);
235#ifdef ECHO_RCV
236 {
237 int i;
238 unsigned char *cp = port->read_urb->transfer_buffer;
239 for (i = 0; i < port->read_urb->actual_length; i++) {
240 if ((i % 32) == 0)
241 printk("\nru[%02x] ", i);
242 printk("%02x ", *cp++);
243 }
244 printk("\n");
245 }
246#endif
247 tty = tty_port_tty_get(&port->port); 226 tty = tty_port_tty_get(&port->port);
227 if (!tty)
228 return;
229
248 if (safe) { 230 if (safe) {
249 __u16 fcs; 231 __u16 fcs;
250 fcs = fcs_compute10(data, length, CRC10_INITFCS); 232 fcs = fcs_compute10(data, length, CRC10_INITFCS);
@@ -268,21 +250,8 @@ static void safe_read_bulk_callback(struct urb *urb)
268 tty_insert_flip_string(tty, data, length); 250 tty_insert_flip_string(tty, data, length);
269 tty_flip_buffer_push(tty); 251 tty_flip_buffer_push(tty);
270 } 252 }
271 tty_kref_put(tty);
272 253
273 /* Continue trying to always read */ 254 tty_kref_put(tty);
274 usb_fill_bulk_urb(urb, port->serial->dev,
275 usb_rcvbulkpipe(port->serial->dev,
276 port->bulk_in_endpointAddress),
277 urb->transfer_buffer, urb->transfer_buffer_length,
278 safe_read_bulk_callback, port);
279
280 result = usb_submit_urb(urb, GFP_ATOMIC);
281 if (result)
282 dev_err(&port->dev,
283 "%s - failed resubmitting read urb, error %d\n",
284 __func__, result);
285 /* FIXME: Need a mechanism to retry later if this happens */
286} 255}
287 256
288static int safe_prepare_write_buffer(struct usb_serial_port *port, 257static int safe_prepare_write_buffer(struct usb_serial_port *port,
@@ -343,7 +312,7 @@ static struct usb_serial_driver safe_device = {
343 .id_table = id_table, 312 .id_table = id_table,
344 .usb_driver = &safe_driver, 313 .usb_driver = &safe_driver,
345 .num_ports = 1, 314 .num_ports = 1,
346 .read_bulk_callback = safe_read_bulk_callback, 315 .process_read_urb = safe_process_read_urb,
347 .prepare_write_buffer = safe_prepare_write_buffer, 316 .prepare_write_buffer = safe_prepare_write_buffer,
348 .attach = safe_startup, 317 .attach = safe_startup,
349}; 318};