[PATCH v5 3/8] iio: adc: at91_adc: switch to device_get_match_data()

From: Abdelnasser Hussein

Date: Mon Nov 23 2026 - 02:01:52 EST


Use the firmware-agnostic device_get_match_data() instead of the
OF-specific of_device_get_match_data() to retrieve the device
capabilities.

Check the returned pointer so that probing a device without matching
capabilities fails cleanly instead of dereferencing NULL later on.

Signed-off-by: Abdelnasser Hussein <abdelnasserhussein11@xxxxxxxxx>
---
drivers/iio/adc/at91_adc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 76000486b17a..2a378540837d 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -18,6 +18,7 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
+#include <linux/property.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/wait.h>
@@ -1002,7 +1003,9 @@ static int at91_adc_probe(struct platform_device *pdev)

st = iio_priv(idev);

- st->caps = of_device_get_match_data(&pdev->dev);
+ st->caps = device_get_match_data(&pdev->dev);
+ if (!st->caps)
+ return -ENODEV;

st->use_external = of_property_read_bool(node, "atmel,adc-use-external-triggers");

--
2.56.0