提交 4ce86bfa 编写于 作者: R Robert Baldyga 提交者: Felipe Balbi

usb: gadget: legacy: dbgp: 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 dbgp, 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: NRobert Baldyga <r.baldyga@samsung.com>
Signed-off-by: NFelipe Balbi <balbi@ti.com>
上级 18411c0f
...@@ -79,10 +79,7 @@ static int dbgp_consume(char *buf, unsigned len) ...@@ -79,10 +79,7 @@ static int dbgp_consume(char *buf, unsigned len)
static void __disable_ep(struct usb_ep *ep) static void __disable_ep(struct usb_ep *ep)
{ {
if (ep && ep->driver_data == dbgp.gadget) { usb_ep_disable(ep);
usb_ep_disable(ep);
ep->driver_data = NULL;
}
} }
static void dbgp_disable_ep(void) static void dbgp_disable_ep(void)
...@@ -171,7 +168,6 @@ static int __enable_ep(struct usb_ep *ep, struct usb_endpoint_descriptor *desc) ...@@ -171,7 +168,6 @@ static int __enable_ep(struct usb_ep *ep, struct usb_endpoint_descriptor *desc)
int err; int err;
ep->desc = desc; ep->desc = desc;
err = usb_ep_enable(ep); err = usb_ep_enable(ep);
ep->driver_data = dbgp.gadget;
return err; return err;
} }
...@@ -229,8 +225,6 @@ static void dbgp_unbind(struct usb_gadget *gadget) ...@@ -229,8 +225,6 @@ static void dbgp_unbind(struct usb_gadget *gadget)
usb_ep_free_request(gadget->ep0, dbgp.req); usb_ep_free_request(gadget->ep0, dbgp.req);
dbgp.req = NULL; dbgp.req = NULL;
} }
gadget->ep0->driver_data = NULL;
} }
#ifdef CONFIG_USB_G_DBGP_SERIAL #ifdef CONFIG_USB_G_DBGP_SERIAL
...@@ -249,18 +243,15 @@ static int dbgp_configure_endpoints(struct usb_gadget *gadget) ...@@ -249,18 +243,15 @@ static int dbgp_configure_endpoints(struct usb_gadget *gadget)
goto fail_1; goto fail_1;
} }
dbgp.i_ep->driver_data = gadget;
i_desc.wMaxPacketSize = i_desc.wMaxPacketSize =
cpu_to_le16(USB_DEBUG_MAX_PACKET_SIZE); cpu_to_le16(USB_DEBUG_MAX_PACKET_SIZE);
dbgp.o_ep = usb_ep_autoconfig(gadget, &o_desc); dbgp.o_ep = usb_ep_autoconfig(gadget, &o_desc);
if (!dbgp.o_ep) { if (!dbgp.o_ep) {
dbgp.i_ep->driver_data = NULL;
stp = 2; stp = 2;
goto fail_2; goto fail_1;
} }
dbgp.o_ep->driver_data = gadget;
o_desc.wMaxPacketSize = o_desc.wMaxPacketSize =
cpu_to_le16(USB_DEBUG_MAX_PACKET_SIZE); cpu_to_le16(USB_DEBUG_MAX_PACKET_SIZE);
...@@ -277,8 +268,6 @@ static int dbgp_configure_endpoints(struct usb_gadget *gadget) ...@@ -277,8 +268,6 @@ static int dbgp_configure_endpoints(struct usb_gadget *gadget)
return 0; return 0;
fail_2:
dbgp.i_ep->driver_data = NULL;
fail_1: fail_1:
dev_dbg(&dbgp.gadget->dev, "ep config: failure (%d)\n", stp); dev_dbg(&dbgp.gadget->dev, "ep config: failure (%d)\n", stp);
return -ENODEV; return -ENODEV;
...@@ -306,7 +295,6 @@ static int dbgp_bind(struct usb_gadget *gadget, ...@@ -306,7 +295,6 @@ static int dbgp_bind(struct usb_gadget *gadget,
} }
dbgp.req->length = DBGP_REQ_EP0_LEN; dbgp.req->length = DBGP_REQ_EP0_LEN;
gadget->ep0->driver_data = gadget;
#ifdef CONFIG_USB_G_DBGP_SERIAL #ifdef CONFIG_USB_G_DBGP_SERIAL
dbgp.serial = kzalloc(sizeof(struct gserial), GFP_KERNEL); dbgp.serial = kzalloc(sizeof(struct gserial), GFP_KERNEL);
...@@ -356,8 +344,6 @@ static int dbgp_setup(struct usb_gadget *gadget, ...@@ -356,8 +344,6 @@ static int dbgp_setup(struct usb_gadget *gadget,
void *data = NULL; void *data = NULL;
u16 len = 0; u16 len = 0;
gadget->ep0->driver_data = gadget;
if (request == USB_REQ_GET_DESCRIPTOR) { if (request == USB_REQ_GET_DESCRIPTOR) {
switch (value>>8) { switch (value>>8) {
case USB_DT_DEVICE: case USB_DT_DEVICE:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册