linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: berlin: fix the dt_free_map function
@ 2014-09-10  9:15 Antoine Tenart
  2014-09-11 21:04 ` Sebastian Hesselbarth
  2014-09-23 15:02 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Antoine Tenart @ 2014-09-10  9:15 UTC (permalink / raw)
  To: linus.walleij
  Cc: Antoine Tenart, sebastian.hesselbarth, alexandre.belloni,
	thomas.petazzoni, zmxu, jszhang, linux-arm-kernel, linux-kernel

The berlin_pinctrl_dt_free_map function tries to free memory
allocated and handled by the of subsystem. This is wrong and
already handled by pinctrl_dt_free_maps() which calls
of_node_put().

This patch fixes the Berlin pinctrl way of freeing its maps,
avoiding a kernel BUG(), by using the common
pinctrl_utils_dt_free_map function instead.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/pinctrl/berlin/berlin.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/drivers/pinctrl/berlin/berlin.c b/drivers/pinctrl/berlin/berlin.c
index 86db2235ab00..6cd5e928fc7f 100644
--- a/drivers/pinctrl/berlin/berlin.c
+++ b/drivers/pinctrl/berlin/berlin.c
@@ -99,30 +99,11 @@ static int berlin_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrl_dev,
 	return 0;
 }
 
-static void berlin_pinctrl_dt_free_map(struct pinctrl_dev *pctrl_dev,
-				       struct pinctrl_map *map,
-				       unsigned nmaps)
-{
-	int i;
-
-	for (i = 0; i < nmaps; i++) {
-		if (map[i].type == PIN_MAP_TYPE_MUX_GROUP) {
-			kfree(map[i].data.mux.group);
-
-			/* a function can be applied to multiple groups */
-			if (i == 0)
-				kfree(map[i].data.mux.function);
-		}
-	}
-
-	kfree(map);
-}
-
 static const struct pinctrl_ops berlin_pinctrl_ops = {
 	.get_groups_count	= &berlin_pinctrl_get_group_count,
 	.get_group_name		= &berlin_pinctrl_get_group_name,
 	.dt_node_to_map		= &berlin_pinctrl_dt_node_to_map,
-	.dt_free_map		= &berlin_pinctrl_dt_free_map,
+	.dt_free_map		= &pinctrl_utils_dt_free_map,
 };
 
 static int berlin_pinmux_get_functions_count(struct pinctrl_dev *pctrl_dev)
-- 
1.9.1


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

* Re: [PATCH] pinctrl: berlin: fix the dt_free_map function
  2014-09-10  9:15 [PATCH] pinctrl: berlin: fix the dt_free_map function Antoine Tenart
@ 2014-09-11 21:04 ` Sebastian Hesselbarth
  2014-09-23 15:02 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Sebastian Hesselbarth @ 2014-09-11 21:04 UTC (permalink / raw)
  To: Antoine Tenart, linus.walleij
  Cc: alexandre.belloni, thomas.petazzoni, zmxu, jszhang,
	linux-arm-kernel, linux-kernel

On 09/10/2014 11:15 AM, Antoine Tenart wrote:
> The berlin_pinctrl_dt_free_map function tries to free memory
> allocated and handled by the of subsystem. This is wrong and
> already handled by pinctrl_dt_free_maps() which calls
> of_node_put().
> 
> This patch fixes the Berlin pinctrl way of freeing its maps,
> avoiding a kernel BUG(), by using the common
> pinctrl_utils_dt_free_map function instead.
> 
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
> ---
>  drivers/pinctrl/berlin/berlin.c | 21 +--------------------
>  1 file changed, 1 insertion(+), 20 deletions(-)

I like the diffstat :)

I am very short on time, so if it works for you, I am fine with it.

Acked-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>

Sebastian

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

* Re: [PATCH] pinctrl: berlin: fix the dt_free_map function
  2014-09-10  9:15 [PATCH] pinctrl: berlin: fix the dt_free_map function Antoine Tenart
  2014-09-11 21:04 ` Sebastian Hesselbarth
@ 2014-09-23 15:02 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2014-09-23 15:02 UTC (permalink / raw)
  To: Antoine Tenart
  Cc: Sebastian Hesselbarth, Alexandre Belloni, Thomas Petazzoni,
	zhiming Xu, Jisheng Zhang, linux-arm-kernel, linux-kernel

On Wed, Sep 10, 2014 at 11:15 AM, Antoine Tenart
<antoine.tenart@free-electrons.com> wrote:

> The berlin_pinctrl_dt_free_map function tries to free memory
> allocated and handled by the of subsystem. This is wrong and
> already handled by pinctrl_dt_free_maps() which calls
> of_node_put().
>
> This patch fixes the Berlin pinctrl way of freeing its maps,
> avoiding a kernel BUG(), by using the common
> pinctrl_utils_dt_free_map function instead.
>
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>

Patch applied with Sebastian's ACK.

Yours,
Linus Walleij

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

end of thread, other threads:[~2014-09-23 15:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-10  9:15 [PATCH] pinctrl: berlin: fix the dt_free_map function Antoine Tenart
2014-09-11 21:04 ` Sebastian Hesselbarth
2014-09-23 15:02 ` Linus Walleij

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