diff options
author | Stefan Agner <stefan@agner.ch> | 2014-09-06 12:25:04 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2014-09-23 05:45:47 -0400 |
commit | 3dac1918a4912cea9375e76cb3916b751cef22db (patch) | |
tree | 7497cb27472c195901735c1b5e6fa926331bd72e /drivers/pinctrl | |
parent | 3ccc11f6b82c34646c8a4233278251d9e9e99390 (diff) |
pinctrl: imx: detect uninitialized pins
The pinctrl driver initialized the register offsets for the pins
with 0. On Vybrid an offset of 0 is a valid offset for the pinctrl
mux register. So far, this was solved using the ZERO_OFFSET_VALID
flag which allowed offsets of 0. However, this does not allow to
verify whether a pins struct imx_pmx_func was initialized or not.
Use signed offset values for register offsets and initialize those
with -1 in order to detect uninitialized offset values reliable.
Signed-off-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r-- | drivers/pinctrl/freescale/pinctrl-imx.c | 9 | ||||
-rw-r--r-- | drivers/pinctrl/freescale/pinctrl-imx.h | 7 | ||||
-rw-r--r-- | drivers/pinctrl/freescale/pinctrl-vf610.c | 2 |
3 files changed, 9 insertions, 9 deletions
diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c index e89268c09e4c..f2446769247f 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx.c +++ b/drivers/pinctrl/freescale/pinctrl-imx.c | |||
@@ -204,7 +204,7 @@ static int imx_pmx_set(struct pinctrl_dev *pctldev, unsigned selector, | |||
204 | pin_id = pin->pin; | 204 | pin_id = pin->pin; |
205 | pin_reg = &info->pin_regs[pin_id]; | 205 | pin_reg = &info->pin_regs[pin_id]; |
206 | 206 | ||
207 | if (!(info->flags & ZERO_OFFSET_VALID) && !pin_reg->mux_reg) { | 207 | if (pin_reg->mux_reg == -1) { |
208 | dev_err(ipctl->dev, "Pin(%s) does not support mux function\n", | 208 | dev_err(ipctl->dev, "Pin(%s) does not support mux function\n", |
209 | info->pins[pin_id].name); | 209 | info->pins[pin_id].name); |
210 | return -EINVAL; | 210 | return -EINVAL; |
@@ -308,7 +308,7 @@ static int imx_pinconf_get(struct pinctrl_dev *pctldev, | |||
308 | const struct imx_pinctrl_soc_info *info = ipctl->info; | 308 | const struct imx_pinctrl_soc_info *info = ipctl->info; |
309 | const struct imx_pin_reg *pin_reg = &info->pin_regs[pin_id]; | 309 | const struct imx_pin_reg *pin_reg = &info->pin_regs[pin_id]; |
310 | 310 | ||
311 | if (!(info->flags & ZERO_OFFSET_VALID) && !pin_reg->conf_reg) { | 311 | if (pin_reg->conf_reg == -1) { |
312 | dev_err(info->dev, "Pin(%s) does not support config function\n", | 312 | dev_err(info->dev, "Pin(%s) does not support config function\n", |
313 | info->pins[pin_id].name); | 313 | info->pins[pin_id].name); |
314 | return -EINVAL; | 314 | return -EINVAL; |
@@ -331,7 +331,7 @@ static int imx_pinconf_set(struct pinctrl_dev *pctldev, | |||
331 | const struct imx_pin_reg *pin_reg = &info->pin_regs[pin_id]; | 331 | const struct imx_pin_reg *pin_reg = &info->pin_regs[pin_id]; |
332 | int i; | 332 | int i; |
333 | 333 | ||
334 | if (!(info->flags & ZERO_OFFSET_VALID) && !pin_reg->conf_reg) { | 334 | if (pin_reg->conf_reg == -1) { |
335 | dev_err(info->dev, "Pin(%s) does not support config function\n", | 335 | dev_err(info->dev, "Pin(%s) does not support config function\n", |
336 | info->pins[pin_id].name); | 336 | info->pins[pin_id].name); |
337 | return -EINVAL; | 337 | return -EINVAL; |
@@ -586,10 +586,11 @@ int imx_pinctrl_probe(struct platform_device *pdev, | |||
586 | if (!ipctl) | 586 | if (!ipctl) |
587 | return -ENOMEM; | 587 | return -ENOMEM; |
588 | 588 | ||
589 | info->pin_regs = devm_kzalloc(&pdev->dev, sizeof(*info->pin_regs) * | 589 | info->pin_regs = devm_kmalloc(&pdev->dev, sizeof(*info->pin_regs) * |
590 | info->npins, GFP_KERNEL); | 590 | info->npins, GFP_KERNEL); |
591 | if (!info->pin_regs) | 591 | if (!info->pin_regs) |
592 | return -ENOMEM; | 592 | return -ENOMEM; |
593 | memset(info->pin_regs, 0xff, sizeof(*info->pin_regs) * info->npins); | ||
593 | 594 | ||
594 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 595 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
595 | ipctl->base = devm_ioremap_resource(&pdev->dev, res); | 596 | ipctl->base = devm_ioremap_resource(&pdev->dev, res); |
diff --git a/drivers/pinctrl/freescale/pinctrl-imx.h b/drivers/pinctrl/freescale/pinctrl-imx.h index db408b057000..49e55d39f7c8 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx.h +++ b/drivers/pinctrl/freescale/pinctrl-imx.h | |||
@@ -67,8 +67,8 @@ struct imx_pmx_func { | |||
67 | * @conf_reg: config register offset | 67 | * @conf_reg: config register offset |
68 | */ | 68 | */ |
69 | struct imx_pin_reg { | 69 | struct imx_pin_reg { |
70 | u16 mux_reg; | 70 | s16 mux_reg; |
71 | u16 conf_reg; | 71 | s16 conf_reg; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | struct imx_pinctrl_soc_info { | 74 | struct imx_pinctrl_soc_info { |
@@ -83,8 +83,7 @@ struct imx_pinctrl_soc_info { | |||
83 | unsigned int flags; | 83 | unsigned int flags; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | #define ZERO_OFFSET_VALID 0x1 | 86 | #define SHARE_MUX_CONF_REG 0x1 |
87 | #define SHARE_MUX_CONF_REG 0x2 | ||
88 | 87 | ||
89 | #define NO_MUX 0x0 | 88 | #define NO_MUX 0x0 |
90 | #define NO_PAD 0x0 | 89 | #define NO_PAD 0x0 |
diff --git a/drivers/pinctrl/freescale/pinctrl-vf610.c b/drivers/pinctrl/freescale/pinctrl-vf610.c index bddd913d28ba..b788e1578954 100644 --- a/drivers/pinctrl/freescale/pinctrl-vf610.c +++ b/drivers/pinctrl/freescale/pinctrl-vf610.c | |||
@@ -299,7 +299,7 @@ static const struct pinctrl_pin_desc vf610_pinctrl_pads[] = { | |||
299 | static struct imx_pinctrl_soc_info vf610_pinctrl_info = { | 299 | static struct imx_pinctrl_soc_info vf610_pinctrl_info = { |
300 | .pins = vf610_pinctrl_pads, | 300 | .pins = vf610_pinctrl_pads, |
301 | .npins = ARRAY_SIZE(vf610_pinctrl_pads), | 301 | .npins = ARRAY_SIZE(vf610_pinctrl_pads), |
302 | .flags = ZERO_OFFSET_VALID | SHARE_MUX_CONF_REG, | 302 | .flags = SHARE_MUX_CONF_REG, |
303 | }; | 303 | }; |
304 | 304 | ||
305 | static struct of_device_id vf610_pinctrl_of_match[] = { | 305 | static struct of_device_id vf610_pinctrl_of_match[] = { |