diff mbox series

[RESEND,v2,28/33] ARM: davinci: cp-intc: unify error handling

Message ID 20190211122606.8662-29-brgl@bgdev.pl (mailing list archive)
State New, archived
Headers show
Series ARM: davinci: modernize the irq support | expand

Commit Message

Bartosz Golaszewski Feb. 11, 2019, 12:26 p.m. UTC
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Use WARN_ON() on eny error in cp-intc initialization and drop all
custom error messages.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: David Lechner <david@lechnology.com>
---
 arch/arm/mach-davinci/cp_intc.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

Comments

Marc Zyngier Feb. 11, 2019, 1:07 p.m. UTC | #1
On 11/02/2019 12:26, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> Use WARN_ON() on eny error in cp-intc initialization and drop all
> custom error messages.
> 
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> Reviewed-by: David Lechner <david@lechnology.com>
> ---
>  arch/arm/mach-davinci/cp_intc.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/arm/mach-davinci/cp_intc.c b/arch/arm/mach-davinci/cp_intc.c
> index f3787ae4cdbd..c1efb9390655 100644
> --- a/arch/arm/mach-davinci/cp_intc.c
> +++ b/arch/arm/mach-davinci/cp_intc.c
> @@ -200,20 +200,16 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config,
>  			DAVINCI_CP_INTC_CHAN_MAP(offset));
>  
>  	irq_base = irq_alloc_descs(-1, 0, config->num_irqs, 0);
> -	if (irq_base < 0) {
> -		pr_warn("Couldn't allocate IRQ numbers\n");
> -		irq_base = 0;
> -	}
> +	if (WARN_ON(irq_base < 0))
> +		return irq_base;
>  
>  	/* create a legacy host */
>  	davinci_cp_intc_irq_domain = irq_domain_add_legacy(
>  					node, config->num_irqs, irq_base, 0,
>  					&davinci_cp_intc_irq_domain_ops, NULL);
>  
> -	if (!davinci_cp_intc_irq_domain) {
> -		pr_err("cp_intc: failed to allocate irq host!\n");
> +	if (WARN_ON(!davinci_cp_intc_irq_domain))
>  		return -EINVAL;
> -	}
>  
>  	set_handle_irq(davinci_cp_intc_handle_irq);
>  
> 

I'm sorry, but how is turning an explicit message into a long stack
trace really useful?

	M.
Bartosz Golaszewski Feb. 11, 2019, 1:10 p.m. UTC | #2
pon., 11 lut 2019 o 14:08 Marc Zyngier <marc.zyngier@arm.com> napisał(a):
>
> On 11/02/2019 12:26, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> >
> > Use WARN_ON() on eny error in cp-intc initialization and drop all
> > custom error messages.
> >
> > Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> > Reviewed-by: David Lechner <david@lechnology.com>
> > ---
> >  arch/arm/mach-davinci/cp_intc.c | 10 +++-------
> >  1 file changed, 3 insertions(+), 7 deletions(-)
> >
> > diff --git a/arch/arm/mach-davinci/cp_intc.c b/arch/arm/mach-davinci/cp_intc.c
> > index f3787ae4cdbd..c1efb9390655 100644
> > --- a/arch/arm/mach-davinci/cp_intc.c
> > +++ b/arch/arm/mach-davinci/cp_intc.c
> > @@ -200,20 +200,16 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config,
> >                       DAVINCI_CP_INTC_CHAN_MAP(offset));
> >
> >       irq_base = irq_alloc_descs(-1, 0, config->num_irqs, 0);
> > -     if (irq_base < 0) {
> > -             pr_warn("Couldn't allocate IRQ numbers\n");
> > -             irq_base = 0;
> > -     }
> > +     if (WARN_ON(irq_base < 0))
> > +             return irq_base;
> >
> >       /* create a legacy host */
> >       davinci_cp_intc_irq_domain = irq_domain_add_legacy(
> >                                       node, config->num_irqs, irq_base, 0,
> >                                       &davinci_cp_intc_irq_domain_ops, NULL);
> >
> > -     if (!davinci_cp_intc_irq_domain) {
> > -             pr_err("cp_intc: failed to allocate irq host!\n");
> > +     if (WARN_ON(!davinci_cp_intc_irq_domain))
> >               return -EINVAL;
> > -     }
> >
> >       set_handle_irq(davinci_cp_intc_handle_irq);
> >
> >
>
> I'm sorry, but how is turning an explicit message into a long stack
> trace really useful?
>

