diff mbox

[1/2] pinctrl: pinctrl-single: Make sure we do not change bits outside of mask

Message ID 1346835718-21325-2-git-send-email-peter.ujfalusi@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Ujfalusi Sept. 5, 2012, 9:01 a.m. UTC
Use the pcs->fmask to make sure that the value is not changing (setting)
bits in areas where it should not.
To avoid situations like this:

pmx_dummy: pinmux@4a100040 {
	compatible = "pinctrl-single";
	reg = <0x4a100040 0x0196>;
	#address-cells = <1>;
	#size-cells = <0>;
	pinctrl-single,register-width = <16>;
	pinctrl-single,function-mask = <0x00ff>;
};

&pmx_dummy {
	pinctrl-names = "default";
	pinctrl-0 = <&board_pins>;

	board_pins: pinmux_board_pins {
		pinctrl-single,pins = <
			0x6c 0xf0f
			0x6e 0x10f
			0x70 0x23f
			0x72 0xa5f
		>;
	};
};

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/pinctrl/pinctrl-single.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Tony Lindgren Sept. 6, 2012, 6:59 p.m. UTC | #1
* Peter Ujfalusi <peter.ujfalusi@ti.com> [120905 02:02]:
> Use the pcs->fmask to make sure that the value is not changing (setting)
> bits in areas where it should not.
> To avoid situations like this:
> 
> pmx_dummy: pinmux@4a100040 {
> 	compatible = "pinctrl-single";
> 	reg = <0x4a100040 0x0196>;
> 	#address-cells = <1>;
> 	#size-cells = <0>;
> 	pinctrl-single,register-width = <16>;
> 	pinctrl-single,function-mask = <0x00ff>;
> };
> 
> &pmx_dummy {
> 	pinctrl-names = "default";
> 	pinctrl-0 = <&board_pins>;
> 
> 	board_pins: pinmux_board_pins {
> 		pinctrl-single,pins = <
> 			0x6c 0xf0f
> 			0x6e 0x10f
> 			0x70 0x23f
> 			0x72 0xa5f
> 		>;
> 	};
> };
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

Thanks this is a valid fix:

Acked-by: Tony Lindgren <tony@atomide.com>

> ---
>  drivers/pinctrl/pinctrl-single.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
> index 76a4260..3508631 100644
> --- a/drivers/pinctrl/pinctrl-single.c
> +++ b/drivers/pinctrl/pinctrl-single.c
> @@ -337,7 +337,7 @@ static int pcs_enable(struct pinctrl_dev *pctldev, unsigned fselector,
>  		vals = &func->vals[i];
>  		val = pcs->read(vals->reg);
>  		val &= ~pcs->fmask;
> -		val |= vals->val;
> +		val |= (vals->val & pcs->fmask);
>  		pcs->write(val, vals->reg);
>  	}
>  
> -- 
> 1.7.12
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Linus Walleij Sept. 7, 2012, 9:13 p.m. UTC | #2
On Thu, Sep 6, 2012 at 8:59 PM, Tony Lindgren <tony@atomide.com> wrote:
> * Peter Ujfalusi <peter.ujfalusi@ti.com> [120905 02:02]:
>> Use the pcs->fmask to make sure that the value is not changing (setting)
>> bits in areas where it should not.
>> To avoid situations like this:
>>
>> pmx_dummy: pinmux@4a100040 {
>>       compatible = "pinctrl-single";
>>       reg = <0x4a100040 0x0196>;
>>       #address-cells = <1>;
>>       #size-cells = <0>;
>>       pinctrl-single,register-width = <16>;
>>       pinctrl-single,function-mask = <0x00ff>;
>> };
>>
>> &pmx_dummy {
>>       pinctrl-names = "default";
>>       pinctrl-0 = <&board_pins>;
>>
>>       board_pins: pinmux_board_pins {
>>               pinctrl-single,pins = <
>>                       0x6c 0xf0f
>>                       0x6e 0x10f
>>                       0x70 0x23f
>>                       0x72 0xa5f
>>               >;
>>       };
>> };
>>
>> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
>
> Thanks this is a valid fix:
>
> Acked-by: Tony Lindgren <tony@atomide.com>

Since nothing in v3.6 is using pinctrl-simple yet, it's not a regression
right?

So can you just group this with the other pinctrl things you are
harvesting in the OMAP tree? I was going to push it for
the v3.7 cycle otherwise.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tony Lindgren Sept. 7, 2012, 9:39 p.m. UTC | #3
* Linus Walleij <linus.walleij@linaro.org> [120907 14:13]:
> On Thu, Sep 6, 2012 at 8:59 PM, Tony Lindgren <tony@atomide.com> wrote:
> > * Peter Ujfalusi <peter.ujfalusi@ti.com> [120905 02:02]:
> >> Use the pcs->fmask to make sure that the value is not changing (setting)
> >> bits in areas where it should not.
> >> To avoid situations like this:
> >>
> >> pmx_dummy: pinmux@4a100040 {
> >>       compatible = "pinctrl-single";
> >>       reg = <0x4a100040 0x0196>;
> >>       #address-cells = <1>;
> >>       #size-cells = <0>;
> >>       pinctrl-single,register-width = <16>;
> >>       pinctrl-single,function-mask = <0x00ff>;
> >> };
> >>
> >> &pmx_dummy {
> >>       pinctrl-names = "default";
> >>       pinctrl-0 = <&board_pins>;
> >>
> >>       board_pins: pinmux_board_pins {
> >>               pinctrl-single,pins = <
> >>                       0x6c 0xf0f
> >>                       0x6e 0x10f
> >>                       0x70 0x23f
> >>                       0x72 0xa5f
> >>               >;
> >>       };
> >> };
> >>
> >> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> >
> > Thanks this is a valid fix:
> >
> > Acked-by: Tony Lindgren <tony@atomide.com>
> 
> Since nothing in v3.6 is using pinctrl-simple yet, it's not a regression
> right?

Right.
 
> So can you just group this with the other pinctrl things you are
> harvesting in the OMAP tree? I was going to push it for
> the v3.7 cycle otherwise.

You can take this for v3.7, the changes I have are just adding .dts
entries to use the driver. The driver related changes are being
merged by the related driver lists.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Linus Walleij Sept. 10, 2012, 7:09 a.m. UTC | #4
On Wed, Sep 5, 2012 at 11:01 AM, Peter Ujfalusi <peter.ujfalusi@ti.com> wrote:

> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

Applied with Tony's ACK.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 76a4260..3508631 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -337,7 +337,7 @@  static int pcs_enable(struct pinctrl_dev *pctldev, unsigned fselector,
 		vals = &func->vals[i];
 		val = pcs->read(vals->reg);
 		val &= ~pcs->fmask;
-		val |= vals->val;
+		val |= (vals->val & pcs->fmask);
 		pcs->write(val, vals->reg);
 	}