Patchwork pata_platform struct resource signness fix

login
register
mail settings
Submitter Wang Jian
Date Sept. 25, 2008, 8:54 a.m.
Message ID <48DB51C3.6040504@linux.net.cn>
Download mbox | patch
Permalink /patch/1466/
State Not Applicable
Headers show

Comments

Wang Jian - Sept. 25, 2008, 8:54 a.m.
The alternative fix can be.

I just didn't spend much time to see which is better.

Wang Jian wrote:
> Hi,
> 
> This patch is to pata_platform.c but at this time, it's powerpc specific
> because it can only be triggerred using openfirmware, so I post the patch
> here. The patch is against 2.6.26-rc8.
> 
> The problem is triggerred when ata device is populated using 
> pata_of_platform.c, and no irq is assigned (poll mode, such as CF card).
> 
> pata_of_platform_probe() parse device tree and
> 
>         if (ret == NO_IRQ)
> 	                irq_res.start = irq_res.end = -1;
> 
> Then irq is 0xffffffff, not NULL. Probe will fail coz irq can't be
> requested.
> 
> 
> ---
> (irq_res->start > 0) will be true even when it is (-1). When the device
> has no irq, irq_res->start is assigned (-1).
> 
> Signed-off-by: Wang Jian <lark@linux.net.cn>
> ---
>  drivers/ata/pata_platform.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c
> index 8f65ad6..b12cd0c 100644
> --- a/drivers/ata/pata_platform.c
> +++ b/drivers/ata/pata_platform.c
> @@ -123,7 +123,7 @@ int __devinit __pata_platform_probe(struct device *dev,
>  	/*
>  	 * And the IRQ
>  	 */
> -	if (irq_res && irq_res->start > 0) {
> +	if (irq_res && irq_res->start != -1) {
>  		irq = irq_res->start;
>  		irq_flags = irq_res->flags;
>  	}
Anton Vorontsov - Sept. 25, 2008, 10:48 a.m.
On Thu, Sep 25, 2008 at 06:40:59PM +0800, Li Yang wrote:
> On Thu, Sep 25, 2008 at 4:54 PM, Wang Jian <lark@linux.net.cn> wrote:
> > The alternative fix can be.
> 
> This one is better as 0 is defined as 'invalid irq' for all
> architectures.  Added linux-ide and Anton to cc.

Thanks for the correct Cc.

I've sent a patch to fix the issue more than a month ago.

http://www.mail-archive.com/linuxppc-dev@ozlabs.org/msg22851.html

Jeff, could you apply the patch?

Thanks!
Wang Jian - Sept. 25, 2008, 3:33 p.m.
Li Yang wrote:
> On Thu, Sep 25, 2008 at 4:54 PM, Wang Jian <lark@linux.net.cn> wrote:
>> The alternative fix can be.
> 
> This one is better as 0 is defined as 'invalid irq' for all
> architectures.  Added linux-ide and Anton to cc.

However, this is not very true. Just git grep "#define NO_IRQ" and see. It
seems that the NO_IRQ is in transition from (-1) to (0).

I happened to code the same 2 patches as Anton Vorontsov <avorontsov@ru.mvista.com>
had done without knowing his earlier work. I think he was also confused by (-1)
and (0).

> 
> - Leo
> 
>> diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c
>> index 408da30..1f18ad9 100644
>> --- a/drivers/ata/pata_of_platform.c
>> +++ b/drivers/ata/pata_of_platform.c
>> @@ -52,7 +52,7 @@ static int __devinit pata_of_platform_probe(struct
>> of_device *ofdev,
>>
>>        ret = of_irq_to_resource(dn, 0, &irq_res);
>>        if (ret == NO_IRQ)
>> -               irq_res.start = irq_res.end = -1;
>> +               irq_res.start = irq_res.end = 0;
>>        else
>>                irq_res.flags = 0;
>>
>> I just didn't spend much time to see which is better.
>>
>> Wang Jian wrote:
>>> Hi,
>>>
>>> This patch is to pata_platform.c but at this time, it's powerpc specific
>>> because it can only be triggerred using openfirmware, so I post the patch
>>> here. The patch is against 2.6.26-rc8.
>>>
>>> The problem is triggerred when ata device is populated using
>>> pata_of_platform.c, and no irq is assigned (poll mode, such as CF card).
>>>
>>> pata_of_platform_probe() parse device tree and
>>>
>>>        if (ret == NO_IRQ)
>>>                        irq_res.start = irq_res.end = -1;
>>>
>>> Then irq is 0xffffffff, not NULL. Probe will fail coz irq can't be
>>> requested.
>>>
>>>
>>> ---
>>> (irq_res->start > 0) will be true even when it is (-1). When the device
>>> has no irq, irq_res->start is assigned (-1).
>>>
>>> Signed-off-by: Wang Jian <lark@linux.net.cn>
>>> ---
>>>  drivers/ata/pata_platform.c |    2 +-
>>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c
>>> index 8f65ad6..b12cd0c 100644
>>> --- a/drivers/ata/pata_platform.c
>>> +++ b/drivers/ata/pata_platform.c
>>> @@ -123,7 +123,7 @@ int __devinit __pata_platform_probe(struct device
>>> *dev,
>>>        /*
>>>         * And the IRQ
>>>         */
>>> -       if (irq_res && irq_res->start > 0) {
>>> +       if (irq_res && irq_res->start != -1) {
>>>                irq = irq_res->start;
>>>                irq_flags = irq_res->flags;
>>>        }
>> _______________________________________________
>> Linuxppc-dev mailing list
>> Linuxppc-dev@ozlabs.org
>> https://ozlabs.org/mailman/listinfo/linuxppc-dev
>>
> 
>
Anton Vorontsov - Sept. 25, 2008, 3:47 p.m.
On Thu, Sep 25, 2008 at 11:33:35PM +0800, Wang Jian wrote:
> Li Yang wrote:
>> On Thu, Sep 25, 2008 at 4:54 PM, Wang Jian <lark@linux.net.cn> wrote:
>>> The alternative fix can be.
>>
>> This one is better as 0 is defined as 'invalid irq' for all
>> architectures.  Added linux-ide and Anton to cc.
>
> However, this is not very true. Just git grep "#define NO_IRQ" and see. It
> seems that the NO_IRQ is in transition from (-1) to (0).

Yeah, there is a mess, but it gets better as time goes by.
The platforms/drivers should be fixed, since 0 is the only
invalid VIRQ.
Jeff Garzik - Sept. 29, 2008, 4:19 a.m.
Anton Vorontsov wrote:
> On Thu, Sep 25, 2008 at 06:40:59PM +0800, Li Yang wrote:
>> On Thu, Sep 25, 2008 at 4:54 PM, Wang Jian <lark@linux.net.cn> wrote:
>>> The alternative fix can be.
>> This one is better as 0 is defined as 'invalid irq' for all
>> architectures.  Added linux-ide and Anton to cc.
> 
> Thanks for the correct Cc.
> 
> I've sent a patch to fix the issue more than a month ago.
> 
> http://www.mail-archive.com/linuxppc-dev@ozlabs.org/msg22851.html
> 
> Jeff, could you apply the patch?

Can you resend, I don't seem to have it...

Patch

diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c
index 408da30..1f18ad9 100644
--- a/drivers/ata/pata_of_platform.c
+++ b/drivers/ata/pata_of_platform.c
@@ -52,7 +52,7 @@  static int __devinit pata_of_platform_probe(struct of_device *ofdev,

         ret = of_irq_to_resource(dn, 0, &irq_res);
         if (ret == NO_IRQ)
-               irq_res.start = irq_res.end = -1;
+               irq_res.start = irq_res.end = 0;
         else
                 irq_res.flags = 0;