diff mbox series

iio: imu: adis16475: add spi_device_id table

Message ID 20231102125258.3284830-1-nuno.sa@analog.com (mailing list archive)
State Accepted
Headers show
Series iio: imu: adis16475: add spi_device_id table | expand

Commit Message

Nuno Sa Nov. 2, 2023, 12:52 p.m. UTC
This prevents the warning message "SPI driver has no spi_device_id for..."
when registering the driver. More importantly, it makes sure that
module autoloading works as spi relies on spi: modaliases and not of.

While at it, move the of_device_id table to it's natural place.

Fixes: fff7352bf7a3c ("iio: imu: Add support for adis16475")
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
---

I'm adding the fixes tag as module autoloading might be a nice thing to
backport... Jonathan, if you don't see a real need for it, feel free to
drop the tag.

 drivers/iio/imu/adis16475.c | 117 ++++++++++++++++++++++--------------
 1 file changed, 72 insertions(+), 45 deletions(-)

Comments

Jonathan Cameron Nov. 26, 2023, 4:41 p.m. UTC | #1
On Thu, 2 Nov 2023 13:52:58 +0100
Nuno Sa <nuno.sa@analog.com> wrote:

> This prevents the warning message "SPI driver has no spi_device_id for..."
> when registering the driver. More importantly, it makes sure that
> module autoloading works as spi relies on spi: modaliases and not of.
> 
> While at it, move the of_device_id table to it's natural place.
> 
> Fixes: fff7352bf7a3c ("iio: imu: Add support for adis16475")
> Signed-off-by: Nuno Sa <nuno.sa@analog.com>
> ---
> 
> I'm adding the fixes tag as module autoloading might be a nice thing to
> backport... Jonathan, if you don't see a real need for it, feel free to
> drop the tag.

Fine to have the fixes tag.  I've marked it for stable as well.

