Message ID | cover.1684493615.git.mazziesaccount@gmail.com |
---|---|
Headers | show |
Series | fix fwnode_irq_get[_byname()] returnvalue | expand |
On Fri, 19 May 2023 14:04:32 +0300 Matti Vaittinen <mazziesaccount@gmail.com> wrote: > fwnode_irq_get[_byname]() were changed to not return 0 anymore. The > special error case where device-tree based IRQ mapping fails can't no > longer be reliably detected from this return value. This yields a > functional change in the driver where the mapping failure is treated as > an error. > > The mapping failure can occur for example when the device-tree IRQ > information translation call-back(s) (xlate) fail, IRQ domain is not > found, IRQ type conflicts, etc. In most cases this indicates an error in > the device-tree and special handling is not really required. > > One more thing to note is that ACPI APIs do not return zero for any > failures so this special handling did only apply on device-tree based > systems. > > Drop the special handling for DT mapping failures as these can no longer > be separated from other errors at driver side. > > Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> > > --- > > Please note that I don't have the hardware to test this change. > Furthermore, testing this type of device-tree error cases is not > trivial, as the question we probably dive in is "what happens with the > existing users who have errors in the device-tree". Answering to this > question is not simple. > > I did this patch with minimal code changes - but a question is if we > should really jump into the else branch below on all IRQ getting errors? > > } else { > indio_dev->info = &ad7150_info_no_irq; > switch (id->driver_data) { > case AD7150: > indio_dev->channels = ad7150_channels_no_irq; > indio_dev->num_channels = > ARRAY_SIZE(ad7150_channels_no_irq); > break; > case AD7151: > indio_dev->channels = ad7151_channels_no_irq; > indio_dev->num_channels = > ARRAY_SIZE(ad7151_channels_no_irq); > break; > default: > return -EINVAL; > } > > Why do we have special handling for !chip->interrupts[0] while other > errors on getting the fwnode_irq_get(dev_fwnode(&client->dev), 0); will > abort the probe? Gut feeling is that this was a rework of board file code where 0 meant not provided. We should look to do the same here. I'm not sure we have a consistent return for no irq though across the various fw types. The driver looks like it should support either no interrupts or all the ones for a given device. Currrently it definitely doesn't handle the no irqs provided case right. Its not elegant, but if we have to have all failures to get irqs result in carrying on without them then that's better than now. Jonathan > > The first patch of the series changes the fwnode_irq_get() so this depends > on the first patch of the series and should not be applied alone. > --- > drivers/iio/cdc/ad7150.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/iio/cdc/ad7150.c b/drivers/iio/cdc/ad7150.c > index 79aeb0aaea67..d7ba50b9780d 100644 > --- a/drivers/iio/cdc/ad7150.c > +++ b/drivers/iio/cdc/ad7150.c > @@ -567,8 +567,7 @@ static int ad7150_probe(struct i2c_client *client) > if (chip->interrupts[1] < 0) > return chip->interrupts[1]; > } > - if (chip->interrupts[0] && > - (id->driver_data == AD7151 || chip->interrupts[1])) { > + if (id->driver_data == AD7151 || chip->interrupts[1]) { > irq_set_status_flags(chip->interrupts[0], IRQ_NOAUTOEN); > ret = devm_request_threaded_irq(&client->dev, > chip->interrupts[0],
Fri, May 19, 2023 at 02:01:47PM +0300, Matti Vaittinen kirjoitti: > fwnode_irq_get[_byname]() were changed to not return 0 anymore. > > Drop check for return value 0. ... > - if (v->irq <= 0) { > + if (v->irq < 0) { > ret = -EINVAL; ret = v->irq; ? > goto err; > }
Hi Andy, On 5/21/23 20:19, andy.shevchenko@gmail.com wrote: > Fri, May 19, 2023 at 02:01:47PM +0300, Matti Vaittinen kirjoitti: >> fwnode_irq_get[_byname]() were changed to not return 0 anymore. >> >> Drop check for return value 0. > > ... > >> - if (v->irq <= 0) { >> + if (v->irq < 0) { >> ret = -EINVAL; > > ret = v->irq; > > ? For me that seems to be correct, yes. This, however, would be a functional change and in my opinion it should be done separately from this API change. > >> goto err; >> } >
On Mon, 22 May 2023 08:15:01 +0300 Matti Vaittinen <mazziesaccount@gmail.com> wrote: > Hi Andy, > > On 5/21/23 20:19, andy.shevchenko@gmail.com wrote: > > Fri, May 19, 2023 at 02:01:47PM +0300, Matti Vaittinen kirjoitti: > >> fwnode_irq_get[_byname]() were changed to not return 0 anymore. > >> > >> Drop check for return value 0. > > > > ... > > > >> - if (v->irq <= 0) { > >> + if (v->irq < 0) { > >> ret = -EINVAL; > > > > ret = v->irq; > > > > ? > > For me that seems to be correct, yes. This, however, would be a > functional change and in my opinion it should be done separately from > this API change. Ah. I commented on this as well in v6. Roll us that separate patch and I expect we'll both be happy ;) Jonathan > > > > >> goto err; > >> } > > >