]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: frequency: ad9832: devicetree probing support
authorSiddharth Menon <simeddon@gmail.com>
Sat, 22 Mar 2025 16:28:11 +0000 (21:58 +0530)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 22 Apr 2025 18:09:51 +0000 (19:09 +0100)
Introduce struct for device match of_device_id to avoid relying on fallback
mechanisms, which could lead to false matches against other AD9832 variants
in the future.

Suggested-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Signed-off-by: Siddharth Menon <simeddon@gmail.com>
Link: https://patch.msgid.link/20250322163211.253009-1-simeddon@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/staging/iio/frequency/ad9832.c

index db42810c7664b5b1e39f8556b2be58e3880b89b8..1bf23384d28bb035de2cfbf09216aa4e9cddce1a 100644 (file)
@@ -402,6 +402,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},
@@ -412,6 +419,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,