Commit 5ffbe4daa8104145cca4050d717d68b0b256df45

Authored by Ming Lei
Committed by David S. Miller
1 parent 9c06a2b582

usbnet: net1080: apply introduced usb command APIs

Acked-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 30 additions and 80 deletions Side-by-side Diff

drivers/net/usb/net1080.c
... ... @@ -109,13 +109,11 @@
109 109 static int
110 110 nc_vendor_read(struct usbnet *dev, u8 req, u8 regnum, u16 *retval_ptr)
111 111 {
112   - int status = usb_control_msg(dev->udev,
113   - usb_rcvctrlpipe(dev->udev, 0),
114   - req,
115   - USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
116   - 0, regnum,
117   - retval_ptr, sizeof *retval_ptr,
118   - USB_CTRL_GET_TIMEOUT);
  112 + int status = usbnet_read_cmd(dev, req,
  113 + USB_DIR_IN | USB_TYPE_VENDOR |
  114 + USB_RECIP_DEVICE,
  115 + 0, regnum, retval_ptr,
  116 + sizeof *retval_ptr);
119 117 if (status > 0)
120 118 status = 0;
121 119 if (!status)
... ... @@ -133,13 +131,9 @@
133 131 static void
134 132 nc_vendor_write(struct usbnet *dev, u8 req, u8 regnum, u16 value)
135 133 {
136   - usb_control_msg(dev->udev,
137   - usb_sndctrlpipe(dev->udev, 0),
138   - req,
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);
  134 + usbnet_write_cmd(dev, req,
  135 + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  136 + value, regnum, NULL, 0);
143 137 }
144 138  
145 139 static inline void
146 140  
147 141  
148 142  
149 143  
150 144  
151 145  
152 146  
... ... @@ -288,37 +282,34 @@
288 282 static int net1080_reset(struct usbnet *dev)
289 283 {
290 284 u16 usbctl, status, ttl;
291   - u16 *vp = kmalloc(sizeof (u16), GFP_KERNEL);
  285 + u16 vp;
292 286 int retval;
293 287  
294   - if (!vp)
295   - return -ENOMEM;
296   -
297 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 291 netdev_dbg(dev->net, "can't read %s-%s status: %d\n",
301 292 dev->udev->bus->bus_name, dev->udev->devpath, retval);
302 293 goto done;
303 294 }
304   - status = *vp;
  295 + status = vp;
305 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 299 netdev_dbg(dev->net, "can't read USBCTL, %d\n", retval);
309 300 goto done;
310 301 }
311   - usbctl = *vp;
  302 + usbctl = vp;
312 303 nc_dump_usbctl(dev, usbctl);
313 304  
314 305 nc_register_write(dev, REG_USBCTL,
315 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 309 netdev_dbg(dev->net, "can't read TTL, %d\n", retval);
319 310 goto done;
320 311 }
321   - ttl = *vp;
  312 + ttl = vp;
322 313 // nc_dump_ttl(dev, ttl);
323 314  
324 315 nc_register_write(dev, REG_TTL,
... ... @@ -331,7 +322,6 @@
331 322 retval = 0;
332 323  
333 324 done:
334   - kfree(vp);
335 325 return retval;
336 326 }
337 327  
338 328  
... ... @@ -339,13 +329,10 @@
339 329 {
340 330 int retval;
341 331 u16 status;
342   - u16 *vp = kmalloc(sizeof (u16), GFP_KERNEL);
  332 + u16 vp;
343 333  
344   - if (!vp)
345   - return -ENOMEM;
346   - retval = nc_register_read(dev, REG_STATUS, vp);
347   - status = *vp;
348   - kfree(vp);
  334 + retval = nc_register_read(dev, REG_STATUS, &vp);
  335 + status = vp;
349 336 if (retval != 0) {
350 337 netdev_dbg(dev->net, "net1080_check_conn read - %d\n", retval);
351 338 return retval;
352 339  
353 340  
354 341  
... ... @@ -355,59 +342,22 @@
355 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 345 static void nc_ensure_sync(struct usbnet *dev)
365 346 {
366   - dev->frame_errors++;
367   - if (dev->frame_errors > 5) {
368   - struct urb *urb;
369   - struct usb_ctrlrequest *req;
370   - int status;
  347 + if (++dev->frame_errors <= 5)
  348 + return;
371 349  
372   - /* Send a flush */
373   - urb = usb_alloc_urb(0, GFP_ATOMIC);
374   - if (!urb)
375   - return;
  350 + if (usbnet_write_cmd_async(dev, REQUEST_REGISTER,
  351 + USB_DIR_OUT | USB_TYPE_VENDOR |
  352 + USB_RECIP_DEVICE,
  353 + USBCTL_FLUSH_THIS |
  354 + USBCTL_FLUSH_OTHER,
  355 + REG_USBCTL, NULL, 0))
  356 + return;
376 357  
377   - req = kmalloc(sizeof *req, GFP_ATOMIC);
378   - if (!req) {
379   - usb_free_urb(urb);
380   - return;
381   - }
382   -
383   - req->bRequestType = USB_DIR_OUT
384   - | USB_TYPE_VENDOR
385   - | USB_RECIP_DEVICE;
386   - req->bRequest = REQUEST_REGISTER;
387   - req->wValue = cpu_to_le16(USBCTL_FLUSH_THIS
388   - | USBCTL_FLUSH_OTHER);
389   - req->wIndex = cpu_to_le16(REG_USBCTL);
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   -
407   - netif_dbg(dev, rx_err, dev->net,
408   - "flush net1080; too many framing errors\n");
409   - dev->frame_errors = 0;
410   - }
  358 + netif_dbg(dev, rx_err, dev->net,
  359 + "flush net1080; too many framing errors\n");
  360 + dev->frame_errors = 0;
411 361 }
412 362  
413 363 static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb)