Skip to contentSkip to conversation

iio: adc: ad7192: Revert "properly check spi_get_device_match_data()"

PATCH Applied Andy Shevchenko 4 participants 10 messages Feb 17 – Feb 23

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: adc: ad7192: Revert "properly check spi_get_device_match_data()"

This reverts commit b7f99fa1b64af2f696b13cec581cb4cd7d3982b8.

The added code is currently a dead code. Moreover, the driver is not designed to have any defaults effectively making driver data a mandatory information to work with. Taking all together, revert unneeded change.

---
 drivers/iio/adc/ad7192.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/iio/adc/ad7192.c +0 -3
index 530e1d307860..8b1664f6b102 100644
@@ -1402,9 +1402,6 @@ static int ad7192_probe(struct spi_device *spi)
 	st->int_vref_mv = ret == -ENODEV ? avdd_mv : ret / MILLI;
 
 	st->chip_info = spi_get_device_match_data(spi);
-	if (!st->chip_info)
-		return -ENODEV;
-
 	indio_dev->name = st->chip_info->name;
 	indio_dev->modes = INDIO_DIRECT_MODE;
 	indio_dev->info = st->chip_info->info;
Signature · 1 line
2.50.1
#1 lore raw
Quoted 20 lines · Andy Shevchenko

This reverts commit b7f99fa1b64af2f696b13cec581cb4cd7d3982b8.

The added code is currently a dead code. Moreover, the driver is not designed to have any defaults effectively making driver data a mandatory information to work with. Taking all together, revert unneeded change.

---
 drivers/iio/adc/ad7192.c | 3 ---

 1 file changed, 3 deletions(-)
drivers/iio/adc/ad7192.c +0 -0
index 530e1d307860..8b1664f6b102 100644
@@ -1402,9 +1402,6 @@ static int ad7192_probe(struct spi_device *spi)
  	st->int_vref_mv = ret == -ENODEV ? avdd_mv : ret / MILLI;


  st->chip_info = spi_get_device_match_data(spi);

drivers/iio/adc/ad7192.c static int ad7192_probe(struct spi_device *spi) · line 1406

Quoted 2 lines
drivers/iio/adc/ad7192.c +0 -2
-	if (!st->chip_info)
-		return -ENODEV;

I'm ok with this but as long as we get some consistency agreed on. So far, IIRC, the policy was to check for the NULL case even for the cases where that was not possible to happen.

- Nuno Sá

#2 lore raw
Quoted 13 lines · Nuno Sá
Quoted 12 lines · Andy Shevchenko

This reverts commit b7f99fa1b64af2f696b13cec581cb4cd7d3982b8.

The added code is currently a dead code. Moreover, the driver is not designed to have any defaults effectively making driver data a mandatory information to work with. Taking all together, revert unneeded change.

---
 drivers/iio/adc/ad7192.c | 3 ---

 1 file changed, 3 deletions(-)
Quoted 14 lines

drivers/iio/adc/ad7192.c static int ad7192_probe(struct spi_device *spi) · line 1406

Quoted 10 lines
drivers/iio/adc/ad7192.c +0 -0
index 530e1d307860..8b1664f6b102 100644
@@ -1402,9 +1402,6 @@ static int ad7192_probe(struct spi_device *spi)
  	st->int_vref_mv = ret == -ENODEV ? avdd_mv : ret / MILLI;


  st->chip_info = spi_get_device_match_data(spi);

drivers/iio/adc/ad7192.c +0 -2
-	if (!st->chip_info)
-		return -ENODEV;

I'm ok with this but as long as we get some consistency agreed on. So far, IIRC, the policy was to check for the NULL case even for the cases where that was not possible to happen.

Is it kernel-wide policy?
Because what I have heard is that:
- we don't do defensive programming for in-kernel data;
- we don't add a dead code
(only for the exceptional cases usually accompanied with BUG() or WARN() call).

Both are kernel-wide. Am I mistaken?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 29 lines · Andy Shevchenko
Quoted 13 lines · Nuno Sá
Quoted 12 lines · Andy Shevchenko

This reverts commit b7f99fa1b64af2f696b13cec581cb4cd7d3982b8.

The added code is currently a dead code. Moreover, the driver is not designed to have any defaults effectively making driver data a mandatory information to work with. Taking all together, revert unneeded change.

---
 drivers/iio/adc/ad7192.c | 3 ---

 1 file changed, 3 deletions(-)
Quoted 14 lines

drivers/iio/adc/ad7192.c static int ad7192_probe(struct spi_device *spi) · line 1406

Quoted 10 lines
drivers/iio/adc/ad7192.c +0 -0
index 530e1d307860..8b1664f6b102 100644
@@ -1402,9 +1402,6 @@ static int ad7192_probe(struct spi_device *spi)
  	st->int_vref_mv = ret == -ENODEV ? avdd_mv : ret / MILLI;


  st->chip_info = spi_get_device_match_data(spi);

drivers/iio/adc/ad7192.c +0 -2
-	if (!st->chip_info)
-		return -ENODEV;

I'm ok with this but as long as we get some consistency agreed on. So far, IIRC, the policy was to check for the NULL case even for the cases where that was not possible to happen.

Quoted 1 line

Is it kernel-wide policy?

Nope... Just IIO IIRC. Actually, I'm pretty sure we had patches in the past just adding the check. But again, I'm fine with the above as long as we are consistent from now on.

- Nuno Sá

