devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 4/4] ARM: pinctrl: sunxi-pinctrl: fix pin funtion can not be match correctly.
@ 2017-12-13 14:47 hao_zhang
  2017-12-13 15:45 ` Maxime Ripard
  2017-12-20  8:05 ` Linus Walleij
  0 siblings, 2 replies; 5+ messages in thread
From: hao_zhang @ 2017-12-13 14:47 UTC (permalink / raw)
  To: thierry.reding, robh+dt, mark.rutland, linux, wens, linus.walleij,
	maxime.ripard
  Cc: linux-kernel, devicetree, linux-arm-kernel, linux-pwm,
	linux-amlogic, hao5781286

Pin function can not be match correctly when SUNXI_PIN describe with
mutiple variant and same function.

such as:
on pinctrl-sun4i-a10.c

SUNXI_PIN(SUNXI_PINCTRL_PIN(B, 2),
		SUNXI_FUNCTION(0x0, "gpio_in"),
		SUNXI_FUNCTION(0x1, "gpio_out"),
		SUNXI_FUNCTION_VARIANT(0x2, "pwm",    /* PWM0 */
			PINCTRL_SUN4I_A10 |
			PINCTRL_SUN7I_A20),
		SUNXI_FUNCTION_VARIANT(0x3, "pwm",    /* PWM0 */
			PINCTRL_SUN8I_R40)),

it would always match to the first variant function
(PINCTRL_SUN4I_A10, PINCTRL_SUN7I_A20)

so we should add variant compare on it.

Signed-off-by: hao_zhang <hao5781286@gmail.com>
---
 drivers/pinctrl/sunxi/pinctrl-sunxi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
index 4b6cb25..f23e74e 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
@@ -83,9 +83,11 @@ sunxi_pinctrl_desc_find_function_by_name(struct sunxi_pinctrl *pctl,
 			struct sunxi_desc_function *func = pin->functions;
 
 			while (func->name) {
-				if (!strcmp(func->name, func_name))
+				if (!strcmp(func->name, func_name)) {
+					if (!(func->variant) ||
+					   (func->variant & pctl->variant))
 					return func;
-
+				}
 				func++;
 			}
 		}
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 4/4] ARM: pinctrl: sunxi-pinctrl: fix pin funtion can not be match correctly.
  2017-12-13 14:47 [PATCH v4 4/4] ARM: pinctrl: sunxi-pinctrl: fix pin funtion can not be match correctly hao_zhang
@ 2017-12-13 15:45 ` Maxime Ripard
       [not found]   ` <20171213154549.5zn4uxhsssqw3pb7-ZC1Zs529Oq4@public.gmane.org>
  2017-12-20  8:05 ` Linus Walleij
  1 sibling, 1 reply; 5+ messages in thread
From: Maxime Ripard @ 2017-12-13 15:45 UTC (permalink / raw)
  To: hao_zhang
  Cc: thierry.reding, robh+dt, mark.rutland, linux, wens, linus.walleij,
	linux-kernel, devicetree, linux-arm-kernel, linux-pwm,
	linux-amlogic

[-- Attachment #1: Type: text/plain, Size: 1775 bytes --]

Hi,

Thanks for your patch!

On Wed, Dec 13, 2017 at 10:47:48PM +0800, hao_zhang wrote:
> Pin function can not be match correctly when SUNXI_PIN describe with
> mutiple variant and same function.
> 
> such as:
> on pinctrl-sun4i-a10.c
> 
> SUNXI_PIN(SUNXI_PINCTRL_PIN(B, 2),
> 		SUNXI_FUNCTION(0x0, "gpio_in"),
> 		SUNXI_FUNCTION(0x1, "gpio_out"),
> 		SUNXI_FUNCTION_VARIANT(0x2, "pwm",    /* PWM0 */
> 			PINCTRL_SUN4I_A10 |
> 			PINCTRL_SUN7I_A20),
> 		SUNXI_FUNCTION_VARIANT(0x3, "pwm",    /* PWM0 */
> 			PINCTRL_SUN8I_R40)),
> 
> it would always match to the first variant function
> (PINCTRL_SUN4I_A10, PINCTRL_SUN7I_A20)
> 
> so we should add variant compare on it.
> 
> Signed-off-by: hao_zhang <hao5781286@gmail.com>
> ---
>  drivers/pinctrl/sunxi/pinctrl-sunxi.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> index 4b6cb25..f23e74e 100644
> --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> @@ -83,9 +83,11 @@ sunxi_pinctrl_desc_find_function_by_name(struct sunxi_pinctrl *pctl,
>  			struct sunxi_desc_function *func = pin->functions;
>  
>  			while (func->name) {
> -				if (!strcmp(func->name, func_name))
> +				if (!strcmp(func->name, func_name)) {
> +					if (!(func->variant) ||
> +					   (func->variant & pctl->variant))

I guess it would be better to have:
	if (!strcmp(func->name, func_name) &&
	    (!func->variant || (func->variant & pctl->variant)))

Once fixed,
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 4/4] ARM: pinctrl: sunxi-pinctrl: fix pin funtion can not be match correctly.
  2017-12-13 14:47 [PATCH v4 4/4] ARM: pinctrl: sunxi-pinctrl: fix pin funtion can not be match correctly hao_zhang
  2017-12-13 15:45 ` Maxime Ripard
