diff mbox

vt8500: pinctrl: Change devicetree data parsing

Message ID 1390458701-30238-1-git-send-email-linux@prisktech.co.nz (mailing list archive)
State New, archived
Headers show

Commit Message

Tony Prisk Jan. 23, 2014, 6:31 a.m. UTC
Due to an assumption in the VT8500 pinctrl driver, the value passed
from devicetree for 'wm,pull' was not explicitly translated before
being passed to pinconf.

With changes to 'enum pin_config_param', PIN_CONFIG_BIAS_PULL_(UP/DOWN)
no longer map 1-to-1 with the expected values in devicetree.

This patch adds a small translation between the devicetree values (0..2)
and the enum pin_config_param equivalent values.

Signed-off-by: Tony Prisk <linux@prisktech.co.nz>
---
 drivers/pinctrl/vt8500/pinctrl-wmt.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Linus Walleij Jan. 23, 2014, 8:43 a.m. UTC | #1
On Thu, Jan 23, 2014 at 7:31 AM, Tony Prisk <linux@prisktech.co.nz> wrote:

> Due to an assumption in the VT8500 pinctrl driver, the value passed
> from devicetree for 'wm,pull' was not explicitly translated before
> being passed to pinconf.
>
> With changes to 'enum pin_config_param', PIN_CONFIG_BIAS_PULL_(UP/DOWN)
> no longer map 1-to-1 with the expected values in devicetree.
>
> This patch adds a small translation between the devicetree values (0..2)
> and the enum pin_config_param equivalent values.
>
> Signed-off-by: Tony Prisk <linux@prisktech.co.nz>

Isn't this a regression fix for stable?

> +       switch (pull) {
> +       case 0:
> +               pull = PIN_CONFIG_BIAS_DISABLE;
> +               break;
> +       case 1:
> +               pull = PIN_CONFIG_BIAS_PULL_DOWN;
> +               break;
> +       case 2:
> +               pull = PIN_CONFIG_BIAS_PULL_UP;
> +               break;
> +       }
>         configs[0] = pull;

1. You're not adding a default: clause (I bet the static checkers will
warn about this!)

2. Please conjure a different variable name for the thing that
actually gets set in the config so we see we are mapping one
thing to another and not just altering an existing variable.

Yours,
Linus Walleij
Tony Prisk Jan. 23, 2014, 9 a.m. UTC | #2
On 23/01/14 21:43, Linus Walleij wrote:
> On Thu, Jan 23, 2014 at 7:31 AM, Tony Prisk <linux@prisktech.co.nz> wrote:
>
>> Due to an assumption in the VT8500 pinctrl driver, the value passed
>> from devicetree for 'wm,pull' was not explicitly translated before
>> being passed to pinconf.
>>
>> With changes to 'enum pin_config_param', PIN_CONFIG_BIAS_PULL_(UP/DOWN)
>> no longer map 1-to-1 with the expected values in devicetree.
>>
>> This patch adds a small translation between the devicetree values (0..2)
>> and the enum pin_config_param equivalent values.
>>
>> Signed-off-by: Tony Prisk <linux@prisktech.co.nz>
> Isn't this a regression fix for stable?
>
I wasn't sure how to handle this since it's been a problem since 3.10 
but no one has mentioned it (or patched it).

I assume this is because:
a) pinctrl is only used for I2C in mainline - and there is no mainline 
I2C consumer device drivers for the WonderMedia devices
b) most  users are using the non-mainline kernel which has more support 
(as nasty as some of it is).

Regards
Tony Prisk
diff mbox

Patch

diff --git a/drivers/pinctrl/vt8500/pinctrl-wmt.c b/drivers/pinctrl/vt8500/pinctrl-wmt.c
index 39aec08..fa4fdbd 100644
--- a/drivers/pinctrl/vt8500/pinctrl-wmt.c
+++ b/drivers/pinctrl/vt8500/pinctrl-wmt.c
@@ -276,6 +276,17 @@  static int wmt_pctl_dt_node_to_map_pull(struct wmt_pinctrl_data *data,
 	if (!configs)
 		return -ENOMEM;
 
+	switch (pull) {
+	case 0:
+		pull = PIN_CONFIG_BIAS_DISABLE;
+		break;
+	case 1:
+		pull = PIN_CONFIG_BIAS_PULL_DOWN;
+		break;
+	case 2:
+		pull = PIN_CONFIG_BIAS_PULL_UP;
+		break;
+	}
 	configs[0] = pull;
 
 	map->type = PIN_MAP_TYPE_CONFIGS_PIN;