Skip to content

Commit 0db434f

Browse files
robherringlag-linaro
authored andcommitted
mfd: Use i2c_get_match_data() in a selection of drivers
Use preferred i2c_get_match_data() instead of of_match_device() and i2c driver_data 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: Chanwoo Choi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 830fafc commit 0db434f

File tree

6 files changed

+15
-55
lines changed

6 files changed

+15
-55
lines changed

drivers/mfd/lochnagar-i2c.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#include <linux/i2c.h>
1616
#include <linux/lockdep.h>
1717
#include <linux/mfd/core.h>
18+
#include <linux/mod_devicetable.h>
1819
#include <linux/mutex.h>
19-
#include <linux/of.h>
2020
#include <linux/of_platform.h>
2121
#include <linux/regmap.h>
2222

@@ -270,7 +270,6 @@ static int lochnagar_i2c_probe(struct i2c_client *i2c)
270270
{
271271
struct device *dev = &i2c->dev;
272272
const struct lochnagar_config *config = NULL;
273-
const struct of_device_id *of_id;
274273
struct lochnagar *lochnagar;
275274
struct gpio_desc *reset, *present;
276275
unsigned int val;
@@ -282,11 +281,7 @@ static int lochnagar_i2c_probe(struct i2c_client *i2c)
282281
if (!lochnagar)
283282
return -ENOMEM;
284283

285-
of_id = of_match_device(lochnagar_of_match, dev);
286-
if (!of_id)
287-
return -EINVAL;
288-
289-
config = of_id->data;
284+
config = i2c_get_match_data(i2c);
290285

291286
lochnagar->dev = dev;
292287
mutex_init(&lochnagar->analogue_config_lock);

drivers/mfd/lp87565.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
*/
77

88
#include <linux/gpio/consumer.h>
9+
#include <linux/i2c.h>
910
#include <linux/interrupt.h>
1011
#include <linux/mfd/core.h>
12+
#include <linux/mod_devicetable.h>
1113
#include <linux/module.h>
12-
#include <linux/of_device.h>
1314
#include <linux/regmap.h>
1415

1516
#include <linux/mfd/lp87565.h>
@@ -46,7 +47,6 @@ MODULE_DEVICE_TABLE(of, of_lp87565_match_table);
4647
static int lp87565_probe(struct i2c_client *client)
4748
{
4849
struct lp87565 *lp87565;
49-
const struct of_device_id *of_id;
5050
int ret;
5151
unsigned int otpid;
5252

@@ -89,10 +89,7 @@ static int lp87565_probe(struct i2c_client *client)
8989
}
9090

9191
lp87565->rev = otpid & LP87565_OTP_REV_OTP_ID;
92-
93-
of_id = of_match_device(of_lp87565_match_table, &client->dev);
94-
if (of_id)
95-
lp87565->dev_type = (uintptr_t)of_id->data;
92+
lp87565->dev_type = (uintptr_t)i2c_get_match_data(client);
9693

9794
i2c_set_clientdata(client, lp87565);
9895

drivers/mfd/max14577.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
// This driver is based on max8997.c
1010

1111
#include <linux/err.h>
12+
#include <linux/i2c.h>
13+
#include <linux/mod_devicetable.h>
1214
#include <linux/module.h>
1315
#include <linux/interrupt.h>
14-
#include <linux/of_device.h>
1516
#include <linux/mfd/core.h>
1617
#include <linux/mfd/max14577.h>
1718
#include <linux/mfd/max14577-private.h>
@@ -357,7 +358,6 @@ static void max77836_remove(struct max14577 *max14577)
357358

358359
static int max14577_i2c_probe(struct i2c_client *i2c)
359360
{
360-
const struct i2c_device_id *id = i2c_client_get_device_id(i2c);
361361
struct max14577 *max14577;
362362
struct max14577_platform_data *pdata = dev_get_platdata(&i2c->dev);
363363
struct device_node *np = i2c->dev.of_node;
@@ -397,15 +397,7 @@ static int max14577_i2c_probe(struct i2c_client *i2c)
397397
return ret;
398398
}
399399

400-
if (np) {
401-
const struct of_device_id *of_id;
402-
403-
of_id = of_match_device(max14577_dt_match, &i2c->dev);
404-
if (of_id)
405-
max14577->dev_type = (uintptr_t)of_id->data;
406-
} else {
407-
max14577->dev_type = id->driver_data;
408-
}
400+
max14577->dev_type = (enum maxim_device_type)i2c_get_match_data(i2c);
409401

410402
max14577_print_dev_type(max14577);
411403

drivers/mfd/rn5t618.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <linux/mfd/core.h>
1414
#include <linux/mfd/rn5t618.h>
1515
#include <linux/module.h>
16-
#include <linux/of_device.h>
16+
#include <linux/of.h>
1717
#include <linux/platform_device.h>
1818
#include <linux/reboot.h>
1919
#include <linux/regmap.h>
@@ -179,22 +179,15 @@ MODULE_DEVICE_TABLE(of, rn5t618_of_match);
179179

180180
static int rn5t618_i2c_probe(struct i2c_client *i2c)
181181
{
182-
const struct of_device_id *of_id;
183182
struct rn5t618 *priv;
184183
int ret;
185184

186-
of_id = of_match_device(rn5t618_of_match, &i2c->dev);
187-
if (!of_id) {
188-
dev_err(&i2c->dev, "Failed to find matching DT ID\n");
189-
return -EINVAL;
190-
}
191-
192185
priv = devm_kzalloc(&i2c->dev, sizeof(*priv), GFP_KERNEL);
193186
if (!priv)
194187
return -ENOMEM;
195188

196189
i2c_set_clientdata(i2c, priv);
197-
priv->variant = (long)of_id->data;
190+
priv->variant = (long)i2c_get_match_data(i2c);
198191
priv->irq = i2c->irq;
199192
priv->dev = &i2c->dev;
200193

drivers/mfd/wm831x-i2c.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,22 @@
1515
#include <linux/slab.h>
1616
#include <linux/err.h>
1717
#include <linux/of.h>
18-
#include <linux/of_device.h>
1918
#include <linux/regmap.h>
2019

2120
#include <linux/mfd/wm831x/core.h>
2221
#include <linux/mfd/wm831x/pdata.h>
2322

2423
static int wm831x_i2c_probe(struct i2c_client *i2c)
2524
{
26-
const struct i2c_device_id *id = i2c_client_get_device_id(i2c);
2725
struct wm831x_pdata *pdata = dev_get_platdata(&i2c->dev);
28-
const struct of_device_id *of_id;
2926
struct wm831x *wm831x;
3027
enum wm831x_parent type;
3128
int ret;
3229

33-
if (i2c->dev.of_node) {
34-
of_id = of_match_device(wm831x_of_match, &i2c->dev);
35-
if (!of_id) {
36-
dev_err(&i2c->dev, "Failed to match device\n");
37-
return -ENODEV;
38-
}
39-
type = (uintptr_t)of_id->data;
40-
} else {
41-
type = (enum wm831x_parent)id->driver_data;
30+
type = (uintptr_t)i2c_get_match_data(i2c);
31+
if (!type) {
32+
dev_err(&i2c->dev, "Failed to match device\n");
33+
return -ENODEV;
4234
}
4335

4436
wm831x = devm_kzalloc(&i2c->dev, sizeof(struct wm831x), GFP_KERNEL);

drivers/mfd/wm8994-core.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <linux/delay.h>
1616
#include <linux/mfd/core.h>
1717
#include <linux/of.h>
18-
#include <linux/of_device.h>
1918
#include <linux/pm_runtime.h>
2019
#include <linux/regmap.h>
2120
#include <linux/regulator/consumer.h>
@@ -612,8 +611,6 @@ MODULE_DEVICE_TABLE(of, wm8994_of_match);
612611

613612
static int wm8994_i2c_probe(struct i2c_client *i2c)
614613
{
615-
const struct i2c_device_id *id = i2c_client_get_device_id(i2c);
616-
const struct of_device_id *of_id;
617614
struct wm8994 *wm8994;
618615
int ret;
619616

@@ -625,13 +622,7 @@ static int wm8994_i2c_probe(struct i2c_client *i2c)
625622
wm8994->dev = &i2c->dev;
626623
wm8994->irq = i2c->irq;
627624

628-
if (i2c->dev.of_node) {
629-
of_id = of_match_device(wm8994_of_match, &i2c->dev);
630-
if (of_id)
631-
wm8994->type = (uintptr_t)of_id->data;
632-
} else {
633-
wm8994->type = id->driver_data;
634-
}
625+
wm8994->type = (enum wm8994_type)i2c_get_match_data(i2c);
635626

636627
wm8994->regmap = devm_regmap_init_i2c(i2c, &wm8994_base_regmap_config);
637628
if (IS_ERR(wm8994->regmap)) {

0 commit comments

Comments
 (0)