lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <e6e11085-2112-62bb-6b27-e5c2395e69b2@cogentembedded.com>
Date:   Mon, 19 Sep 2016 13:30:19 +0300
From:   Sergei Shtylyov <sergei.shtylyov@...entembedded.com>
To:     Fabien Lahoudere <fabien.lahoudere@...labora.co.uk>,
        hzpeterchen@...il.com
Cc:     linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 1/3] usb: chipidea: imx: Change switch order

Hello.

On 9/19/2016 1:22 PM, Fabien Lahoudere wrote:

> Each USB controller have different behaviour, so in order to avoid to have
> several "swicth(data->index)" and lock/unlock, we prefer to get the index

   Switch.

> and then test for features if they exist for this index.
>
> Signed-off-by: Fabien Lahoudere <fabien.lahoudere@...labora.co.uk>
> ---
>  drivers/usb/chipidea/usbmisc_imx.c | 44 +++++++++++++++++++++++++-------------
>  1 file changed, 29 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c
> index 20d02a5..ed324d1 100644
> --- a/drivers/usb/chipidea/usbmisc_imx.c
> +++ b/drivers/usb/chipidea/usbmisc_imx.c
> @@ -199,31 +199,45 @@ static int usbmisc_imx53_init(struct imx_usbmisc_data *data)
>  	val |= MX53_USB_PLL_DIV_24_MHZ;
>  	writel(val, usbmisc->base + MX53_USB_OTG_PHY_CTRL_1_OFFSET);
>
> -	if (data->disable_oc) {
> -		spin_lock_irqsave(&usbmisc->lock, flags);
> -		switch (data->index) {
> +	spin_lock_irqsave(&usbmisc->lock, flags);
> +
> +	switch (data->index) {
>  		case 0:

    Should start at the same column as *switch*.

> -			reg = usbmisc->base + MX53_USB_OTG_PHY_CTRL_0_OFFSET;
> -			val = readl(reg) | MX53_BM_OVER_CUR_DIS_OTG;
> +			if (data->disable_oc) {
> +				reg = usbmisc->base + MX53_USB_OTG_PHY_CTRL_0_OFFSET;
> +				val = readl(reg) | MX53_BM_OVER_CUR_DIS_OTG;
> +				if (reg && val)

    You mean 'reg' can be NULL? If so, readl() would cause kernel oops.

> +					writel(val, reg);
> +			}
>  			break;
>  		case 1:
> -			reg = usbmisc->base + MX53_USB_OTG_PHY_CTRL_0_OFFSET;
> -			val = readl(reg) | MX53_BM_OVER_CUR_DIS_H1;
> +			if (data->disable_oc) {
> +				reg = usbmisc->base + MX53_USB_OTG_PHY_CTRL_0_OFFSET;
> +				val = readl(reg) | MX53_BM_OVER_CUR_DIS_H1;
> +				if (reg && val)
> +					writel(val, reg);

    Same here.

> +			}
>  			break;
>  		case 2:
> -			reg = usbmisc->base + MX53_USB_UH2_CTRL_OFFSET;
> -			val = readl(reg) | MX53_BM_OVER_CUR_DIS_UHx;
> +			if (data->disable_oc) {
> +				reg = usbmisc->base + MX53_USB_UH2_CTRL_OFFSET;
> +				val = readl(reg) | MX53_BM_OVER_CUR_DIS_UHx;
> +				if (reg && val)
> +					writel(val, reg);

    Same here.

> +			}
>  			break;
>  		case 3:
> -			reg = usbmisc->base + MX53_USB_UH3_CTRL_OFFSET;
> -			val = readl(reg) | MX53_BM_OVER_CUR_DIS_UHx;
> +			if (data->disable_oc) {
> +				reg = usbmisc->base + MX53_USB_UH3_CTRL_OFFSET;
> +				val = readl(reg) | MX53_BM_OVER_CUR_DIS_UHx;
> +				if (reg && val)
> +					writel(val, reg);
> +			}

    And here.

>  			break;
> -		}
> -		if (reg && val)
> -			writel(val, reg);

    Ah, the original code was wrong...

> -		spin_unlock_irqrestore(&usbmisc->lock, flags);
>  	}
[...]

MBR, Sergei

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