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

usb: gadget: legacy: tcm: 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 tcm, ep->driver_data was used only for endpoint claiming so
we can simplify code by reducing it. We also remove give_back_ep()
function which is not needed after all - when error code is returned
from bind() function, composite will release all endpoints anyway.

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
5cd22f80 4ce86bfa

-18
-18
drivers/usb/gadget/legacy/tcm_usb_gadget.c
··· 2018 2018 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 2019 2019 }; 2020 2020 2021 - static void give_back_ep(struct usb_ep **pep) 2022 - { 2023 - struct usb_ep *ep = *pep; 2024 - if (!ep) 2025 - return; 2026 - ep->driver_data = NULL; 2027 - } 2028 - 2029 2021 static int usbg_bind(struct usb_configuration *c, struct usb_function *f) 2030 2022 { 2031 2023 struct f_uas *fu = to_f_uas(f); ··· 2037 2045 &uasp_bi_ep_comp_desc); 2038 2046 if (!ep) 2039 2047 goto ep_fail; 2040 - 2041 - ep->driver_data = fu; 2042 2048 fu->ep_in = ep; 2043 2049 2044 2050 ep = usb_ep_autoconfig_ss(gadget, &uasp_ss_bo_desc, 2045 2051 &uasp_bo_ep_comp_desc); 2046 2052 if (!ep) 2047 2053 goto ep_fail; 2048 - ep->driver_data = fu; 2049 2054 fu->ep_out = ep; 2050 2055 2051 2056 ep = usb_ep_autoconfig_ss(gadget, &uasp_ss_status_desc, 2052 2057 &uasp_status_in_ep_comp_desc); 2053 2058 if (!ep) 2054 2059 goto ep_fail; 2055 - ep->driver_data = fu; 2056 2060 fu->ep_status = ep; 2057 2061 2058 2062 ep = usb_ep_autoconfig_ss(gadget, &uasp_ss_cmd_desc, 2059 2063 &uasp_cmd_comp_desc); 2060 2064 if (!ep) 2061 2065 goto ep_fail; 2062 - ep->driver_data = fu; 2063 2066 fu->ep_cmd = ep; 2064 2067 2065 2068 /* Assume endpoint addresses are the same for both speeds */ ··· 2078 2091 return 0; 2079 2092 ep_fail: 2080 2093 pr_err("Can't claim all required eps\n"); 2081 - 2082 - give_back_ep(&fu->ep_in); 2083 - give_back_ep(&fu->ep_out); 2084 - give_back_ep(&fu->ep_status); 2085 - give_back_ep(&fu->ep_cmd); 2086 2094 return -ENOTSUPP; 2087 2095 } 2088 2096