Skip to contentSkip to conversation

iio: frequency: ad9832: devicetree probing support

PATCH Superseded Siddharth Menon 3 participants 4 messages Mar 22, 2025 – Mar 23, 2025

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: frequency: ad9832: devicetree probing support

Introduce struct for device match of_device_id

---
 drivers/staging/iio/frequency/ad9832.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/staging/iio/frequency/ad9832.c +8 -0
index 9a27acd88926..506478ddede3 100644
@@ -439,6 +439,13 @@ static int ad9832_probe(struct spi_device *spi)
 	return devm_iio_device_register(&spi->dev, indio_dev);
 }
 
+static const struct of_device_id ad9832_of_match[] = {
+	{ .compatible = "adi,ad9832" },
+	{ .compatible = "adi,ad9835" },
+	{},
+};
+MODULE_DEVICE_TABLE(of, ad9832_of_match);
+
 static const struct spi_device_id ad9832_id[] = {
 	{"ad9832", 0},
 	{"ad9835", 0},
@@ -449,6 +456,7 @@ MODULE_DEVICE_TABLE(spi, ad9832_id);
 static struct spi_driver ad9832_driver = {
 	.driver = {
 		.name	= "ad9832",
+		.of_match_table = ad9832_of_match,
 	},
 	.probe		= ad9832_probe,
 	.id_table	= ad9832_id,
Signature · 1 line
2.48.1
Reviewed-by on v1 1/1
#1 lore raw

LGTM, one minor suggestion inline.
With that applied,

Quoted 13 lines · Siddharth Menon

Introduce struct for device match of_device_id

---
 drivers/staging/iio/frequency/ad9832.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/staging/iio/frequency/ad9832.c +0 -0
index 9a27acd88926..506478ddede3 100644

drivers/staging/iio/frequency/ad9832.c static int ad9832_probe(struct spi_device *spi) · line 445

Quoted 7 lines
drivers/staging/iio/frequency/ad9832.c +4 -0
@@ -439,6 +439,13 @@ static int ad9832_probe(struct spi_device *spi)
 	return devm_iio_device_register(&spi->dev, indio_dev);
 }
 
+static const struct of_device_id ad9832_of_match[] = {
+	{ .compatible = "adi,ad9832" },
+	{ .compatible = "adi,ad9835" },
+	{},

I think Jonathan prefers to have a space separating the null terminator braces.

	{ },
Quoted 17 lines
drivers/staging/iio/frequency/ad9832.c +4 -0
+};
+MODULE_DEVICE_TABLE(of, ad9832_of_match);
+
 static const struct spi_device_id ad9832_id[] = {
 	{"ad9832", 0},
 	{"ad9835", 0},
@@ -449,6 +456,7 @@ MODULE_DEVICE_TABLE(spi, ad9832_id);
 static struct spi_driver ad9832_driver = {
 	.driver = {
 		.name	= "ad9832",
+		.of_match_table = ad9832_of_match,
 	},
 	.probe		= ad9832_probe,
 	.id_table	= ad9832_id,
Signature · 1 line
2.48.1
maintainer
#2 lore raw
Quoted 21 lines · On Sat, 22 Mar 2025 10:40:17 -0300 Marcelo Schmitt…

LGTM, one minor suggestion inline.
With that applied,

Quoted 16 lines · Siddharth Menon

Introduce struct for device match of_device_id

---
 drivers/staging/iio/frequency/ad9832.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/staging/iio/frequency/ad9832.c +0 -0
index 9a27acd88926..506478ddede3 100644
@@ -439,6 +439,13 @@ static int ad9832_probe(struct spi_device *spi)
 	return devm_iio_device_register(&spi->dev, indio_dev);
 }
 
Quoted 6 lines

drivers/staging/iio/frequency/ad9832.c static int ad9832_probe(struct spi_device *spi) · line 445

Quoted 4 lines
drivers/staging/iio/frequency/ad9832.c +4 -0
+static const struct of_device_id ad9832_of_match[] = {
+	{ .compatible = "adi,ad9832" },
+	{ .compatible = "adi,ad9835" },
+	{},  

I think Jonathan prefers to have a space separating the null terminator braces.

	{ },

Indeed, but just for the record, no trailing comma on 'terminating entries'.

Whilst that's not in the style guide that is pretty much default preference across the kernel (unlike the bracket things which is my random choice :)

Jonathan

Quoted 18 lines
Quoted 18 lines
drivers/staging/iio/frequency/ad9832.c +4 -0
+};
+MODULE_DEVICE_TABLE(of, ad9832_of_match);
+
 static const struct spi_device_id ad9832_id[] = {
 	{"ad9832", 0},
 	{"ad9835", 0},
@@ -449,6 +456,7 @@ MODULE_DEVICE_TABLE(spi, ad9832_id);
 static struct spi_driver ad9832_driver = {
 	.driver = {
 		.name	= "ad9832",
+		.of_match_table = ad9832_of_match,
 	},
 	.probe		= ad9832_probe,
 	.id_table	= ad9832_id,
Signature · 1 line
2.48.1
maintainer
#3 lore raw
In reply to Siddharth Menon
Quoted 1 line · On Sat, 22 Mar 2025 13:37:45 +0530 Siddharth Menon <[email protected]> wrote:

Introduce struct for device match of_device_id

Good to say why. Key is that it will probe from a dts
entry without this due to the various matching fallback paths, but it will be matching with the less informative bit after the manufacturer. So we might get a false match in future against some other ad9832 part.

Quoted 12 lines
---
 drivers/staging/iio/frequency/ad9832.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/staging/iio/frequency/ad9832.c +0 -0
index 9a27acd88926..506478ddede3 100644

drivers/staging/iio/frequency/ad9832.c static int ad9832_probe(struct spi_device *spi) · line 445

Quoted 7 lines
drivers/staging/iio/frequency/ad9832.c +4 -0
@@ -439,6 +439,13 @@ static int ad9832_probe(struct spi_device *spi)
 	return devm_iio_device_register(&spi->dev, indio_dev);
 }
 
+static const struct of_device_id ad9832_of_match[] = {
+	{ .compatible = "adi,ad9832" },
+	{ .compatible = "adi,ad9835" },
+	{},

No comma on a terminating entry like this. We don't want to make it easy to add stuff after it!
Also, I'm trying to standardize the formatting of these tables across IIO. So I made the random choice of having a space between the brackets and am slowly changing drivers to that standard.

	{ }
Quoted 14 lines
drivers/staging/iio/frequency/ad9832.c +4 -0
+};
+MODULE_DEVICE_TABLE(of, ad9832_of_match);
+
 static const struct spi_device_id ad9832_id[] = {
 	{"ad9832", 0},
 	{"ad9835", 0},
@@ -449,6 +456,7 @@ MODULE_DEVICE_TABLE(spi, ad9832_id);
 static struct spi_driver ad9832_driver = {
 	.driver = {
 		.name	= "ad9832",
+		.of_match_table = ad9832_of_match,
 	},
 	.probe		= ad9832_probe,
 	.id_table	= ad9832_id,