mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fabien Lahoudere <fabien.lahoudere@collabora.co.uk>
To: Peter Chen <hzpeterchen@gmail.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 1/3] usb: chipidea: imx: Change switch order
Date: Wed, 21 Sep 2016 09:51:16 +0200	[thread overview]
Message-ID: <f867337a-d2be-0993-85c2-9892707588f7@collabora.co.uk> (raw)
In-Reply-To: <20160921065739.GB23435@b29397-desktop>

Hi,

On 21/09/16 08:57, Peter Chen wrote:
> On Mon, Sep 19, 2016 at 01:45:38PM +0200, 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.
>> This patch also remove useless test of reg and val. Those two values cannot
>> be NULL.
>
> Sorry, I can't see the benefits of this change.
> Considering certain controller doesn't have oc feature, with current
> code it only needs one comparison (flag disable_oc), but with your
> changes, it needs two comparisons.

The benefits are visible with next patches only but you ask me to split 
it, so I do.

Thanks

Fabien

>
> Peter
>>
>> Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.co.uk>
>> ---
>>  drivers/usb/chipidea/usbmisc_imx.c | 38 ++++++++++++++++++++++++--------------
>>  1 file changed, 24 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c
>> index 20d02a5..9549821 100644
>> --- a/drivers/usb/chipidea/usbmisc_imx.c
>> +++ b/drivers/usb/chipidea/usbmisc_imx.c
>> @@ -199,31 +199,41 @@ 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) {
>> -		case 0:
>> +	spin_lock_irqsave(&usbmisc->lock, flags);
>> +
>> +	switch (data->index) {
>> +	case 0:
>> +		if (data->disable_oc) {
>>  			reg = usbmisc->base + MX53_USB_OTG_PHY_CTRL_0_OFFSET;
>>  			val = readl(reg) | MX53_BM_OVER_CUR_DIS_OTG;
>> -			break;
>> -		case 1:
>> +			writel(val, reg);
>> +		}
>> +		break;
>> +	case 1:
>> +		if (data->disable_oc) {
>>  			reg = usbmisc->base + MX53_USB_OTG_PHY_CTRL_0_OFFSET;
>>  			val = readl(reg) | MX53_BM_OVER_CUR_DIS_H1;
>> -			break;
>> -		case 2:
>> +			writel(val, reg);
>> +		}
>> +		break;
>> +	case 2:
>> +		if (data->disable_oc) {
>>  			reg = usbmisc->base + MX53_USB_UH2_CTRL_OFFSET;
>>  			val = readl(reg) | MX53_BM_OVER_CUR_DIS_UHx;
>> -			break;
>> -		case 3:
>> +			writel(val, reg);
>> +		}
>> +		break;
>> +	case 3:
>> +		if (data->disable_oc) {
>>  			reg = usbmisc->base + MX53_USB_UH3_CTRL_OFFSET;
>>  			val = readl(reg) | MX53_BM_OVER_CUR_DIS_UHx;
>> -			break;
>> -		}
>> -		if (reg && val)
>>  			writel(val, reg);
>> -		spin_unlock_irqrestore(&usbmisc->lock, flags);
>> +		}
>> +		break;
>>  	}
>>
>> +	spin_unlock_irqrestore(&usbmisc->lock, flags);
>> +
>>  	return 0;
>>  }
>>
>> --
>> 2.1.4
>>
>

  reply	other threads:[~2016-09-21  7:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-19 11:45 [PATCH v4 0/3] usb: chipidea: imx: Add USB configuration for imx53 Fabien Lahoudere
2016-09-19 11:45 ` [PATCH v4 1/3] usb: chipidea: imx: Change switch order Fabien Lahoudere
2016-09-21  6:57   ` Peter Chen
2016-09-21  7:51     ` Fabien Lahoudere [this message]
2016-09-19 11:45 ` [PATCH v4 2/3] usb: chipidea: imx: configure imx for ULPI phy Fabien Lahoudere
2016-09-21  7:12   ` Peter Chen
2016-09-21  7:54     ` Fabien Lahoudere
2016-09-19 11:45 ` [PATCH v4 3/3] usb: chipidea: imx: Add binding to disable USB 60Mhz clock Fabien Lahoudere
2016-09-21  7:19   ` Peter Chen

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=f867337a-d2be-0993-85c2-9892707588f7@collabora.co.uk \
    --to=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®