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

Joshua Crofts crofts at kernel.org
Sun Nov 22 23:52:19 PST 2026


On 23-Nov-26 8:00, Abdelnasser Hussein wrote:
> 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 at gmail.com>
> ---
>  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;
-ENODATA is better.

-- 
Kind regards,
Joshua Crofts




More information about the linux-arm-kernel mailing list