mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 17:25:38 +00:00
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 <robh@kernel.org> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Link: https://lore.kernel.org/r/20231017203603.2700864-1-robh@kernel.org Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
parent
830fafce06
commit
0db434f513
@ -15,8 +15,8 @@
|
|||||||
#include <linux/i2c.h>
|
#include <linux/i2c.h>
|
||||||
#include <linux/lockdep.h>
|
#include <linux/lockdep.h>
|
||||||
#include <linux/mfd/core.h>
|
#include <linux/mfd/core.h>
|
||||||
|
#include <linux/mod_devicetable.h>
|
||||||
#include <linux/mutex.h>
|
#include <linux/mutex.h>
|
||||||
#include <linux/of.h>
|
|
||||||
#include <linux/of_platform.h>
|
#include <linux/of_platform.h>
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
|
|
||||||
@ -270,7 +270,6 @@ static int lochnagar_i2c_probe(struct i2c_client *i2c)
|
|||||||
{
|
{
|
||||||
struct device *dev = &i2c->dev;
|
struct device *dev = &i2c->dev;
|
||||||
const struct lochnagar_config *config = NULL;
|
const struct lochnagar_config *config = NULL;
|
||||||
const struct of_device_id *of_id;
|
|
||||||
struct lochnagar *lochnagar;
|
struct lochnagar *lochnagar;
|
||||||
struct gpio_desc *reset, *present;
|
struct gpio_desc *reset, *present;
|
||||||
unsigned int val;
|
unsigned int val;
|
||||||
@ -282,11 +281,7 @@ static int lochnagar_i2c_probe(struct i2c_client *i2c)
|
|||||||
if (!lochnagar)
|
if (!lochnagar)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
of_id = of_match_device(lochnagar_of_match, dev);
|
config = i2c_get_match_data(i2c);
|
||||||
if (!of_id)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
config = of_id->data;
|
|
||||||
|
|
||||||
lochnagar->dev = dev;
|
lochnagar->dev = dev;
|
||||||
mutex_init(&lochnagar->analogue_config_lock);
|
mutex_init(&lochnagar->analogue_config_lock);
|
||||||
|
@ -6,10 +6,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/gpio/consumer.h>
|
#include <linux/gpio/consumer.h>
|
||||||
|
#include <linux/i2c.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/mfd/core.h>
|
#include <linux/mfd/core.h>
|
||||||
|
#include <linux/mod_devicetable.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of_device.h>
|
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
|
|
||||||
#include <linux/mfd/lp87565.h>
|
#include <linux/mfd/lp87565.h>
|
||||||
@ -46,7 +47,6 @@ MODULE_DEVICE_TABLE(of, of_lp87565_match_table);
|
|||||||
static int lp87565_probe(struct i2c_client *client)
|
static int lp87565_probe(struct i2c_client *client)
|
||||||
{
|
{
|
||||||
struct lp87565 *lp87565;
|
struct lp87565 *lp87565;
|
||||||
const struct of_device_id *of_id;
|
|
||||||
int ret;
|
int ret;
|
||||||
unsigned int otpid;
|
unsigned int otpid;
|
||||||
|
|
||||||
@ -89,10 +89,7 @@ static int lp87565_probe(struct i2c_client *client)
|
|||||||
}
|
}
|
||||||
|
|
||||||
lp87565->rev = otpid & LP87565_OTP_REV_OTP_ID;
|
lp87565->rev = otpid & LP87565_OTP_REV_OTP_ID;
|
||||||
|
lp87565->dev_type = (uintptr_t)i2c_get_match_data(client);
|
||||||
of_id = of_match_device(of_lp87565_match_table, &client->dev);
|
|
||||||
if (of_id)
|
|
||||||
lp87565->dev_type = (uintptr_t)of_id->data;
|
|
||||||
|
|
||||||
i2c_set_clientdata(client, lp87565);
|
i2c_set_clientdata(client, lp87565);
|
||||||
|
|
||||||
|
@ -9,9 +9,10 @@
|
|||||||
// This driver is based on max8997.c
|
// This driver is based on max8997.c
|
||||||
|
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
|
#include <linux/i2c.h>
|
||||||
|
#include <linux/mod_devicetable.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/of_device.h>
|
|
||||||
#include <linux/mfd/core.h>
|
#include <linux/mfd/core.h>
|
||||||
#include <linux/mfd/max14577.h>
|
#include <linux/mfd/max14577.h>
|
||||||
#include <linux/mfd/max14577-private.h>
|
#include <linux/mfd/max14577-private.h>
|
||||||
@ -357,7 +358,6 @@ static void max77836_remove(struct max14577 *max14577)
|
|||||||
|
|
||||||
static int max14577_i2c_probe(struct i2c_client *i2c)
|
static int max14577_i2c_probe(struct i2c_client *i2c)
|
||||||
{
|
{
|
||||||
const struct i2c_device_id *id = i2c_client_get_device_id(i2c);
|
|
||||||
struct max14577 *max14577;
|
struct max14577 *max14577;
|
||||||
struct max14577_platform_data *pdata = dev_get_platdata(&i2c->dev);
|
struct max14577_platform_data *pdata = dev_get_platdata(&i2c->dev);
|
||||||
struct device_node *np = i2c->dev.of_node;
|
struct device_node *np = i2c->dev.of_node;
|
||||||
@ -397,15 +397,7 @@ static int max14577_i2c_probe(struct i2c_client *i2c)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (np) {
|
max14577->dev_type = (enum maxim_device_type)i2c_get_match_data(i2c);
|
||||||
const struct of_device_id *of_id;
|
|
||||||
|
|
||||||
of_id = of_match_device(max14577_dt_match, &i2c->dev);
|
|
||||||
if (of_id)
|
|
||||||
max14577->dev_type = (uintptr_t)of_id->data;
|
|
||||||
} else {
|
|
||||||
max14577->dev_type = id->driver_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
max14577_print_dev_type(max14577);
|
max14577_print_dev_type(max14577);
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include <linux/mfd/core.h>
|
#include <linux/mfd/core.h>
|
||||||
#include <linux/mfd/rn5t618.h>
|
#include <linux/mfd/rn5t618.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of_device.h>
|
#include <linux/of.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/reboot.h>
|
#include <linux/reboot.h>
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
@ -179,22 +179,15 @@ MODULE_DEVICE_TABLE(of, rn5t618_of_match);
|
|||||||
|
|
||||||
static int rn5t618_i2c_probe(struct i2c_client *i2c)
|
static int rn5t618_i2c_probe(struct i2c_client *i2c)
|
||||||
{
|
{
|
||||||
const struct of_device_id *of_id;
|
|
||||||
struct rn5t618 *priv;
|
struct rn5t618 *priv;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
of_id = of_match_device(rn5t618_of_match, &i2c->dev);
|
|
||||||
if (!of_id) {
|
|
||||||
dev_err(&i2c->dev, "Failed to find matching DT ID\n");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
priv = devm_kzalloc(&i2c->dev, sizeof(*priv), GFP_KERNEL);
|
priv = devm_kzalloc(&i2c->dev, sizeof(*priv), GFP_KERNEL);
|
||||||
if (!priv)
|
if (!priv)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
i2c_set_clientdata(i2c, priv);
|
i2c_set_clientdata(i2c, priv);
|
||||||
priv->variant = (long)of_id->data;
|
priv->variant = (long)i2c_get_match_data(i2c);
|
||||||
priv->irq = i2c->irq;
|
priv->irq = i2c->irq;
|
||||||
priv->dev = &i2c->dev;
|
priv->dev = &i2c->dev;
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/of_device.h>
|
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
|
|
||||||
#include <linux/mfd/wm831x/core.h>
|
#include <linux/mfd/wm831x/core.h>
|
||||||
@ -23,22 +22,15 @@
|
|||||||
|
|
||||||
static int wm831x_i2c_probe(struct i2c_client *i2c)
|
static int wm831x_i2c_probe(struct i2c_client *i2c)
|
||||||
{
|
{
|
||||||
const struct i2c_device_id *id = i2c_client_get_device_id(i2c);
|
|
||||||
struct wm831x_pdata *pdata = dev_get_platdata(&i2c->dev);
|
struct wm831x_pdata *pdata = dev_get_platdata(&i2c->dev);
|
||||||
const struct of_device_id *of_id;
|
|
||||||
struct wm831x *wm831x;
|
struct wm831x *wm831x;
|
||||||
enum wm831x_parent type;
|
enum wm831x_parent type;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (i2c->dev.of_node) {
|
type = (uintptr_t)i2c_get_match_data(i2c);
|
||||||
of_id = of_match_device(wm831x_of_match, &i2c->dev);
|
if (!type) {
|
||||||
if (!of_id) {
|
dev_err(&i2c->dev, "Failed to match device\n");
|
||||||
dev_err(&i2c->dev, "Failed to match device\n");
|
return -ENODEV;
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
type = (uintptr_t)of_id->data;
|
|
||||||
} else {
|
|
||||||
type = (enum wm831x_parent)id->driver_data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wm831x = devm_kzalloc(&i2c->dev, sizeof(struct wm831x), GFP_KERNEL);
|
wm831x = devm_kzalloc(&i2c->dev, sizeof(struct wm831x), GFP_KERNEL);
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/mfd/core.h>
|
#include <linux/mfd/core.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/of_device.h>
|
|
||||||
#include <linux/pm_runtime.h>
|
#include <linux/pm_runtime.h>
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
#include <linux/regulator/consumer.h>
|
#include <linux/regulator/consumer.h>
|
||||||
@ -612,8 +611,6 @@ MODULE_DEVICE_TABLE(of, wm8994_of_match);
|
|||||||
|
|
||||||
static int wm8994_i2c_probe(struct i2c_client *i2c)
|
static int wm8994_i2c_probe(struct i2c_client *i2c)
|
||||||
{
|
{
|
||||||
const struct i2c_device_id *id = i2c_client_get_device_id(i2c);
|
|
||||||
const struct of_device_id *of_id;
|
|
||||||
struct wm8994 *wm8994;
|
struct wm8994 *wm8994;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -625,13 +622,7 @@ static int wm8994_i2c_probe(struct i2c_client *i2c)
|
|||||||
wm8994->dev = &i2c->dev;
|
wm8994->dev = &i2c->dev;
|
||||||
wm8994->irq = i2c->irq;
|
wm8994->irq = i2c->irq;
|
||||||
|
|
||||||
if (i2c->dev.of_node) {
|
wm8994->type = (enum wm8994_type)i2c_get_match_data(i2c);
|
||||||
of_id = of_match_device(wm8994_of_match, &i2c->dev);
|
|
||||||
if (of_id)
|
|
||||||
wm8994->type = (uintptr_t)of_id->data;
|
|
||||||
} else {
|
|
||||||
wm8994->type = id->driver_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
wm8994->regmap = devm_regmap_init_i2c(i2c, &wm8994_base_regmap_config);
|
wm8994->regmap = devm_regmap_init_i2c(i2c, &wm8994_base_regmap_config);
|
||||||
if (IS_ERR(wm8994->regmap)) {
|
if (IS_ERR(wm8994->regmap)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user