public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* question about arch/arm/mach-s3c24xx/irq.c
@ 2013-02-24 11:45 Julia Lawall
  2013-02-24 12:38 ` Russell King - ARM Linux
  0 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2013-02-24 11:45 UTC (permalink / raw)
  To: linux-arm-kernel

The function s3c24xx_irq_map in arch/arm/mach-s3c24xx/irq.c contains the
code:

                parent_irq_data = &parent_intc->irqs[irq_data->parent_irq];
		if (!irq_data) {
                        pr_err("irq-s3c24xx: no irq data found for hwirq %lu\n",
                               hw);
                        goto err;
		}

At this point irq_data has already been tested, so the null test on
irq_data does not look correct.  But I wonder if parent_irq_data could
ever be null here?

julia

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

* question about arch/arm/mach-s3c24xx/irq.c
  2013-02-24 11:45 question about arch/arm/mach-s3c24xx/irq.c Julia Lawall
@ 2013-02-24 12:38 ` Russell King - ARM Linux
  2013-02-24 13:39   ` Julia Lawall
  0 siblings, 1 reply; 6+ messages in thread
From: Russell King - ARM Linux @ 2013-02-24 12:38 UTC (permalink / raw)
  To: linux-arm-kernel

On Sun, Feb 24, 2013 at 12:45:11PM +0100, Julia Lawall wrote:
> The function s3c24xx_irq_map in arch/arm/mach-s3c24xx/irq.c contains the
> code:
> 
>                 parent_irq_data = &parent_intc->irqs[irq_data->parent_irq];
> 		if (!irq_data) {
>                         pr_err("irq-s3c24xx: no irq data found for hwirq %lu\n",
>                                hw);
>                         goto err;
> 		}
> 
> At this point irq_data has already been tested, so the null test on
> irq_data does not look correct.  But I wonder if parent_irq_data could
> ever be null here?

That would be really obscure - because that would require parent_intc to
be a "negative" pointer (to counter-act the indexing by
irq_data->parent_irq).  So it looks to me like the above is redundant.

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

* question about arch/arm/mach-s3c24xx/irq.c
  2013-02-24 12:38 ` Russell King - ARM Linux
@ 2013-02-24 13:39   ` Julia Lawall
  2013-02-24 15:11     ` Heiko Stübner
  0 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2013-02-24 13:39 UTC (permalink / raw)
  To: linux-arm-kernel

[Adding the person who introduced the code]

On Sun, 24 Feb 2013, Russell King - ARM Linux wrote:

> On Sun, Feb 24, 2013 at 12:45:11PM +0100, Julia Lawall wrote:
> > The function s3c24xx_irq_map in arch/arm/mach-s3c24xx/irq.c contains the
> > code:
> >
> >                 parent_irq_data = &parent_intc->irqs[irq_data->parent_irq];
> > 		if (!irq_data) {
> >                         pr_err("irq-s3c24xx: no irq data found for hwirq %lu\n",
> >                                hw);
> >                         goto err;
> > 		}
> >
> > At this point irq_data has already been tested, so the null test on
> > irq_data does not look correct.  But I wonder if parent_irq_data could
> > ever be null here?
>
> That would be really obscure - because that would require parent_intc to
> be a "negative" pointer (to counter-act the indexing by
> irq_data->parent_irq).  So it looks to me like the above is redundant.

Even at its original definition irq_data seems unlikely to be NULL:

        struct s3c_irq_intc *intc = h->host_data;
	struct s3c_irq_data *irq_data = &intc->irqs[hw];
	...
	if (!irq_data) {
                pr_err("irq-s3c24xx: no irq data found for hwirq %lu\n", hw);
                return -EINVAL;
        }

That is, it could be an invalid value, but whether it actually hits 0
would seem to depend on the value hw?

Heiko, is NULL really a possibility?

thanks,
julia

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

