linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5 v3] iio: Silence no spi_device_id warnings
@ 2022-09-21 16:36 Wei Yongjun
  2022-09-21 16:36 ` [PATCH 1/5 v3] iio: adc: ti-ads131e08: " Wei Yongjun
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Wei Yongjun @ 2022-09-21 16:36 UTC (permalink / raw)
  To: Lars-Peter Clausen, Andy Shevchenko, Michael Hennerich, Jonathan Cameron
  Cc: Wei Yongjun, linux-iio

From: Wei Yongjun <weiyongjun1@huawei.com>

SPI devices use the spi_device_id for module autoloading even on
systems using device tree.

Commit 5fa6863ba692 ("spi: Check we have a spi_device_id for each DT
compatible") added a test to check that every SPI driver has a
spi_device_id for each DT compatiable string defined by driver
and warns if the spi_device_id is missing.

This series add spi_device_id entries to silence the warnings, and
ensure driver module autoloading works.

v2 -> v3:
 - post as patch series
 - make use of the spi_get_device_id(spi)->driver_data
   path to provide the chip info structure if
   of_device_get_match_data() returns NULL.

Wei Yongjun (5):
  iio: adc: ti-ads131e08: Silence no spi_device_id warnings
  iio: accel: sca3300: Silence no spi_device_id warning
  iio: adc: ad9467: Silence no spi_device_id warnings
  iio: adc: ad7192: Silence no spi_device_id warnings
  iio: adc: ad7124: Silence no spi_device_id warnings

 drivers/iio/accel/sca3300.c    | 12 ++++++++++--
 drivers/iio/adc/ad7124.c       | 10 ++++++++++
 drivers/iio/adc/ad7192.c       | 12 ++++++++++++
 drivers/iio/adc/ad9467.c       | 11 +++++++++++
 drivers/iio/adc/ti-ads131e08.c | 11 +++++++++++
 5 files changed, 54 insertions(+), 2 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/5 v3] iio: adc: ti-ads131e08: Silence no spi_device_id warnings
  2022-09-21 16:36 [PATCH 0/5 v3] iio: Silence no spi_device_id warnings Wei Yongjun
@ 2022-09-21 16:36 ` Wei Yongjun
  2022-09-22  5:43   ` Uwe Kleine-König
  2022-09-21 16:36 ` [PATCH 2/5 v3] iio: accel: sca3300: Silence no spi_device_id warning Wei Yongjun
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Wei Yongjun @ 2022-09-21 16:36 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Nuno Sá,
	Andy Shevchenko, Uwe Kleine-König
  Cc: Wei Yongjun, linux-iio

From: Wei Yongjun <weiyongjun1@huawei.com>

