diff options
Diffstat (limited to 'drivers/net/usb/net1080.c')
-rw-r--r-- | drivers/net/usb/net1080.c | 110 |
1 files changed, 30 insertions, 80 deletions
diff --git a/drivers/net/usb/net1080.c b/drivers/net/usb/net1080.c index c062a3e8295c..93e0716a118c 100644 --- a/drivers/net/usb/net1080.c +++ b/drivers/net/usb/net1080.c | |||
@@ -109,13 +109,11 @@ struct nc_trailer { | |||
109 | static int | 109 | static int |
110 | nc_vendor_read(struct usbnet *dev, u8 req, u8 regnum, u16 *retval_ptr) | 110 | nc_vendor_read(struct usbnet *dev, u8 req, u8 regnum, u16 *retval_ptr) |
111 | { | 111 | { |
112 | int status = usb_control_msg(dev->udev, | 112 | int status = usbnet_read_cmd(dev, req, |
113 | usb_rcvctrlpipe(dev->udev, 0), | 113 | USB_DIR_IN | USB_TYPE_VENDOR | |
114 | req, | 114 | USB_RECIP_DEVICE, |
115 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 115 | 0, regnum, retval_ptr, |
116 | 0, regnum, | 116 | sizeof *retval_ptr); |
117 | retval_ptr, sizeof *retval_ptr, | ||
118 | USB_CTRL_GET_TIMEOUT); | ||
119 | if (status > 0) | 117 | if (status > 0) |
120 | status = 0; | 118 | status = 0; |
121 | if (!status) | 119 | if (!status) |
@@ -133,13 +131,9 @@ nc_register_read(struct usbnet *dev, u8 regnum, u16 *retval_ptr) | |||
133 | static void | 131 | static void |
134 | nc_vendor_write(struct usbnet *dev, u8 req, u8 regnum, u16 value) | 132 | nc_vendor_write(struct usbnet *dev, u8 req, u8 regnum, u16 value) |
135 | { | 133 | { |
136 | usb_control_msg(dev->udev, | 134 | usbnet_write_cmd(dev, req, |
137 | usb_sndctrlpipe(dev->udev, 0), | 135 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
138 | req, | 136 | value, regnum, NULL, 0); |
139 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
140 | value, regnum, | ||
141 | NULL, 0, // data is in setup packet | ||
142 | USB_CTRL_SET_TIMEOUT); | ||
143 | } | 137 | } |
144 | 138 | ||
145 | static inline void | 139 | static inline void |
@@ -288,37 +282,34 @@ static inline void nc_dump_ttl(struct usbnet *dev, u16 ttl) | |||
288 | static int net1080_reset(struct usbnet *dev) | 282 | static int net1080_reset(struct usbnet *dev) |
289 | { | 283 | { |
290 | u16 usbctl, status, ttl; | 284 | u16 usbctl, status, ttl; |
291 | u16 *vp = kmalloc(sizeof (u16), GFP_KERNEL); | 285 | u16 vp; |
292 | int retval; | 286 | int retval; |
293 | 287 | ||
294 | if (!vp) | ||
295 | return -ENOMEM; | ||
296 | |||
297 | // nc_dump_registers(dev); | 288 | // nc_dump_registers(dev); |
298 | 289 | ||
299 | if ((retval = nc_register_read(dev, REG_STATUS, vp)) < 0) { | 290 | if ((retval = nc_register_read(dev, REG_STATUS, &vp)) < 0) { |
300 | netdev_dbg(dev->net, "can't read %s-%s status: %d\n", | 291 | netdev_dbg(dev->net, "can't read %s-%s status: %d\n", |
301 | dev->udev->bus->bus_name, dev->udev->devpath, retval); | 292 | dev->udev->bus->bus_name, dev->udev->devpath, retval); |
302 | goto done; | 293 | goto done; |
303 | } | 294 | } |
304 | status = *vp; | 295 | status = vp; |
305 | nc_dump_status(dev, status); | 296 | nc_dump_status(dev, status); |
306 | 297 | ||
307 | if ((retval = nc_register_read(dev, REG_USBCTL, vp)) < 0) { | 298 | if ((retval = nc_register_read(dev, REG_USBCTL, &vp)) < 0) { |
308 | netdev_dbg(dev->net, "can't read USBCTL, %d\n", retval); | 299 | netdev_dbg(dev->net, "can't read USBCTL, %d\n", retval); |
309 | goto done; | 300 | goto done; |
310 | } | 301 | } |
311 | usbctl = *vp; | 302 | usbctl = vp; |
312 | nc_dump_usbctl(dev, usbctl); | 303 | nc_dump_usbctl(dev, usbctl); |
313 | 304 | ||
314 | nc_register_write(dev, REG_USBCTL, | 305 | nc_register_write(dev, REG_USBCTL, |
315 | USBCTL_FLUSH_THIS | USBCTL_FLUSH_OTHER); | 306 | USBCTL_FLUSH_THIS | USBCTL_FLUSH_OTHER); |
316 | 307 | ||
317 | if ((retval = nc_register_read(dev, REG_TTL, vp)) < 0) { | 308 | if ((retval = nc_register_read(dev, REG_TTL, &vp)) < 0) { |
318 | netdev_dbg(dev->net, "can't read TTL, %d\n", retval); | 309 | netdev_dbg(dev->net, "can't read TTL, %d\n", retval); |
319 | goto done; | 310 | goto done; |
320 | } | 311 | } |
321 | ttl = *vp; | 312 | ttl = vp; |
322 | // nc_dump_ttl(dev, ttl); | 313 | // nc_dump_ttl(dev, ttl); |
323 | 314 | ||
324 | nc_register_write(dev, REG_TTL, | 315 | nc_register_write(dev, REG_TTL, |
@@ -331,7 +322,6 @@ static int net1080_reset(struct usbnet *dev) | |||
331 | retval = 0; | 322 | retval = 0; |
332 | 323 | ||
333 | done: | 324 | done: |
334 | kfree(vp); | ||
335 | return retval; | 325 | return retval; |
336 | } | 326 | } |
337 | 327 | ||
@@ -339,13 +329,10 @@ static int net1080_check_connect(struct usbnet *dev) | |||
339 | { | 329 | { |
340 | int retval; | 330 | int retval; |
341 | u16 status; | 331 | u16 status; |
342 | u16 *vp = kmalloc(sizeof (u16), GFP_KERNEL); | 332 | u16 vp; |
343 | 333 | ||
344 | if (!vp) | 334 | retval = nc_register_read(dev, REG_STATUS, &vp); |
345 | return -ENOMEM; | 335 | status = vp; |
346 | retval = nc_register_read(dev, REG_STATUS, vp); | ||
347 | status = *vp; | ||
348 | kfree(vp); | ||
349 | if (retval != 0) { | 336 | if (retval != 0) { |
350 | netdev_dbg(dev->net, "net1080_check_conn read - %d\n", retval); | 337 | netdev_dbg(dev->net, "net1080_check_conn read - %d\n", retval); |
351 | return retval; | 338 | return retval; |
@@ -355,59 +342,22 @@ static int net1080_check_connect(struct usbnet *dev) | |||
355 | return 0; | 342 | return 0; |
356 | } | 343 | } |
357 | 344 | ||
358 | static void nc_flush_complete(struct urb *urb) | ||
359 | { | ||
360 | kfree(urb->context); | ||
361 | usb_free_urb(urb); | ||
362 | } | ||
363 | |||
364 | static void nc_ensure_sync(struct usbnet *dev) | 345 | static void nc_ensure_sync(struct usbnet *dev) |
365 | { | 346 | { |
366 | dev->frame_errors++; | 347 | if (++dev->frame_errors <= 5) |
367 | if (dev->frame_errors > 5) { | 348 | return; |
368 | struct urb *urb; | ||
369 | struct usb_ctrlrequest *req; | ||
370 | int status; | ||
371 | |||
372 | /* Send a flush */ | ||
373 | urb = usb_alloc_urb(0, GFP_ATOMIC); | ||
374 | if (!urb) | ||
375 | return; | ||
376 | |||
377 | req = kmalloc(sizeof *req, GFP_ATOMIC); | ||
378 | if (!req) { | ||
379 | usb_free_urb(urb); | ||
380 | return; | ||
381 | } | ||
382 | 349 | ||
383 | req->bRequestType = USB_DIR_OUT | 350 | if (usbnet_write_cmd_async(dev, REQUEST_REGISTER, |
384 | | USB_TYPE_VENDOR | 351 | USB_DIR_OUT | USB_TYPE_VENDOR | |
385 | | USB_RECIP_DEVICE; | 352 | USB_RECIP_DEVICE, |
386 | req->bRequest = REQUEST_REGISTER; | 353 | USBCTL_FLUSH_THIS | |
387 | req->wValue = cpu_to_le16(USBCTL_FLUSH_THIS | 354 | USBCTL_FLUSH_OTHER, |
388 | | USBCTL_FLUSH_OTHER); | 355 | REG_USBCTL, NULL, 0)) |
389 | req->wIndex = cpu_to_le16(REG_USBCTL); | 356 | return; |
390 | req->wLength = cpu_to_le16(0); | ||
391 | |||
392 | /* queue an async control request, we don't need | ||
393 | * to do anything when it finishes except clean up. | ||
394 | */ | ||
395 | usb_fill_control_urb(urb, dev->udev, | ||
396 | usb_sndctrlpipe(dev->udev, 0), | ||
397 | (unsigned char *) req, | ||
398 | NULL, 0, | ||
399 | nc_flush_complete, req); | ||
400 | status = usb_submit_urb(urb, GFP_ATOMIC); | ||
401 | if (status) { | ||
402 | kfree(req); | ||
403 | usb_free_urb(urb); | ||
404 | return; | ||
405 | } | ||
406 | 357 | ||
407 | netif_dbg(dev, rx_err, dev->net, | 358 | netif_dbg(dev, rx_err, dev->net, |
408 | "flush net1080; too many framing errors\n"); | 359 | "flush net1080; too many framing errors\n"); |
409 | dev->frame_errors = 0; | 360 | dev->frame_errors = 0; |
410 | } | ||
411 | } | 361 | } |
412 | 362 | ||
413 | static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | 363 | static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb) |