iio: dac: ad5755: fix unised of_match table
Subsystems (2)
PATCH 1/1 iio: dac: ad5755: fix unised of_match table
If the ad5755 is not being built as a module, then we get an unused warning about the ad5755_of_match[] array as this is only used by the macro MODULE_DEVICE_TABLE. Fix this by adding an #ifdef MODULE around it to silence:
drivers/iio/dac/ad5755.c:866:34: warning: ‘ad5755_of_match’ defined but not used [-Wunused-const-variable=]
866 | static const struct of_device_id ad5755_of_match[] = {
--- drivers/iio/dac/ad5755.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/dac/ad5755.c +2 -0
@@ -863,6 +863,7 @@ static const struct spi_device_id ad5755_id[] = { };MODULE_DEVICE_TABLE (spi, ad5755_id); +#ifndef MODULE static const struct of_device_id ad5755_of_match[] = { { .compatible ="adi,ad5755" }, { .compatible = "adi,ad5755-1" },
@@ -872,6 +873,7 @@ static const struct of_device_id ad5755_of_match[] = { { } };MODULE_DEVICE_TABLE (of, ad5755_of_match); +#endif static struct spi_driver ad5755_driver = { .driver = {
Signature · 1 line
2.37.2.352.g3c44437643
Quoted 18 lines · Ben Dooks
If the ad5755 is not being built as a module, then we get an unused warning about the ad5755_of_match[] array as this is only used by the macro
MODULE_DEVICE_TABLE. Fix this by adding an #ifdef MODULE around it to silence:
drivers/iio/dac/ad5755.c:866:34: warning: ‘ad5755_of_match’ defined but not used [-Wunused-const-variable=]
866 | static const structof_device_idad5755_of_match[] = {Signed-off-by Ben Dooks <[email protected]>--- drivers/iio/dac/ad5755.c | 2 ++ 1 file changed, 2 insertions(+)drivers/iio/dac/ad5755.c +0
-0
drivers/iio/dac/ad5755.c static const struct spi_device_id ad5755_id[] = { · line 866
Quoted 4 lines
drivers/iio/dac/ad5755.c +1
-0@@ -863,6 +863,7 @@ static const struct spi_device_id ad5755_id[] = { };MODULE_DEVICE_TABLE (spi, ad5755_id); +#ifndef MODULE
Just noticed the use of ifnded instead of ifdef here. Will fix Monday.
Quoted 11 lines
drivers/iio/dac/ad5755.c +1
-0static const struct of_device_id ad5755_of_match[] = { { .compatible ="adi,ad5755" }, { .compatible ="adi,ad5755-1" },@@ -872,6 +873,7 @@ static const struct of_device_id ad5755_of_match[] = { { } };MODULE_DEVICE_TABLE (of, ad5755_of_match); +#endif static struct spi_driver ad5755_driver = { .driver = {
Signature · 4 lines
Ben Dooks http://www.codethink.co.uk/ Senior Engineer Codethink - Providing Genius https://www.codethink.co.uk/privacy.html
Jonathan Cameron
maintainerQuoted 22 lines · On Fri, 8 Mar 2024 18:55:09 +0000 Ben Dooks <[email protected]> wrote:
Quoted 21 lines · Ben Dooks
If the ad5755 is not being built as a module, then we get an unused warning about the ad5755_of_match[] array as this is only used by the macro
MODULE_DEVICE_TABLE. Fix this by adding an #ifdef MODULE around it to silence:
drivers/iio/dac/ad5755.c:866:34: warning: ‘ad5755_of_match’ defined but not used [-Wunused-const-variable=]
866 | static const structof_device_idad5755_of_match[] = {Signed-off-by Ben Dooks <[email protected]>--- drivers/iio/dac/ad5755.c | 2 ++ 1 file changed, 2 insertions(+)drivers/iio/dac/ad5755.c +0
-0@@ -863,6 +863,7 @@ static const struct spi_device_id ad5755_id[] = { };MODULE_DEVICE_TABLE (spi, ad5755_id);
Quoted 3 lines
drivers/iio/dac/ad5755.c static const struct spi_device_id ad5755_id[] = { · line 866
Quoted 1 line
drivers/iio/dac/ad5755.c +1
-0+#ifndef MODULE Just noticed the use of ifnded instead of ifdef here. Will fix Monday.
Krzystof posted a different fix for this a while back but that had some issues.
https://lore.kernel.org/linux-iio/20240226192555.14aa178e@jic23-huawei/
The simple fix is just hook up the of_device_match pointer.
But to use the general data matching from spi_get_device_match_data() the data needs to change to be pointers and not enums hammered into a pointer. I'm really not keen on the horrible workaround of avoiding the enum value of 0.
So this needs a more complex fix in general - for now we can get away with using the table and the fallback stuff that relies on the of_device_id and spi_device_id table entries matching but that is fragile.
Quoted 13 lines
Quoted 12 lines
drivers/iio/dac/ad5755.c +1
-0static const struct of_device_id ad5755_of_match[] = { { .compatible ="adi,ad5755" }, { .compatible ="adi,ad5755-1" },@@ -872,6 +873,7 @@ static const struct of_device_id ad5755_of_match[] = { { } };MODULE_DEVICE_TABLE (of, ad5755_of_match); +#endif static struct spi_driver ad5755_driver = { .driver = {