Applied
> 
>  drivers/iio/imu/adis16475.c | 117 ++++++++++++++++++++++--------------
>  1 file changed, 72 insertions(+), 45 deletions(-)
> 
> diff --git a/drivers/iio/imu/adis16475.c b/drivers/iio/imu/adis16475.c
> index b7cbe1565aee..04153a2725d5 100644
> --- a/drivers/iio/imu/adis16475.c
> +++ b/drivers/iio/imu/adis16475.c
> @@ -1406,50 +1406,6 @@ static int adis16475_config_irq_pin(struct adis16475 *st)
>  	return 0;
>  }
>  
> -static const struct of_device_id adis16475_of_match[] = {
> -	{ .compatible = "adi,adis16470",
> -		.data = &adis16475_chip_info[ADIS16470] },
> -	{ .compatible = "adi,adis16475-1",
> -		.data = &adis16475_chip_info[ADIS16475_1] },
> -	{ .compatible = "adi,adis16475-2",
> -		.data = &adis16475_chip_info[ADIS16475_2] },
> -	{ .compatible = "adi,adis16475-3",
> -		.data = &adis16475_chip_info[ADIS16475_3] },
> -	{ .compatible = "adi,adis16477-1",
> -		.data = &adis16475_chip_info[ADIS16477_1] },
> -	{ .compatible = "adi,adis16477-2",
> -		.data = &adis16475_chip_info[ADIS16477_2] },
> -	{ .compatible = "adi,adis16477-3",
> -		.data = &adis16475_chip_info[ADIS16477_3] },
> -	{ .compatible = "adi,adis16465-1",
> -		.data = &adis16475_chip_info[ADIS16465_1] },
> -	{ .compatible = "adi,adis16465-2",
> -		.data = &adis16475_chip_info[ADIS16465_2] },
> -	{ .compatible = "adi,adis16465-3",
> -		.data = &adis16475_chip_info[ADIS16465_3] },
> -	{ .compatible = "adi,adis16467-1",
> -		.data = &adis16475_chip_info[ADIS16467_1] },
> -	{ .compatible = "adi,adis16467-2",
> -		.data = &adis16475_chip_info[ADIS16467_2] },
> -	{ .compatible = "adi,adis16467-3",
> -		.data = &adis16475_chip_info[ADIS16467_3] },
> -	{ .compatible = "adi,adis16500",
> -		.data = &adis16475_chip_info[ADIS16500] },
> -	{ .compatible = "adi,adis16505-1",
> -		.data = &adis16475_chip_info[ADIS16505_1] },
> -	{ .compatible = "adi,adis16505-2",
> -		.data = &adis16475_chip_info[ADIS16505_2] },
> -	{ .compatible = "adi,adis16505-3",
> -		.data = &adis16475_chip_info[ADIS16505_3] },
> -	{ .compatible = "adi,adis16507-1",
> -		.data = &adis16475_chip_info[ADIS16507_1] },
> -	{ .compatible = "adi,adis16507-2",
> -		.data = &adis16475_chip_info[ADIS16507_2] },
> -	{ .compatible = "adi,adis16507-3",
> -		.data = &adis16475_chip_info[ADIS16507_3] },
> -	{ },
> -};
> -MODULE_DEVICE_TABLE(of, adis16475_of_match);
>  
>  static int adis16475_probe(struct spi_device *spi)
>  {
> @@ -1463,7 +1419,7 @@ static int adis16475_probe(struct spi_device *spi)
>  
>  	st = iio_priv(indio_dev);
>  
> -	st->info = device_get_match_data(&spi->dev);
> +	st->info = spi_get_device_match_data(spi);
>  	if (!st->info)
>  		return -EINVAL;
>  
> @@ -1503,12 +1459,83 @@ static int adis16475_probe(struct spi_device *spi)
>  	return 0;
>  }
>  
> +static const struct of_device_id adis16475_of_match[] = {
> +	{ .compatible = "adi,adis16470",
> +		.data = &adis16475_chip_info[ADIS16470] },
> +	{ .compatible = "adi,adis16475-1",
> +		.data = &adis16475_chip_info[ADIS16475_1] },
> +	{ .compatible = "adi,adis16475-2",
> +		.data = &adis16475_chip_info[ADIS16475_2] },
> +	{ .compatible = "adi,adis16475-3",
> +		.data = &adis16475_chip_info[ADIS16475_3] },
> +	{ .compatible = "adi,adis16477-1",
> +		.data = &adis16475_chip_info[ADIS16477_1] },
> +	{ .compatible = "adi,adis16477-2",
> +		.data = &adis16475_chip_info[ADIS16477_2] },
> +	{ .compatible = "adi,adis16477-3",
> +		.data = &adis16475_chip_info[ADIS16477_3] },
> +	{ .compatible = "adi,adis16465-1",
> +		.data = &adis16475_chip_info[ADIS16465_1] },
> +	{ .compatible = "adi,adis16465-2",
> +		.data = &adis16475_chip_info[ADIS16465_2] },
> +	{ .compatible = "adi,adis16465-3",
> +		.data = &adis16475_chip_info[ADIS16465_3] },
> +	{ .compatible = "adi,adis16467-1",
> +		.data = &adis16475_chip_info[ADIS16467_1] },
> +	{ .compatible = "adi,adis16467-2",
> +		.data = &adis16475_chip_info[ADIS16467_2] },
> +	{ .compatible = "adi,adis16467-3",
> +		.data = &adis16475_chip_info[ADIS16467_3] },
> +	{ .compatible = "adi,adis16500",
> +		.data = &adis16475_chip_info[ADIS16500] },
> +	{ .compatible = "adi,adis16505-1",
> +		.data = &adis16475_chip_info[ADIS16505_1] },
> +	{ .compatible = "adi,adis16505-2",
> +		.data = &adis16475_chip_info[ADIS16505_2] },
> +	{ .compatible = "adi,adis16505-3",
> +		.data = &adis16475_chip_info[ADIS16505_3] },
> +	{ .compatible = "adi,adis16507-1",
> +		.data = &adis16475_chip_info[ADIS16507_1] },
> +	{ .compatible = "adi,adis16507-2",
> +		.data = &adis16475_chip_info[ADIS16507_2] },
> +	{ .compatible = "adi,adis16507-3",
> +		.data = &adis16475_chip_info[ADIS16507_3] },
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(of, adis16475_of_match);
> +
> +static const struct spi_device_id adis16475_ids[] = {
> +	{ "adis16470", (kernel_ulong_t)&adis16475_chip_info[ADIS16470] },
> +	{ "adis16475-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16475_1] },
> +	{ "adis16475-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16475_2] },
> +	{ "adis16475-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16475_3] },
> +	{ "adis16477-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16477_1] },
> +	{ "adis16477-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16477_2] },
> +	{ "adis16477-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16477_3] },
> +	{ "adis16465-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16465_1] },
> +	{ "adis16465-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16465_2] },
> +	{ "adis16465-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16465_3] },
> +	{ "adis16467-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16467_1] },
> +	{ "adis16467-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16467_2] },
> +	{ "adis16467-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16467_3] },
> +	{ "adis16500", (kernel_ulong_t)&adis16475_chip_info[ADIS16500] },
> +	{ "adis16505-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16505_1] },
> +	{ "adis16505-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16505_2] },
> +	{ "adis16505-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16505_3] },
> +	{ "adis16507-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16507_1] },
> +	{ "adis16507-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16507_2] },
> +	{ "adis16507-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16507_3] },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(spi, adis16475_ids);
> +
>  static struct spi_driver adis16475_driver = {
>  	.driver = {
>  		.name = "adis16475",
>  		.of_match_table = adis16475_of_match,
>  	},
>  	.probe = adis16475_probe,
> +	.id_table = adis16475_ids,
>  };
>  module_spi_driver(adis16475_driver);
>
diff mbox series

Patch

diff --git a/drivers/iio/imu/adis16475.c b/drivers/iio/imu/adis16475.c
index b7cbe1565aee..04153a2725d5 100644
--- a/drivers/iio/imu/adis16475.c
+++ b/drivers/iio/imu/adis16475.c
@@ -1406,50 +1406,6 @@  static int adis16475_config_irq_pin(struct adis16475 *st)
 	return 0;
 }
 
-static const struct of_device_id adis16475_of_match[] = {
-	{ .compatible = "adi,adis16470",
-		.data = &adis16475_chip_info[ADIS16470] },
-	{ .compatible = "adi,adis16475-1",
-		.data = &adis16475_chip_info[ADIS16475_1] },
-	{ .compatible = "adi,adis16475-2",
-		.data = &adis16475_chip_info[ADIS16475_2] },
-	{ .compatible = "adi,adis16475-3",
-		.data = &adis16475_chip_info[ADIS16475_3] },
-	{ .compatible = "adi,adis16477-1",
-		.data = &adis16475_chip_info[ADIS16477_1] },
-	{ .compatible = "adi,adis16477-2",
-		.data = &adis16475_chip_info[ADIS16477_2] },
-	{ .compatible = "adi,adis16477-3",
-		.data = &adis16475_chip_info[ADIS16477_3] },
-	{ .compatible = "adi,adis16465-1",
-		.data = &adis16475_chip_info[ADIS16465_1] },
-	{ .compatible = "adi,adis16465-2",
-		.data = &adis16475_chip_info[ADIS16465_2] },
-	{ .compatible = "adi,adis16465-3",
-		.data = &adis16475_chip_info[ADIS16465_3] },
-	{ .compatible = "adi,adis16467-1",
-		.data = &adis16475_chip_info[ADIS16467_1] },
-	{ .compatible = "adi,adis16467-2",
-		.data = &adis16475_chip_info[ADIS16467_2] },
-	{ .compatible = "adi,adis16467-3",
-		.data = &adis16475_chip_info[ADIS16467_3] },
-	{ .compatible = "adi,adis16500",
-		.data = &adis16475_chip_info[ADIS16500] },
-	{ .compatible = "adi,adis16505-1",
-		.data = &adis16475_chip_info[ADIS16505_1] },
-	{ .compatible = "adi,adis16505-2",
-		.data = &adis16475_chip_info[ADIS16505_2] },
-	{ .compatible = "adi,adis16505-3",
-		.data = &adis16475_chip_info[ADIS16505_3] },
-	{ .compatible = "adi,adis16507-1",
-		.data = &adis16475_chip_info[ADIS16507_1] },
-	{ .compatible = "adi,adis16507-2",
-		.data = &adis16475_chip_info[ADIS16507_2] },
-	{ .compatible = "adi,adis16507-3",
-		.data = &adis16475_chip_info[ADIS16507_3] },
-	{ },
-};
-MODULE_DEVICE_TABLE(of, adis16475_of_match);
 
 static int adis16475_probe(struct spi_device *spi)
 {
@@ -1463,7 +1419,7 @@  static int adis16475_probe(struct spi_device *spi)
 
 	st = iio_priv(indio_dev);
 
-	st->info = device_get_match_data(&spi->dev);
+	st->info = spi_get_device_match_data(spi);
 	if (!st->info)
 		return -EINVAL;
 
@@ -1503,12 +1459,83 @@  static int adis16475_probe(struct spi_device *spi)
 	return 0;
 }
 
+static const struct of_device_id adis16475_of_match[] = {
+	{ .compatible = "adi,adis16470",
+		.data = &adis16475_chip_info[ADIS16470] },
+	{ .compatible = "adi,adis16475-1",
+		.data = &adis16475_chip_info[ADIS16475_1] },
+	{ .compatible = "adi,adis16475-2",
+		.data = &adis16475_chip_info[ADIS16475_2] },
+	{ .compatible = "adi,adis16475-3",
+		.data = &adis16475_chip_info[ADIS16475_3] },
+	{ .compatible = "adi,adis16477-1",
+		.data = &adis16475_chip_info[ADIS16477_1] },
+	{ .compatible = "adi,adis16477-2",
+		.data = &adis16475_chip_info[ADIS16477_2] },
+	{ .compatible = "adi,adis16477-3",
+		.data = &adis16475_chip_info[ADIS16477_3] },
+	{ .compatible = "adi,adis16465-1",
+		.data = &adis16475_chip_info[ADIS16465_1] },
+	{ .compatible = "adi,adis16465-2",
+		.data = &adis16475_chip_info[ADIS16465_2] },
+	{ .compatible = "adi,adis16465-3",
+		.data = &adis16475_chip_info[ADIS16465_3] },
+	{ .compatible = "adi,adis16467-1",
+		.data = &adis16475_chip_info[ADIS16467_1] },
+	{ .compatible = "adi,adis16467-2",
+		.data = &adis16475_chip_info[ADIS16467_2] },
+	{ .compatible = "adi,adis16467-3",
+		.data = &adis16475_chip_info[ADIS16467_3] },
+	{ .compatible = "adi,adis16500",
+		.data = &adis16475_chip_info[ADIS16500] },
+	{ .compatible = "adi,adis16505-1",
+		.data = &adis16475_chip_info[ADIS16505_1] },
+	{ .compatible = "adi,adis16505-2",
+		.data = &adis16475_chip_info[ADIS16505_2] },
+	{ .compatible = "adi,adis16505-3",
+		.data = &adis16475_chip_info[ADIS16505_3] },
+	{ .compatible = "adi,adis16507-1",
+		.data = &adis16475_chip_info[ADIS16507_1] },
+	{ .compatible = "adi,adis16507-2",
+		.data = &adis16475_chip_info[ADIS16507_2] },
+	{ .compatible = "adi,adis16507-3",
+		.data = &adis16475_chip_info[ADIS16507_3] },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, adis16475_of_match);
+
+static const struct spi_device_id adis16475_ids[] = {
+	{ "adis16470", (kernel_ulong_t)&adis16475_chip_info[ADIS16470] },
+	{ "adis16475-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16475_1] },
+	{ "adis16475-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16475_2] },
+	{ "adis16475-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16475_3] },
+	{ "adis16477-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16477_1] },
+	{ "adis16477-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16477_2] },
+	{ "adis16477-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16477_3] },
+	{ "adis16465-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16465_1] },
+	{ "adis16465-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16465_2] },
+	{ "adis16465-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16465_3] },
+	{ "adis16467-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16467_1] },
+	{ "adis16467-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16467_2] },
+	{ "adis16467-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16467_3] },
+	{ "adis16500", (kernel_ulong_t)&adis16475_chip_info[ADIS16500] },
+	{ "adis16505-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16505_1] },
+	{ "adis16505-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16505_2] },
+	{ "adis16505-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16505_3] },
+	{ "adis16507-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16507_1] },
+	{ "adis16507-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16507_2] },
+	{ "adis16507-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16507_3] },
+	{ }
+};
+MODULE_DEVICE_TABLE(spi, adis16475_ids);
+
 static struct spi_driver adis16475_driver = {
 	.driver = {
 		.name = "adis16475",
 		.of_match_table = adis16475_of_match,
 	},
 	.probe = adis16475_probe,
+	.id_table = adis16475_ids,
 };
 module_spi_driver(adis16475_driver);