* drivers: usb: dwc3: A question...
@ 2017-02-09 8:14 ` Gustavo A. R. Silva
0 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2017-02-09 8:14 UTC (permalink / raw)
To: balbi, Greg KH; +Cc: linux-usb, linux-omap, linux-kernel, Peter Senna Tschudin
Hello everybody,
I ran into the following piece of code at
drivers/usb/dwc3/dwc3-omap.c:218 (linux-next)
218static void dwc3_omap_set_mailbox(struct dwc3_omap *omap,
219 enum omap_dwc3_vbus_id_status status)
220{
221 int ret;
222 u32 val;
223
224 switch (status) {
225 case OMAP_DWC3_ID_GROUND:
226 if (omap->vbus_reg) {
227 ret = regulator_enable(omap->vbus_reg);
228 if (ret) {
229 dev_err(omap->dev, "regulator
enable failed\n");
230 return;
231 }
232 }
233
234 val = dwc3_omap_read_utmi_ctrl(omap);
235 val &= ~USBOTGSS_UTMI_OTG_CTRL_IDDIG;
236 dwc3_omap_write_utmi_ctrl(omap, val);
237 break;
238
239 case OMAP_DWC3_VBUS_VALID:
240 val = dwc3_omap_read_utmi_ctrl(omap);
241 val &= ~USBOTGSS_UTMI_OTG_CTRL_SESSEND;
242 val |= USBOTGSS_UTMI_OTG_CTRL_VBUSVALID
243 | USBOTGSS_UTMI_OTG_CTRL_SESSVALID;
244 dwc3_omap_write_utmi_ctrl(omap, val);
245 break;
246
247 case OMAP_DWC3_ID_FLOAT:
248 if (omap->vbus_reg)
249 regulator_disable(omap->vbus_reg);
250 val = dwc3_omap_read_utmi_ctrl(omap);
251 val |= USBOTGSS_UTMI_OTG_CTRL_IDDIG;
252 dwc3_omap_write_utmi_ctrl(omap, val);
253
254 case OMAP_DWC3_VBUS_OFF:
255 val = dwc3_omap_read_utmi_ctrl(omap);
256 val &= ~(USBOTGSS_UTMI_OTG_CTRL_SESSVALID
257 | USBOTGSS_UTMI_OTG_CTRL_VBUSVALID);
258 val |= USBOTGSS_UTMI_OTG_CTRL_SESSEND;
259 dwc3_omap_write_utmi_ctrl(omap, val);
260 break;
261
262 default:
263 dev_WARN(omap->dev, "invalid state\n");
264 }
265}
The thing is that the case for OMAP_DWC3_ID_FLOAT is not terminated by
a break statement, and it falls through to the next case
OMAP_DWC3_VBUS_OFF.
My question here is if for any reason this code is intentional?
In case it is not, I will write a patch to fix this, but first it
would be great to hear any comment about it.
Thank you
--
Gustavo A. R. Silva
^ permalink raw reply [flat|nested] 4+ messages in thread
* drivers: usb: dwc3: A question...
@ 2017-02-09 8:14 ` Gustavo A. R. Silva
0 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2017-02-09 8:14 UTC (permalink / raw)
To: balbi-DgEjT+Ai2ygdnm+yROfE0A, Greg KH
Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-omap-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Peter Senna Tschudin
Hello everybody,
I ran into the following piece of code at
drivers/usb/dwc3/dwc3-omap.c:218 (linux-next)
218static void dwc3_omap_set_mailbox(struct dwc3_omap *omap,
219 enum omap_dwc3_vbus_id_status status)
220{
221 int ret;
222 u32 val;
223
224 switch (status) {
225 case OMAP_DWC3_ID_GROUND:
226 if (omap->vbus_reg) {
227 ret = regulator_enable(omap->vbus_reg);
228 if (ret) {
229 dev_err(omap->dev, "regulator
enable failed\n");
230 return;
231 }
232 }
233
234 val = dwc3_omap_read_utmi_ctrl(omap);
235 val &= ~USBOTGSS_UTMI_OTG_CTRL_IDDIG;
236 dwc3_omap_write_utmi_ctrl(omap, val);
237 break;
238
239 case OMAP_DWC3_VBUS_VALID:
240 val = dwc3_omap_read_utmi_ctrl(omap);
241 val &= ~USBOTGSS_UTMI_OTG_CTRL_SESSEND;
242 val |= USBOTGSS_UTMI_OTG_CTRL_VBUSVALID
243 | USBOTGSS_UTMI_OTG_CTRL_SESSVALID;
244 dwc3_omap_write_utmi_ctrl(omap, val);
245 break;
246
247 case OMAP_DWC3_ID_FLOAT:
248 if (omap->vbus_reg)
249 regulator_disable(omap->vbus_reg);
250 val = dwc3_omap_read_utmi_ctrl(omap);
251 val |= USBOTGSS_UTMI_OTG_CTRL_IDDIG;
252 dwc3_omap_write_utmi_ctrl(omap, val);
253
254 case OMAP_DWC3_VBUS_OFF:
255 val = dwc3_omap_read_utmi_ctrl(omap);
256 val &= ~(USBOTGSS_UTMI_OTG_CTRL_SESSVALID
257 | USBOTGSS_UTMI_OTG_CTRL_VBUSVALID);
258 val |= USBOTGSS_UTMI_OTG_CTRL_SESSEND;
259 dwc3_omap_write_utmi_ctrl(omap, val);
260 break;
261
262 default:
263 dev_WARN(omap->dev, "invalid state\n");
264 }
265}
The thing is that the case for OMAP_DWC3_ID_FLOAT is not terminated by
a break statement, and it falls through to the next case
OMAP_DWC3_VBUS_OFF.
My question here is if for any reason this code is intentional?
In case it is not, I will write a patch to fix this, but first it
would be great to hear any comment about it.
Thank you
--
Gustavo A. R. Silva
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: drivers: usb: dwc3: A question...
@ 2017-02-09 8:45 ` Roger Quadros
0 siblings, 0 replies; 4+ messages in thread
From: Roger Quadros @ 2017-02-09 8:45 UTC (permalink / raw)
To: Gustavo A. R. Silva, balbi, Greg KH
Cc: linux-usb, linux-omap, linux-kernel, Peter Senna Tschudin
Hi,
On 09/02/17 10:14, Gustavo A. R. Silva wrote:
> Hello everybody,
>
> I ran into the following piece of code at drivers/usb/dwc3/dwc3-omap.c:218 (linux-next)
>
> 218static void dwc3_omap_set_mailbox(struct dwc3_omap *omap,
> 219 enum omap_dwc3_vbus_id_status status)
> 220{
> 221 int ret;
> 222 u32 val;
> 223
> 224 switch (status) {
> 225 case OMAP_DWC3_ID_GROUND:
> 226 if (omap->vbus_reg) {
> 227 ret = regulator_enable(omap->vbus_reg);
> 228 if (ret) {
> 229 dev_err(omap->dev, "regulator enable failed\n");
> 230 return;
> 231 }
> 232 }
> 233
> 234 val = dwc3_omap_read_utmi_ctrl(omap);
> 235 val &= ~USBOTGSS_UTMI_OTG_CTRL_IDDIG;
> 236 dwc3_omap_write_utmi_ctrl(omap, val);
> 237 break;
> 238
> 239 case OMAP_DWC3_VBUS_VALID:
> 240 val = dwc3_omap_read_utmi_ctrl(omap);
> 241 val &= ~USBOTGSS_UTMI_OTG_CTRL_SESSEND;
> 242 val |= USBOTGSS_UTMI_OTG_CTRL_VBUSVALID
> 243 | USBOTGSS_UTMI_OTG_CTRL_SESSVALID;
> 244 dwc3_omap_write_utmi_ctrl(omap, val);
> 245 break;
> 246
> 247 case OMAP_DWC3_ID_FLOAT:
> 248 if (omap->vbus_reg)
> 249 regulator_disable(omap->vbus_reg);
> 250 val = dwc3_omap_read_utmi_ctrl(omap);
> 251 val |= USBOTGSS_UTMI_OTG_CTRL_IDDIG;
> 252 dwc3_omap_write_utmi_ctrl(omap, val);
> 253
> 254 case OMAP_DWC3_VBUS_OFF:
> 255 val = dwc3_omap_read_utmi_ctrl(omap);
> 256 val &= ~(USBOTGSS_UTMI_OTG_CTRL_SESSVALID
> 257 | USBOTGSS_UTMI_OTG_CTRL_VBUSVALID);
> 258 val |= USBOTGSS_UTMI_OTG_CTRL_SESSEND;
> 259 dwc3_omap_write_utmi_ctrl(omap, val);
> 260 break;
> 261
> 262 default:
> 263 dev_WARN(omap->dev, "invalid state\n");
> 264 }
> 265}
>
> The thing is that the case for OMAP_DWC3_ID_FLOAT is not terminated by a break statement, and it falls through to the next case OMAP_DWC3_VBUS_OFF.
>
> My question here is if for any reason this code is intentional?
>
> In case it is not, I will write a patch to fix this, but first it would be great to hear any comment about it.
You are right that it is a mistake. Thanks for pointing out.
I had already submitted a patch
https://patchwork.kernel.org/patch/9532195/
Felipe,
I think we should pick it up regardless of the rest of the series and mark for -stable.
Please do add
Reported-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Thanks :)
cheers,
-roger
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: drivers: usb: dwc3: A question...
@ 2017-02-09 8:45 ` Roger Quadros
0 siblings, 0 replies; 4+ messages in thread
From: Roger Quadros @ 2017-02-09 8:45 UTC (permalink / raw)
To: Gustavo A. R. Silva, balbi-DgEjT+Ai2ygdnm+yROfE0A, Greg KH
Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-omap-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Peter Senna Tschudin
Hi,
On 09/02/17 10:14, Gustavo A. R. Silva wrote:
> Hello everybody,
>
> I ran into the following piece of code at drivers/usb/dwc3/dwc3-omap.c:218 (linux-next)
>
> 218static void dwc3_omap_set_mailbox(struct dwc3_omap *omap,
> 219 enum omap_dwc3_vbus_id_status status)
> 220{
> 221 int ret;
> 222 u32 val;
> 223
> 224 switch (status) {
> 225 case OMAP_DWC3_ID_GROUND:
> 226 if (omap->vbus_reg) {
> 227 ret = regulator_enable(omap->vbus_reg);
> 228 if (ret) {
> 229 dev_err(omap->dev, "regulator enable failed\n");
> 230 return;
> 231 }
> 232 }
> 233
> 234 val = dwc3_omap_read_utmi_ctrl(omap);
> 235 val &= ~USBOTGSS_UTMI_OTG_CTRL_IDDIG;
> 236 dwc3_omap_write_utmi_ctrl(omap, val);
> 237 break;
> 238
> 239 case OMAP_DWC3_VBUS_VALID:
> 240 val = dwc3_omap_read_utmi_ctrl(omap);
> 241 val &= ~USBOTGSS_UTMI_OTG_CTRL_SESSEND;
> 242 val |= USBOTGSS_UTMI_OTG_CTRL_VBUSVALID
> 243 | USBOTGSS_UTMI_OTG_CTRL_SESSVALID;
> 244 dwc3_omap_write_utmi_ctrl(omap, val);
> 245 break;
> 246
> 247 case OMAP_DWC3_ID_FLOAT:
> 248 if (omap->vbus_reg)
> 249 regulator_disable(omap->vbus_reg);
> 250 val = dwc3_omap_read_utmi_ctrl(omap);
> 251 val |= USBOTGSS_UTMI_OTG_CTRL_IDDIG;
> 252 dwc3_omap_write_utmi_ctrl(omap, val);
> 253
> 254 case OMAP_DWC3_VBUS_OFF:
> 255 val = dwc3_omap_read_utmi_ctrl(omap);
> 256 val &= ~(USBOTGSS_UTMI_OTG_CTRL_SESSVALID
> 257 | USBOTGSS_UTMI_OTG_CTRL_VBUSVALID);
> 258 val |= USBOTGSS_UTMI_OTG_CTRL_SESSEND;
> 259 dwc3_omap_write_utmi_ctrl(omap, val);
> 260 break;
> 261
> 262 default:
> 263 dev_WARN(omap->dev, "invalid state\n");
> 264 }
> 265}
>
> The thing is that the case for OMAP_DWC3_ID_FLOAT is not terminated by a break statement, and it falls through to the next case OMAP_DWC3_VBUS_OFF.
>
> My question here is if for any reason this code is intentional?
>
> In case it is not, I will write a patch to fix this, but first it would be great to hear any comment about it.
You are right that it is a mistake. Thanks for pointing out.
I had already submitted a patch
https://patchwork.kernel.org/patch/9532195/
Felipe,
I think we should pick it up regardless of the rest of the series and mark for -stable.
Please do add
Reported-by: Gustavo A. R. Silva <garsilva-L1vi/lXTdts+Va1GwOuvDg@public.gmane.org>
Thanks :)
cheers,
-roger
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-02-09 9:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-09 8:14 drivers: usb: dwc3: A question Gustavo A. R. Silva
2017-02-09 8:14 ` Gustavo A. R. Silva
2017-02-09 8:45 ` Roger Quadros
2017-02-09 8:45 ` Roger Quadros
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.