linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] iio: dac: ad5755: make use of of_device_id table
@ 2024-02-25 20:16 Krzysztof Kozlowski
  2024-02-25 20:16 ` [PATCH v2 2/2] iio: proximity: isl29501: " Krzysztof Kozlowski
  2024-02-26 19:25 ` [PATCH v2 1/2] iio: dac: ad5755: " Jonathan Cameron
  0 siblings, 2 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2024-02-25 20:16 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	linux-iio, linux-kernel, llvm
  Cc: Krzysztof Kozlowski

Populate the of_device_id table with match data, reference it in the
spi_driver struct and use spi_get_device_match_data() to perform the
type matching to fix warning:

  ad5755.c:866:34: error: unused variable 'ad5755_of_match' [-Werror,-Wunused-const-variable]

This is also preferred way of matching device variants, then relying on
fallback via spi_device_id.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

---

Rework according to comments.

An old v1:
https://lore.kernel.org/all/20230810111933.205619-1-krzysztof.kozlowski@linaro.org/
---
 drivers/iio/dac/ad5755.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c
index 404865e35460..877c1125d892 100644
--- a/drivers/iio/dac/ad5755.c
+++ b/drivers/iio/dac/ad5755.c
@@ -809,7 +809,7 @@ static struct ad5755_platform_data *ad5755_parse_fw(struct device *dev)
 
 static int ad5755_probe(struct spi_device *spi)
 {
-	enum ad5755_type type = spi_get_device_id(spi)->driver_data;
+	enum ad5755_type type = (kernel_ulong_t)spi_get_device_match_data(spi);
 	const struct ad5755_platform_data *pdata;
 	struct iio_dev *indio_dev;
 	struct ad5755_state *st;
@@ -864,11 +864,11 @@ static const struct spi_device_id ad5755_id[] = {
 MODULE_DEVICE_TABLE(spi, ad5755_id);
 
 static const struct of_device_id ad5755_of_match[] = {
-	{ .compatible = "adi,ad5755" },
-	{ .compatible = "adi,ad5755-1" },
-	{ .compatible = "adi,ad5757" },
-	{ .compatible = "adi,ad5735" },
-	{ .compatible = "adi,ad5737" },
+	{ .compatible = "adi,ad5755", (void *)ID_AD5755 },
+	{ .compatible = "adi,ad5755-1", (void *)ID_AD5755 },
+	{ .compatible = "adi,ad5757", (void *)ID_AD5757 },
+	{ .compatible = "adi,ad5735", (void *)ID_AD5735 },
+	{ .compatible = "adi,ad5737", (void *)ID_AD5737 },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, ad5755_of_match);
@@ -876,6 +876,7 @@ MODULE_DEVICE_TABLE(of, ad5755_of_match);
 static struct spi_driver ad5755_driver = {
 	.driver = {
 		.name = "ad5755",
+		.of_match_table = ad5755_of_match,
 	},
 	.probe = ad5755_probe,
 	.id_table = ad5755_id,
-- 
2.34.1


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

* [PATCH v2 2/2] iio: proximity: isl29501: make use of of_device_id table
  2024-02-25 20:16 [PATCH v2 1/2] iio: dac: ad5755: make use of of_device_id table Krzysztof Kozlowski
@ 2024-02-25 20:16 ` Krzysztof Kozlowski
  2024-02-26 19:27   ` Jonathan Cameron
  2024-02-26 19:25 ` [PATCH v2 1/2] iio: dac: ad5755: " Jonathan Cameron
  1 sibling, 1 reply; 4+ messages in thread
From: Krzysztof Kozlowski @ 2024-02-25 20:16 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	linux-iio, linux-kernel, llvm
  Cc: Krzysztof Kozlowski

Reference the of_device_id table in the driver structure, so it will be
used for module autoloading and device matching.  This fixes clang W=1
warning:

  isl29501.c:999:34: error: unused variable 'isl29501_i2c_matches' [-Werror,-Wunused-const-variable]

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

---

Rework according to comments.

An old v1:
https://lore.kernel.org/all/20230810111933.205619-1-krzysztof.kozlowski@linaro.org/
---
 drivers/iio/proximity/isl29501.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/iio/proximity/isl29501.c b/drivers/iio/proximity/isl29501.c
index bcebacaf3dab..4982686fb4c3 100644
--- a/drivers/iio/proximity/isl29501.c
+++ b/drivers/iio/proximity/isl29501.c
@@ -995,17 +995,16 @@ static const struct i2c_device_id isl29501_id[] = {
 
 MODULE_DEVICE_TABLE(i2c, isl29501_id);
 
-#if defined(CONFIG_OF)
 static const struct of_device_id isl29501_i2c_matches[] = {
 	{ .compatible = "renesas,isl29501" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, isl29501_i2c_matches);
-#endif
 
 static struct i2c_driver isl29501_driver = {
 	.driver = {
 		.name	= "isl29501",
+		.of_match_table = isl29501_i2c_matches,
 	},
 	.id_table	= isl29501_id,
 	.probe		= isl29501_probe,
-- 
2.34.1


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

* Re: [PATCH v2 1/2] iio: dac: ad5755: make use of of_device_id table
  2024-02-25 20:16 [PATCH v2 1/2] iio: dac: ad5755: make use of of_device_id table Krzysztof Kozlowski
  2024-02-25 20:16 ` [PATCH v2 2/2] iio: proximity: isl29501: " Krzysztof Kozlowski
@ 2024-02-26 19:25 ` Jonathan Cameron
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2024-02-26 19:25 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Lars-Peter Clausen, Michael Hennerich, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, linux-iio,
	linux-kernel, llvm

On Sun, 25 Feb 2024 21:16:53 +0100
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> wrote:

> Populate the of_device_id table with match data, reference it in the
> spi_driver struct and use spi_get_device_match_data() to perform the
> type matching to fix warning:
> 
>   ad5755.c:866:34: error: unused variable 'ad5755_of_match' [-Werror,-Wunused-const-variable]
> 
> This is also preferred way of matching device variants, then relying on
> fallback via spi_device_id.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> 
> ---
> 
> Rework according to comments.
> 
> An old v1:
> https://lore.kernel.org/all/20230810111933.205619-1-krzysztof.kozlowski@linaro.org/
> ---
>  drivers/iio/dac/ad5755.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c
> index 404865e35460..877c1125d892 100644
> --- a/drivers/iio/dac/ad5755.c
> +++ b/drivers/iio/dac/ad5755.c
> @@ -809,7 +809,7 @@ static struct ad5755_platform_data *ad5755_parse_fw(struct device *dev)
>  
>  static int ad5755_probe(struct spi_device *spi)
>  {
> -	enum ad5755_type type = spi_get_device_id(spi)->driver_data;
> +	enum ad5755_type type = (kernel_ulong_t)spi_get_device_match_data(spi);
>  	const struct ad5755_platform_data *pdata;
>  	struct iio_dev *indio_dev;
>  	struct ad5755_state *st;
> @@ -864,11 +864,11 @@ static const struct spi_device_id ad5755_id[] = {
>  MODULE_DEVICE_TABLE(spi, ad5755_id);
>  
>  static const struct of_device_id ad5755_of_match[] = {
> -	{ .compatible = "adi,ad5755" },
> -	{ .compatible = "adi,ad5755-1" },
> -	{ .compatible = "adi,ad5757" },
> -	{ .compatible = "adi,ad5735" },
> -	{ .compatible = "adi,ad5737" },
> +	{ .compatible = "adi,ad5755", (void *)ID_AD5755 },
> +	{ .compatible = "adi,ad5755-1", (void *)ID_AD5755 },
> +	{ .compatible = "adi,ad5757", (void *)ID_AD5757 },
> +	{ .compatible = "adi,ad5735", (void *)ID_AD5735 },
> +	{ .compatible = "adi,ad5737", (void *)ID_AD5737 },
If the enum value is 0, what happens?  We ignore the return value and
check the other table - so still fragile :(

That's why I asked that these be pointers, not enum values...

>  	{ }
>  };
>  MODULE_DEVICE_TABLE(of, ad5755_of_match);
> @@ -876,6 +876,7 @@ MODULE_DEVICE_TABLE(of, ad5755_of_match);
>  static struct spi_driver ad5755_driver = {
>  	.driver = {
>  		.name = "ad5755",
> +		.of_match_table = ad5755_of_match,
>  	},
>  	.probe = ad5755_probe,
>  	.id_table = ad5755_id,


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

* Re: [PATCH v2 2/2] iio: proximity: isl29501: make use of of_device_id table
  2024-02-25 20:16 ` [PATCH v2 2/2] iio: proximity: isl29501: " Krzysztof Kozlowski
@ 2024-02-26 19:27   ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2024-02-26 19:27 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Lars-Peter Clausen, Michael Hennerich, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, linux-iio,
	linux-kernel, llvm

On Sun, 25 Feb 2024 21:16:54 +0100
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> wrote:

> Reference the of_device_id table in the driver structure, so it will be
> used for module autoloading and device matching.  This fixes clang W=1
> warning:
> 
>   isl29501.c:999:34: error: unused variable 'isl29501_i2c_matches' [-Werror,-Wunused-const-variable]
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Applied just patch 2.

Thanks,

Jonathan
> 
> ---
> 
> Rework according to comments.
> 
> An old v1:
> https://lore.kernel.org/all/20230810111933.205619-1-krzysztof.kozlowski@linaro.org/
> ---
>  drivers/iio/proximity/isl29501.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/proximity/isl29501.c b/drivers/iio/proximity/isl29501.c
> index bcebacaf3dab..4982686fb4c3 100644
> --- a/drivers/iio/proximity/isl29501.c
> +++ b/drivers/iio/proximity/isl29501.c
> @@ -995,17 +995,16 @@ static const struct i2c_device_id isl29501_id[] = {
>  
>  MODULE_DEVICE_TABLE(i2c, isl29501_id);
>  
> -#if defined(CONFIG_OF)
>  static const struct of_device_id isl29501_i2c_matches[] = {
>  	{ .compatible = "renesas,isl29501" },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(of, isl29501_i2c_matches);
> -#endif
>  
>  static struct i2c_driver isl29501_driver = {
>  	.driver = {
>  		.name	= "isl29501",
> +		.of_match_table = isl29501_i2c_matches,
>  	},
>  	.id_table	= isl29501_id,
>  	.probe		= isl29501_probe,


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

end of thread, other threads:[~2024-02-26 19:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-25 20:16 [PATCH v2 1/2] iio: dac: ad5755: make use of of_device_id table Krzysztof Kozlowski
2024-02-25 20:16 ` [PATCH v2 2/2] iio: proximity: isl29501: " Krzysztof Kozlowski
2024-02-26 19:27   ` Jonathan Cameron
2024-02-26 19:25 ` [PATCH v2 1/2] iio: dac: ad5755: " Jonathan Cameron

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).