浏览代码

usb: gadget: f_ecm: 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_ecm, ep->driver_data was used only for endpoint claiming
and marking endpoints as enabled, so we can simplify code by reducing
it.

Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Robert Baldyga 10 年之前
父节点
当前提交
92fbfc3884
共有 1 个文件被更改,包括 7 次插入24 次删除
  1. 7 24
      drivers/usb/gadget/function/f_ecm.c

+ 7 - 24
drivers/usb/gadget/function/f_ecm.c

@@ -541,24 +541,21 @@ static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
 		if (alt != 0)
 		if (alt != 0)
 			goto fail;
 			goto fail;
 
 
-		if (ecm->notify->driver_data) {
-			VDBG(cdev, "reset ecm control %d\n", intf);
-			usb_ep_disable(ecm->notify);
-		}
+		VDBG(cdev, "reset ecm control %d\n", intf);
+		usb_ep_disable(ecm->notify);
 		if (!(ecm->notify->desc)) {
 		if (!(ecm->notify->desc)) {
 			VDBG(cdev, "init ecm ctrl %d\n", intf);
 			VDBG(cdev, "init ecm ctrl %d\n", intf);
 			if (config_ep_by_speed(cdev->gadget, f, ecm->notify))
 			if (config_ep_by_speed(cdev->gadget, f, ecm->notify))
 				goto fail;
 				goto fail;
 		}
 		}
 		usb_ep_enable(ecm->notify);
 		usb_ep_enable(ecm->notify);
-		ecm->notify->driver_data = ecm;
 
 
 	/* Data interface has two altsettings, 0 and 1 */
 	/* Data interface has two altsettings, 0 and 1 */
 	} else if (intf == ecm->data_id) {
 	} else if (intf == ecm->data_id) {
 		if (alt > 1)
 		if (alt > 1)
 			goto fail;
 			goto fail;
 
 
-		if (ecm->port.in_ep->driver_data) {
+		if (ecm->port.in_ep->enabled) {
 			DBG(cdev, "reset ecm\n");
 			DBG(cdev, "reset ecm\n");
 			gether_disconnect(&ecm->port);
 			gether_disconnect(&ecm->port);
 		}
 		}
@@ -618,7 +615,7 @@ static int ecm_get_alt(struct usb_function *f, unsigned intf)
 
 
 	if (intf == ecm->ctrl_id)
 	if (intf == ecm->ctrl_id)
 		return 0;
 		return 0;
-	return ecm->port.in_ep->driver_data ? 1 : 0;
+	return ecm->port.in_ep->enabled ? 1 : 0;
 }
 }
 
 
 static void ecm_disable(struct usb_function *f)
 static void ecm_disable(struct usb_function *f)
@@ -628,14 +625,11 @@ static void ecm_disable(struct usb_function *f)
 
 
 	DBG(cdev, "ecm deactivated\n");
 	DBG(cdev, "ecm deactivated\n");
 
 
-	if (ecm->port.in_ep->driver_data)
+	if (ecm->port.in_ep->enabled)
 		gether_disconnect(&ecm->port);
 		gether_disconnect(&ecm->port);
 
 
-	if (ecm->notify->driver_data) {
-		usb_ep_disable(ecm->notify);
-		ecm->notify->driver_data = NULL;
-		ecm->notify->desc = NULL;
-	}
+	usb_ep_disable(ecm->notify);
+	ecm->notify->desc = NULL;
 }
 }
 
 
 /*-------------------------------------------------------------------------*/
 /*-------------------------------------------------------------------------*/
@@ -750,13 +744,11 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f)
 	if (!ep)
 	if (!ep)
 		goto fail;
 		goto fail;
 	ecm->port.in_ep = ep;
 	ecm->port.in_ep = ep;
-	ep->driver_data = cdev;	/* claim */
 
 
 	ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_out_desc);
 	ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_out_desc);
 	if (!ep)
 	if (!ep)
 		goto fail;
 		goto fail;
 	ecm->port.out_ep = ep;
 	ecm->port.out_ep = ep;
-	ep->driver_data = cdev;	/* claim */
 
 
 	/* NOTE:  a status/notification endpoint is *OPTIONAL* but we
 	/* NOTE:  a status/notification endpoint is *OPTIONAL* but we
 	 * don't treat it that way.  It's simpler, and some newer CDC
 	 * don't treat it that way.  It's simpler, and some newer CDC
@@ -766,7 +758,6 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f)
 	if (!ep)
 	if (!ep)
 		goto fail;
 		goto fail;
 	ecm->notify = ep;
 	ecm->notify = ep;
-	ep->driver_data = cdev;	/* claim */
 
 
 	status = -ENOMEM;
 	status = -ENOMEM;
 
 
@@ -820,14 +811,6 @@ fail:
 		usb_ep_free_request(ecm->notify, ecm->notify_req);
 		usb_ep_free_request(ecm->notify, ecm->notify_req);
 	}
 	}
 
 
-	/* we might as well release our claims on endpoints */
-	if (ecm->notify)
-		ecm->notify->driver_data = NULL;
-	if (ecm->port.out_ep)
-		ecm->port.out_ep->driver_data = NULL;
-	if (ecm->port.in_ep)
-		ecm->port.in_ep->driver_data = NULL;
-
 	ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
 	ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
 
 
 	return status;
 	return status;