On Thu, Jun 20, 2019 at 05:52:21PM +0300, Andy Shevchenko wrote:
> On Thu, Jun 20, 2019 at 02:34:15PM +0100, Charles Keepax wrote:
> > Use the available IRQ helper functions, most of the functions have
> > additional helpful side affects like configuring the trigger type of the
> > IRQ.
> > 
> > Reviewed-by: Mika Westerberg <mika.westerb...@linux.intel.com>
> > Reviewed-by: Andy Shevchenko <andriy.shevche...@linux.intel.com>
> > Signed-off-by: Charles Keepax <ckee...@opensource.cirrus.com>
> 
> Some last minute observations / questions.
> 
> > +   struct resource r;
> > +
> > +   if (*irq <= 0 && acpi_dev_resource_interrupt(ares, 0, &r))
> > +           *irq = i2c_dev_irq_from_resources(&r, 1);
> > +
> > +   return 1; /* No need to add resource to the list */
> 
> If we don't add it to the list, do we still need to manage the empty
> resource_list below?
> 

I think you are right looking closely I think we can skip this. I
might update the comment here to make it clear the list needs
freed if this is changed though.

> >     /* Then fill IRQ number if any */
> >     INIT_LIST_HEAD(&resource_list);
> > -   ret = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
> > +   ret = acpi_dev_get_resources(adev, &resource_list,
> > +                                i2c_acpi_add_resource, &irq);
> >     if (ret < 0)
> >             return -EINVAL;
> >  
> > -   resource_list_for_each_entry(entry, &resource_list) {
> > -           if (resource_type(entry->res) == IORESOURCE_IRQ) {
> > -                   info->irq = entry->res->start;
> > -                   break;
> > -           }
> > -   }
> 
> > +   if (irq > 0)
> > +           info->irq = irq;
> 
> Hmm... can't we just assign it directly inside the _add_resource() call back 
> as
> original code did?
> 

Again I think you are correct here, my thinking had been to
preserve the original functionality of only overwriting the value
in info->irq if we found one. But it looks like all callers don't
pass anything meaningful in this field so changing that behaviour
shouldn't matter.

Thanks,
Charles

Reply via email to