[PATCH 1/3] iio: adc: rockchip_saradc: Use of_device_get_match_data to simplify code

From: Tang Bin
Date: Tue Oct 19 2021 - 06:09:59 EST


Retrieve OF match data, it's better and cleaner to use
'of_device_get_match_data' over 'of_match_device'.

Signed-off-by: Tang Bin <tangbin@xxxxxxxxxxxxxxxxxxxx>
---
drivers/iio/adc/rockchip_saradc.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c
index f3eb8d2e5..e221e7aaa 100644
--- a/drivers/iio/adc/rockchip_saradc.c
+++ b/drivers/iio/adc/rockchip_saradc.c
@@ -304,7 +304,6 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
struct device_node *np = pdev->dev.of_node;
struct iio_dev *indio_dev = NULL;
struct resource *mem;
- const struct of_device_id *match;
int ret;
int irq;

@@ -318,14 +317,12 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
}
info = iio_priv(indio_dev);

- match = of_match_device(rockchip_saradc_match, &pdev->dev);
- if (!match) {
+ info->data = of_device_get_match_data(&pdev->dev);
+ if (!info->data) {
dev_err(&pdev->dev, "failed to match device\n");
return -ENODEV;
}

- info->data = match->data;
-
/* Sanity check for possible later IP variants with more channels */
if (info->data->num_channels > SARADC_MAX_CHANNELS) {
dev_err(&pdev->dev, "max channels exceeded");
--
2.20.1.windows.1