SPI devices use the spi_device_id for module autoloading even on
systems using device tree, after commit 5fa6863ba692 ("spi: Check
we have a spi_device_id for each DT compatible"), kernel warns as
follows since the spi_device_id is missing:

SPI driver ads131e08 has no spi_device_id for ti,ads131e04
SPI driver ads131e08 has no spi_device_id for ti,ads131e06

Add spi_device_id entries to silence the warnings, and ensure driver
module autoloading works.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/iio/adc/ti-ads131e08.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/iio/adc/ti-ads131e08.c b/drivers/iio/adc/ti-ads131e08.c
index 5235a93f28bc..fcfc46254313 100644
--- a/drivers/iio/adc/ti-ads131e08.c
+++ b/drivers/iio/adc/ti-ads131e08.c
@@ -807,6 +807,8 @@ static int ads131e08_probe(struct spi_device *spi)
 	int ret;
 
 	info = device_get_match_data(&spi->dev);
+	if (!info)
+		info = (void *)spi_get_device_id(spi)->driver_data;
 	if (!info) {
 		dev_err(&spi->dev, "failed to get match data\n");
 		return -ENODEV;
@@ -926,12 +928,21 @@ static const struct of_device_id ads131e08_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, ads131e08_of_match);
 
+static const struct spi_device_id ads131e08_ids[] = {
+	{ "ads131e04", (kernel_ulong_t)&ads131e08_info_tbl[ads131e04] },
+	{ "ads131e06", (kernel_ulong_t)&ads131e08_info_tbl[ads131e06] },
+	{ "ads131e08", (kernel_ulong_t)&ads131e08_info_tbl[ads131e08] },
+	{}
+};
+MODULE_DEVICE_TABLE(spi, ads131e08_ids);
+
 static struct spi_driver ads131e08_driver = {
 	.driver = {
 		.name = "ads131e08",
 		.of_match_table = ads131e08_of_match,
 	},
 	.probe = ads131e08_probe,
+	.id_table = ads131e08_ids,
 };
 module_spi_driver(ads131e08_driver);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/5 v3] iio: accel: sca3300: Silence no spi_device_id warning
  2022-09-21 16:36 [PATCH 0/5 v3] iio: Silence no spi_device_id warnings Wei Yongjun
  2022-09-21 16:36 ` [PATCH 1/5 v3] iio: adc: ti-ads131e08: " Wei Yongjun
@ 2022-09-21 16:36 ` Wei Yongjun
  2022-09-22  6:12   ` Tomas Melin
  2022-09-21 16:36 ` [PATCH 3/5 v3] iio: adc: ad9467: Silence no spi_device_id warnings Wei Yongjun
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Wei Yongjun @ 2022-09-21 16:36 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Andy Shevchenko, LI Qingwu,
	Tomas Melin, Nuno Sรก
  Cc: Wei Yongjun, linux-iio

From: Wei Yongjun <weiyongjun1@huawei.com>

SPI devices use the spi_device_id for module autoloading even on
systems using device tree, after commit 5fa6863ba692 ("spi: Check
we have a spi_device_id for each DT compatible"), kernel warns as
follows since the spi_device_id is missing:

SPI driver sca3300 has no spi_device_id for murata,scl3300

Add spi_device_id entries to silence the warning, and ensure driver
module autoloading works.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/iio/accel/sca3300.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/accel/sca3300.c b/drivers/iio/accel/sca3300.c
index eaa0c9cfda44..306482b70fad 100644
--- a/drivers/iio/accel/sca3300.c
+++ b/drivers/iio/accel/sca3300.c
@@ -679,12 +679,20 @@ static const struct of_device_id sca3300_dt_ids[] = {
 };
 MODULE_DEVICE_TABLE(of, sca3300_dt_ids);
 
+static const struct spi_device_id sca3300_ids[] = {
+	{ "sca3300" },
+	{ "scl3300" },
+	{}
+};
+MODULE_DEVICE_TABLE(spi, sca3300_ids);
+
 static struct spi_driver sca3300_driver = {
-	.driver = {
+	.driver   = {
 		.name		= SCA3300_ALIAS,
 		.of_match_table = sca3300_dt_ids,
 	},
-	.probe	= sca3300_probe,
+	.probe	  = sca3300_probe,
+	.id_table = sca3300_ids,
 };
 module_spi_driver(sca3300_driver);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/5 v3] iio: adc: ad9467: Silence no spi_device_id warnings
  2022-09-21 16:36 [PATCH 0/5 v3] iio: Silence no spi_device_id warnings Wei Yongjun
  2022-09-21 16:36 ` [PATCH 1/5 v3] iio: adc: ti-ads131e08: " Wei Yongjun
  2022-09-21 16:36 ` [PATCH 2/5 v3] iio: accel: sca3300: Silence no spi_device_id warning Wei Yongjun
@ 2022-09-21 16:36 ` Wei Yongjun
  2022-09-21 16:36 ` [PATCH 4/5 v3] iio: adc: ad7192: " Wei Yongjun
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Wei Yongjun @ 2022-09-21 16:36 UTC (permalink / raw)
  To: Lars-Peter Clausen, Andy Shevchenko, Michael Hennerich, Jonathan Cameron
  Cc: Wei Yongjun, linux-iio

From: Wei Yongjun <weiyongjun1@huawei.com>

SPI devices use the spi_device_id for module autoloading even on
systems using device tree, after commit 5fa6863ba692 ("spi: Check
we have a spi_device_id for each DT compatible"), kernel warns as
follows since the spi_device_id is missing:

SPI driver ad9467 has no spi_device_id for adi,ad9265
SPI driver ad9467 has no spi_device_id for adi,ad9434

Add spi_device_id entries to silence the warnings, and ensure driver
module autoloading works.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/iio/adc/ad9467.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/iio/adc/ad9467.c b/drivers/iio/adc/ad9467.c
index 7534572f7475..0621cf59d614 100644
--- a/drivers/iio/adc/ad9467.c
+++ b/drivers/iio/adc/ad9467.c
@@ -387,6 +387,8 @@ static int ad9467_probe(struct spi_device *spi)
 	int ret;
 
 	info = of_device_get_match_data(&spi->dev);
+	if (!info)
+		info = (void *)spi_get_device_id(spi)->driver_data;
 	if (!info)
 		return -ENODEV;
 
@@ -447,12 +449,21 @@ static const struct of_device_id ad9467_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, ad9467_of_match);
 
+static const struct spi_device_id ad9467_ids[] = {
+	{ "ad9265", (kernel_ulong_t)&ad9467_chip_tbl[ID_AD9265] },
+	{ "ad9434", (kernel_ulong_t)&ad9467_chip_tbl[ID_AD9434] },
+	{ "ad9467", (kernel_ulong_t)&ad9467_chip_tbl[ID_AD9467] },
+	{}
+};
+MODULE_DEVICE_TABLE(spi, ad9467_ids);
+
 static struct spi_driver ad9467_driver = {
 	.driver = {
 		.name = "ad9467",
 		.of_match_table = ad9467_of_match,
 	},
 	.probe = ad9467_probe,
+	.id_table = ad9467_ids,
 };
 module_spi_driver(ad9467_driver);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 4/5 v3] iio: adc: ad7192: Silence no spi_device_id warnings
  2022-09-21 16:36 [PATCH 0/5 v3] iio: Silence no spi_device_id warnings Wei Yongjun
                   ` (2 preceding siblings ...)
  2022-09-21 16:36 ` [PATCH 3/5 v3] iio: adc: ad9467: Silence no spi_device_id warnings Wei Yongjun
