Re: [PATCH v1 12/14] usb: dwc2: Clear fifo_map when resetting core.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Fri, Apr 19, 2019 at 1:06 PM Artur Petrosyan
<Arthur.Petrosyan@xxxxxxxxxxxx> wrote:
>
> If core enters host hibernation when switching from
> device mode to host mode disconnection of host cable
> asserts a WARNING in dwc2_hsotg_init_fifo() that
> fifo_map is not cleared.
>
> To avoid the WARNING, fifo_map should be cleared
> in dwc2_core_reset() function.
>
> - Cleared fifo_map when resetting the core.
>
> Signed-off-by: Artur Petrosyan <arturp@xxxxxxxxxxxx>
> ---
>  drivers/usb/dwc2/core.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
> index fb471d18a3de..fbbd6a2f10ad 100644
> --- a/drivers/usb/dwc2/core.c
> +++ b/drivers/usb/dwc2/core.c
> @@ -532,6 +532,12 @@ int dwc2_core_reset(struct dwc2_hsotg *hsotg, bool skip_wait)
>         greset |= GRSTCTL_CSFTRST;
>         dwc2_writel(hsotg, greset, GRSTCTL);
>
> +       /* Clear fifo_map */
> +       #if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \
> +               IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
> +       hsotg->fifo_map = 0;
> +       #endif /* CONFIG_USB_DWC2_PERIPHERAL || CONFIG_USB_DWC2_DUAL_ROLE */

Please please no sprinkling "#if" statements in code like this.  Here
lies the way to madness.  The right way to do this in the style of the
Linux kernel is to add a function that is a "static inline" no-op when
the options are compiled out.

As one example you can see my recent patch:

https://lkml.kernel.org/r/20190425154021.4465-1-dianders@xxxxxxxxxxxx



-Doug



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux