aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/omninet.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/omninet.c')
-rw-r--r--drivers/usb/serial/omninet.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index ee94d9616d82..7b7422f49478 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -95,9 +95,6 @@ static struct usb_serial_driver zyxel_omninet_device = {
95 .description = "ZyXEL - omni.net lcd plus usb", 95 .description = "ZyXEL - omni.net lcd plus usb",
96 .usb_driver = &omninet_driver, 96 .usb_driver = &omninet_driver,
97 .id_table = id_table, 97 .id_table = id_table,
98 .num_interrupt_in = 1,
99 .num_bulk_in = 1,
100 .num_bulk_out = 2,
101 .num_ports = 1, 98 .num_ports = 1,
102 .attach = omninet_attach, 99 .attach = omninet_attach,
103 .open = omninet_open, 100 .open = omninet_open,
@@ -153,7 +150,7 @@ static int omninet_attach (struct usb_serial *serial)
153 150
154 od = kmalloc( sizeof(struct omninet_data), GFP_KERNEL ); 151 od = kmalloc( sizeof(struct omninet_data), GFP_KERNEL );
155 if( !od ) { 152 if( !od ) {
156 err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct omninet_data)); 153 err("%s- kmalloc(%Zd) failed.", __func__, sizeof(struct omninet_data));
157 return -ENOMEM; 154 return -ENOMEM;
158 } 155 }
159 usb_set_serial_port_data(port, od); 156 usb_set_serial_port_data(port, od);
@@ -166,7 +163,7 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp)
166 struct usb_serial_port *wport; 163 struct usb_serial_port *wport;
167 int result = 0; 164 int result = 0;
168 165
169 dbg("%s - port %d", __FUNCTION__, port->number); 166 dbg("%s - port %d", __func__, port->number);
170 167
171 wport = serial->port[1]; 168 wport = serial->port[1];
172 wport->tty = port->tty; 169 wport->tty = port->tty;
@@ -178,7 +175,7 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp)
178 omninet_read_bulk_callback, port); 175 omninet_read_bulk_callback, port);
179 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 176 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
180 if (result) { 177 if (result) {
181 err("%s - failed submitting read urb, error %d", __FUNCTION__, result); 178 err("%s - failed submitting read urb, error %d", __func__, result);
182 } 179 }
183 180
184 return result; 181 return result;
@@ -186,7 +183,7 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp)
186 183
187static void omninet_close (struct usb_serial_port *port, struct file * filp) 184static void omninet_close (struct usb_serial_port *port, struct file * filp)
188{ 185{
189 dbg("%s - port %d", __FUNCTION__, port->number); 186 dbg("%s - port %d", __func__, port->number);
190 usb_kill_urb(port->read_urb); 187 usb_kill_urb(port->read_urb);
191} 188}
192 189
@@ -197,18 +194,18 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp)
197 194
198static void omninet_read_bulk_callback (struct urb *urb) 195static void omninet_read_bulk_callback (struct urb *urb)
199{ 196{
200 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 197 struct usb_serial_port *port = urb->context;
201 unsigned char *data = urb->transfer_buffer; 198 unsigned char *data = urb->transfer_buffer;
202 struct omninet_header *header = (struct omninet_header *) &data[0]; 199 struct omninet_header *header = (struct omninet_header *) &data[0];
203 int status = urb->status; 200 int status = urb->status;
204 int i; 201 int i;
205 int result; 202 int result;
206 203
207 dbg("%s - port %d", __FUNCTION__, port->number); 204 dbg("%s - port %d", __func__, port->number);
208 205
209 if (status) { 206 if (status) {
210 dbg("%s - nonzero read bulk status received: %d", 207 dbg("%s - nonzero read bulk status received: %d",
211 __FUNCTION__, status); 208 __func__, status);
212 return; 209 return;
213 } 210 }
214 211
@@ -236,7 +233,7 @@ static void omninet_read_bulk_callback (struct urb *urb)
236 omninet_read_bulk_callback, port); 233 omninet_read_bulk_callback, port);
237 result = usb_submit_urb(urb, GFP_ATOMIC); 234 result = usb_submit_urb(urb, GFP_ATOMIC);
238 if (result) 235 if (result)
239 err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); 236 err("%s - failed resubmitting read urb, error %d", __func__, result);
240 237
241 return; 238 return;
242} 239}
@@ -251,17 +248,17 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf
251 248
252 int result; 249 int result;
253 250
254 dbg("%s - port %d", __FUNCTION__, port->number); 251 dbg("%s - port %d", __func__, port->number);
255 252
256 if (count == 0) { 253 if (count == 0) {
257 dbg("%s - write request of 0 bytes", __FUNCTION__); 254 dbg("%s - write request of 0 bytes", __func__);
258 return (0); 255 return (0);
259 } 256 }
260 257
261 spin_lock_bh(&wport->lock); 258 spin_lock_bh(&wport->lock);
262 if (wport->write_urb_busy) { 259 if (wport->write_urb_busy) {
263 spin_unlock_bh(&wport->lock); 260 spin_unlock_bh(&wport->lock);
264 dbg("%s - already writing", __FUNCTION__); 261 dbg("%s - already writing", __func__);
265 return 0; 262 return 0;
266 } 263 }
267 wport->write_urb_busy = 1; 264 wport->write_urb_busy = 1;
@@ -271,7 +268,7 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf
271 268
272 memcpy (wport->write_urb->transfer_buffer + OMNINET_DATAOFFSET, buf, count); 269 memcpy (wport->write_urb->transfer_buffer + OMNINET_DATAOFFSET, buf, count);
273 270
274 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, wport->write_urb->transfer_buffer); 271 usb_serial_debug_data(debug, &port->dev, __func__, count, wport->write_urb->transfer_buffer);
275 272
276 header->oh_seq = od->od_outseq++; 273 header->oh_seq = od->od_outseq++;
277 header->oh_len = count; 274 header->oh_len = count;
@@ -285,7 +282,7 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf
285 result = usb_submit_urb(wport->write_urb, GFP_ATOMIC); 282 result = usb_submit_urb(wport->write_urb, GFP_ATOMIC);
286 if (result) { 283 if (result) {
287 wport->write_urb_busy = 0; 284 wport->write_urb_busy = 0;
288 err("%s - failed submitting write urb, error %d", __FUNCTION__, result); 285 err("%s - failed submitting write urb, error %d", __func__, result);
289 } else 286 } else
290 result = count; 287 result = count;
291 288
@@ -298,12 +295,13 @@ static int omninet_write_room (struct usb_serial_port *port)
298 struct usb_serial *serial = port->serial; 295 struct usb_serial *serial = port->serial;
299 struct usb_serial_port *wport = serial->port[1]; 296 struct usb_serial_port *wport = serial->port[1];
300 297
301 int room = 0; // Default: no room 298 int room = 0; /* Default: no room */
302 299
300 /* FIXME: no consistent locking for write_urb_busy */
303 if (wport->write_urb_busy) 301 if (wport->write_urb_busy)
304 room = wport->bulk_out_size - OMNINET_HEADERLEN; 302 room = wport->bulk_out_size - OMNINET_HEADERLEN;
305 303
306 dbg("%s - returns %d", __FUNCTION__, room); 304 dbg("%s - returns %d", __func__, room);
307 305
308 return (room); 306 return (room);
309} 307}
@@ -311,15 +309,15 @@ static int omninet_write_room (struct usb_serial_port *port)
311static void omninet_write_bulk_callback (struct urb *urb) 309static void omninet_write_bulk_callback (struct urb *urb)
312{ 310{
313/* struct omninet_header *header = (struct omninet_header *) urb->transfer_buffer; */ 311/* struct omninet_header *header = (struct omninet_header *) urb->transfer_buffer; */
314 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 312 struct usb_serial_port *port = urb->context;
315 int status = urb->status; 313 int status = urb->status;
316 314
317 dbg("%s - port %0x\n", __FUNCTION__, port->number); 315 dbg("%s - port %0x\n", __func__, port->number);
318 316
319 port->write_urb_busy = 0; 317 port->write_urb_busy = 0;
320 if (status) { 318 if (status) {
321 dbg("%s - nonzero write bulk status received: %d", 319 dbg("%s - nonzero write bulk status received: %d",
322 __FUNCTION__, status); 320 __func__, status);
323 return; 321 return;
324 } 322 }
325 323
@@ -331,7 +329,7 @@ static void omninet_shutdown (struct usb_serial *serial)
331{ 329{
332 struct usb_serial_port *wport = serial->port[1]; 330 struct usb_serial_port *wport = serial->port[1];
333 struct usb_serial_port *port = serial->port[0]; 331 struct usb_serial_port *port = serial->port[0];
334 dbg ("%s", __FUNCTION__); 332 dbg ("%s", __func__);
335 333
336 usb_kill_urb(wport->write_urb); 334 usb_kill_urb(wport->write_urb);
337 kfree(usb_get_serial_port_data(port)); 335 kfree(usb_get_serial_port_data(port));