* question about arch/arm/mach-s3c24xx/irq.c
  2013-02-24 13:39   ` Julia Lawall
@ 2013-02-24 15:11     ` Heiko Stübner
  2013-02-24 15:45       ` Julia Lawall
  0 siblings, 1 reply; 6+ messages in thread
From: Heiko Stübner @ 2013-02-24 15:11 UTC (permalink / raw)
  To: linux-arm-kernel

Am Sonntag, 24. Februar 2013, 14:39:45 schrieb Julia Lawall:
> [Adding the person who introduced the code]
> 
> On Sun, 24 Feb 2013, Russell King - ARM Linux wrote:
> > On Sun, Feb 24, 2013 at 12:45:11PM +0100, Julia Lawall wrote:
> > > The function s3c24xx_irq_map in arch/arm/mach-s3c24xx/irq.c contains
> > > the
> > > 
> > > code:
> > >                 parent_irq_data =
> > >                 &parent_intc->irqs[irq_data->parent_irq];
> > > 		
> > > 		if (!irq_data) {
> > > 		
> > >                         pr_err("irq-s3c24xx: no irq data found for
> > >                         hwirq %lu\n",
> > >                         
> > >                                hw);
> > >                         
> > >                         goto err;
> > > 		
> > > 		}
> > > 
> > > At this point irq_data has already been tested, so the null test on
> > > irq_data does not look correct.  But I wonder if parent_irq_data could
> > > ever be null here?
> > 
> > That would be really obscure - because that would require parent_intc to
> > be a "negative" pointer (to counter-act the indexing by
> > irq_data->parent_irq).  So it looks to me like the above is redundant.
> 
> Even at its original definition irq_data seems unlikely to be NULL:
> 
>         struct s3c_irq_intc *intc = h->host_data;
> 	struct s3c_irq_data *irq_data = &intc->irqs[hw];
> 	...
> 	if (!irq_data) {
>                 pr_err("irq-s3c24xx: no irq data found for hwirq %lu\n",
> hw); return -EINVAL;
>         }
> 
> That is, it could be an invalid value, but whether it actually hits 0
> would seem to depend on the value hw?
> 
> Heiko, is NULL really a possibility?

The test you quoted is of course wrong ... it would need to test 
parent_irq_data. But you're also right that the test is not necessary at all.

All the s3c_irq_data arrays used always contain 32 entries to reach all bits 
of the register (which is used differently on each SoC). So if we have found 
the parent_intc at all, it should contain a 32 entries array of irq_data 
structs, so no need to test for the existence of the individual array element.


And now that I look at it, I also see another glitch. The code tests for 
parent_irq != 0, which of course won't work if the parent_irq is the 0-hwirq 
of the parent controller.
The only SoC using such a mapping is the s3c2412 [0], which explains why I 
haven't been bitten by this myself.


Heiko


[0] http://www.mail-archive.com/linux-samsung-
soc at vger.kernel.org/msg15709.html

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

* question about arch/arm/mach-s3c24xx/irq.c
  2013-02-24 15:11     ` Heiko Stübner
@ 2013-02-24 15:45       ` Julia Lawall
  2013-02-24 17:49         ` Heiko Stübner
  0 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2013-02-24 15:45 UTC (permalink / raw)
  To: linux-arm-kernel

On Sun, 24 Feb 2013, Heiko St?bner wrote:

> Am Sonntag, 24. Februar 2013, 14:39:45 schrieb Julia Lawall:
> > [Adding the person who introduced the code]
> >
> > On Sun, 24 Feb 2013, Russell King - ARM Linux wrote:
> > > On Sun, Feb 24, 2013 at 12:45:11PM +0100, Julia Lawall wrote:
> > > > The function s3c24xx_irq_map in arch/arm/mach-s3c24xx/irq.c contains
> > > > the
> > > >
> > > > code:
> > > >                 parent_irq_data =
> > > >                 &parent_intc->irqs[irq_data->parent_irq];
> > > >
> > > > 		if (!irq_data) {
> > > >
> > > >                         pr_err("irq-s3c24xx: no irq data found for
> > > >                         hwirq %lu\n",
> > > >
> > > >                                hw);
> > > >
> > > >                         goto err;
> > > >
> > > > 		}
> > > >
> > > > At this point irq_data has already been tested, so the null test on
> > > > irq_data does not look correct.  But I wonder if parent_irq_data could
> > > > ever be null here?
> > >
> > > That would be really obscure - because that would require parent_intc to
> > > be a "negative" pointer (to counter-act the indexing by
> > > irq_data->parent_irq).  So it looks to me like the above is redundant.
> >
> > Even at its original definition irq_data seems unlikely to be NULL:
> >
> >         struct s3c_irq_intc *intc = h->host_data;
> > 	struct s3c_irq_data *irq_data = &intc->irqs[hw];
> > 	...
> > 	if (!irq_data) {
> >                 pr_err("irq-s3c24xx: no irq data found for hwirq %lu\n",
> > hw); return -EINVAL;
> >         }
> >
> > That is, it could be an invalid value, but whether it actually hits 0
> > would seem to depend on the value hw?
> >
> > Heiko, is NULL really a possibility?
>
> The test you quoted is of course wrong ... it would need to test
> parent_irq_data. But you're also right that the test is not necessary at all.
>
> All the s3c_irq_data arrays used always contain 32 entries to reach all bits
> of the register (which is used differently on each SoC). So if we have found
> the parent_intc at all, it should contain a 32 entries array of irq_data
> structs, so no need to test for the existence of the individual array element.
>
>
> And now that I look at it, I also see another glitch. The code tests for
> parent_irq != 0, which of course won't work if the parent_irq is the 0-hwirq
> of the parent controller.
> The only SoC using such a mapping is the s3c2412 [0], which explains why I
> haven't been bitten by this myself.

