Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>

authored by

Robert Baldyga and committed by
Felipe Balbi
4ce86bfa 18411c0f

+2 -16
+2 -16
drivers/usb/gadget/legacy/dbgp.c
··· 79 79 80 80 static void __disable_ep(struct usb_ep *ep) 81 81 { 82 - if (ep && ep->driver_data == dbgp.gadget) { 83 - usb_ep_disable(ep); 84 - ep->driver_data = NULL; 85 - } 82 + usb_ep_disable(ep); 86 83 } 87 84 88 85 static void dbgp_disable_ep(void) ··· 168 171 int err; 169 172 ep->desc = desc; 170 173 err = usb_ep_enable(ep); 171 - ep->driver_data = dbgp.gadget; 172 174 return err; 173 175 } 174 176 ··· 225 229 usb_ep_free_request(gadget->ep0, dbgp.req); 226 230 dbgp.req = NULL; 227 231 } 228 - 229 - gadget->ep0->driver_data = NULL; 230 232 } 231 233 232 234 #ifdef CONFIG_USB_G_DBGP_SERIAL ··· 243 249 goto fail_1; 244 250 } 245 251 246 - dbgp.i_ep->driver_data = gadget; 247 252 i_desc.wMaxPacketSize = 248 253 cpu_to_le16(USB_DEBUG_MAX_PACKET_SIZE); 249 254 250 255 dbgp.o_ep = usb_ep_autoconfig(gadget, &o_desc); 251 256 if (!dbgp.o_ep) { 252 - dbgp.i_ep->driver_data = NULL; 253 257 stp = 2; 254 - goto fail_2; 258 + goto fail_1; 255 259 } 256 260 257 - dbgp.o_ep->driver_data = gadget; 258 261 o_desc.wMaxPacketSize = 259 262 cpu_to_le16(USB_DEBUG_MAX_PACKET_SIZE); 260 263 ··· 268 277 269 278 return 0; 270 279 271 - fail_2: 272 - dbgp.i_ep->driver_data = NULL; 273 280 fail_1: 274 281 dev_dbg(&dbgp.gadget->dev, "ep config: failure (%d)\n", stp); 275 282 return -ENODEV; ··· 295 306 } 296 307 297 308 dbgp.req->length = DBGP_REQ_EP0_LEN; 298 - gadget->ep0->driver_data = gadget; 299 309 300 310 #ifdef CONFIG_USB_G_DBGP_SERIAL 301 311 dbgp.serial = kzalloc(sizeof(struct gserial), GFP_KERNEL); ··· 343 355 int err = -EOPNOTSUPP; 344 356 void *data = NULL; 345 357 u16 len = 0; 346 - 347 - gadget->ep0->driver_data = gadget; 348 358 349 359 if (request == USB_REQ_GET_DESCRIPTOR) { 350 360 switch (value>>8) {