Correctly handle plaform_get_irq()'s result in the libata drivers
Subsystems (2)
cover Correctly handle plaform_get_irq()'s result in the libata drivers
Here are 2 patches against the 'master' branch of the Jens Axboe's 'linux-block.git' repo. The affected drivers call platform_get_irq() but mis-interprete its result -- they consider IRQ0 as error and the real error codes as valid IRQs... :-/
[1/2] pata_arasan_cf: fix IRQ check
[2/2] pata_ipx4xx_cf: fix IRQ check
PATCH 1/2 pata_arasan_cf: fix IRQ check
The driver's probe() method is written as if platform_get_irq() returns 0 on error, while actually it returns a negative error code (with all the other values considered valid IRQs). Rewrite the driver's IRQ checking code to pass the positive IRQ #s to ata_host_activate(), propagate upstream -EPROBE_DEFER, and set up the driver to polling mode on (negative) errors and IRQ0 (libata treats IRQ #0 as a polling mode anyway)...
---
This patch is against the 'master' branch of Jens Axboe's 'linux-block.git' repo.
drivers/ata/pata_arasan_cf.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/ata/pata_arasan_cf.c +11 -4
@@ -818,12 +818,19 @@ static int arasan_cf_probe(struct platfoelse quirk =CF_BROKEN_UDMA ;/* as it is on spear1340 */ -/* if irq is 0, support only PIO */ - acdev->irq =platform_get_irq (pdev,0 ); -if (acdev->irq) +/* +* If there's an error getting IRQ (or we do get IRQ0), +* support only PIO +*/ + ret =platform_get_irq (pdev,0 ); +if (ret >0 ) { + acdev->irq = ret; irq_handler = arasan_cf_interrupt; -else + }else if (ret == -EPROBE_DEFER ) { +return ret; + }else { quirk |=CF_BROKEN_MWDMA |CF_BROKEN_UDMA ; + } acdev->pbase = res->start; acdev->vbase = devm_ioremap(&pdev->dev, res->start,
Re: [PATCH 1/2] pata_arasan_cf: fix IRQ check
Quoted 35 lines · Sergey Shtylyov
The driver's
probe()method is written as ifplatform_get_irq()returns 0 on error, while actually it returns a negative error code (with all the other values considered valid IRQs). Rewrite the driver's IRQ checking code to pass the positive IRQ #s toata_host_activate(), propagate upstream -EPROBE_DEFER, and set up the driver to polling mode on (negative) errors and IRQ0 (libata treats IRQ #0 as a polling mode anyway)...Fixes a480167b23ef ("pata_arasan_cf: Adding support for arasan compact flash host controller")Signed-off-by Sergey Shtylyov <[email protected]>---
This patch is against the 'master' branch of Jens Axboe's 'linux-block.git' repo.drivers/ata/pata_arasan_cf.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)Index:
linux-block/drivers/ata/pata_arasan_cf.c
===================================================================drivers/ata/pata_arasan_cf.c +7
-3@@ -818,12 +818,19 @@ static int arasan_cf_probe(struct platfoelse quirk =CF_BROKEN_UDMA ;/* as it is on spear1340 */ -/* if irq is 0, support only PIO */ - acdev->irq =platform_get_irq (pdev,0 ); -if (acdev->irq) +/* +* If there's an error getting IRQ (or we do get IRQ0), +* support only PIO +*/ + ret =platform_get_irq (pdev,0 ); +if (ret >0 ) { + acdev->irq = ret;
drivers/ata/pata_arasan_cf.c static int arasan_cf_probe(struct platfo · line 836
Quoted 10 lines
drivers/ata/pata_arasan_cf.c +4
-1irq_handler = arasan_cf_interrupt; - else + }else if (ret == -EPROBE_DEFER ) { +return ret; + }else { quirk |=CF_BROKEN_MWDMA |CF_BROKEN_UDMA ; + } acdev->pbase = res->start; acdev->vbase = devm_ioremap(&pdev->dev, res->start,
Signature · 1 line
viresh
PATCH 2/2 pata_ipx4xx_cf: fix IRQ check
In reply to Sergey ShtylyovThe driver's probe() method is written as if platform_get_irq() returns 0 on error, while actually it returns a negative error code (with all the other values considered valid IRQs). Rewrite the driver's IRQ checking code to pass the positive IRQ #s to ata_host_activate(), propagate errors upstream, and treat IRQ0 as error, returning -EINVAL, as the libata code treats 0 as an indication that polling should be used anyway...
--- drivers/ata/pata_ixp4xx_cf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/ata/pata_ixp4xx_cf.c +5 -1
@@ -165,8 +165,12 @@ static int ixp4xx_pata_probe(struct platreturn -ENOMEM ; irq =platform_get_irq (pdev,0 ); -if (irq) +if (irq >0 )irq_set_irq_type (irq,IRQ_TYPE_EDGE_RISING ); +else if (irq <0 ) +return irq; +else +return -EINVAL ;/* Setup expansion bus chip selects */ *data->cs0_cfg = data->cs0_bits;
Jens Axboe
AppliedQuoted 6 lines · Sergey Shtylyov
Here are 2 patches against the 'master' branch of the Jens Axboe's 'linux-block.git' repo. The affected drivers call
platform_get_irq()but mis-interprete its result -- they consider IRQ0 as error and the real error codes as valid IRQs... :-/[1/2]
pata_arasan_cf: fix IRQ check
[2/2]pata_ipx4xx_cf: fix IRQ check
Applied, thanks.
Signature · 1 line
Jens Axboe