linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] at91: pmc: Fixed irq's name allocation for programmable clocks
@ 2014-02-03 16:46 Jean-Jacques Hiblot
  2014-02-03 17:13 ` boris brezillon
  2014-02-04  8:21 ` [PATCH v2] " Jean-Jacques Hiblot
  0 siblings, 2 replies; 7+ messages in thread
From: Jean-Jacques Hiblot @ 2014-02-03 16:46 UTC (permalink / raw)
  To: linux-arm-kernel

The name provided to request_irq() must be valid until the irq is
released.
This patch allocates and formats the string with kasprintf().

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
---
 drivers/clk/at91/clk-programmable.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/at91/clk-programmable.c b/drivers/clk/at91/clk-programmable.c
index 8e242c7..0f8bf0f 100644
--- a/drivers/clk/at91/clk-programmable.c
+++ b/drivers/clk/at91/clk-programmable.c
@@ -19,6 +19,7 @@
 #include <linux/sched.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
+#include <linux/string.h>
 
 #include "pmc.h"
 
@@ -247,7 +248,7 @@ at91_clk_register_programmable(struct at91_pmc *pmc, unsigned int irq,
 	struct clk_programmable *prog;
 	struct clk *clk = NULL;
 	struct clk_init_data init;
-	char irq_name[11];
+	char *irq_name;
 
 	if (id > PROG_ID_MAX)
 		return ERR_PTR(-EINVAL);
@@ -269,7 +270,7 @@ at91_clk_register_programmable(struct at91_pmc *pmc, unsigned int irq,
 	prog->irq = irq;
 	init_waitqueue_head(&prog->wait);
 	irq_set_status_flags(prog->irq, IRQ_NOAUTOEN);
-	snprintf(irq_name, sizeof(irq_name), "clk-prog%d", id);
+	irq_name = kasprintf(GFP_KERNEL, "clk-prog%d", id);
 	ret = request_irq(prog->irq, clk_programmable_irq_handler,
 			  IRQF_TRIGGER_HIGH, irq_name, prog);
 	if (ret)
-- 
1.8.5.2

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

* [PATCH] at91: pmc: Fixed irq's name allocation for programmable clocks
  2014-02-03 16:46 [PATCH] at91: pmc: Fixed irq's name allocation for programmable clocks Jean-Jacques Hiblot
@ 2014-02-03 17:13 ` boris brezillon
  2014-02-04  8:21 ` [PATCH v2] " Jean-Jacques Hiblot
  1 sibling, 0 replies; 7+ messages in thread
From: boris brezillon @ 2014-02-03 17:13 UTC (permalink / raw)
  To: linux-arm-kernel

Hello JJ,

On 03/02/2014 17:46, Jean-Jacques Hiblot wrote:
> The name provided to request_irq() must be valid until the irq is
> released.
> This patch allocates and formats the string with kasprintf().

Thanks for reporting this bug.

>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
> ---
>   drivers/clk/at91/clk-programmable.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/at91/clk-programmable.c b/drivers/clk/at91/clk-programmable.c
> index 8e242c7..0f8bf0f 100644
> --- a/drivers/clk/at91/clk-programmable.c
> +++ b/drivers/clk/at91/clk-programmable.c
> @@ -19,6 +19,7 @@
>   #include <linux/sched.h>
>   #include <linux/interrupt.h>
>   #include <linux/irq.h>
> +#include <linux/string.h>
>   
>   #include "pmc.h"
>   
> @@ -247,7 +248,7 @@ at91_clk_register_programmable(struct at91_pmc *pmc, unsigned int irq,
>   	struct clk_programmable *prog;
>   	struct clk *clk = NULL;
>   	struct clk_init_data init;
> -	char irq_name[11];
> +	char *irq_name;
>   
>   	if (id > PROG_ID_MAX)
>   		return ERR_PTR(-EINVAL);
> @@ -269,7 +270,7 @@ at91_clk_register_programmable(struct at91_pmc *pmc, unsigned int irq,
>   	prog->irq = irq;
>   	init_waitqueue_head(&prog->wait);
>   	irq_set_status_flags(prog->irq, IRQ_NOAUTOEN);
> -	snprintf(irq_name, sizeof(irq_name), "clk-prog%d", id);
> +	irq_name = kasprintf(GFP_KERNEL, "clk-prog%d", id);

Could you either use a static table with the prog clk names or store the 
name in
the clk_programmable struct ?
This way we could avoid the additional dynamic allocation.

static prog_clk_names = {
   "clk-prog0",
[...]
   "clk-prog7",
};

[...]
     ret = request_irq(prog->irq, clk_programmable_irq_handler, 
IRQF_TRIGGER_HIGH, prog_clk_names[id], prog);


or

struct clk_programmable {
[...]
     char irq_name[11];
[...]
};

[...]

snprintf(prog->irq_name, sizeof(prog->irq_name), "clk-prog%d", id);
ret = request_irq(prog->irq, clk_programmable_irq_handler, 
IRQF_TRIGGER_HIGH, prog->irq_name, prog);

Best Regards,

Boris
>   	ret = request_irq(prog->irq, clk_programmable_irq_handler,
>   			  IRQF_TRIGGER_HIGH, irq_name, prog);
>   	if (ret)

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

* [PATCH v2] at91: pmc: Fixed irq's name allocation for programmable clocks
  2014-02-03 16:46 [PATCH] at91: pmc: Fixed irq's name allocation for programmable clocks Jean-Jacques Hiblot
  2014-02-03 17:13 ` boris brezillon
@ 2014-02-04  8:21 ` Jean-Jacques Hiblot
  2014-02-04  8:29   ` Boris BREZILLON
                     ` (2 more replies)
  1 sibling, 3 replies; 7+ messages in thread
From: Jean-Jacques Hiblot @ 2014-02-04  8:21 UTC (permalink / raw)
  To: linux-arm-kernel

The name provided to request_irq() must be valid until the irq is released.
This patch stores the name in the internal data structure.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
---
 drivers/clk/at91/clk-programmable.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/at91/clk-programmable.c b/drivers/clk/at91/clk-programmable.c
index 8e242c7..799b75c 100644
--- a/drivers/clk/at91/clk-programmable.c
+++ b/drivers/clk/at91/clk-programmable.c
@@ -44,6 +44,7 @@ struct clk_programmable {
 	u8 css;
 	u8 pres;
 	u8 slckmck;
+	char irq_name[11];
 	const struct clk_programmable_layout *layout;
 };
 
@@ -247,7 +248,6 @@ at91_clk_register_programmable(struct at91_pmc *pmc, unsigned int irq,
 	struct clk_programmable *prog;
 	struct clk *clk = NULL;
 	struct clk_init_data init;
-	char irq_name[11];
 
 	if (id > PROG_ID_MAX)
 		return ERR_PTR(-EINVAL);
@@ -269,9 +269,9 @@ at91_clk_register_programmable(struct at91_pmc *pmc, unsigned int irq,
 	prog->irq = irq;
 	init_waitqueue_head(&prog->wait);
 	irq_set_status_flags(prog->irq, IRQ_NOAUTOEN);
-	snprintf(irq_name, sizeof(irq_name), "clk-prog%d", id);
+	snprintf(prog->irq_name, sizeof(prog->irq_name), "clk-prog%d", id);
 	ret = request_irq(prog->irq, clk_programmable_irq_handler,
-			  IRQF_TRIGGER_HIGH, irq_name, prog);
+			  IRQF_TRIGGER_HIGH, prog->irq_name, prog);
 	if (ret)
 		return ERR_PTR(ret);
 
-- 
1.8.5.2

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

* [PATCH v2] at91: pmc: Fixed irq's name allocation for programmable clocks
  2014-02-04  8:21 ` [PATCH v2] " Jean-Jacques Hiblot
@ 2014-02-04  8:29   ` Boris BREZILLON
  2014-02-04  8:42   ` Boris BREZILLON
  2014-02-04  9:03   ` Nicolas Ferre
  2 siblings, 0 replies; 7+ messages in thread
From: Boris BREZILLON @ 2014-02-04  8:29 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/02/2014 09:21, Jean-Jacques Hiblot wrote:
> The name provided to request_irq() must be valid until the irq is released.
> This patch stores the name in the internal data structure.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
Acked-by: Boris BREZILLON <b.brezillon@overkiz.com>
> ---
>   drivers/clk/at91/clk-programmable.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/clk/at91/clk-programmable.c b/drivers/clk/at91/clk-programmable.c
> index 8e242c7..799b75c 100644
> --- a/drivers/clk/at91/clk-programmable.c
> +++ b/drivers/clk/at91/clk-programmable.c
> @@ -44,6 +44,7 @@ struct clk_programmable {
>   	u8 css;
>   	u8 pres;
>   	u8 slckmck;
> +	char irq_name[11];
>   	const struct clk_programmable_layout *layout;
>   };
>   
> @@ -247,7 +248,6 @@ at91_clk_register_programmable(struct at91_pmc *pmc, unsigned int irq,
>   	struct clk_programmable *prog;
>   	struct clk *clk = NULL;
>   	struct clk_init_data init;
> -	char irq_name[11];
>   
>   	if (id > PROG_ID_MAX)
>   		return ERR_PTR(-EINVAL);
> @@ -269,9 +269,9 @@ at91_clk_register_programmable(struct at91_pmc *pmc, unsigned int irq,
>   	prog->irq = irq;
>   	init_waitqueue_head(&prog->wait);
>   	irq_set_status_flags(prog->irq, IRQ_NOAUTOEN);
> -	snprintf(irq_name, sizeof(irq_name), "clk-prog%d", id);
> +	snprintf(prog->irq_name, sizeof(prog->irq_name), "clk-prog%d", id);
>   	ret = request_irq(prog->irq, clk_programmable_irq_handler,
> -			  IRQF_TRIGGER_HIGH, irq_name, prog);
> +			  IRQF_TRIGGER_HIGH, prog->irq_name, prog);
>   	if (ret)
>   		return ERR_PTR(ret);
>   

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

* [PATCH v2] at91: pmc: Fixed irq's name allocation for programmable clocks
  2014-02-04  8:21 ` [PATCH v2] " Jean-Jacques Hiblot
  2014-02-04  8:29   ` Boris BREZILLON
@ 2014-02-04  8:42   ` Boris BREZILLON
  2014-02-04 13:57     ` Boris BREZILLON
  2014-02-04  9:03   ` Nicolas Ferre
  2 siblings, 1 reply; 7+ messages in thread
From: Boris BREZILLON @ 2014-02-04  8:42 UTC (permalink / raw)
  To: linux-arm-kernel

Hello JJ,

Sorry for the noise (I added Mike in the CC list).

BTW, thanks for fixing this bug.

Mike, could you take this bug fix for the next 3.14 release ?

Best Regards,

Boris

On 04/02/2014 09:21, Jean-Jacques Hiblot wrote:
> The name provided to request_irq() must be valid until the irq is released.
> This patch stores the name in the internal data structure.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
Acked-by: Boris BREZILLON <b.brezillon@overkiz.com>
> ---
>   drivers/clk/at91/clk-programmable.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/clk/at91/clk-programmable.c b/drivers/clk/at91/clk-programmable.c
> index 8e242c7..799b75c 100644
> --- a/drivers/clk/at91/clk-programmable.c
> +++ b/drivers/clk/at91/clk-programmable.c
> @@ -44,6 +44,7 @@ struct clk_programmable {
>   	u8 css;
>   	u8 pres;
>   	u8 slckmck;
> +	char irq_name[11];
>   	const struct clk_programmable_layout *layout;
>   };
>   
> @@ -247,7 +248,6 @@ at91_clk_register_programmable(struct at91_pmc *pmc, unsigned int irq,
>   	struct clk_programmable *prog;
>   	struct clk *clk = NULL;
>   	struct clk_init_data init;
> -	char irq_name[11];
>   
>   	if (id > PROG_ID_MAX)
>   		return ERR_PTR(-EINVAL);
> @@ -269,9 +269,9 @@ at91_clk_register_programmable(struct at91_pmc *pmc, unsigned int irq,
>   	prog->irq = irq;
>   	init_waitqueue_head(&prog->wait);
>   	irq_set_status_flags(prog->irq, IRQ_NOAUTOEN);
> -	snprintf(irq_name, sizeof(irq_name), "clk-prog%d", id);
> +	snprintf(prog->irq_name, sizeof(prog->irq_name), "clk-prog%d", id);
>   	ret = request_irq(prog->irq, clk_programmable_irq_handler,
> -			  IRQF_TRIGGER_HIGH, irq_name, prog);
> +			  IRQF_TRIGGER_HIGH, prog->irq_name, prog);
>   	if (ret)
>   		return ERR_PTR(ret);
>   

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

* [PATCH v2] at91: pmc: Fixed irq's name allocation for programmable clocks
  2014-02-04  8:21 ` [PATCH v2] " Jean-Jacques Hiblot
  2014-02-04  8:29   ` Boris BREZILLON
  2014-02-04  8:42   ` Boris BREZILLON
@ 2014-02-04  9:03   ` Nicolas Ferre
  2 siblings, 0 replies; 7+ messages in thread
From: Nicolas Ferre @ 2014-02-04  9:03 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/02/2014 09:21, Jean-Jacques Hiblot :
> The name provided to request_irq() must be valid until the irq is released.
> This patch stores the name in the internal data structure.
> 
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

Thanks. Bye,

> ---
>  drivers/clk/at91/clk-programmable.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/clk/at91/clk-programmable.c b/drivers/clk/at91/clk-programmable.c
> index 8e242c7..799b75c 100644
> --- a/drivers/clk/at91/clk-programmable.c
> +++ b/drivers/clk/at91/clk-programmable.c
> @@ -44,6 +44,7 @@ struct clk_programmable {
>  	u8 css;
>  	u8 pres;
>  	u8 slckmck;
> +	char irq_name[11];
>  	const struct clk_programmable_layout *layout;
>  };
>  
> @@ -247,7 +248,6 @@ at91_clk_register_programmable(struct at91_pmc *pmc, unsigned int irq,
>  	struct clk_programmable *prog;
>  	struct clk *clk = NULL;
>  	struct clk_init_data init;
> -	char irq_name[11];
>  
>  	if (id > PROG_ID_MAX)
>  		return ERR_PTR(-EINVAL);
> @@ -269,9 +269,9 @@ at91_clk_register_programmable(struct at91_pmc *pmc, unsigned int irq,
>  	prog->irq = irq;
>  	init_waitqueue_head(&prog->wait);
>  	irq_set_status_flags(prog->irq, IRQ_NOAUTOEN);
> -	snprintf(irq_name, sizeof(irq_name), "clk-prog%d", id);
> +	snprintf(prog->irq_name, sizeof(prog->irq_name), "clk-prog%d", id);
>  	ret = request_irq(prog->irq, clk_programmable_irq_handler,
> -			  IRQF_TRIGGER_HIGH, irq_name, prog);
> +			  IRQF_TRIGGER_HIGH, prog->irq_name, prog);
>  	if (ret)
>  		return ERR_PTR(ret);
>  
> 


-- 
Nicolas Ferre

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

* [PATCH v2] at91: pmc: Fixed irq's name allocation for programmable clocks
  2014-02-04  8:42   ` Boris BREZILLON
@ 2014-02-04 13:57     ` Boris BREZILLON
  0 siblings, 0 replies; 7+ messages in thread
From: Boris BREZILLON @ 2014-02-04 13:57 UTC (permalink / raw)
  To: linux-arm-kernel

Hello, Mike,

Please do not take this patch: the work of JJ to fix the prog clk 
prepare bug
will remove the irq handling from the prog clk driver, as a result, we won't
have to request the irq anymore.

Sorry for the inconvenience.

Best Regards,

Boris

On 04/02/2014 09:42, Boris BREZILLON wrote:
> Hello JJ,
>
> Sorry for the noise (I added Mike in the CC list).
>
> BTW, thanks for fixing this bug.
>
> Mike, could you take this bug fix for the next 3.14 release ?
>
> Best Regards,
>
> Boris
>
> On 04/02/2014 09:21, Jean-Jacques Hiblot wrote:
>> The name provided to request_irq() must be valid until the irq is 
>> released.
>> This patch stores the name in the internal data structure.
>>
>> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
> Acked-by: Boris BREZILLON <b.brezillon@overkiz.com>
>> ---
>>   drivers/clk/at91/clk-programmable.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/clk/at91/clk-programmable.c 
>> b/drivers/clk/at91/clk-programmable.c
>> index 8e242c7..799b75c 100644
>> --- a/drivers/clk/at91/clk-programmable.c
>> +++ b/drivers/clk/at91/clk-programmable.c
>> @@ -44,6 +44,7 @@ struct clk_programmable {
>>       u8 css;
>>       u8 pres;
>>       u8 slckmck;
>> +    char irq_name[11];
>>       const struct clk_programmable_layout *layout;
>>   };
>>   @@ -247,7 +248,6 @@ at91_clk_register_programmable(struct at91_pmc 
>> *pmc, unsigned int irq,
>>       struct clk_programmable *prog;
>>       struct clk *clk = NULL;
>>       struct clk_init_data init;
>> -    char irq_name[11];
>>         if (id > PROG_ID_MAX)
>>           return ERR_PTR(-EINVAL);
>> @@ -269,9 +269,9 @@ at91_clk_register_programmable(struct at91_pmc 
>> *pmc, unsigned int irq,
>>       prog->irq = irq;
>>       init_waitqueue_head(&prog->wait);
>>       irq_set_status_flags(prog->irq, IRQ_NOAUTOEN);
>> -    snprintf(irq_name, sizeof(irq_name), "clk-prog%d", id);
>> +    snprintf(prog->irq_name, sizeof(prog->irq_name), "clk-prog%d", id);
>>       ret = request_irq(prog->irq, clk_programmable_irq_handler,
>> -              IRQF_TRIGGER_HIGH, irq_name, prog);
>> +              IRQF_TRIGGER_HIGH, prog->irq_name, prog);
>>       if (ret)
>>           return ERR_PTR(ret);
>

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

end of thread, other threads:[~2014-02-04 13:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-03 16:46 [PATCH] at91: pmc: Fixed irq's name allocation for programmable clocks Jean-Jacques Hiblot
2014-02-03 17:13 ` boris brezillon
2014-02-04  8:21 ` [PATCH v2] " Jean-Jacques Hiblot
2014-02-04  8:29   ` Boris BREZILLON
2014-02-04  8:42   ` Boris BREZILLON
2014-02-04 13:57     ` Boris BREZILLON
2014-02-04  9:03   ` Nicolas Ferre

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