public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] pinctrl: free allocated pinctrl_map structure only once and use kernel facilities for IMX_PMX_DUMP
@ 2012-06-02 17:03 Devendra Naga
  2012-06-04 11:37 ` devendra.aaru
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Devendra Naga @ 2012-06-02 17:03 UTC (permalink / raw)
  To: Linus Walleij, linux-kernel; +Cc: Devendra Naga

a) as we allocate the pinctrl_map structure at imx_dt_node_to_map at  line 167, anyway
if its an element, or a num_elements * (sizeof(type)) elements allocated to one single
pointer must be freed only once.

CASE. A)

as new_map is not moved and allocated like,

for (i = 0; i < MAX_ELEMS; i++) {
	new_map[i] = kmalloc(numelems * size, GFP_KERNEL);
}

its freed as

for (i = 0; i < MAX_ELEMS; i++) {
	kfree(new_map[i]);
}

CASE. B)
and its allocated like
	new_map = kmalloc(numelems * size, GFP_KERNEL);

it just needs kfree not as case A's.

b) use KERN_DEBUG facility for the IMX_PMX_DUMP macro.

Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
---
 drivers/pinctrl/pinctrl-imx.c |   23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-imx.c b/drivers/pinctrl/pinctrl-imx.c
index f6e7c67..553ed95 100644
--- a/drivers/pinctrl/pinctrl-imx.c
+++ b/drivers/pinctrl/pinctrl-imx.c
@@ -27,16 +27,16 @@
 #include "core.h"
 #include "pinctrl-imx.h"
 
-#define IMX_PMX_DUMP(info, p, m, c, n)		\
-{						\
-	int i, j;				\
-	printk("Format: Pin Mux Config\n");	\
-	for (i = 0; i < n; i++) {		\
-		j = p[i];			\
-		printk("%s %d 0x%lx\n",		\
-			info->pins[j].name,	\
-			m[i], c[i]);		\
-	}					\
+#define IMX_PMX_DUMP(info, p, m, c, n)			\
+{							\
+	int i, j;					\
+	printk(KERN_DEBUG "Format: Pin Mux Config\n");	\
+	for (i = 0; i < n; i++) {			\
+		j = p[i];				\
+		printk(KERN_DEBUG "%s %d 0x%lx\n",	\
+			info->pins[j].name,		\
+			m[i], c[i]);			\
+	}						\
 }
 
 /* The bits in CONFIG cell defined in binding doc*/
@@ -203,8 +203,7 @@ static void imx_dt_free_map(struct pinctrl_dev *pctldev,
 {
 	int i;
 
-	for (i = 0; i < num_maps; i++)
-		kfree(map);
+	kfree(map);
 }
 
 static struct pinctrl_ops imx_pctrl_ops = {
-- 
1.7.9.5


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

* Re: [PATCH 1/2] pinctrl: free allocated pinctrl_map structure only once and use kernel facilities for IMX_PMX_DUMP
  2012-06-02 17:03 [PATCH 1/2] pinctrl: free allocated pinctrl_map structure only once and use kernel facilities for IMX_PMX_DUMP Devendra Naga
@ 2012-06-04 11:37 ` devendra.aaru
  2012-06-07 11:04   ` Linus Walleij
  2012-06-07 11:03 ` Linus Walleij
  2012-06-07 12:05 ` Dong Aisheng
  2 siblings, 1 reply; 7+ messages in thread
From: devendra.aaru @ 2012-06-04 11:37 UTC (permalink / raw)
  To: Linus Walleij, linux-kernel; +Cc: Devendra Naga

Anybody Please??

On Sat, Jun 2, 2012 at 10:33 PM, Devendra Naga <devendra.aaru@gmail.com> wrote:
> a) as we allocate the pinctrl_map structure at imx_dt_node_to_map at  line 167, anyway
> if its an element, or a num_elements * (sizeof(type)) elements allocated to one single
> pointer must be freed only once.
>
> CASE. A)
>
> as new_map is not moved and allocated like,
>
> for (i = 0; i < MAX_ELEMS; i++) {
>        new_map[i] = kmalloc(numelems * size, GFP_KERNEL);
> }
>
> its freed as
>
> for (i = 0; i < MAX_ELEMS; i++) {
>        kfree(new_map[i]);
> }
>
> CASE. B)
> and its allocated like
>        new_map = kmalloc(numelems * size, GFP_KERNEL);
>
> it just needs kfree not as case A's.
>
> b) use KERN_DEBUG facility for the IMX_PMX_DUMP macro.
>
> Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
> ---
>  drivers/pinctrl/pinctrl-imx.c |   23 +++++++++++------------
>  1 file changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-imx.c b/drivers/pinctrl/pinctrl-imx.c
> index f6e7c67..553ed95 100644
> --- a/drivers/pinctrl/pinctrl-imx.c
> +++ b/drivers/pinctrl/pinctrl-imx.c
> @@ -27,16 +27,16 @@
>  #include "core.h"
>  #include "pinctrl-imx.h"
>
> -#define IMX_PMX_DUMP(info, p, m, c, n)         \
> -{                                              \
> -       int i, j;                               \
> -       printk("Format: Pin Mux Config\n");     \
> -       for (i = 0; i < n; i++) {               \
> -               j = p[i];                       \
> -               printk("%s %d 0x%lx\n",         \
> -                       info->pins[j].name,     \
> -                       m[i], c[i]);            \
> -       }                                       \
> +#define IMX_PMX_DUMP(info, p, m, c, n)                 \
> +{                                                      \
> +       int i, j;                                       \
> +       printk(KERN_DEBUG "Format: Pin Mux Config\n");  \
> +       for (i = 0; i < n; i++) {                       \
> +               j = p[i];                               \
> +               printk(KERN_DEBUG "%s %d 0x%lx\n",      \
> +                       info->pins[j].name,             \
> +                       m[i], c[i]);                    \
> +       }                                               \
>  }
>
>  /* The bits in CONFIG cell defined in binding doc*/
> @@ -203,8 +203,7 @@ static void imx_dt_free_map(struct pinctrl_dev *pctldev,
>  {
>        int i;
>
> -       for (i = 0; i < num_maps; i++)
> -               kfree(map);
> +       kfree(map);
>  }
>
>  static struct pinctrl_ops imx_pctrl_ops = {
> --
> 1.7.9.5
>

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

* Re: [PATCH 1/2] pinctrl: free allocated pinctrl_map structure only once and use kernel facilities for IMX_PMX_DUMP
  2012-06-02 17:03 [PATCH 1/2] pinctrl: free allocated pinctrl_map structure only once and use kernel facilities for IMX_PMX_DUMP Devendra Naga
  2012-06-04 11:37 ` devendra.aaru
