pata_platform struct resource signness fix
PATCH 1/1 pata_platform struct resource signness fix
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).
--- drivers/ata/pata_platform.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/ata/pata_platform.c +1 -1
@@ -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; }
Signature · 1 line
1.5.5.4
The alternative fix can be.
drivers/ata/pata_of_platform.c +1 -1
@@ -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.
Quoted 39 lines · Wang Jian
Hi,
This patch is to
pata_platform.cbut 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 andif (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->startis assigned (-1).Signed-off-by Wang Jian <[email protected]>--- drivers/ata/pata_platform.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/ata/pata_platform.c +1
-1@@ -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; }
Quoted 5 lines · Wang Jian
Hi,
This patch is to
pata_platform.cbut 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.
Powerpc isn't the only arch to use openfirmware. Anyway, you have to cc [email protected] if you want the patch to be merged.
- Leo
As I said, I didn't spend much time on the issue, so I don't know which patch is better. (But I do think the patch to pata_of_platform.c is better ATM).
AFAIK, powerpc is the only consumer of pata_of_platform.c, so I think this list is better for discussion.
I should cc: Anton Vorontsov <[email protected]> but last time I cc:
him I got bounced.
Quoted 13 lines · Leo Li
Quoted 5 lines · Wang Jian
Hi,
This patch is to
pata_platform.cbut 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.Powerpc isn't the only arch to use openfirmware. Anyway, you have to cc [email protected] if you want the patch to be merged.
- Leo
Quoted 1 line · Wang Jian
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.
- Leo
Quoted 66 lines
drivers/ata/pata_of_platform.c +1
-1@@ -52,7 +52,7 @@ static int __devinit pata_of_platform_probe(structof_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.
Quoted 41 lines · Wang Jian
Hi,
This patch is to
pata_platform.cbut 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 andif (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->startis assigned (-1).Signed-off-by Wang Jian <[email protected]>--- drivers/ata/pata_platform.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/ata/pata_platform.c +1
-1@@ -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;Quoted 1 line
}_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev
Quoted 5 lines · Li Yang
Quoted 1 line · Wang Jian
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/[email protected]/msg22851.html
Jeff, could you apply the patch?
Thanks!
Signature · 3 lines
Anton Vorontsov email: [email protected] irc://irc.freenode.net/bd2
Quoted 5 lines · Li Yang
Quoted 1 line · Wang Jian
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 <[email protected]> had done without knowing his earlier work. I think he was also confused by (-1) and (0).
Quoted 68 lines
- Leo
Quoted 63 lines
drivers/ata/pata_of_platform.c +1
-1@@ -52,7 +52,7 @@ static int __devinit pata_of_platform_probe(structof_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.
Quoted 40 lines · Wang Jian
Hi,
This patch is to
pata_platform.cbut 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 andif (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->startis assigned (-1).Signed-off-by Wang Jian <[email protected]>--- drivers/ata/pata_platform.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/ata/pata_platform.c +1
-1@@ -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;Quoted 1 line
}_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev
Quoted 9 lines · Wang Jian
Quoted 5 lines · Li Yang
Quoted 1 line · Wang Jian
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 theNO_IRQis 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.
Signature · 3 lines
Anton Vorontsov email: [email protected] irc://irc.freenode.net/bd2
Quoted 6 lines · Anton Vorontsov
Quoted 4 lines · Li Yang
Quoted 1 line · Wang Jian
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.
Quoted 7 lines
Thanks for the correct Cc.
I've sent a patch to fix the issue more than a month ago.
http://www.mail-archive.com/[email protected]/msg22851.html
Jeff, could you apply the patch?
Can you resend, I don't seem to have it...
PATCH 1/1 pata_of_platform: fix no irq handling
When no irq specified the pata_of_platform fills the irq_res with -1, which is wrong to do for two reasons:
1. By definition, 'no irq' should be IRQ 0, not some negative integer;
2. pata_platform checks for irq_res.start > 0, but since irq_res.start is unsigned type, the check will be true for `-1'.
---
Quoted 9 lines · Jeff Garzik
Quoted 8 lines · Anton Vorontsov
Quoted 4 lines · Li Yang
Quoted 1 line · Wang Jian
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.
Quoted 7 lines
Quoted 5 lines
I've sent a patch to fix the issue more than a month ago.
http://www.mail-archive.com/[email protected]/msg22851.html
Jeff, could you apply the patch?
Can you resend, I don't seem to have it...
Here it is.
Thanks,
drivers/ata/pata_of_platform.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/ata/pata_of_platform.c +1 -1
@@ -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 ;
Signature · 1 line
1.5.6.3