usb: fixes for v4.15-rc2

After a long time, we finally have a good solution for how to handle
 OS descriptor on FFS. From now on we will force the Reserved field to
 be 1 as mandated by the specification.
 
 Apart from that, we have a couple other smaller fixes:
 
 - FFS learned to not sleep in atomic context.
 - UDC-core has a fix for the way we set a UDC's operating speed.
 - Renesas USB3 has a fix for the maximum number of pipes supported
 - Allow legacy drivers to be compiled without USB_ETH
 - Fix some coccinelle warnings
 -----BEGIN PGP SIGNATURE-----
 
 iQJRBAABCgA7FiEElLzh7wn96CXwjh2IzL64meEamQYFAlof73odHGZlbGlwZS5i
 YWxiaUBsaW51eC5pbnRlbC5jb20ACgkQzL64meEamQYceA//RG7Zr6FYZXlmjtQR
 klW3em7lI7706Ha7Tn+wFb6eK6Hl0NgkpuGsaRyk+JD1XK2mC5AIWAkzMJY3P+5b
 v1GDGS9AcZB5XA70wfe+o8USCF5C4YY/96zYIq4dpugKxMUuU0LnhAJMkZ34zsAD
 6oH2Wxku+wClnciMthHCegNcu2WFHIO/ef7PsamK3JGdEUC6AoOolizowc7XPhvP
 mc1Gc7MwsCkk0u1OPsAxKWZrokdrAjJPMTV79rSNnkE6FtTBtRckeuilq5yQ8aWY
 M0rJ+cYZeR8JOADINxIBucQ4d5PDemGrq6JX5aats8RvS+7q9M6xqfBugRNA/GBN
 RVut4GMuTvQQMTTLKN/MZKE2uGjIuncgOT6QmSrDqKzFg73fZAV4gh5rCvtNeccO
 y0GBHU4F8zFLdLLqPAAGWsHq19ZEa+EIuRVhB7vPR02VtjZ0UZNXymKgwzVDKhuF
 N5CHHJzqyypKqx2L2vyBkKakYb2KXZhWlNVuWaTiMCRe0SIQ/LqBjhzDK/rSHPZe
 pEA37vYlCF0UWddqBrwA4wgnJhHdv980z4SroAFpTrV6dblLGA2nkwO2ZmaHuHBO
 VSXIFLhvN1iyRrJ6cfoD5FAXliatxSwIz91HAplAzVP2W+dPUCd9qvgTyirS7BLi
 dovO1gCgVzDnKr1tj01bdycy3Fo=
 =hBSF
 -----END PGP SIGNATURE-----

Merge tag 'fixes-for-v4.15-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-linus

Felipe writes:

usb: fixes for v4.15-rc2

After a long time, we finally have a good solution for how to handle
OS descriptor on FFS. From now on we will force the Reserved field to
be 1 as mandated by the specification.

Apart from that, we have a couple other smaller fixes:

- FFS learned to not sleep in atomic context.
- UDC-core has a fix for the way we set a UDC's operating speed.
- Renesas USB3 has a fix for the maximum number of pipes supported
- Allow legacy drivers to be compiled without USB_ETH
- Fix some coccinelle warnings
This commit is contained in:
Greg Kroah-Hartman 2017-11-30 16:33:59 +00:00
commit 05bcccebda
7 changed files with 36 additions and 11 deletions

View File

@ -508,8 +508,8 @@ choice
controller, and the relevant drivers for each function declared
by the device.
source "drivers/usb/gadget/legacy/Kconfig"
endchoice
source "drivers/usb/gadget/legacy/Kconfig"
endif # USB_GADGET

View File

@ -146,7 +146,6 @@ int config_ep_by_speed(struct usb_gadget *g,
struct usb_function *f,
struct usb_ep *_ep)
{
struct usb_composite_dev *cdev = get_gadget_data(g);
struct usb_endpoint_descriptor *chosen_desc = NULL;
struct usb_descriptor_header **speed_desc = NULL;
@ -226,8 +225,12 @@ ep_found:
_ep->maxburst = comp_desc->bMaxBurst + 1;
break;
default:
if (comp_desc->bMaxBurst != 0)
if (comp_desc->bMaxBurst != 0) {
struct usb_composite_dev *cdev;
cdev = get_gadget_data(g);
ERROR(cdev, "ep0 bMaxBurst must be 0\n");
}
_ep->maxburst = 1;
break;
}

View File

@ -1012,7 +1012,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
else
ret = ep->status;
goto error_mutex;
} else if (!(req = usb_ep_alloc_request(ep->ep, GFP_KERNEL))) {
} else if (!(req = usb_ep_alloc_request(ep->ep, GFP_ATOMIC))) {
ret = -ENOMEM;
} else {
req->buf = data;
@ -2282,9 +2282,18 @@ static int __ffs_data_do_os_desc(enum ffs_os_desc_type type,
int i;
if (len < sizeof(*d) ||
d->bFirstInterfaceNumber >= ffs->interfaces_count ||
!d->Reserved1)
d->bFirstInterfaceNumber >= ffs->interfaces_count)
return -EINVAL;
if (d->Reserved1 != 1) {
/*
* According to the spec, Reserved1 must be set to 1
* but older kernels incorrectly rejected non-zero
* values. We fix it here to avoid returning EINVAL
* in response to values we used to accept.
*/
pr_debug("usb_ext_compat_desc::Reserved1 forced to 1\n");
d->Reserved1 = 1;
}
for (i = 0; i < ARRAY_SIZE(d->Reserved2); ++i)
if (d->Reserved2[i])
return -EINVAL;

View File

@ -13,6 +13,14 @@
# both kinds of controller can also support "USB On-the-Go" (CONFIG_USB_OTG).
#
menuconfig USB_GADGET_LEGACY
bool "Legacy USB Gadget Support"
help
Legacy USB gadgets are USB gadgets that do not use the USB gadget
configfs interface.
if USB_GADGET_LEGACY
config USB_ZERO
tristate "Gadget Zero (DEVELOPMENT)"
select USB_LIBCOMPOSITE
@ -490,3 +498,5 @@ config USB_G_WEBCAM
Say "y" to link the driver statically, or "m" to build a
dynamically linked module called "g_webcam".
endif

View File

@ -642,7 +642,6 @@ static const struct of_device_id bdc_of_match[] = {
static struct platform_driver bdc_driver = {
.driver = {
.name = BRCM_BDC_NAME,
.owner = THIS_MODULE,
.pm = &bdc_pm_ops,
.of_match_table = bdc_of_match,
},

View File

@ -1069,8 +1069,12 @@ static inline void usb_gadget_udc_stop(struct usb_udc *udc)
static inline void usb_gadget_udc_set_speed(struct usb_udc *udc,
enum usb_device_speed speed)
{
if (udc->gadget->ops->udc_set_speed)
udc->gadget->ops->udc_set_speed(udc->gadget, speed);
if (udc->gadget->ops->udc_set_speed) {
enum usb_device_speed s;
s = min(speed, udc->gadget->max_speed);
udc->gadget->ops->udc_set_speed(udc->gadget, s);
}
}
/**

View File

@ -252,7 +252,7 @@
#define USB3_EP0_SS_MAX_PACKET_SIZE 512
#define USB3_EP0_HSFS_MAX_PACKET_SIZE 64
#define USB3_EP0_BUF_SIZE 8
#define USB3_MAX_NUM_PIPES 30
#define USB3_MAX_NUM_PIPES 6 /* This includes PIPE 0 */
#define USB3_WAIT_US 3
#define USB3_DMA_NUM_SETTING_AREA 4
/*