@ 2012-06-07 11:03 ` Linus Walleij
  2012-06-07 12:05 ` Dong Aisheng
  2 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2012-06-07 11:03 UTC (permalink / raw)
  To: Devendra Naga, Shawn Guo, Dong Aisheng; +Cc: linux-kernel

On Sat, Jun 2, 2012 at 7:03 PM, Devendra Naga <devendra.aaru@gmail.com> wrote:

> a) as we allocate the pinctrl_map structure at imx_dt_node_to_map at  line 167, anyway
> if its an element, or a num_elements * (sizeof(type)) elements allocated to one single
> pointer must be freed only once.
>
> CASE. A)
>
> as new_map is not moved and allocated like,
>
> for (i = 0; i < MAX_ELEMS; i++) {
>        new_map[i] = kmalloc(numelems * size, GFP_KERNEL);
> }
>
> its freed as
>
> for (i = 0; i < MAX_ELEMS; i++) {
>        kfree(new_map[i]);
> }
>
> CASE. B)
> and its allocated like
>        new_map = kmalloc(numelems * size, GFP_KERNEL);
>
> it just needs kfree not as case A's.
>
> b) use KERN_DEBUG facility for the IMX_PMX_DUMP macro.
>
> Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
> ---
>  drivers/pinctrl/pinctrl-imx.c |   23 +++++++++++------------
>  1 file changed, 11 insertions(+), 12 deletions(-)

Shawn/Dong: can you look at this patch too?

Yours,
Linus Walleij

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

* Re: [PATCH 1/2] pinctrl: free allocated pinctrl_map structure only once and use kernel facilities for IMX_PMX_DUMP
  2012-06-04 11:37 ` devendra.aaru
@ 2012-06-07 11:04   ` Linus Walleij
  2012-06-07 11:39     ` devendra.aaru
  0 siblings, 1 reply; 7+ messages in thread
From: Linus Walleij @ 2012-06-07 11:04 UTC (permalink / raw)
  To: devendra.aaru; +Cc: linux-kernel

On Mon, Jun 4, 2012 at 1:37 PM, devendra.aaru <devendra.aaru@gmail.com> wrote:

> Anybody Please??

Take it easy. Give the Freescalers some time to review...

If nothing happens for a week I'll just apply it so they can shout
if there's something wrong with it :-D

Linus

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

* Re: [PATCH 1/2] pinctrl: free allocated pinctrl_map structure only once and use kernel facilities for IMX_PMX_DUMP
  2012-06-07 11:04   ` Linus Walleij
