public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clocksource: em_sti: fix error return codes in em_sti_probe()
@ 2017-06-30  4:42 Gustavo A. R. Silva
  2017-06-30  5:44 ` Frans Klaver
  0 siblings, 1 reply; 5+ messages in thread
From: Gustavo A. R. Silva @ 2017-06-30  4:42 UTC (permalink / raw)
  To: Daniel Lezcano, Thomas Gleixner; +Cc: linux-kernel, Gustavo A. R. Silva

Propagate the return values of platform_get_irq and
devm_request_irq on failure.

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/clocksource/em_sti.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/em_sti.c b/drivers/clocksource/em_sti.c
index bc48cbf..c4818dd 100644
--- a/drivers/clocksource/em_sti.c
+++ b/drivers/clocksource/em_sti.c
@@ -305,7 +305,7 @@ static int em_sti_probe(struct platform_device *pdev)
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(&pdev->dev, "failed to get irq\n");
-		return -EINVAL;
+		return irq;
 	}
 
 	/* map memory, let base point to the STI instance */
@@ -314,11 +314,12 @@ static int em_sti_probe(struct platform_device *pdev)
 	if (IS_ERR(p->base))
 		return PTR_ERR(p->base);
 
-	if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
+	irq = devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
 			     IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
-			     dev_name(&pdev->dev), p)) {
+			     dev_name(&pdev->dev), p);
+	if (irq) {
 		dev_err(&pdev->dev, "failed to request low IRQ\n");
-		return -ENOENT;
+		return irq;
 	}
 
 	/* get hold of clock */
-- 
2.5.0

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

* Re: [PATCH] clocksource: em_sti: fix error return codes in em_sti_probe()
  2017-06-30  4:42 [PATCH] clocksource: em_sti: fix error return codes in em_sti_probe() Gustavo A. R. Silva
@ 2017-06-30  5:44 ` Frans Klaver
  2017-06-30  5:51   ` Gustavo A. R. Silva
  0 siblings, 1 reply; 5+ messages in thread
From: Frans Klaver @ 2017-06-30  5:44 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Daniel Lezcano, Thomas Gleixner, linux-kernel@vger.kernel.org

On Fri, Jun 30, 2017 at 6:42 AM, Gustavo A. R. Silva
<garsilva@embeddedor.com> wrote:
> Propagate the return values of platform_get_irq and
> devm_request_irq on failure.
>
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
>  drivers/clocksource/em_sti.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/clocksource/em_sti.c b/drivers/clocksource/em_sti.c
> index bc48cbf..c4818dd 100644
> --- a/drivers/clocksource/em_sti.c
> +++ b/drivers/clocksource/em_sti.c
> @@ -305,7 +305,7 @@ static int em_sti_probe(struct platform_device *pdev)
>         irq = platform_get_irq(pdev, 0);
>         if (irq < 0) {
>                 dev_err(&pdev->dev, "failed to get irq\n");
> -               return -EINVAL;
> +               return irq;
>         }
>
>         /* map memory, let base point to the STI instance */
> @@ -314,11 +314,12 @@ static int em_sti_probe(struct platform_device *pdev)
>         if (IS_ERR(p->base))
>                 return PTR_ERR(p->base);
>
> -       if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
> +       irq = devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
>                              IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
> -                            dev_name(&pdev->dev), p)) {
> +                            dev_name(&pdev->dev), p);
> +       if (irq) {
>                 dev_err(&pdev->dev, "failed to request low IRQ\n");
> -               return -ENOENT;
> +               return irq;
>         }

This works. Yet I think that 'ret' would be a better candidate for
taking the result of devm_request_irq, since it doesn't return the irq
number on success. Should someone decide to reference irq at a later
point in the code, this has to be changed.

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

* Re: [PATCH] clocksource: em_sti: fix error return codes in em_sti_probe()
  2017-06-30  5:44 ` Frans Klaver
@ 2017-06-30  5:51   ` Gustavo A. R. Silva
  2017-06-30  6:14     ` [PATCH v2] " Gustavo A. R. Silva
  0 siblings, 1 reply; 5+ messages in thread
From: Gustavo A. R. Silva @ 2017-06-30  5:51 UTC (permalink / raw)
  To: Frans Klaver; +Cc: Daniel Lezcano, Thomas Gleixner, linux-kernel

Hi Frans,

Quoting Frans Klaver <fransklaver@gmail.com>:

