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

Felipe writes:

usb: fixes for v4.8-rc6

Unfortunately we have a bogus dwc3 patch leaked through the cracks and
got merged into Linus' HEAD. That patch ended up causing off-by-1 error
in our TRB accounting logic. Thankfully John Youn found out the problem
and we provided a revert to the bogus dwc3 patch in no time.

Apart from this off-by-1 error, we have two fixes to the Renesas drivers,
a small fix to our generic phy driver, a NULL pointer dereference fix for
f_eem and a build warning fix in dwc3.

Changed files
+25 -7
drivers
usb
dwc3
gadget
function
udc
phy
renesas_usbhs
+3 -1
drivers/usb/dwc3/dwc3-pci.c
··· 249 249 250 250 return pm_runtime_get(&dwc3->dev); 251 251 } 252 + #endif /* CONFIG_PM */ 252 253 254 + #ifdef CONFIG_PM_SLEEP 253 255 static int dwc3_pci_pm_dummy(struct device *dev) 254 256 { 255 257 /* ··· 264 262 */ 265 263 return 0; 266 264 } 267 - #endif /* CONFIG_PM */ 265 + #endif /* CONFIG_PM_SLEEP */ 268 266 269 267 static struct dev_pm_ops dwc3_pci_dev_pm_ops = { 270 268 SET_SYSTEM_SLEEP_PM_OPS(dwc3_pci_pm_dummy, dwc3_pci_pm_dummy)
+4 -1
drivers/usb/dwc3/gadget.c
··· 884 884 return DWC3_TRB_NUM - 1; 885 885 } 886 886 887 - trbs_left = dep->trb_dequeue - dep->trb_enqueue - 1; 887 + trbs_left = dep->trb_dequeue - dep->trb_enqueue; 888 888 trbs_left &= (DWC3_TRB_NUM - 1); 889 + 890 + if (dep->trb_dequeue < dep->trb_enqueue) 891 + trbs_left--; 889 892 890 893 return trbs_left; 891 894 }
+1 -1
drivers/usb/gadget/function/f_eem.c
··· 342 342 struct sk_buff *skb2 = NULL; 343 343 struct usb_ep *in = port->in_ep; 344 344 int headroom, tailroom, padlen = 0; 345 - u16 len = skb->len; 345 + u16 len; 346 346 347 347 if (!skb) 348 348 return NULL;
+2
drivers/usb/gadget/udc/renesas_usb3.c
··· 106 106 107 107 /* DRD_CON */ 108 108 #define DRD_CON_PERI_CON BIT(24) 109 + #define DRD_CON_VBOUT BIT(0) 109 110 110 111 /* USB_INT_ENA_1 and USB_INT_STA_1 */ 111 112 #define USB_INT_1_B3_PLLWKUP BIT(31) ··· 364 363 { 365 364 /* FIXME: How to change host / peripheral mode as well? */ 366 365 usb3_set_bit(usb3, DRD_CON_PERI_CON, USB3_DRD_CON); 366 + usb3_clear_bit(usb3, DRD_CON_VBOUT, USB3_DRD_CON); 367 367 368 368 usb3_write(usb3, ~0, USB3_USB_INT_STA_1); 369 369 usb3_enable_irq_1(usb3, USB_INT_1_VBUS_CNG);
+6 -2
drivers/usb/phy/phy-generic.c
··· 144 144 int usb_gen_phy_init(struct usb_phy *phy) 145 145 { 146 146 struct usb_phy_generic *nop = dev_get_drvdata(phy->dev); 147 + int ret; 147 148 148 149 if (!IS_ERR(nop->vcc)) { 149 150 if (regulator_enable(nop->vcc)) 150 151 dev_err(phy->dev, "Failed to enable power\n"); 151 152 } 152 153 153 - if (!IS_ERR(nop->clk)) 154 - clk_prepare_enable(nop->clk); 154 + if (!IS_ERR(nop->clk)) { 155 + ret = clk_prepare_enable(nop->clk); 156 + if (ret) 157 + return ret; 158 + } 155 159 156 160 nop_reset(nop); 157 161
+9 -2
drivers/usb/renesas_usbhs/mod.c
··· 282 282 if (usbhs_mod_is_host(priv)) 283 283 usbhs_write(priv, INTSTS1, ~irq_state.intsts1 & INTSTS1_MAGIC); 284 284 285 - usbhs_write(priv, BRDYSTS, ~irq_state.brdysts); 285 + /* 286 + * The driver should not clear the xxxSTS after the line of 287 + * "call irq callback functions" because each "if" statement is 288 + * possible to call the callback function for avoiding any side effects. 289 + */ 290 + if (irq_state.intsts0 & BRDY) 291 + usbhs_write(priv, BRDYSTS, ~irq_state.brdysts); 286 292 usbhs_write(priv, NRDYSTS, ~irq_state.nrdysts); 287 - usbhs_write(priv, BEMPSTS, ~irq_state.bempsts); 293 + if (irq_state.intsts0 & BEMP) 294 + usbhs_write(priv, BEMPSTS, ~irq_state.bempsts); 288 295 289 296 /* 290 297 * call irq callback functions