@ 2012-06-07 11:39     ` devendra.aaru
  0 siblings, 0 replies; 7+ messages in thread
From: devendra.aaru @ 2012-06-07 11:39 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-kernel

Hi Linus,

Thanks for the reply,

On Thu, Jun 7, 2012 at 4:34 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Mon, Jun 4, 2012 at 1:37 PM, devendra.aaru <devendra.aaru@gmail.com> wrote:
>
>> Anybody Please??
>
> Take it easy. Give the Freescalers some time to review...
>
> If nothing happens for a week I'll just apply it so they can shout
> if there's something wrong with it :-D
>
Sorry for shouting ... :(
> Linus

Thanks,
Devendra.

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

* Re: [PATCH 1/2] pinctrl: free allocated pinctrl_map structure only once and use kernel facilities for IMX_PMX_DUMP
  2012-06-02 17:03 [PATCH 1/2] pinctrl: free allocated pinctrl_map structure only once and use kernel facilities for IMX_PMX_DUMP Devendra Naga
  2012-06-04 11:37 ` devendra.aaru
  2012-06-07 11:03 ` Linus Walleij
@ 2012-06-07 12:05 ` Dong Aisheng
  2012-06-07 12:45   ` devendra.aaru
  2 siblings, 1 reply; 7+ messages in thread
From: Dong Aisheng @ 2012-06-07 12:05 UTC (permalink / raw)
  To: Devendra Naga; +Cc: Linus Walleij, linux-kernel

On Sat, Jun 02, 2012 at 10:33:53PM +0530, Devendra Naga wrote:
> a) as we allocate the pinctrl_map structure at imx_dt_node_to_map at  line 167, anyway
> if its an element, or a num_elements * (sizeof(type)) elements allocated to one single
> pointer must be freed only once.
> 
> CASE. A)
> 
> as new_map is not moved and allocated like,
> 
> for (i = 0; i < MAX_ELEMS; i++) {
> 	new_map[i] = kmalloc(numelems * size, GFP_KERNEL);
> }
> 
> its freed as
> 
> for (i = 0; i < MAX_ELEMS; i++) {
> 	kfree(new_map[i]);
> }
> 
> CASE. B)
> and its allocated like
> 	new_map = kmalloc(numelems * size, GFP_KERNEL);
> 
> it just needs kfree not as case A's.
> 
> b) use KERN_DEBUG facility for the IMX_PMX_DUMP macro.
> 
> Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
> ---
>  drivers/pinctrl/pinctrl-imx.c |   23 +++++++++++------------
>  1 file changed, 11 insertions(+), 12 deletions(-)
>
Sorry for late reply.
I missed this patch series.
You can CC me next time. :)

> diff --git a/drivers/pinctrl/pinctrl-imx.c b/drivers/pinctrl/pinctrl-imx.c
> index f6e7c67..553ed95 100644
> --- a/drivers/pinctrl/pinctrl-imx.c
> +++ b/drivers/pinctrl/pinctrl-imx.c
> @@ -27,16 +27,16 @@
>  #include "core.h"
>  #include "pinctrl-imx.h"
>  
> -#define IMX_PMX_DUMP(info, p, m, c, n)		\
> -{						\
> -	int i, j;				\
> -	printk("Format: Pin Mux Config\n");	\
> -	for (i = 0; i < n; i++) {		\
> -		j = p[i];			\
> -		printk("%s %d 0x%lx\n",		\
> -			info->pins[j].name,	\
> -			m[i], c[i]);		\
> -	}					\
> +#define IMX_PMX_DUMP(info, p, m, c, n)			\
> +{							\
> +	int i, j;					\
> +	printk(KERN_DEBUG "Format: Pin Mux Config\n");	\
> +	for (i = 0; i < n; i++) {			\
> +		j = p[i];				\
> +		printk(KERN_DEBUG "%s %d 0x%lx\n",	\
> +			info->pins[j].name,		\
> +			m[i], c[i]);			\
> +	}						\
I can't remember clearly but i encountered a strange issue before
that the format was not what i want with KERN_DEBUG...
But i just tried your patch and it did not appear.
So i'm ok with this change.

>  }
>  
>  /* The bits in CONFIG cell defined in binding doc*/
> @@ -203,8 +203,7 @@ static void imx_dt_free_map(struct pinctrl_dev *pctldev,
>  {
>  	int i;
Also need removed?

>  
> -	for (i = 0; i < num_maps; i++)
> -		kfree(map);
> +	kfree(map);

BTW, it would be better if the change the patch title to:
"pinctrl: pinctrl-imx: ...."

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

Regards
Dong Aisheng


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

* Re: [PATCH 1/2] pinctrl: free allocated pinctrl_map structure only once and use kernel facilities for IMX_PMX_DUMP
  2012-06-07 12:05 ` Dong Aisheng
