Skip to content

Commit 8cafbf2

Browse files
robherringwsakernel
authored andcommitted
i2c: 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 <[email protected]> Reviewed-by: Andi Shyti <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 0f75d48 commit 8cafbf2

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

drivers/i2c/busses/i2c-mv64xxx.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@
1919
#include <linux/platform_device.h>
2020
#include <linux/pinctrl/consumer.h>
2121
#include <linux/pm_runtime.h>
22+
#include <linux/property.h>
2223
#include <linux/reset.h>
2324
#include <linux/io.h>
2425
#include <linux/of.h>
25-
#include <linux/of_device.h>
26-
#include <linux/of_irq.h>
2726
#include <linux/clk.h>
2827
#include <linux/err.h>
2928
#include <linux/delay.h>
@@ -859,7 +858,7 @@ static int
859858
mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data,
860859
struct device *dev)
861860
{
862-
const struct of_device_id *device;
861+
const struct mv64xxx_i2c_regs *data;
863862
struct device_node *np = dev->of_node;
864863
u32 bus_freq, tclk;
865864
int rc = 0;
@@ -897,11 +896,11 @@ mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data,
897896
*/
898897
drv_data->adapter.timeout = HZ;
899898

900-
device = of_match_device(mv64xxx_i2c_of_match_table, dev);
901-
if (!device)
899+
data = device_get_match_data(dev);
900+
if (!data)
902901
return -ENODEV;
903902

904-
memcpy(&drv_data->reg_offsets, device->data, sizeof(drv_data->reg_offsets));
903+
memcpy(&drv_data->reg_offsets, data, sizeof(drv_data->reg_offsets));
905904

906905
/*
907906
* For controllers embedded in new SoCs activate the

drivers/i2c/busses/i2c-omap.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
#include <linux/clk.h>
2626
#include <linux/io.h>
2727
#include <linux/of.h>
28-
#include <linux/of_device.h>
2928
#include <linux/slab.h>
3029
#include <linux/platform_data/i2c-omap.h>
3130
#include <linux/pm_runtime.h>
3231
#include <linux/pinctrl/consumer.h>
32+
#include <linux/property.h>
3333

3434
/* I2C controller revisions */
3535
#define OMAP_I2C_OMAP1_REV_2 0x20
@@ -1358,7 +1358,6 @@ omap_i2c_probe(struct platform_device *pdev)
13581358
const struct omap_i2c_bus_platform_data *pdata =
13591359
dev_get_platdata(&pdev->dev);
13601360
struct device_node *node = pdev->dev.of_node;
1361-
const struct of_device_id *match;
13621361
int irq;
13631362
int r;
13641363
u32 rev;
@@ -1376,11 +1375,10 @@ omap_i2c_probe(struct platform_device *pdev)
13761375
if (IS_ERR(omap->base))
13771376
return PTR_ERR(omap->base);
13781377

1379-
match = of_match_device(of_match_ptr(omap_i2c_of_match), &pdev->dev);
1380-
if (match) {
1378+
if (pdev->dev.of_node) {
13811379
u32 freq = I2C_MAX_STANDARD_MODE_FREQ;
13821380

1383-
pdata = match->data;
1381+
pdata = device_get_match_data(&pdev->dev);
13841382
omap->flags = pdata->flags;
13851383

13861384
of_property_read_u32(node, "clock-frequency", &freq);

drivers/i2c/busses/i2c-pxa.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <linux/pinctrl/consumer.h>
3333
#include <linux/platform_device.h>
3434
#include <linux/platform_data/i2c-pxa.h>
35+
#include <linux/property.h>
3536
#include <linux/slab.h>
3637

3738
/* I2C register field definitions */
@@ -1252,10 +1253,8 @@ static int i2c_pxa_probe_dt(struct platform_device *pdev, struct pxa_i2c *i2c,
12521253
enum pxa_i2c_types *i2c_types)
12531254
{
12541255
struct device_node *np = pdev->dev.of_node;
1255-
const struct of_device_id *of_id =
1256-
of_match_device(i2c_pxa_dt_ids, &pdev->dev);
12571256

1258-
if (!of_id)
1257+
if (!pdev->dev.of_node)
12591258
return 1;
12601259

12611260
/* For device tree we always use the dynamic or alias-assigned ID */
@@ -1264,7 +1263,7 @@ static int i2c_pxa_probe_dt(struct platform_device *pdev, struct pxa_i2c *i2c,
12641263
i2c->use_pio = of_property_read_bool(np, "mrvl,i2c-polling");
12651264
i2c->fast_mode = of_property_read_bool(np, "mrvl,i2c-fast-mode");
12661265

1267-
*i2c_types = (enum pxa_i2c_types)(of_id->data);
1266+
*i2c_types = (enum pxa_i2c_types)device_get_match_data(&pdev->dev);
12681267

12691268
return 0;
12701269
}

0 commit comments

Comments
 (0)