Skip to contentSkip to conversation

ARM: pinctrl: sunxi-pinctrl: fix pin funtion can not be match correctly.

PATCH RESEND In review hao_zhang 3 participants 3 messages Jan 9, 2018 – Jan 10, 2018

Subsystems (3)
lore
Share & tools
lore

hao_zhang

author
#0 lore raw

PATCH RESEND 1/1 ARM: pinctrl: sunxi-pinctrl: fix pin funtion can not be match correctly.

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.

Regards
Hao

---
 drivers/pinctrl/sunxi/pinctrl-sunxi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pinctrl/sunxi/pinctrl-sunxi.c +3 -1
index 4b6cb25..131adf7 100644
@@ -83,7 +83,9 @@ 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) &&
+					(!func->variant ||
+					func->variant & pctl->variant))
 					return func;
 
 				func++;
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw
Quoted 18 lines · hao_zhang

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)

Quoted 6 lines

so we should add variant compare on it.

Regards
Hao

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180109/d70f6fc5/attachment-0001.sig>
#2 lore raw
In reply to hao_zhang
Quoted 18 lines · hao_zhang

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)

Quoted 6 lines

so we should add variant compare on it.

Regards
Hao

Patch applied with Maxime's ACK.

Yours,
Linus Walleij