@ 2012-06-07 12:45   ` devendra.aaru
  0 siblings, 0 replies; 7+ messages in thread
From: devendra.aaru @ 2012-06-07 12:45 UTC (permalink / raw)
  To: Dong Aisheng; +Cc: Linus Walleij, linux-kernel

Hi Dong,

Thanks for the review.

On Thu, Jun 7, 2012 at 5:35 PM, Dong Aisheng <aisheng.dong@freescale.com> wrote:
> On Sat, Jun 02, 2012 at 10:33:53PM +0530, Devendra Naga wrote:
>> a) as we allocate the pinctrl_map structure at imx_dt_node_to_map at  line 167, anyway
>> if its an element, or a num_elements * (sizeof(type)) elements allocated to one single
>> pointer must be freed only once.
>>
>> CASE. A)
>>
>> as new_map is not moved and allocated like,
>>
>> for (i = 0; i < MAX_ELEMS; i++) {
>>       new_map[i] = kmalloc(numelems * size, GFP_KERNEL);
>> }
>>
>> its freed as
>>
>> for (i = 0; i < MAX_ELEMS; i++) {
>>       kfree(new_map[i]);
>> }
>>
>> CASE. B)
>> and its allocated like
>>       new_map = kmalloc(numelems * size, GFP_KERNEL);
>>
>> it just needs kfree not as case A's.
>>
>> b) use KERN_DEBUG facility for the IMX_PMX_DUMP macro.
>>
>> Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
>> ---
>>  drivers/pinctrl/pinctrl-imx.c |   23 +++++++++++------------
>>  1 file changed, 11 insertions(+), 12 deletions(-)
>>
> Sorry for late reply.
> I missed this patch series.
> You can CC me next time. :)
>
>> diff --git a/drivers/pinctrl/pinctrl-imx.c b/drivers/pinctrl/pinctrl-imx.c
>> index f6e7c67..553ed95 100644
>> --- a/drivers/pinctrl/pinctrl-imx.c
>> +++ b/drivers/pinctrl/pinctrl-imx.c
>> @@ -27,16 +27,16 @@
>>  #include "core.h"
>>  #include "pinctrl-imx.h"
>>
>> -#define IMX_PMX_DUMP(info, p, m, c, n)               \
>> -{                                            \
>> -     int i, j;                               \
>> -     printk("Format: Pin Mux Config\n");     \
>> -     for (i = 0; i < n; i++) {               \
>> -             j = p[i];                       \
>> -             printk("%s %d 0x%lx\n",         \
>> -                     info->pins[j].name,     \
>> -                     m[i], c[i]);            \
>> -     }                                       \
>> +#define IMX_PMX_DUMP(info, p, m, c, n)                       \
>> +{                                                    \
>> +     int i, j;                                       \
>> +     printk(KERN_DEBUG "Format: Pin Mux Config\n");  \
>> +     for (i = 0; i < n; i++) {                       \
>> +             j = p[i];                               \
>> +             printk(KERN_DEBUG "%s %d 0x%lx\n",      \
>> +                     info->pins[j].name,             \
>> +                     m[i], c[i]);                    \
>> +     }                                               \
> I can't remember clearly but i encountered a strange issue before
> that the format was not what i want with KERN_DEBUG...
> But i just tried your patch and it did not appear.
> So i'm ok with this change.
>
>>  }
>>
>>  /* The bits in CONFIG cell defined in binding doc*/
>> @@ -203,8 +203,7 @@ static void imx_dt_free_map(struct pinctrl_dev *pctldev,
>>  {
>>       int i;
> Also need removed?
>
Yeah. sorry , will send again with you Ack.
>>
>> -     for (i = 0; i < num_maps; i++)
>> -             kfree(map);
>> +     kfree(map);
>
> BTW, it would be better if the change the patch title to:
> "pinctrl: pinctrl-imx: ...."
Ok sure.
>
> Otherwise,
> Acked-by: Dong Aisheng <dong.aisheng@linaro.org>
>
> Regards
> Dong Aisheng
>

Thanks,
Devendra.

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

end of thread, other threads:[~2012-06-07 12:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-02 17:03 [PATCH 1/2] pinctrl: free allocated pinctrl_map structure only once and use kernel facilities for IMX_PMX_DUMP Devendra Naga
2012-06-04 11:37 ` devendra.aaru
2012-06-07 11:04   ` Linus Walleij
2012-06-07 11:39     ` devendra.aaru
2012-06-07 11:03 ` Linus Walleij
2012-06-07 12:05 ` Dong Aisheng
2012-06-07 12:45   ` devendra.aaru

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox