diff mbox series

[v3] soc: ti: smartreflex: Use platform_get_irq_optional() to get the interrupt

Message ID 20211224202231.31130-1-prabhakar.mahadev-lad.rj@bp.renesas.com
State Superseded
Headers show
Series [v3] soc: ti: smartreflex: Use platform_get_irq_optional() to get the interrupt | expand

Commit Message

Prabhakar Mahadev Lad Dec. 24, 2021, 8:22 p.m. UTC
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 bypasses the hierarchical setup and messes up the
irq chaining.

In preparation for removal of static setup of IRQ resource from DT core
code use platform_get_irq_optional().

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
v2->v3
* Switch back to platform_get_irq_optional()
* Only print error in case of error, and not when interrupt is missing.

v1->v2
* Updated commit message
* Drop check for IRQ0
* Switched to using platform_get_irq() so that the probe won't
  fail silently as requested by Nishanth.

v1:
* https://www.spinics.net/lists/arm-kernel/msg942549.html
---
 drivers/soc/ti/smartreflex.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

Comments

Andy Shevchenko Dec. 25, 2021, 4:56 p.m. UTC | #1
On Sat, Dec 25, 2021 at 4:08 AM Lad Prabhakar
<prabhakar.mahadev-lad.rj@bp.renesas.com> 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 bypasses the hierarchical setup and messes up the
> irq chaining.
>
> In preparation for removal of static setup of IRQ resource from DT core
> code use platform_get_irq_optional().

...

> +       ret = platform_get_irq_optional(pdev, 0);
> +       if (ret < 0 && ret != -ENXIO) {

> +               dev_err(&pdev->dev, "%s: failed to get IRQ resource\n", __func__);
> +               return ret;

Almost fine, but you should exclude this from the deferred probe, so switch to

  return dev_err_probe(...);

> +       }
> +       if (ret > 0)
> +               sr_info->irq = ret;

...

> +       ret = 0;

I do not see the context, is it really necessary?
Prabhakar Dec. 25, 2021, 5:10 p.m. UTC | #2
Hi Andy,

Thank you for the review.

On Sat, Dec 25, 2021 at 4:56 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Sat, Dec 25, 2021 at 4:08 AM Lad Prabhakar
> <prabhakar.mahadev-lad.rj@bp.renesas.com> 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 bypasses the hierarchical setup and messes up the
> > irq chaining.
> >
> > In preparation for removal of static setup of IRQ resource from DT core
> > code use platform_get_irq_optional().
>
> ...
>
> > +       ret = platform_get_irq_optional(pdev, 0);
> > +       if (ret < 0 && ret != -ENXIO) {
>
> > +               dev_err(&pdev->dev, "%s: failed to get IRQ resource\n", __func__);
> > +               return ret;
>
> Almost fine, but you should exclude this from the deferred probe, so switch to
>
>   return dev_err_probe(...);
>
Agreed.

> > +       }
> > +       if (ret > 0)
> > +               sr_info->irq = ret;
>
> ...
>
> > +       ret = 0;
>
> I do not see the context, is it really necessary?
>
Yes the change is necessary as the probe callback returns ret on
success, and in the below code flow there might be a case where ret
inst set. So setting the ret here.

Cheers,
Prabhakar
Andy Shevchenko Dec. 25, 2021, 5:18 p.m. UTC | #3
On Sat, Dec 25, 2021 at 7:10 PM Lad, Prabhakar
<prabhakar.csengg@gmail.com> wrote:
> On Sat, Dec 25, 2021 at 4:56 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Sat, Dec 25, 2021 at 4:08 AM Lad Prabhakar
> > <prabhakar.mahadev-lad.rj@bp.renesas.com> wrote:

...

> > > +       ret = 0;
> >
> > I do not see the context, is it really necessary?
> >
> Yes the change is necessary as the probe callback returns ret on
> success, and in the below code flow there might be a case where ret
> inst set. So setting the ret here.

I can't believe this, so I have checked the code and it seems it uses
return ret at the end where it should be simply return 0. So, please,
fix it there.
diff mbox series

Patch

diff --git a/drivers/soc/ti/smartreflex.c b/drivers/soc/ti/smartreflex.c
index b5b2fa538d5c..e2e3eb3db4cc 100644
--- a/drivers/soc/ti/smartreflex.c
+++ b/drivers/soc/ti/smartreflex.c
@@ -819,7 +819,7 @@  static int omap_sr_probe(struct platform_device *pdev)
 {
 	struct omap_sr *sr_info;
 	struct omap_sr_data *pdata = pdev->dev.platform_data;
-	struct resource *mem, *irq;
+	struct resource *mem;
 	struct dentry *nvalue_dir;
 	int i, ret = 0;
 
@@ -844,7 +844,14 @@  static int omap_sr_probe(struct platform_device *pdev)
 	if (IS_ERR(sr_info->base))
 		return PTR_ERR(sr_info->base);
 
-	irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	ret = platform_get_irq_optional(pdev, 0);
+	if (ret < 0 && ret != -ENXIO) {
+		dev_err(&pdev->dev, "%s: failed to get IRQ resource\n", __func__);
+		return ret;
+	}
+	if (ret > 0)
+		sr_info->irq = ret;
+	ret = 0;
 
 	sr_info->fck = devm_clk_get(pdev->dev.parent, "fck");
 	if (IS_ERR(sr_info->fck))
@@ -870,9 +877,6 @@  static int omap_sr_probe(struct platform_device *pdev)
 	sr_info->autocomp_active = false;
 	sr_info->ip_type = pdata->ip_type;
 
-	if (irq)
-		sr_info->irq = irq->start;
-
 	sr_set_clk_length(sr_info);
 
 	list_add(&sr_info->node, &sr_list);