@ 2017-12-20  8:05 ` Linus Walleij
  1 sibling, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2017-12-20  8:05 UTC (permalink / raw)
  To: hao_zhang
  Cc: thierry.reding@gmail.com, Rob Herring, Mark Rutland, Russell King,
	Chen-Yu Tsai, Maxime Ripard, linux-kernel@vger.kernel.org,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Linux ARM, linux-pwm, open list:ARM/Amlogic Meson...

On Wed, Dec 13, 2017 at 3:47 PM, hao_zhang <hao5781286@gmail.com> wrote:
> Pin function can not be match correctly when SUNXI_PIN describe with
> mutiple variant and same function.
>
> such as:
> on pinctrl-sun4i-a10.c
>
> SUNXI_PIN(SUNXI_PINCTRL_PIN(B, 2),
>                 SUNXI_FUNCTION(0x0, "gpio_in"),
>                 SUNXI_FUNCTION(0x1, "gpio_out"),
>                 SUNXI_FUNCTION_VARIANT(0x2, "pwm",    /* PWM0 */
>                         PINCTRL_SUN4I_A10 |
>                         PINCTRL_SUN7I_A20),
>                 SUNXI_FUNCTION_VARIANT(0x3, "pwm",    /* PWM0 */
>                         PINCTRL_SUN8I_R40)),
>
> it would always match to the first variant function
> (PINCTRL_SUN4I_A10, PINCTRL_SUN7I_A20)
>
> so we should add variant compare on it.
>
> Signed-off-by: hao_zhang <hao5781286@gmail.com>

Please resend patch with Maxime's suggestions fixed and his
ACK added so I can apply it.

I can take this patch separatelt, it does not need to be part of
the PWM series.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 4/4] ARM: pinctrl: sunxi-pinctrl: fix pin funtion can not be match correctly.
       [not found]   ` <20171213154549.5zn4uxhsssqw3pb7-ZC1Zs529Oq4@public.gmane.org>
@ 2018-01-08 11:08     ` Hao Zhang
  2018-01-08 15:46       ` Maxime Ripard
  0 siblings, 1 reply; 5+ messages in thread
From: Hao Zhang @ 2018-01-08 11:08 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Thierry Reding, robh+dt-DgEjT+Ai2ygdnm+yROfE0A, Mark Rutland,
	linux-I+IVW8TIWO2tmTQ+vhA3Yw, Chen-Yu Tsai, Linus Walleij,
	open list,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	moderated list:ARM/Allwinner sunXi SoC support,
	linux-pwm-u79uwXL29TY76Z2rM5mHXA