@ 2022-09-21 16:36 ` Wei Yongjun
  2022-09-21 16:36 ` [PATCH 5/5 v3] iio: adc: ad7124: " Wei Yongjun
  2022-09-21 20:41 ` [PATCH 0/5 v3] iio: " Andy Shevchenko
  5 siblings, 0 replies; 13+ messages in thread
From: Wei Yongjun @ 2022-09-21 16:36 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Andy Shevchenko,
	Alexandru Tachici, Jonathan Cameron
  Cc: Wei Yongjun, linux-iio

From: Wei Yongjun <weiyongjun1@huawei.com>

SPI devices use the spi_device_id for module autoloading even on
systems using device tree, after commit 5fa6863ba692 ("spi: Check
we have a spi_device_id for each DT compatible"), kernel warns as
follows since the spi_device_id is missing:

SPI driver ad7192 has no spi_device_id for adi,ad7190
SPI driver ad7192 has no spi_device_id for adi,ad7193
SPI driver ad7192 has no spi_device_id for adi,ad7195

Add spi_device_id entries to silence the warnings, and ensure driver
module autoloading works.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/iio/adc/ad7192.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c
index d71977be7d22..f5067173deb6 100644
--- a/drivers/iio/adc/ad7192.c
+++ b/drivers/iio/adc/ad7192.c
@@ -1037,6 +1037,8 @@ static int ad7192_probe(struct spi_device *spi)
 	st->int_vref_mv = ret / 1000;
 
 	st->chip_info = of_device_get_match_data(&spi->dev);
+	if (!st->chip_info)
+		st->chip_info = (void *)spi_get_device_id(spi)->driver_data;
 	indio_dev->name = st->chip_info->name;
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
@@ -1098,12 +1100,22 @@ static const struct of_device_id ad7192_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, ad7192_of_match);
 
+static const struct spi_device_id ad7192_ids[] = {
+	{ "ad7190", (kernel_ulong_t)&ad7192_chip_info_tbl[ID_AD7190] },
+	{ "ad7192", (kernel_ulong_t)&ad7192_chip_info_tbl[ID_AD7192] },
+	{ "ad7193", (kernel_ulong_t)&ad7192_chip_info_tbl[ID_AD7193] },
+	{ "ad7195", (kernel_ulong_t)&ad7192_chip_info_tbl[ID_AD7195] },
+	{}
+};
+MODULE_DEVICE_TABLE(spi, ad7192_ids);
+
 static struct spi_driver ad7192_driver = {
 	.driver = {
 		.name	= "ad7192",
 		.of_match_table = ad7192_of_match,
 	},
 	.probe		= ad7192_probe,
+	.id_table	= ad7192_ids,
 };
 module_spi_driver(ad7192_driver);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 5/5 v3] iio: adc: ad7124: Silence no spi_device_id warnings
  2022-09-21 16:36 [PATCH 0/5 v3] iio: Silence no spi_device_id warnings Wei Yongjun
                   ` (3 preceding siblings ...)
  2022-09-21 16:36 ` [PATCH 4/5 v3] iio: adc: ad7192: " Wei Yongjun
@ 2022-09-21 16:36 ` Wei Yongjun
  2022-09-21 20:41 ` [PATCH 0/5 v3] iio: " Andy Shevchenko
  5 siblings, 0 replies; 13+ messages in thread
From: Wei Yongjun @ 2022-09-21 16:36 UTC (permalink / raw)
  To: Lars-Peter Clausen, Andy Shevchenko, Michael Hennerich, Jonathan Cameron
  Cc: Wei Yongjun, linux-iio

From: Wei Yongjun <weiyongjun1@huawei.com>

SPI devices use the spi_device_id for module autoloading even on
systems using device tree, after commit 5fa6863ba692 ("spi: Check
we have a spi_device_id for each DT compatible"), kernel warns as
follows since the spi_device_id is missing:

SPI driver ad7124 has no spi_device_id for adi,ad7124-4
SPI driver ad7124 has no spi_device_id for adi,ad7124-8

Add spi_device_id entries to silence the warnings, and ensure driver
module autoloading works.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/iio/adc/ad7124.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
index 4088786e1026..050a2fbf5c49 100644
--- a/drivers/iio/adc/ad7124.c
+++ b/drivers/iio/adc/ad7124.c
@@ -944,6 +944,8 @@ static int ad7124_probe(struct spi_device *spi)
 	int i, ret;
 
 	info = of_device_get_match_data(&spi->dev);
+	if (!info)
+		info = (void *)spi_get_device_id(spi)->driver_data;
 	if (!info)
 		return -ENODEV;
 
@@ -1021,12 +1023,20 @@ static const struct of_device_id ad7124_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, ad7124_of_match);
 
+static const struct spi_device_id ad71124_ids[] = {
+	{ "ad7124-4", (kernel_ulong_t)&ad7124_chip_info_tbl[ID_AD7124_4] },
+	{ "ad7124-8", (kernel_ulong_t)&ad7124_chip_info_tbl[ID_AD7124_8] },
+	{}
+};
+MODULE_DEVICE_TABLE(spi, ad71124_ids);
+
 static struct spi_driver ad71124_driver = {
 	.driver = {
 		.name = "ad7124",
 		.of_match_table = ad7124_of_match,
 	},
 	.probe = ad7124_probe,
+	.id_table = ad71124_ids,
 };
 module_spi_driver(ad71124_driver);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/5 v3] iio: Silence no spi_device_id warnings
  2022-09-21 16:36 [PATCH 0/5 v3] iio: Silence no spi_device_id warnings Wei Yongjun
                   ` (4 preceding siblings ...)
  2022-09-21 16:36 ` [PATCH 5/5 v3] iio: adc: ad7124: " Wei Yongjun
@ 2022-09-21 20:41 ` Andy Shevchenko
  2022-10-02 14:03   ` Jonathan Cameron
  5 siblings, 1 reply; 13+ messages in thread
From: Andy Shevchenko @ 2022-09-21 20:41 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Wei Yongjun, linux-iio

On Wed, Sep 21, 2022 at 7:19 PM Wei Yongjun <weiyongjun@huaweicloud.com> wrote:
>
> From: Wei Yongjun <weiyongjun1@huawei.com>
>
> SPI devices use the spi_device_id for module autoloading even on
> systems using device tree.
>
> Commit 5fa6863ba692 ("spi: Check we have a spi_device_id for each DT
> compatible") added a test to check that every SPI driver has a
> spi_device_id for each DT compatiable string defined by driver
> and warns if the spi_device_id is missing.
>
> This series add spi_device_id entries to silence the warnings, and
> ensure driver module autoloading works.

Nice, but I would like to avoid the unneeded churn in the future and
right away use a new API for that. I will submit a patch soon that you
may attach to your series as a prerequisite.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/5 v3] iio: adc: ti-ads131e08: Silence no spi_device_id warnings
  2022-09-21 16:36 ` [PATCH 1/5 v3] iio: adc: ti-ads131e08: " Wei Yongjun
