Re: [PATCH v1 09/43] clocksource: ep93xx: Add driver for Cirrus Logic EP93xx

From: Andy Shevchenko
Date: Thu Jun 29 2023 - 15:23:03 EST


On Thu, Jun 29, 2023 at 5:16 PM Nikita Shubin <nikita.shubin@xxxxxxxxxxx> wrote:
> On Thu, 2023-06-29 at 16:39 +0300, Andy Shevchenko wrote:
> > On Thu, Jun 29, 2023 at 4:10 PM Nikita Shubin
> > <nikita.shubin@xxxxxxxxxxx> wrote:
> > > On Wed, 2023-06-21 at 11:28 +0300, Andy Shevchenko wrote:
> > > > On Wed, Jun 21, 2023 at 11:22 AM Nikita Shubin
> > > > <nikita.shubin@xxxxxxxxxxx> wrote:

...

> > > > > > > + irq = irq_of_parse_and_map(np, 0);
> > > > > > > + if (irq <= 0) {
> > > > > > > + pr_err("ERROR: invalid interrupt
> > > > > > > number\n");
> > > > > > > + ret = -EINVAL;
> > > > > >
> > > > > > Shadowed error in case of negative returned code. Why?
> > > > >
> > > > > Majority of clocksource drivers shadow it. Same like above.
> > > >
> > > > It doesn't mean they are correct or using brand new APIs.
> > >
> > > Or may be this because irq_of_parse_and_map can return zero as
> > > error,
> > > and returning zero from timer_init means success ?
> > >
> > > Please correct me if i am wrong here.
> >
> > 0 means no mapped IRQ.
> >
> > > > Can you use fwnode_irq_get() instead?
> > >
> > > Will it help ?
> >
> > Yes, definitely, in two aspects:
> > 1/ it makes code less OF-dependent (helps also OF people to clean up
> > the spread of OF headers and APIs where they are not needed);
> > 2/ it takes care about proper error codes.
> >
>
> Well... every use of fwnode_irq_get in 6.4 looks like:
>
> err = fwnode_irq_get(fwnode, 0);
> if (err < 0)
> return err;
> if (!err)
> return -EINVAL;
>
> So i don't see any special care as it still calls of_irq_get just like
> irq_of_parse_and_map.

Well, this change is not a fix and not going to land v6.4 anyway, have
you checked what's in the v6.5-rc1? I believe it will have
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/commit/?h=driver-core-next&id=39d422555e43379516d4d13f5b7162a3dee6e646,
will we?

> But i am convinced to use the same approach, thank you!

No, please, don't copy the old and ugly variant, use a brand new one.

--
With Best Regards,
Andy Shevchenko