aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/function/f_acm.c
diff options
context:
space:
mode:
authorRobert Baldyga <r.baldyga@samsung.com>2015-09-16 06:10:44 -0400
committerFelipe Balbi <balbi@ti.com>2015-09-27 11:54:31 -0400
commit4aab757ca44ad8f9d629c4bf5a513e94cff9aeb1 (patch)
tree84365b4db3e2b24edce54f38fa334a6870860675 /drivers/usb/gadget/function/f_acm.c
parent92fbfc3884733a4deae313169ef4eca20c0e6e72 (diff)
usb: gadget: f_acm: eliminate abuse of ep->driver data
Since ep->driver_data is not used for endpoint claiming, neither for enabled/disabled state storing, we can reduce number of places where we read or modify it's value, as now it has no particular meaning for function or framework logic. In case of f_acm we only need to store in ep->driver_data pointer to struct f_acm, as it's used in acm_complete_set_line_coding() callback. All other uses of ep->driver_data are now meaningless and can be safely removed. Signed-off-by: Robert Baldyga <r.baldyga@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/function/f_acm.c')
-rw-r--r--drivers/usb/gadget/function/f_acm.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/drivers/usb/gadget/function/f_acm.c b/drivers/usb/gadget/function/f_acm.c
index be9df09fde26..22e723d12d36 100644
--- a/drivers/usb/gadget/function/f_acm.c
+++ b/drivers/usb/gadget/function/f_acm.c
@@ -428,21 +428,18 @@ static int acm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
428 /* we know alt == 0, so this is an activation or a reset */ 428 /* we know alt == 0, so this is an activation or a reset */
429 429
430 if (intf == acm->ctrl_id) { 430 if (intf == acm->ctrl_id) {
431 if (acm->notify->driver_data) { 431 dev_vdbg(&cdev->gadget->dev,
432 dev_vdbg(&cdev->gadget->dev, 432 "reset acm control interface %d\n", intf);
433 "reset acm control interface %d\n", intf); 433 usb_ep_disable(acm->notify);
434 usb_ep_disable(acm->notify);
435 }
436 434
437 if (!acm->notify->desc) 435 if (!acm->notify->desc)
438 if (config_ep_by_speed(cdev->gadget, f, acm->notify)) 436 if (config_ep_by_speed(cdev->gadget, f, acm->notify))
439 return -EINVAL; 437 return -EINVAL;
440 438
441 usb_ep_enable(acm->notify); 439 usb_ep_enable(acm->notify);
442 acm->notify->driver_data = acm;
443 440
444 } else if (intf == acm->data_id) { 441 } else if (intf == acm->data_id) {
445 if (acm->port.in->driver_data) { 442 if (acm->notify->enabled) {
446 dev_dbg(&cdev->gadget->dev, 443 dev_dbg(&cdev->gadget->dev,
447 "reset acm ttyGS%d\n", acm->port_num); 444 "reset acm ttyGS%d\n", acm->port_num);
448 gserial_disconnect(&acm->port); 445 gserial_disconnect(&acm->port);
@@ -475,7 +472,6 @@ static void acm_disable(struct usb_function *f)
475 dev_dbg(&cdev->gadget->dev, "acm ttyGS%d deactivated\n", acm->port_num); 472 dev_dbg(&cdev->gadget->dev, "acm ttyGS%d deactivated\n", acm->port_num);
476 gserial_disconnect(&acm->port); 473 gserial_disconnect(&acm->port);
477 usb_ep_disable(acm->notify); 474 usb_ep_disable(acm->notify);
478 acm->notify->driver_data = NULL;
479} 475}
480 476
481/*-------------------------------------------------------------------------*/ 477/*-------------------------------------------------------------------------*/
@@ -655,19 +651,16 @@ acm_bind(struct usb_configuration *c, struct usb_function *f)
655 if (!ep) 651 if (!ep)
656 goto fail; 652 goto fail;
657 acm->port.in = ep; 653 acm->port.in = ep;
658 ep->driver_data = cdev; /* claim */
659 654
660 ep = usb_ep_autoconfig(cdev->gadget, &acm_fs_out_desc); 655 ep = usb_ep_autoconfig(cdev->gadget, &acm_fs_out_desc);
661 if (!ep) 656 if (!ep)
662 goto fail; 657 goto fail;
663 acm->port.out = ep; 658 acm->port.out = ep;
664 ep->driver_data = cdev; /* claim */
665 659
666 ep = usb_ep_autoconfig(cdev->gadget, &acm_fs_notify_desc); 660 ep = usb_ep_autoconfig(cdev->gadget, &acm_fs_notify_desc);
667 if (!ep) 661 if (!ep)
668 goto fail; 662 goto fail;
669 acm->notify = ep; 663 acm->notify = ep;
670 ep->driver_data = cdev; /* claim */
671 664
672 /* allocate notification */ 665 /* allocate notification */
673 acm->notify_req = gs_alloc_req(ep, 666 acm->notify_req = gs_alloc_req(ep,
@@ -709,14 +702,6 @@ fail:
709 if (acm->notify_req) 702 if (acm->notify_req)
710 gs_free_req(acm->notify, acm->notify_req); 703 gs_free_req(acm->notify, acm->notify_req);
711 704
712 /* we might as well release our claims on endpoints */
713 if (acm->notify)
714 acm->notify->driver_data = NULL;
715 if (acm->port.out)
716 acm->port.out->driver_data = NULL;
717 if (acm->port.in)
718 acm->port.in->driver_data = NULL;
719
720 ERROR(cdev, "%s/%p: can't bind, err %d\n", f->name, f, status); 705 ERROR(cdev, "%s/%p: can't bind, err %d\n", f->name, f, status);
721 706
722 return status; 707 return status;