linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] pinctrl: pinctrl-imx: fix map setting problem if NO_PAD_CTL is set
@ 2012-06-20 10:13 Hui Wang
  2012-06-20 10:28 ` Dong Aisheng
  2012-06-20 19:25 ` Linus Walleij
  0 siblings, 2 replies; 5+ messages in thread
From: Hui Wang @ 2012-06-20 10:13 UTC (permalink / raw)
  To: linux-arm-kernel

new_map is allocated according to map_num instead of grp->npins,
if a pin or some pins of a group has NO_PAD_CTL property, the map_num
and the grp->npin are different definitely.

When we set mapping information to the new_map[], we should skip those
pins with NO_PAD_CTL from index, otherwise it is possible the driver
will aceesss to a unallocated region.

Cc: Dong Aisheng <dong.aisheng@linaro.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Hui Wang <jason77.wang@gmail.com>
---
In the v2, according to dong.aisheng's suggestion, change to use j as index.

 drivers/pinctrl/pinctrl-imx.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-imx.c b/drivers/pinctrl/pinctrl-imx.c
index dd6d93a..2bafb5d 100644
--- a/drivers/pinctrl/pinctrl-imx.c
+++ b/drivers/pinctrl/pinctrl-imx.c
@@ -146,7 +146,7 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev,
 	struct pinctrl_map *new_map;
 	struct device_node *parent;
 	int map_num = 1;
-	int i;
+	int i, j;
 
 	/*
 	 * first find the group of this node and check if we need create
@@ -184,13 +184,14 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev,
 
 	/* create config map */
 	new_map++;
