Message ID | be289a3d-b230-be2c-c367-d9a42b1cde82@omprussia.ru |
---|---|
State | New |
Headers | show |
Series | Correctly handle plaform_get_irq()'s result in the libata drivers | expand |
On 25-03-21, 23:50, Sergey Shtylyov wrote: > 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)... > > Fixes: a480167b23ef ("pata_arasan_cf: Adding support for arasan compact flash host controller") > Signed-off-by: Sergey Shtylyov <s.shtylyov@omprussia.ru> > > --- > 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 > =================================================================== > --- linux-block.orig/drivers/ata/pata_arasan_cf.c > +++ linux-block/drivers/ata/pata_arasan_cf.c > @@ -818,12 +818,19 @@ static int arasan_cf_probe(struct platfo > else > 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, Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Index: linux-block/drivers/ata/pata_arasan_cf.c =================================================================== --- linux-block.orig/drivers/ata/pata_arasan_cf.c +++ linux-block/drivers/ata/pata_arasan_cf.c @@ -818,12 +818,19 @@ static int arasan_cf_probe(struct platfo else 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,
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)... Fixes: a480167b23ef ("pata_arasan_cf: Adding support for arasan compact flash host controller") Signed-off-by: Sergey Shtylyov <s.shtylyov@omprussia.ru> --- 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(-)