diff mbox series

[v2,3/3] iio: adc: tsc2046: silent spi_device_id warning

Message ID 20220831095601.4157195-3-o.rempel@pengutronix.de (mailing list archive)
State Superseded
Headers show
Series [v2,1/3] dt-bindings: iio: adc: ti,tsc2046: add vref-supply property | expand

Commit Message

Oleksij Rempel Aug. 31, 2022, 9:56 a.m. UTC
Add spi_device_id to silent following kernel runtime warning:
"SPI driver tsc2046 has no spi_device_id for ti,tsc2046e-adc"

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
changes v2:
- attach actual driver_data
- use spi_get_device_id fallback
---
 drivers/iio/adc/ti-tsc2046.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Andy Shevchenko Aug. 31, 2022, 12:33 p.m. UTC | #1
On Wed, Aug 31, 2022 at 1:01 PM Oleksij Rempel <o.rempel@pengutronix.de> wrote:

All below are minors (but you really need to Cc reviewers from the
previous round(s) to pay the respect), so I leave them to IIO
maintainers.

...

> Add spi_device_id to silent following kernel runtime warning:
> "SPI driver tsc2046 has no spi_device_id for ti,tsc2046e-adc"

Missed period.

>         dcfg = device_get_match_data(dev);
> +       if (!dcfg) {

> +               const struct spi_device_id *id;
> +
> +               id = spi_get_device_id(spi);

You can move assignment to the definition line.

> +               dcfg = (const struct tsc2046_adc_dcfg *)id->driver_data;
> +       }

> +

Unneeded blank line, since these all are grouped semantically.

>         if (!dcfg)
>                 return -EINVAL;
diff mbox series

Patch

diff --git a/drivers/iio/adc/ti-tsc2046.c b/drivers/iio/adc/ti-tsc2046.c
index bbc8b4137b0b1..ef78826241ee8 100644
--- a/drivers/iio/adc/ti-tsc2046.c
+++ b/drivers/iio/adc/ti-tsc2046.c
@@ -762,6 +762,13 @@  static int tsc2046_adc_probe(struct spi_device *spi)
 	}
 
 	dcfg = device_get_match_data(dev);
+	if (!dcfg) {
+		const struct spi_device_id *id;
+
+		id = spi_get_device_id(spi);
+		dcfg = (const struct tsc2046_adc_dcfg *)id->driver_data;
+	}
+
 	if (!dcfg)
 		return -EINVAL;
 
@@ -878,11 +885,18 @@  static const struct of_device_id ads7950_of_table[] = {
 };
 MODULE_DEVICE_TABLE(of, ads7950_of_table);
 
+static const struct spi_device_id tsc2046_adc_spi_ids[] = {
+	{ "tsc2046e-adc", (unsigned long)&tsc2046_adc_dcfg_tsc2046e },
+	{ }
+};
+MODULE_DEVICE_TABLE(spi, tsc2046_adc_spi_ids);
+
 static struct spi_driver tsc2046_adc_driver = {
 	.driver = {
 		.name = "tsc2046",
 		.of_match_table = ads7950_of_table,
 	},
+	.id_table = tsc2046_adc_spi_ids,
 	.probe = tsc2046_adc_probe,
 	.remove = tsc2046_adc_remove,
 };