aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/airprime.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/airprime.c')
-rw-r--r--drivers/usb/serial/airprime.c63
1 files changed, 35 insertions, 28 deletions
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
index 725b6b94c274..0798c14ce787 100644
--- a/drivers/usb/serial/airprime.c
+++ b/drivers/usb/serial/airprime.c
@@ -68,8 +68,9 @@ static int airprime_send_setup(struct usb_serial_port *port)
68 val |= 0x02; 68 val |= 0x02;
69 69
70 return usb_control_msg(serial->dev, 70 return usb_control_msg(serial->dev,
71 usb_rcvctrlpipe(serial->dev, 0), 71 usb_rcvctrlpipe(serial->dev, 0),
72 0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT); 72 0x22, 0x21, val, 0, NULL, 0,
73 USB_CTRL_SET_TIMEOUT);
73 } 74 }
74 75
75 return 0; 76 return 0;
@@ -90,17 +91,19 @@ static void airprime_read_bulk_callback(struct urb *urb)
90 __func__, status); 91 __func__, status);
91 return; 92 return;
92 } 93 }
93 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); 94 usb_serial_debug_data(debug, &port->dev, __func__,
95 urb->actual_length, data);
94 96
95 tty = port->tty; 97 tty = port->tty;
96 if (tty && urb->actual_length) { 98 if (tty && urb->actual_length) {
97 tty_insert_flip_string (tty, data, urb->actual_length); 99 tty_insert_flip_string(tty, data, urb->actual_length);
98 tty_flip_buffer_push (tty); 100 tty_flip_buffer_push(tty);
99 } 101 }
100 102
101 result = usb_submit_urb (urb, GFP_ATOMIC); 103 result = usb_submit_urb(urb, GFP_ATOMIC);
102 if (result) 104 if (result)
103 dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", 105 dev_err(&port->dev,
106 "%s - failed resubmitting read urb, error %d\n",
104 __func__, result); 107 __func__, result);
105 return; 108 return;
106} 109}
@@ -115,7 +118,7 @@ static void airprime_write_bulk_callback(struct urb *urb)
115 dbg("%s - port %d", __func__, port->number); 118 dbg("%s - port %d", __func__, port->number);
116 119
117 /* free up the transfer buffer, as usb_free_urb() does not do this */ 120 /* free up the transfer buffer, as usb_free_urb() does not do this */
118 kfree (urb->transfer_buffer); 121 kfree(urb->transfer_buffer);
119 122
120 if (status) 123 if (status)
121 dbg("%s - nonzero write bulk status received: %d", 124 dbg("%s - nonzero write bulk status received: %d",
@@ -171,7 +174,7 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp)
171 } 174 }
172 usb_fill_bulk_urb(urb, serial->dev, 175 usb_fill_bulk_urb(urb, serial->dev,
173 usb_rcvbulkpipe(serial->dev, 176 usb_rcvbulkpipe(serial->dev,
174 port->bulk_out_endpointAddress), 177 port->bulk_out_endpointAddress),
175 buffer, buffer_size, 178 buffer, buffer_size,
176 airprime_read_bulk_callback, port); 179 airprime_read_bulk_callback, port);
177 result = usb_submit_urb(urb, GFP_KERNEL); 180 result = usb_submit_urb(urb, GFP_KERNEL);
@@ -183,7 +186,8 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp)
183 __func__, i, port->number, result); 186 __func__, i, port->number, result);
184 goto errout; 187 goto errout;
185 } 188 }
186 /* remember this urb so we can kill it when the port is closed */ 189 /* remember this urb so we can kill it when the
190 port is closed */
187 priv->read_urbp[i] = urb; 191 priv->read_urbp[i] = urb;
188 } 192 }
189 193
@@ -192,22 +196,22 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp)
192 goto out; 196 goto out;
193 197
194 errout: 198 errout:
195 /* some error happened, cancel any submitted urbs and clean up anything that 199 /* some error happened, cancel any submitted urbs and clean up
196 got allocated successfully */ 200 anything that got allocated successfully */
197 201
198 while (i-- != 0) { 202 while (i-- != 0) {
199 urb = priv->read_urbp[i]; 203 urb = priv->read_urbp[i];
200 buffer = urb->transfer_buffer; 204 buffer = urb->transfer_buffer;
201 usb_kill_urb (urb); 205 usb_kill_urb(urb);
202 usb_free_urb (urb); 206 usb_free_urb(urb);
203 kfree (buffer); 207 kfree(buffer);
204 } 208 }
205 209
206 out: 210 out:
207 return result; 211 return result;
208} 212}
209 213
210static void airprime_close(struct usb_serial_port *port, struct file * filp) 214static void airprime_close(struct usb_serial_port *port, struct file *filp)
211{ 215{
212 struct airprime_private *priv = usb_get_serial_port_data(port); 216 struct airprime_private *priv = usb_get_serial_port_data(port);
213 int i; 217 int i;
@@ -220,16 +224,16 @@ static void airprime_close(struct usb_serial_port *port, struct file * filp)
220 mutex_lock(&port->serial->disc_mutex); 224 mutex_lock(&port->serial->disc_mutex);
221 if (!port->serial->disconnected) 225 if (!port->serial->disconnected)
222 airprime_send_setup(port); 226 airprime_send_setup(port);
223 mutex_lock(&port->serial->disc_mutex); 227 mutex_unlock(&port->serial->disc_mutex);
224 228
225 for (i = 0; i < NUM_READ_URBS; ++i) { 229 for (i = 0; i < NUM_READ_URBS; ++i) {
226 usb_kill_urb (priv->read_urbp[i]); 230 usb_kill_urb(priv->read_urbp[i]);
227 kfree (priv->read_urbp[i]->transfer_buffer); 231 kfree(priv->read_urbp[i]->transfer_buffer);
228 usb_free_urb (priv->read_urbp[i]); 232 usb_free_urb(priv->read_urbp[i]);
229 } 233 }
230 234
231 /* free up private structure */ 235 /* free up private structure */
232 kfree (priv); 236 kfree(priv);
233 usb_set_serial_port_data(port, NULL); 237 usb_set_serial_port_data(port, NULL);
234} 238}
235 239
@@ -259,10 +263,10 @@ static int airprime_write(struct usb_serial_port *port,
259 urb = usb_alloc_urb(0, GFP_ATOMIC); 263 urb = usb_alloc_urb(0, GFP_ATOMIC);
260 if (!urb) { 264 if (!urb) {
261 dev_err(&port->dev, "no more free urbs\n"); 265 dev_err(&port->dev, "no more free urbs\n");
262 kfree (buffer); 266 kfree(buffer);
263 return -ENOMEM; 267 return -ENOMEM;
264 } 268 }
265 memcpy (buffer, buf, count); 269 memcpy(buffer, buf, count);
266 270
267 usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); 271 usb_serial_debug_data(debug, &port->dev, __func__, count, buffer);
268 272
@@ -279,7 +283,7 @@ static int airprime_write(struct usb_serial_port *port,
279 "%s - usb_submit_urb(write bulk) failed with status = %d\n", 283 "%s - usb_submit_urb(write bulk) failed with status = %d\n",
280 __func__, status); 284 __func__, status);
281 count = status; 285 count = status;
282 kfree (buffer); 286 kfree(buffer);
283 } else { 287 } else {
284 spin_lock_irqsave(&priv->lock, flags); 288 spin_lock_irqsave(&priv->lock, flags);
285 ++priv->outstanding_urbs; 289 ++priv->outstanding_urbs;
@@ -287,7 +291,7 @@ static int airprime_write(struct usb_serial_port *port,
287 } 291 }
288 /* we are done with this urb, so let the host driver 292 /* we are done with this urb, so let the host driver
289 * really free it when it is finished with it */ 293 * really free it when it is finished with it */
290 usb_free_urb (urb); 294 usb_free_urb(urb);
291 return count; 295 return count;
292} 296}
293 297
@@ -315,8 +319,10 @@ static int __init airprime_init(void)
315{ 319{
316 int retval; 320 int retval;
317 321
318 airprime_device.num_ports = 322 airprime_device.num_ports = endpoints;
319 (endpoints > 0 && endpoints <= MAX_BULK_EPS) ? endpoints : NUM_BULK_EPS; 323 if (endpoints < 0 || endpoints >= MAX_BULK_EPS)
324 airprime_device.num_ports = NUM_BULK_EPS;
325
320 retval = usb_serial_register(&airprime_device); 326 retval = usb_serial_register(&airprime_device);
321 if (retval) 327 if (retval)
322 return retval; 328 return retval;
@@ -341,6 +347,7 @@ MODULE_LICENSE("GPL");
341module_param(debug, bool, S_IRUGO | S_IWUSR); 347module_param(debug, bool, S_IRUGO | S_IWUSR);
342MODULE_PARM_DESC(debug, "Debug enabled"); 348MODULE_PARM_DESC(debug, "Debug enabled");
343module_param(buffer_size, int, 0); 349module_param(buffer_size, int, 0);
344MODULE_PARM_DESC(buffer_size, "Size of the transfer buffers in bytes (default 4096)"); 350MODULE_PARM_DESC(buffer_size,
351 "Size of the transfer buffers in bytes (default 4096)");
345module_param(endpoints, int, 0); 352module_param(endpoints, int, 0);
346MODULE_PARM_DESC(endpoints, "Number of bulk EPs to configure (default 3)"); 353MODULE_PARM_DESC(endpoints, "Number of bulk EPs to configure (default 3)");