lkml.org 
[lkml]   [2021]   [Dec]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
SubjectRe: [PATCH] ata: pata_of_platform: Use of_irq_to_resource() to populate IRQ resource
From
On 12/17/21 09:12, Lad Prabhakar wrote:
> platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
> allocation of IRQ resources in DT core code, this causes an issue
> when using hierarchical interrupt domains using "interrupts" property
> in the node as this bypassed the hierarchical setup and messed up the

s/bypassed/bypasses
s/messed/messes

> irq chaining.
>
> In preparation for removal of static setup of IRQ resource from DT core
> code use of_irq_to_resource().
>
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
> Hi,
>
> Dropping usage of platform_get_resource() was agreed based on
> the discussion [0].
>
> [0] https://patchwork.kernel.org/project/linux-renesas-soc/
> patch/20211209001056.29774-1-prabhakar.mahadev-lad.rj@bp.renesas.com/
>
> Cheers,
> Prabhakar
> ---
> drivers/ata/pata_of_platform.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c
> index 35aa158fc976..557f349eb533 100644
> --- a/drivers/ata/pata_of_platform.c
> +++ b/drivers/ata/pata_of_platform.c
> @@ -9,6 +9,7 @@
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/of_address.h>
> +#include <linux/of_irq.h>
> #include <linux/platform_device.h>
> #include <linux/ata_platform.h>
> #include <linux/libata.h>
> @@ -25,11 +26,12 @@ static int pata_of_platform_probe(struct platform_device *ofdev)
> struct device_node *dn = ofdev->dev.of_node;
> struct resource io_res;
> struct resource ctl_res;
> - struct resource *irq_res;
> + struct resource irq_res;
> unsigned int reg_shift = 0;
> int pio_mode = 0;
> int pio_mask;
> bool use16bit;
> + int irq;
>
> ret = of_address_to_resource(dn, 0, &io_res);
> if (ret) {
> @@ -45,7 +47,9 @@ static int pata_of_platform_probe(struct platform_device *ofdev)
> return -EINVAL;
> }
>
> - irq_res = platform_get_resource(ofdev, IORESOURCE_IRQ, 0);
> + irq = of_irq_to_resource(dn, 0, &irq_res);
> + if (irq <= 0 && irq != -ENXIO)
> + return irq ? irq : -ENXIO;

Why are you making an exception for ENXIO ? I suspect this is to cover
the case "there is no IRQ for this node", but then how does this
differentiate from a real error case ?

>
> of_property_read_u32(dn, "reg-shift", &reg_shift);
>
> @@ -63,7 +67,8 @@ static int pata_of_platform_probe(struct platform_device *ofdev)
> pio_mask = 1 << pio_mode;
> pio_mask |= (1 << pio_mode) - 1;
>
> - return __pata_platform_probe(&ofdev->dev, &io_res, &ctl_res, irq_res,
> + return __pata_platform_probe(&ofdev->dev, &io_res, &ctl_res,
> + irq > 0 ? &irq_res : NULL,
> reg_shift, pio_mask, &pata_platform_sht,
> use16bit);
> }
>


--
Damien Le Moal
Western Digital Research

\
 
 \ /
  Last update: 2021-12-17 01:24    [W:0.099 / U:3.468 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site