Re: [PATCH v5 1/2] driver core: auxiliary bus: Introduce auxiliary device resource management
From: Raag Jadav
Date: Fri May 16 2025 - 15:23:42 EST
On Thu, May 15, 2025 at 04:06:47PM +0300, Andy Shevchenko wrote:
> On Thu, May 15, 2025 at 03:52:38PM +0300, Raag Jadav wrote:
> > On Wed, May 14, 2025 at 03:36:49PM +0300, Andy Shevchenko wrote:
> > > On Wed, May 14, 2025 at 05:54:31PM +0530, Raag Jadav wrote:
>
> ...
>
> > > > +/**
> > > > + * auxiliary_get_irq_optional - get an optional IRQ for auxiliary device
> > > > + * @auxdev: auxiliary device
> > > > + * @num: IRQ number index
> > > > + *
> > > > + * Gets an IRQ for a auxiliary device. Device drivers should check the return value
> > > > + * for errors so as to not pass a negative integer value to the request_irq()
> > > > + * APIs. This is the same as auxiliary_get_irq(), except that it does not print an
> > > > + * error message if an IRQ can not be obtained.
> > > > + *
> > > > + * For example::
> > > > + *
> > > > + * int irq = auxiliary_get_irq_optional(auxdev, 0);
> > > > + * if (irq < 0)
> > > > + * return irq;
> > > > + *
> > > > + * Return: non-zero IRQ number on success, negative error number on failure.
> > > > + */
> > > > +int auxiliary_get_irq_optional(struct auxiliary_device *auxdev, unsigned int num)
> > > > +{
> > > > + struct resource *r;
> > > > + int ret = -ENXIO;
> > > > +
> > > > + r = auxiliary_get_resource(auxdev, IORESOURCE_IRQ, num);
> > > > + if (!r)
> > > > + goto out;
> > > > +
> > > > + /*
> > > > + * The resources may pass trigger flags to the irqs that need to be
> > > > + * set up. It so happens that the trigger flags for IORESOURCE_BITS
> > > > + * correspond 1-to-1 to the IRQF_TRIGGER* settings.
> > > > + */
> > > > + if (r->flags & IORESOURCE_BITS) {
> > > > + struct irq_data *irqd;
> > > > +
> > > > + irqd = irq_get_irq_data(r->start);
> > > > + if (!irqd)
> > > > + goto out;
> > > > + irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS);
> > > > + }
> > > > +
> > > > + ret = r->start;
> > > > + if (WARN(!ret, "0 is an invalid IRQ number\n"))
> > > > + ret = -EINVAL;
> > > > +out:
> > > > + return ret;
> > > > +}
> > >
> > > Please, do not inherit the issues that the respective platform device API has.
> > > And after all, why do you need this? What's wrong with plain fwnode_irq_get()?
> >
> > Can you please elaborate? Are we expecting fwnode to be supported by auxiliary
> > device?
>
> Platform IRQ getter is legacy for the board files, but it has support for fwnode.
> Why do you need to inherit all that legacy? What's the point?
This is just to abstract get_resource(IRQ) which has been carved up by the
parent device. And since this is an auxiliary child device, I'm not sure if
we have a firmware to work with.
Please correct me if I've misunderstood your question.
Raag