Skip to content

Commit 89a1d2f

Browse files
robherringjic23
authored andcommitted
iio: Use device_get_match_data()
Use preferred device_get_match_data() instead of of_match_device() to get the driver match data. With this, adjust the includes to explicitly include the correct headers. Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20231006224440.442864-1-robh@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 349c1b4 commit 89a1d2f

3 files changed

Lines changed: 11 additions & 19 deletions

File tree

drivers/iio/adc/stm32-adc-core.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
#include <linux/irqdomain.h>
1818
#include <linux/mfd/syscon.h>
1919
#include <linux/module.h>
20-
#include <linux/of_device.h>
20+
#include <linux/of.h>
2121
#include <linux/of_platform.h>
2222
#include <linux/platform_device.h>
2323
#include <linux/pm_runtime.h>
24+
#include <linux/property.h>
2425
#include <linux/regmap.h>
2526
#include <linux/regulator/consumer.h>
2627
#include <linux/slab.h>
@@ -708,8 +709,6 @@ static int stm32_adc_probe(struct platform_device *pdev)
708709
struct stm32_adc_priv *priv;
709710
struct device *dev = &pdev->dev;
710711
struct device_node *np = pdev->dev.of_node;
711-
const struct of_device_id *of_id;
712-
713712
struct resource *res;
714713
u32 max_rate;
715714
int ret;
@@ -722,11 +721,7 @@ static int stm32_adc_probe(struct platform_device *pdev)
722721
return -ENOMEM;
723722
platform_set_drvdata(pdev, &priv->common);
724723

725-
of_id = of_match_device(dev->driver->of_match_table, dev);
726-
if (!of_id)
727-
return -ENODEV;
728-
729-
priv->cfg = (const struct stm32_adc_priv_cfg *)of_id->data;
724+
priv->cfg = device_get_match_data(dev);
730725
priv->nb_adc_max = priv->cfg->num_adcs;
731726
spin_lock_init(&priv->common.lock);
732727

drivers/iio/adc/twl6030-gpadc.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
*/
1717
#include <linux/interrupt.h>
1818
#include <linux/kernel.h>
19+
#include <linux/mod_devicetable.h>
1920
#include <linux/module.h>
2021
#include <linux/platform_device.h>
21-
#include <linux/of_platform.h>
22+
#include <linux/property.h>
2223
#include <linux/mfd/twl.h>
2324
#include <linux/iio/iio.h>
2425
#include <linux/iio/sysfs.h>
@@ -879,17 +880,14 @@ static int twl6030_gpadc_probe(struct platform_device *pdev)
879880
struct device *dev = &pdev->dev;
880881
struct twl6030_gpadc_data *gpadc;
881882
const struct twl6030_gpadc_platform_data *pdata;
882-
const struct of_device_id *match;
883883
struct iio_dev *indio_dev;
884884
int irq;
885885
int ret;
886886

887-
match = of_match_device(of_twl6030_match_tbl, dev);
888-
if (!match)
887+
pdata = device_get_match_data(&pdev->dev);
888+
if (!pdata)
889889
return -EINVAL;
890890

891-
pdata = match->data;
892-
893891
indio_dev = devm_iio_device_alloc(dev, sizeof(*gpadc));
894892
if (!indio_dev)
895893
return -ENOMEM;

drivers/iio/dac/stm32-dac-core.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99

1010
#include <linux/clk.h>
1111
#include <linux/delay.h>
12+
#include <linux/mod_devicetable.h>
1213
#include <linux/module.h>
1314
#include <linux/of_platform.h>
15+
#include <linux/platform_device.h>
1416
#include <linux/pm_runtime.h>
17+
#include <linux/property.h>
1518
#include <linux/regulator/consumer.h>
1619
#include <linux/reset.h>
1720

@@ -94,16 +97,12 @@ static int stm32_dac_probe(struct platform_device *pdev)
9497
struct reset_control *rst;
9598
int ret;
9699

97-
if (!dev->of_node)
98-
return -ENODEV;
99-
100100
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
101101
if (!priv)
102102
return -ENOMEM;
103103
platform_set_drvdata(pdev, &priv->common);
104104

105-
cfg = (const struct stm32_dac_cfg *)
106-
of_match_device(dev->driver->of_match_table, dev)->data;
105+
cfg = device_get_match_data(dev);
107106

108107
mmio = devm_platform_ioremap_resource(pdev, 0);
109108
if (IS_ERR(mmio))

0 commit comments

Comments
 (0)