2017-12-13 23:45 GMT+08:00 Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>:
> Hi,
>
> Thanks for your patch!
>
> On Wed, Dec 13, 2017 at 10:47:48PM +0800, hao_zhang wrote:
>> Pin function can not be match correctly when SUNXI_PIN describe with
>> mutiple variant and same function.
>>
>> such as:
>> on pinctrl-sun4i-a10.c
>>
>> SUNXI_PIN(SUNXI_PINCTRL_PIN(B, 2),
>>               SUNXI_FUNCTION(0x0, "gpio_in"),
>>               SUNXI_FUNCTION(0x1, "gpio_out"),
>>               SUNXI_FUNCTION_VARIANT(0x2, "pwm",    /* PWM0 */
>>                       PINCTRL_SUN4I_A10 |
>>                       PINCTRL_SUN7I_A20),
>>               SUNXI_FUNCTION_VARIANT(0x3, "pwm",    /* PWM0 */
>>                       PINCTRL_SUN8I_R40)),
>>
>> it would always match to the first variant function
>> (PINCTRL_SUN4I_A10, PINCTRL_SUN7I_A20)
>>
>> so we should add variant compare on it.
>>
>> Signed-off-by: hao_zhang <hao5781286-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>> ---
>>  drivers/pinctrl/sunxi/pinctrl-sunxi.c | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
>> index 4b6cb25..f23e74e 100644
>> --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
>> +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
>> @@ -83,9 +83,11 @@ sunxi_pinctrl_desc_find_function_by_name(struct sunxi_pinctrl *pctl,
>>                       struct sunxi_desc_function *func = pin->functions;
>>
>>                       while (func->name) {
>> -                             if (!strcmp(func->name, func_name))
>> +                             if (!strcmp(func->name, func_name)) {
>> +                                     if (!(func->variant) ||
>> +                                        (func->variant & pctl->variant))
>
> I guess it would be better to have:
>         if (!strcmp(func->name, func_name) &&
>             (!func->variant || (func->variant & pctl->variant)))

It would over 80 characters, can i change it by this ?
if (!strcmp(func->name, func_name) &&
         (func->variant & pctl->variant ||
          !func->variant))

>
> Once fixed,
> Acked-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
>
> Thanks!
> Maxime
>
> --
> Maxime Ripard, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe devicetree" 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] 5+ messages in thread

* Re: [PATCH v4 4/4] ARM: pinctrl: sunxi-pinctrl: fix pin funtion can not be match correctly.
  2018-01-08 11:08     ` Hao Zhang
@ 2018-01-08 15:46       ` Maxime Ripard
  0 siblings, 0 replies; 5+ messages in thread
From: Maxime Ripard @ 2018-01-08 15:46 UTC (permalink / raw)
  To: Hao Zhang
  Cc: Thierry Reding, robh+dt, Mark Rutland, linux, Chen-Yu Tsai,
	Linus Walleij, open list,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	moderated list:ARM/Allwinner sunXi SoC support, linux-pwm

[-- Attachment #1: Type: text/plain, Size: 2516 bytes --]

On Mon, Jan 08, 2018 at 07:08:53PM +0800, Hao Zhang wrote:
> 2017-12-13 23:45 GMT+08:00 Maxime Ripard <maxime.ripard@free-electrons.com>:
> > Hi,
> >
> > Thanks for your patch!
> >
> > On Wed, Dec 13, 2017 at 10:47:48PM +0800, hao_zhang wrote:
> >> Pin function can not be match correctly when SUNXI_PIN describe with
> >> mutiple variant and same function.
> >>
> >> such as:
> >> on pinctrl-sun4i-a10.c
> >>
> >> SUNXI_PIN(SUNXI_PINCTRL_PIN(B, 2),
> >>               SUNXI_FUNCTION(0x0, "gpio_in"),
> >>               SUNXI_FUNCTION(0x1, "gpio_out"),
> >>               SUNXI_FUNCTION_VARIANT(0x2, "pwm",    /* PWM0 */
> >>                       PINCTRL_SUN4I_A10 |
> >>                       PINCTRL_SUN7I_A20),
> >>               SUNXI_FUNCTION_VARIANT(0x3, "pwm",    /* PWM0 */
> >>                       PINCTRL_SUN8I_R40)),
> >>
> >> it would always match to the first variant function
> >> (PINCTRL_SUN4I_A10, PINCTRL_SUN7I_A20)
> >>
> >> so we should add variant compare on it.
> >>
> >> Signed-off-by: hao_zhang <hao5781286@gmail.com>
> >> ---
> >>  drivers/pinctrl/sunxi/pinctrl-sunxi.c | 6 ++++--
> >>  1 file changed, 4 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> >> index 4b6cb25..f23e74e 100644
> >> --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> >> +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> >> @@ -83,9 +83,11 @@ sunxi_pinctrl_desc_find_function_by_name(struct sunxi_pinctrl *pctl,
> >>                       struct sunxi_desc_function *func = pin->functions;
> >>
> >>                       while (func->name) {
> >> -                             if (!strcmp(func->name, func_name))
> >> +                             if (!strcmp(func->name, func_name)) {
> >> +                                     if (!(func->variant) ||
> >> +                                        (func->variant & pctl->variant))
> >
> > I guess it would be better to have:
> >         if (!strcmp(func->name, func_name) &&
> >             (!func->variant || (func->variant & pctl->variant)))
> 
> It would over 80 characters, can i change it by this ?
> if (!strcmp(func->name, func_name) &&
>          (func->variant & pctl->variant ||
>           !func->variant))

It feels more natural to have !func->variant first, but feel free to
have it split that way yes.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-01-08 15:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-13 14:47 [PATCH v4 4/4] ARM: pinctrl: sunxi-pinctrl: fix pin funtion can not be match correctly hao_zhang
2017-12-13 15:45 ` Maxime Ripard
     [not found]   ` <20171213154549.5zn4uxhsssqw3pb7-ZC1Zs529Oq4@public.gmane.org>
2018-01-08 11:08     ` Hao Zhang
2018-01-08 15:46       ` Maxime Ripard
2017-12-20  8:05 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).