@ 2022-09-22  5:43   ` Uwe Kleine-König
  2022-09-22 11:13     ` Jonathan Cameron
  0 siblings, 1 reply; 13+ messages in thread
From: Uwe Kleine-König @ 2022-09-22  5:43 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: Jonathan Cameron, Lars-Peter Clausen, Nuno Sá,
	Andy Shevchenko, Wei Yongjun, linux-iio

[-- Attachment #1: Type: text/plain, Size: 2390 bytes --]

On Wed, Sep 21, 2022 at 04:36:16PM +0000, Wei Yongjun wrote:
> From: Wei Yongjun <weiyongjun1@huawei.com>
> 
> SPI devices use the spi_device_id for module autoloading even on
> systems using device tree, after commit 5fa6863ba692 ("spi: Check
> we have a spi_device_id for each DT compatible"), kernel warns as
> follows since the spi_device_id is missing:
> 
> SPI driver ads131e08 has no spi_device_id for ti,ads131e04
> SPI driver ads131e08 has no spi_device_id for ti,ads131e06
> 
> Add spi_device_id entries to silence the warnings, and ensure driver
> module autoloading works.
> 
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
>  drivers/iio/adc/ti-ads131e08.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/iio/adc/ti-ads131e08.c b/drivers/iio/adc/ti-ads131e08.c
> index 5235a93f28bc..fcfc46254313 100644
> --- a/drivers/iio/adc/ti-ads131e08.c
> +++ b/drivers/iio/adc/ti-ads131e08.c
> @@ -807,6 +807,8 @@ static int ads131e08_probe(struct spi_device *spi)
>  	int ret;
>  
>  	info = device_get_match_data(&spi->dev);
> +	if (!info)
> +		info = (void *)spi_get_device_id(spi)->driver_data;

I wonder if this hunk is orthogonal to the patch? For the purpose
mentioned in the commit log it would be enough to skip this hunk and
don't provide driver_data in ads131e08_ids[] below, wouldn't it?

>  	if (!info) {
>  		dev_err(&spi->dev, "failed to get match data\n");
>  		return -ENODEV;
> @@ -926,12 +928,21 @@ static const struct of_device_id ads131e08_of_match[] = {
>  };
>  MODULE_DEVICE_TABLE(of, ads131e08_of_match);
>  
> +static const struct spi_device_id ads131e08_ids[] = {
> +	{ "ads131e04", (kernel_ulong_t)&ads131e08_info_tbl[ads131e04] },
> +	{ "ads131e06", (kernel_ulong_t)&ads131e08_info_tbl[ads131e06] },
> +	{ "ads131e08", (kernel_ulong_t)&ads131e08_info_tbl[ads131e08] },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(spi, ads131e08_ids);
> +
>  static struct spi_driver ads131e08_driver = {
>  	.driver = {
>  		.name = "ads131e08",
>  		.of_match_table = ads131e08_of_match,
>  	},
>  	.probe = ads131e08_probe,
> +	.id_table = ads131e08_ids,
>  };
>  module_spi_driver(ads131e08_driver);

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/5 v3] iio: accel: sca3300: Silence no spi_device_id warning
  2022-09-21 16:36 ` [PATCH 2/5 v3] iio: accel: sca3300: Silence no spi_device_id warning Wei Yongjun
@ 2022-09-22  6:12   ` Tomas Melin
  0 siblings, 0 replies; 13+ messages in thread
From: Tomas Melin @ 2022-09-22  6:12 UTC (permalink / raw)
  To: Wei Yongjun, Jonathan Cameron, Lars-Peter Clausen,
	Andy Shevchenko, LI Qingwu, Nuno Sรก
  Cc: Wei Yongjun, linux-iio


On 21/09/2022 19:36, Wei Yongjun wrote:
> From: Wei Yongjun <weiyongjun1@huawei.com>
> 
> SPI devices use the spi_device_id for module autoloading even on
> systems using device tree, after commit 5fa6863ba692 ("spi: Check
> we have a spi_device_id for each DT compatible"), kernel warns as
> follows since the spi_device_id is missing:
> 
> SPI driver sca3300 has no spi_device_id for murata,scl3300
> 
> Add spi_device_id entries to silence the warning, and ensure driver
> module autoloading works.
> 
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Reviewed-by: Tomas Melin <tomas.melin@vaisala.com>

> ---
>  drivers/iio/accel/sca3300.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/accel/sca3300.c b/drivers/iio/accel/sca3300.c
> index eaa0c9cfda44..306482b70fad 100644
> --- a/drivers/iio/accel/sca3300.c
> +++ b/drivers/iio/accel/sca3300.c
> @@ -679,12 +679,20 @@ static const struct of_device_id sca3300_dt_ids[] = {
>  };
>  MODULE_DEVICE_TABLE(of, sca3300_dt_ids);
>  
> +static const struct spi_device_id sca3300_ids[] = {
> +	{ "sca3300" },
> +	{ "scl3300" },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(spi, sca3300_ids);
> +
>  static struct spi_driver sca3300_driver = {
> -	.driver = {
> +	.driver   = {
>  		.name		= SCA3300_ALIAS,
>  		.of_match_table = sca3300_dt_ids,
>  	},
> -	.probe	= sca3300_probe,
> +	.probe	  = sca3300_probe,
> +	.id_table = sca3300_ids,
>  };
>  module_spi_driver(sca3300_driver);
>  

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/5 v3] iio: adc: ti-ads131e08: Silence no spi_device_id warnings
  2022-09-22  5:43   ` Uwe Kleine-König
@ 2022-09-22 11:13     ` Jonathan Cameron
  2022-09-22 13:26       ` Andy Shevchenko
  0 siblings, 1 reply; 13+ messages in thread
From: Jonathan Cameron @ 2022-09-22 11:13 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Wei Yongjun, Jonathan Cameron, Lars-Peter Clausen, Nuno Sá,
	Andy Shevchenko, Wei Yongjun, linux-iio

On Thu, 22 Sep 2022 07:43:34 +0200
Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:

> On Wed, Sep 21, 2022 at 04:36:16PM +0000, Wei Yongjun wrote:
> > From: Wei Yongjun <weiyongjun1@huawei.com>
> > 
> > SPI devices use the spi_device_id for module autoloading even on
> > systems using device tree, after commit 5fa6863ba692 ("spi: Check
> > we have a spi_device_id for each DT compatible"), kernel warns as
> > follows since the spi_device_id is missing:
> > 
> > SPI driver ads131e08 has no spi_device_id for ti,ads131e04
> > SPI driver ads131e08 has no spi_device_id for ti,ads131e06
> > 
> > Add spi_device_id entries to silence the warnings, and ensure driver
> > module autoloading works.
> > 
> > Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> > ---
> >  drivers/iio/adc/ti-ads131e08.c | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> > 
> > diff --git a/drivers/iio/adc/ti-ads131e08.c b/drivers/iio/adc/ti-ads131e08.c
> > index 5235a93f28bc..fcfc46254313 100644
> > --- a/drivers/iio/adc/ti-ads131e08.c
> > +++ b/drivers/iio/adc/ti-ads131e08.c
> > @@ -807,6 +807,8 @@ static int ads131e08_probe(struct spi_device *spi)
> >  	int ret;
> >  
> >  	info = device_get_match_data(&spi->dev);
> > +	if (!info)
> > +		info = (void *)spi_get_device_id(spi)->driver_data;  
> 
> I wonder if this hunk is orthogonal to the patch? For the purpose
> mentioned in the commit log it would be enough to skip this hunk and
> don't provide driver_data in ads131e08_ids[] below, wouldn't it?

Maybe need to expand the patch description, but this is needed.
Without it the patch is buggy...

By providing the new table, non firmware registration paths are enabled
that were not before (board files + I think Greybus still uses that path?)
If those are used they will get NULL from device_get_match_data() with
predictable bad results.

Jonathan



> 
> >  	if (!info) {
> >  		dev_err(&spi->dev, "failed to get match data\n");
> >  		return -ENODEV;
> > @@ -926,12 +928,21 @@ static const struct of_device_id ads131e08_of_match[] = {
> >  };
> >  MODULE_DEVICE_TABLE(of, ads131e08_of_match);
> >  
> > +static const struct spi_device_id ads131e08_ids[] = {
> > +	{ "ads131e04", (kernel_ulong_t)&ads131e08_info_tbl[ads131e04] },
> > +	{ "ads131e06", (kernel_ulong_t)&ads131e08_info_tbl[ads131e06] },
> > +	{ "ads131e08", (kernel_ulong_t)&ads131e08_info_tbl[ads131e08] },
> > +	{}
> > +};
> > +MODULE_DEVICE_TABLE(spi, ads131e08_ids);
> > +
> >  static struct spi_driver ads131e08_driver = {
> >  	.driver = {
> >  		.name = "ads131e08",
> >  		.of_match_table = ads131e08_of_match,
> >  	},
> >  	.probe = ads131e08_probe,
> > +	.id_table = ads131e08_ids,
> >  };
> >  module_spi_driver(ads131e08_driver);  
> 
> Best regards
> Uwe
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/5 v3] iio: adc: ti-ads131e08: Silence no spi_device_id warnings
  2022-09-22 11:13     ` Jonathan Cameron
@ 2022-09-22 13:26       ` Andy Shevchenko
  0 siblings, 0 replies; 13+ messages in thread
From: Andy Shevchenko @ 2022-09-22 13:26 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Uwe Kleine-König, Wei Yongjun, Jonathan Cameron,
	Lars-Peter Clausen, Nuno Sá,
	Wei Yongjun, linux-iio

On Thu, Sep 22, 2022 at 2:13 PM Jonathan Cameron
<Jonathan.Cameron@huawei.com> wrote:
> On Thu, 22 Sep 2022 07:43:34 +0200
> Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:

...

> By providing the new table, non firmware registration paths are enabled
> that were not before (board files + I think Greybus still uses that path?)
> If those are used they will get NULL from device_get_match_data() with
> predictable bad results.

We still have some board files or board:ish info in the kernel to
support some platforms, so it won't go away (at least soon: in the
parentheses because don't forget about FPGAs that need a possibility
of the reconfiguration at run time).

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/5 v3] iio: Silence no spi_device_id warnings
  2022-09-21 20:41 ` [PATCH 0/5 v3] iio: " Andy Shevchenko
@ 2022-10-02 14:03   ` Jonathan Cameron
  2022-10-03  7:29     ` Andy Shevchenko
  0 siblings, 1 reply; 13+ messages in thread
From: Jonathan Cameron @ 2022-10-02 14:03 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Wei Yongjun, Lars-Peter Clausen, Michael Hennerich, Wei Yongjun,
	linux-iio

On Wed, 21 Sep 2022 23:41:54 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Wed, Sep 21, 2022 at 7:19 PM Wei Yongjun <weiyongjun@huaweicloud.com> wrote:
> >
> > From: Wei Yongjun <weiyongjun1@huawei.com>
> >
> > SPI devices use the spi_device_id for module autoloading even on
> > systems using device tree.
> >
> > Commit 5fa6863ba692 ("spi: Check we have a spi_device_id for each DT
> > compatible") added a test to check that every SPI driver has a
> > spi_device_id for each DT compatiable string defined by driver
> > and warns if the spi_device_id is missing.
> >
> > This series add spi_device_id entries to silence the warnings, and
> > ensure driver module autoloading works.  
> 
> Nice, but I would like to avoid the unneeded churn in the future and
> right away use a new API for that. I will submit a patch soon that you
> may attach to your series as a prerequisite.
> 

Given Andy's suggestion (which I like, but no one else has replied to!)
isn't moving forwards particularly quickly.... I've applied this series
as it stands.  We will just have to cope with the churn (there will be
a lot beyond these few drivers anyway to fully take advantage of
the utility function Andy has suggested)

Applied to the togreg branch of iio.git as 6.2 material. I'll push out
as testing for now for 0-day to see if it can find any problems. Will be
rebasing that tree on rc1.

Jonathan


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/5 v3] iio: Silence no spi_device_id warnings
  2022-10-02 14:03   ` Jonathan Cameron
@ 2022-10-03  7:29     ` Andy Shevchenko
  0 siblings, 0 replies; 13+ messages in thread
From: Andy Shevchenko @ 2022-10-03  7:29 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Wei Yongjun, Lars-Peter Clausen, Michael Hennerich, Wei Yongjun,
	linux-iio

On Sun, Oct 2, 2022 at 5:03 PM Jonathan Cameron <jic23@kernel.org> wrote:
> On Wed, 21 Sep 2022 23:41:54 +0300
> Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

...

> Given Andy's suggestion (which I like, but no one else has replied to!)
> isn't moving forwards particularly quickly.... I've applied this series
> as it stands.  We will just have to cope with the churn (there will be
> a lot beyond these few drivers anyway to fully take advantage of
> the utility function Andy has suggested)

dev_fwnode() now takes a const pointer, so the needed API can be
submitted after -rc1, for v6.2 as well, but then conversion can happen
later on.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-10-03  7:56 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-21 16:36 [PATCH 0/5 v3] iio: Silence no spi_device_id warnings Wei Yongjun
2022-09-21 16:36 ` [PATCH 1/5 v3] iio: adc: ti-ads131e08: " Wei Yongjun
2022-09-22  5:43   ` Uwe Kleine-König
2022-09-22 11:13     ` Jonathan Cameron
2022-09-22 13:26       ` Andy Shevchenko
2022-09-21 16:36 ` [PATCH 2/5 v3] iio: accel: sca3300: Silence no spi_device_id warning Wei Yongjun
2022-09-22  6:12   ` Tomas Melin
2022-09-21 16:36 ` [PATCH 3/5 v3] iio: adc: ad9467: Silence no spi_device_id warnings Wei Yongjun
2022-09-21 16:36 ` [PATCH 4/5 v3] iio: adc: ad7192: " Wei Yongjun
2022-09-21 16:36 ` [PATCH 5/5 v3] iio: adc: ad7124: " Wei Yongjun
2022-09-21 20:41 ` [PATCH 0/5 v3] iio: " Andy Shevchenko
2022-10-02 14:03   ` Jonathan Cameron
2022-10-03  7:29     ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).