If any of these calls fails, the system is fried. I assumed that a
stack trace will point users straight to the offending line.

Bart
Marc Zyngier Feb. 11, 2019, 1:20 p.m. UTC | #3
On 11/02/2019 13:10, Bartosz Golaszewski wrote:
> pon., 11 lut 2019 o 14:08 Marc Zyngier <marc.zyngier@arm.com> napisał(a):
>>
>> On 11/02/2019 12:26, Bartosz Golaszewski wrote:
>>> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>>>
>>> Use WARN_ON() on eny error in cp-intc initialization and drop all
>>> custom error messages.
>>>
>>> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>>> Reviewed-by: David Lechner <david@lechnology.com>
>>> ---
>>>  arch/arm/mach-davinci/cp_intc.c | 10 +++-------
>>>  1 file changed, 3 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/arch/arm/mach-davinci/cp_intc.c b/arch/arm/mach-davinci/cp_intc.c
>>> index f3787ae4cdbd..c1efb9390655 100644
>>> --- a/arch/arm/mach-davinci/cp_intc.c
>>> +++ b/arch/arm/mach-davinci/cp_intc.c
>>> @@ -200,20 +200,16 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config,
>>>                       DAVINCI_CP_INTC_CHAN_MAP(offset));
>>>
>>>       irq_base = irq_alloc_descs(-1, 0, config->num_irqs, 0);
>>> -     if (irq_base < 0) {
>>> -             pr_warn("Couldn't allocate IRQ numbers\n");
>>> -             irq_base = 0;
>>> -     }
>>> +     if (WARN_ON(irq_base < 0))
>>> +             return irq_base;
>>>
>>>       /* create a legacy host */
>>>       davinci_cp_intc_irq_domain = irq_domain_add_legacy(
>>>                                       node, config->num_irqs, irq_base, 0,
>>>                                       &davinci_cp_intc_irq_domain_ops, NULL);
>>>
>>> -     if (!davinci_cp_intc_irq_domain) {
>>> -             pr_err("cp_intc: failed to allocate irq host!\n");
>>> +     if (WARN_ON(!davinci_cp_intc_irq_domain))
>>>               return -EINVAL;
>>> -     }
>>>
>>>       set_handle_irq(davinci_cp_intc_handle_irq);
>>>
>>>
>>
>> I'm sorry, but how is turning an explicit message into a long stack
>> trace really useful?
>>
> 
> If any of these calls fails, the system is fried. I assumed that a
> stack trace will point users straight to the offending line.

The message is a really good clue, because you can actually grep for it,
and it gives you the exact symptom. You are actively removing
information here.

	M.
diff mbox series

Patch

diff --git a/arch/arm/mach-davinci/cp_intc.c b/arch/arm/mach-davinci/cp_intc.c
index f3787ae4cdbd..c1efb9390655 100644
--- a/arch/arm/mach-davinci/cp_intc.c
+++ b/arch/arm/mach-davinci/cp_intc.c
@@ -200,20 +200,16 @@  davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config,
 			DAVINCI_CP_INTC_CHAN_MAP(offset));
 
 	irq_base = irq_alloc_descs(-1, 0, config->num_irqs, 0);
-	if (irq_base < 0) {
-		pr_warn("Couldn't allocate IRQ numbers\n");
-		irq_base = 0;
-	}
+	if (WARN_ON(irq_base < 0))
+		return irq_base;
 
 	/* create a legacy host */
 	davinci_cp_intc_irq_domain = irq_domain_add_legacy(
 					node, config->num_irqs, irq_base, 0,
 					&davinci_cp_intc_irq_domain_ops, NULL);
 
-	if (!davinci_cp_intc_irq_domain) {
-		pr_err("cp_intc: failed to allocate irq host!\n");
+	if (WARN_ON(!davinci_cp_intc_irq_domain))
 		return -EINVAL;
-	}
 
 	set_handle_irq(davinci_cp_intc_handle_irq);