Do you want to make all the fixes?

julia

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

* question about arch/arm/mach-s3c24xx/irq.c
  2013-02-24 15:45       ` Julia Lawall
@ 2013-02-24 17:49         ` Heiko Stübner
  0 siblings, 0 replies; 6+ messages in thread
From: Heiko Stübner @ 2013-02-24 17:49 UTC (permalink / raw)
  To: linux-arm-kernel

Am Sonntag, 24. Februar 2013, 16:45:18 schrieb Julia Lawall:
> On Sun, 24 Feb 2013, Heiko St?bner wrote:
> > Am Sonntag, 24. Februar 2013, 14:39:45 schrieb Julia Lawall:
> > > [Adding the person who introduced the code]
> > > 
> > > On Sun, 24 Feb 2013, Russell King - ARM Linux wrote:
> > > > On Sun, Feb 24, 2013 at 12:45:11PM +0100, Julia Lawall wrote:
> > > > > The function s3c24xx_irq_map in arch/arm/mach-s3c24xx/irq.c
> > > > > contains the
> > > > > 
> > > > > code:
> > > > >                 parent_irq_data =
> > > > >                 &parent_intc->irqs[irq_data->parent_irq];
> > > > > 		
> > > > > 		if (!irq_data) {
> > > > > 		
> > > > >                         pr_err("irq-s3c24xx: no irq data found for
> > > > >                         hwirq %lu\n",
> > > > >                         
> > > > >                                hw);
> > > > >                         
> > > > >                         goto err;
> > > > > 		
> > > > > 		}
> > > > > 
> > > > > At this point irq_data has already been tested, so the null test on
> > > > > irq_data does not look correct.  But I wonder if parent_irq_data
> > > > > could ever be null here?
> > > > 
> > > > That would be really obscure - because that would require parent_intc
> > > > to be a "negative" pointer (to counter-act the indexing by
> > > > irq_data->parent_irq).  So it looks to me like the above is
> > > > redundant.
> > > 
> > > Even at its original definition irq_data seems unlikely to be NULL:
> > >         struct s3c_irq_intc *intc = h->host_data;
> > > 	
> > > 	struct s3c_irq_data *irq_data = &intc->irqs[hw];
> > > 	...
> > > 	if (!irq_data) {
> > > 	
> > >                 pr_err("irq-s3c24xx: no irq data found for hwirq
> > >                 %lu\n",
> > > 
> > > hw); return -EINVAL;
> > > 
> > >         }
> > > 
> > > That is, it could be an invalid value, but whether it actually hits 0
> > > would seem to depend on the value hw?
> > > 
> > > Heiko, is NULL really a possibility?
> > 
> > The test you quoted is of course wrong ... it would need to test
> > parent_irq_data. But you're also right that the test is not necessary at
> > all.
> > 
> > All the s3c_irq_data arrays used always contain 32 entries to reach all
> > bits of the register (which is used differently on each SoC). So if we
> > have found the parent_intc at all, it should contain a 32 entries array
> > of irq_data structs, so no need to test for the existence of the
> > individual array element.
> > 
> > 
> > And now that I look at it, I also see another glitch. The code tests for
> > parent_irq != 0, which of course won't work if the parent_irq is the
> > 0-hwirq of the parent controller.
> > The only SoC using such a mapping is the s3c2412 [0], which explains why
> > I haven't been bitten by this myself.
> 
> Do you want to make all the fixes?

Yep, I just need to find out what the best fix for my parent_irq mess up would 
be :-)

The easiest way would of course be to use a value outside the valid range to 
indicate no parent-irq, so either < 0 (would need a type change) or > 32 .

But I might be overlooking something here.

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

end of thread, other threads:[~2013-02-24 17:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-24 11:45 question about arch/arm/mach-s3c24xx/irq.c Julia Lawall
2013-02-24 12:38 ` Russell King - ARM Linux
2013-02-24 13:39   ` Julia Lawall
2013-02-24 15:11     ` Heiko Stübner
2013-02-24 15:45       ` Julia Lawall
2013-02-24 17:49         ` Heiko Stübner

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