#4 lore raw
Quoted 3 lines · Nuno Sá
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Nuno Sá

On Tue, 2026-02-17 at 09:05 +0100, Andy Shevchenko wrote:

...

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I'm ok with this but as long as we get some consistency agreed on. So far, IIRC, the policy was to check for the NULL case even for the cases where that was not possible to happen.

Is it kernel-wide policy?

Nope... Just IIO IIRC. Actually, I'm pretty sure we had patches in the past just adding the check.

Like you said we need clearer policy.

Quoted 1 line

But again, I'm fine with the above as long as we are consistent from now on.

Exactly!
Jonathan, David, others?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw
Quoted 16 lines · On Wed, 18 Feb 2026 11:40:11 +0200 Andy Shevchenko…
Quoted 3 lines · Nuno Sá
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Nuno Sá

On Tue, 2026-02-17 at 09:05 +0100, Andy Shevchenko wrote:

...

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I'm ok with this but as long as we get some consistency agreed on. So far, IIRC, the policy was to check for the NULL case even for the cases where that was not possible to happen.

Is it kernel-wide policy?

Nope... Just IIO IIRC. Actually, I'm pretty sure we had patches in the past just adding the check.

Quoted 6 lines

Like you said we need clearer policy.

Quoted 1 line

But again, I'm fine with the above as long as we are consistent from now on.

Exactly!
Jonathan, David, others?

As long as no compilers or static analyzers trip up on it and start spouting false warnings, I'm fine with not checking these. I'm not sure I'm bothered about going through the tree
removing the checks though. This one is so small I don't mind if it gets copied
into new drivers. If this is all that needs tidying up I'll tweak it whilst applying.

Jonathan

Quoted 1 line
maintainer Applied
#6 lore raw
Quoted 23 lines · On Wed, 18 Feb 2026 09:58:20 +0000 Jonathan Cameron…
Quoted 20 lines · On Wed, 18 Feb 2026 11:40:11 +0200 Andy Shevchenko…
Quoted 3 lines · Nuno Sá
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Nuno Sá

On Tue, 2026-02-17 at 09:05 +0100, Andy Shevchenko wrote:

...

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I'm ok with this but as long as we get some consistency agreed on. So far, IIRC, the policy was to check for the NULL case even for the cases where that was not possible to happen.

Is it kernel-wide policy?

Nope... Just IIO IIRC. Actually, I'm pretty sure we had patches in the past just adding the check.

Like you said we need clearer policy.

Quoted 1 line

But again, I'm fine with the above as long as we are consistent from now on.

Quoted 8 lines
Quoted 2 lines

Exactly!
Jonathan, David, others?

As long as no compilers or static analyzers trip up on it and start spouting false warnings, I'm fine with not checking these. I'm not sure I'm bothered about going through the tree
removing the checks though. This one is so small I don't mind if it gets copied
into new drivers. If this is all that needs tidying up I'll tweak it whilst applying.

Applied. I also added a link tag to this thread, to say we had agreed to make it policy in IIO to not have these checks.

Thanks,

Jonathan

Quoted 5 lines

Jonathan

Quoted 1 line
#7 lore raw
Quoted 2 lines · Jonathan Cameron

On Wed, 18 Feb 2026 09:58:20 +0000
Jonathan Cameron <[email protected]> wrote:

...

Quoted 2 lines

Applied. I also added a link tag to this thread, to say we had agreed to make it policy in IIO to not have these checks.

Thanks!

Do we still need a process/maintainer-iio.rst?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#8 lore raw
Quoted 4 lines · On Fri, 20 Feb 2026 13:05:04 +0200 Andy Shevchenko…
Quoted 2 lines · Jonathan Cameron

On Wed, 18 Feb 2026 09:58:20 +0000
Jonathan Cameron <[email protected]> wrote:

Quoted 8 lines

...

Quoted 2 lines

Applied. I also added a link tag to this thread, to say we had agreed to make it policy in IIO to not have these checks.

Thanks!

Do we still need a process/maintainer-iio.rst?

Yes. Been meaning to start drawing one up for a long time but there is always something else that takes higher priority :(

If you want to propose something as a straw man that would be great!

Jonathan

Quoted 1 line
#9 lore raw
Quoted 5 lines · Jonathan Cameron
Quoted 3 lines · On Fri, 20 Feb 2026 13:05:04 +0200 Andy Shevchenko…
Quoted 2 lines · Jonathan Cameron

On Wed, 18 Feb 2026 09:58:20 +0000
Jonathan Cameron <[email protected]> wrote:

...

Quoted 10 lines
Quoted 6 lines
Quoted 2 lines

Applied. I also added a link tag to this thread, to say we had agreed to make it policy in IIO to not have these checks.

Thanks!

Do we still need a process/maintainer-iio.rst?

Yes. Been meaning to start drawing one up for a long time but there is always something else that takes higher priority :(

If you want to propose something as a straw man that would be great!

Taking into account my constant lack of time and not being a native speaker I would like somebody else to draft a skeleton. I would be happy to throw ideas how to amend and/or extend it.

OTOH, somebody like David, knowing more about depth of the IIO and the style can also draft if he feels like doing it. David?

At least, existence of that document drops quite a burden of repeating something which can only be scrapped now from the ML archives and IIO existing drivers (taking the date of pulling it in the upstream, the newer the better).

Signature · 2 lines
With Best Regards,
Andy Shevchenko