> On Fri, Jun 30, 2017 at 6:42 AM, Gustavo A. R. Silva
> <garsilva@embeddedor.com> wrote:
>> Propagate the return values of platform_get_irq and
>> devm_request_irq on failure.
>>
>> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
>> ---
>>  drivers/clocksource/em_sti.c | 9 +++++----
>>  1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/clocksource/em_sti.c b/drivers/clocksource/em_sti.c
>> index bc48cbf..c4818dd 100644
>> --- a/drivers/clocksource/em_sti.c
>> +++ b/drivers/clocksource/em_sti.c
>> @@ -305,7 +305,7 @@ static int em_sti_probe(struct platform_device *pdev)
>>         irq = platform_get_irq(pdev, 0);
>>         if (irq < 0) {
>>                 dev_err(&pdev->dev, "failed to get irq\n");
>> -               return -EINVAL;
>> +               return irq;
>>         }
>>
>>         /* map memory, let base point to the STI instance */
>> @@ -314,11 +314,12 @@ static int em_sti_probe(struct platform_device *pdev)
>>         if (IS_ERR(p->base))
>>                 return PTR_ERR(p->base);
>>
>> -       if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
>> +       irq = devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
>>                              IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
>> -                            dev_name(&pdev->dev), p)) {
>> +                            dev_name(&pdev->dev), p);
>> +       if (irq) {
>>                 dev_err(&pdev->dev, "failed to request low IRQ\n");
>> -               return -ENOENT;
>> +               return irq;
>>         }
>
> This works. Yet I think that 'ret' would be a better candidate for
> taking the result of devm_request_irq, since it doesn't return the irq
> number on success. Should someone decide to reference irq at a later
> point in the code, this has to be changed.

Good point. I'll change it and send a new patch shortly.

Thanks!
--
Gustavo A. R. Silva

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

* [PATCH v2] clocksource: em_sti: fix error return codes in em_sti_probe()
  2017-06-30  5:51   ` Gustavo A. R. Silva
@ 2017-06-30  6:14     ` Gustavo A. R. Silva
  2017-08-01 11:56       ` Daniel Lezcano
  0 siblings, 1 reply; 5+ messages in thread
From: Gustavo A. R. Silva @ 2017-06-30  6:14 UTC (permalink / raw)
  To: Frans Klaver, Daniel Lezcano, Thomas Gleixner
  Cc: linux-kernel, Gustavo A. R. Silva

Propagate the return values of platform_get_irq and
devm_request_irq on failure.

Cc: Frans Klaver <fransklaver@gmail.com>
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
Changes in v2:
 Use 'ret' instead of 'irq' for taking the result of devm_request_irq.

 drivers/clocksource/em_sti.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/clocksource/em_sti.c b/drivers/clocksource/em_sti.c
index bc48cbf..269db74 100644
--- a/drivers/clocksource/em_sti.c
+++ b/drivers/clocksource/em_sti.c
@@ -305,7 +305,7 @@ static int em_sti_probe(struct platform_device *pdev)
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(&pdev->dev, "failed to get irq\n");
-		return -EINVAL;
+		return irq;
 	}
 
 	/* map memory, let base point to the STI instance */
@@ -314,11 +314,12 @@ static int em_sti_probe(struct platform_device *pdev)
 	if (IS_ERR(p->base))
 		return PTR_ERR(p->base);
 
-	if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
-			     IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
-			     dev_name(&pdev->dev), p)) {
+	ret = devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
+			       IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
+			       dev_name(&pdev->dev), p);
+	if (ret) {
 		dev_err(&pdev->dev, "failed to request low IRQ\n");
-		return -ENOENT;
+		return ret;
 	}
 
 	/* get hold of clock */
-- 
2.5.0

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

* Re: [PATCH v2] clocksource: em_sti: fix error return codes in em_sti_probe()
  2017-06-30  6:14     ` [PATCH v2] " Gustavo A. R. Silva
@ 2017-08-01 11:56       ` Daniel Lezcano
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Lezcano @ 2017-08-01 11:56 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Frans Klaver, Thomas Gleixner; +Cc: linux-kernel

On 30/06/2017 08:14, Gustavo A. R. Silva wrote:
> Propagate the return values of platform_get_irq and
> devm_request_irq on failure.
> 
> Cc: Frans Klaver <fransklaver@gmail.com>
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---

Applied, thanks.


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

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

end of thread, other threads:[~2017-08-01 11:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-30  4:42 [PATCH] clocksource: em_sti: fix error return codes in em_sti_probe() Gustavo A. R. Silva
2017-06-30  5:44 ` Frans Klaver
2017-06-30  5:51   ` Gustavo A. R. Silva
2017-06-30  6:14     ` [PATCH v2] " Gustavo A. R. Silva
2017-08-01 11:56       ` Daniel Lezcano

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