-	for (i = 0; i < grp->npins; i++) {
+	for (i = j = 0; i < grp->npins; i++) {
 		if (!(grp->configs[i] & IMX_NO_PAD_CTL)) {
-			new_map[i].type = PIN_MAP_TYPE_CONFIGS_PIN;
-			new_map[i].data.configs.group_or_pin =
+			new_map[j].type = PIN_MAP_TYPE_CONFIGS_PIN;
+			new_map[j].data.configs.group_or_pin =
 					pin_get_name(pctldev, grp->pins[i]);
-			new_map[i].data.configs.configs = &grp->configs[i];
-			new_map[i].data.configs.num_configs = 1;
+			new_map[j].data.configs.configs = &grp->configs[i];
+			new_map[j].data.configs.num_configs = 1;
+			j++;
 		}
 	}
 
-- 
1.7.11

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

* [PATCH v2] pinctrl: pinctrl-imx: fix map setting problem if NO_PAD_CTL is set
  2012-06-20 10:13 [PATCH v2] pinctrl: pinctrl-imx: fix map setting problem if NO_PAD_CTL is set Hui Wang
@ 2012-06-20 10:28 ` Dong Aisheng
  2012-06-20 19:25 ` Linus Walleij
  1 sibling, 0 replies; 5+ messages in thread
From: Dong Aisheng @ 2012-06-20 10:28 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jun 20, 2012 at 06:13:47PM +0800, Hui Wang wrote:
> new_map is allocated according to map_num instead of grp->npins,
> if a pin or some pins of a group has NO_PAD_CTL property, the map_num
> and the grp->npin are different definitely.
> 
> When we set mapping information to the new_map[], we should skip those
> pins with NO_PAD_CTL from index, otherwise it is possible the driver
> will aceesss to a unallocated region.
> 
> Cc: Dong Aisheng <dong.aisheng@linaro.org>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Shawn Guo <shawn.guo@linaro.org>
> Signed-off-by: Hui Wang <jason77.wang@gmail.com>
> ---
> In the v2, according to dong.aisheng's suggestion, change to use j as index.
> 

Acked-by: Dong Aisheng <dong.aisheng@linaro.org>

Thanks

Regards
Dong Aisheng

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

* [PATCH v2] pinctrl: pinctrl-imx: fix map setting problem if NO_PAD_CTL is set
  2012-06-20 10:13 [PATCH v2] pinctrl: pinctrl-imx: fix map setting problem if NO_PAD_CTL is set Hui Wang
  2012-06-20 10:28 ` Dong Aisheng
@ 2012-06-20 19:25 ` Linus Walleij
  2012-06-21  1:08   ` Hui Wang
  2012-06-21  2:13   ` Dong Aisheng
  1 sibling, 2 replies; 5+ messages in thread
From: Linus Walleij @ 2012-06-20 19:25 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jun 20, 2012 at 12:13 PM, Hui Wang <jason77.wang@gmail.com> wrote:

> new_map is allocated according to map_num instead of grp->npins,
> if a pin or some pins of a group has NO_PAD_CTL property, the map_num
> and the grp->npin are different definitely.
>
> When we set mapping information to the new_map[], we should skip those
> pins with NO_PAD_CTL from index, otherwise it is possible the driver
> will aceesss to a unallocated region.
>
> Cc: Dong Aisheng <dong.aisheng@linaro.org>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Shawn Guo <shawn.guo@linaro.org>
> Signed-off-by: Hui Wang <jason77.wang@gmail.com>
> ---
> In the v2, according to dong.aisheng's suggestion, change to use j as index.

OK applied this v2 version. Is this a serious bug fix that is causing
regressions right now and needs to go into the -rc:s for v3.5 or can it wait
for v3.6?

Thanks,
Linus Walleij

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

* [PATCH v2] pinctrl: pinctrl-imx: fix map setting problem if NO_PAD_CTL is set
  2012-06-20 19:25 ` Linus Walleij
@ 2012-06-21  1:08   ` Hui Wang
  2012-06-21  2:13   ` Dong Aisheng
  1 sibling, 0 replies; 5+ messages in thread
From: Hui Wang @ 2012-06-21  1:08 UTC (permalink / raw)
  To: linux-arm-kernel

Linus Walleij wrote:
> On Wed, Jun 20, 2012 at 12:13 PM, Hui Wang <jason77.wang@gmail.com> wrote:
>
>   
>> new_map is allocated according to map_num instead of grp->npins,
>> if a pin or some pins of a group has NO_PAD_CTL property, the map_num
>> and the grp->npin are different definitely.
>>
>> When we set mapping information to the new_map[], we should skip those
>> pins with NO_PAD_CTL from index, otherwise it is possible the driver
>> will aceesss to a unallocated region.
>>
>> Cc: Dong Aisheng <dong.aisheng@linaro.org>
>> Cc: Linus Walleij <linus.walleij@linaro.org>
>> Cc: Shawn Guo <shawn.guo@linaro.org>
>> Signed-off-by: Hui Wang <jason77.wang@gmail.com>
>> ---
>> In the v2, according to dong.aisheng's suggestion, change to use j as index.
>>     
>
> OK applied this v2 version. Is this a serious bug fix that is causing
> regressions right now and needs to go into the -rc:s for v3.5 or can it wait
> for v3.6?
>   
It is a bug fix, but currently no {board}.dts can trigger this bug, so 
it  can wait for v3.6.

Regards,
Hui.
> Thanks,
> Linus Walleij
>
>   

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

* [PATCH v2] pinctrl: pinctrl-imx: fix map setting problem if NO_PAD_CTL is set
  2012-06-20 19:25 ` Linus Walleij
  2012-06-21  1:08   ` Hui Wang
@ 2012-06-21  2:13   ` Dong Aisheng
  1 sibling, 0 replies; 5+ messages in thread
From: Dong Aisheng @ 2012-06-21  2:13 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jun 20, 2012 at 09:25:35PM +0200, Linus Walleij wrote:
> On Wed, Jun 20, 2012 at 12:13 PM, Hui Wang <jason77.wang@gmail.com> wrote:
> 
> > new_map is allocated according to map_num instead of grp->npins,
> > if a pin or some pins of a group has NO_PAD_CTL property, the map_num
> > and the grp->npin are different definitely.
> >
> > When we set mapping information to the new_map[], we should skip those
> > pins with NO_PAD_CTL from index, otherwise it is possible the driver
> > will aceesss to a unallocated region.
> >
> > Cc: Dong Aisheng <dong.aisheng@linaro.org>
> > Cc: Linus Walleij <linus.walleij@linaro.org>
> > Cc: Shawn Guo <shawn.guo@linaro.org>
> > Signed-off-by: Hui Wang <jason77.wang@gmail.com>
> > ---
> > In the v2, according to dong.aisheng's suggestion, change to use j as index.
> 
> OK applied this v2 version. Is this a serious bug fix that is causing
> regressions right now and needs to go into the -rc:s for v3.5 or can it wait
> for v3.6?
> 
Yes, it's a serious bug fix.
Although still not triggered by current dts file but it did may block some legal using
defined in binding doc.
So can it go into rc?

Regards
Dong Aisheng

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

end of thread, other threads:[~2012-06-21  2:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-20 10:13 [PATCH v2] pinctrl: pinctrl-imx: fix map setting problem if NO_PAD_CTL is set Hui Wang
2012-06-20 10:28 ` Dong Aisheng
2012-06-20 19:25 ` Linus Walleij
2012-06-21  1:08   ` Hui Wang
2012-06-21  2:13   ` Dong Aisheng

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).