Re: [PATCH 1/5 v3] iio: adc: ti-ads131e08: Silence no spi_device_id warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Sep 21, 2022 at 04:36:16PM +0000, Wei Yongjun wrote:
> From: Wei Yongjun <weiyongjun1@xxxxxxxxxx>
> 
> 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@xxxxxxxxxx>
> ---
>  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: signature.asc
Description: PGP signature


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux