Re: [PATCH v2 21/22] platform: Modify platform_get_irq_optional() to use resource

From: Mark Hasemeyer
Date: Fri Dec 22 2023 - 16:51:55 EST


> > * For example::
> > *
> > - * int irq = platform_get_irq_optional(pdev, 0);
> > + * int irq = platform_get_irq_resource_optional(pdev, 0, &res);
> > * if (irq < 0)
> > * return irq;
> > *
> > * Return: non-zero IRQ number on success, negative error number on failure.
>
> Why do we need the irq to be returned via error code?

We don't really. It just matches the convention of
'platform_get_irq()' and 'of_irq_to_resource()'.

> > int ret;
>
> Missing blank line, have you run checkpatch.pl?

Yes, I normally run checkpatch.pl. I may have missed the warning or it
didn't catch it. I'll add it.

>
> > + if (IS_ERR_OR_NULL(r))
> > + return -EINVAL;
>
> If we ever have an error pointer in r, I prefer to see
>
> if (!r)
> return -EINVAL;
> if (IS_ERR(r))
> return PTR_ERR(r);
>
> But Q is the same as earlier: when would we have the error pointer in @r?

I don't see when we would. I'll drop it.

> Can we save this and be consistent with above fwnode API return code check?
>
> > + ret = ret ?: r->start;
> > goto out;
> > + }
> > }

Yep!