2021-10-19 10:04:04

by Tang Bin

[permalink] [raw]
Subject: [PATCH 0/3] iio: Use of_device_get_match_data to clean code

Hi all:

This patch series replace 'of_match_device' with
'of_device_get_match_data', to make code cleaner and better.

Thanks

Tang Bin (3):
iio: adc: rockchip_saradc: Use of_device_get_match_data to simplify
code
iio: adc: max9611: Use of_device_get_match_data to simplify code
iio: adc: twl6030-gpadc: Use of_device_get_match_data to simplify code

drivers/iio/adc/max9611.c | 4 +---
drivers/iio/adc/rockchip_saradc.c | 7 ++-----
drivers/iio/adc/twl6030-gpadc.c | 7 ++-----
3 files changed, 5 insertions(+), 13 deletions(-)

--
2.20.1.windows.1




2021-10-19 10:04:35

by Tang Bin

[permalink] [raw]
Subject: [PATCH 3/3] iio: adc: twl6030-gpadc: Use of_device_get_match_data to simplify code

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 <[email protected]>
---
drivers/iio/adc/twl6030-gpadc.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/adc/twl6030-gpadc.c b/drivers/iio/adc/twl6030-gpadc.c
index c6416ad79..0859f3f7d 100644
--- a/drivers/iio/adc/twl6030-gpadc.c
+++ b/drivers/iio/adc/twl6030-gpadc.c
@@ -867,17 +867,14 @@ static int twl6030_gpadc_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct twl6030_gpadc_data *gpadc;
const struct twl6030_gpadc_platform_data *pdata;
- const struct of_device_id *match;
struct iio_dev *indio_dev;
int irq;
int ret;

- match = of_match_device(of_twl6030_match_tbl, dev);
- if (!match)
+ pdata = of_device_get_match_data(dev);
+ if (!pdata)
return -EINVAL;

- pdata = match->data;
-
indio_dev = devm_iio_device_alloc(dev, sizeof(*gpadc));
if (!indio_dev)
return -ENOMEM;
--
2.20.1.windows.1



2021-10-19 10:11:24

by Tang Bin

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

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 <[email protected]>
---
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



2021-10-19 10:14:36

by Tang Bin

[permalink] [raw]
Subject: [PATCH 2/3] iio: adc: max9611: Use of_device_get_match_data to simplify code

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 <[email protected]>
---
drivers/iio/adc/max9611.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c
index 052ab23f1..4e754c072 100644
--- a/drivers/iio/adc/max9611.c
+++ b/drivers/iio/adc/max9611.c
@@ -514,8 +514,6 @@ static int max9611_probe(struct i2c_client *client,
{
const char * const shunt_res_prop = "shunt-resistor-micro-ohms";
const struct device_node *of_node = client->dev.of_node;
- const struct of_device_id *of_id =
- of_match_device(max9611_of_table, &client->dev);
struct max9611_dev *max9611;
struct iio_dev *indio_dev;
unsigned int of_shunt;
@@ -545,7 +543,7 @@ static int max9611_probe(struct i2c_client *client,
if (ret)
return ret;

- indio_dev->name = of_id->data;
+ indio_dev->name = of_device_get_match_data(&client->dev);
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &indio_info;
indio_dev->channels = max9611_channels;
--
2.20.1.windows.1