From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Fabien Lahoudere <fabien.lahoudere@collabora.co.uk>,
hzpeterchen@gmail.com
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/3] usb: chipidea: imx: Change switch order
Date: Mon, 19 Sep 2016 13:30:19 +0300 [thread overview]
Message-ID: <e6e11085-2112-62bb-6b27-e5c2395e69b2@cogentembedded.com> (raw)
In-Reply-To: <1474280531-17598-1-git-send-email-fabien.lahoudere@collabora.co.uk>
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@collabora.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
prev parent reply other threads:[~2016-09-19 10:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-19 10:22 Fabien Lahoudere
2016-09-19 10:22 ` [PATCH v3 2/3] usb: chipidea: imx: configure imx for ULPI phy Fabien Lahoudere
2016-09-19 10:22 ` [PATCH v3 3/3] usb: chipidea: imx: Add binding to disable USB 60Mhz clock Fabien Lahoudere
2016-09-19 10:30 ` Sergei Shtylyov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e6e11085-2112-62bb-6b27-e5c2395e69b2@cogentembedded.com \
--to=sergei.shtylyov@cogentembedded.com \
--cc=fabien.lahoudere@collabora.co.uk \
--cc=hzpeterchen@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®