2023-03-29 06:02:11

by Guiting Shen

[permalink] [raw]
Subject: [PATCH] mfd:i2c: remove redundant dev_set_drvdata() function

the i2c_set_clientdata() is the inline function which is
complemented by the dev_set_drvdata() internally. Do not
need to use the i2c_set_clientdata() and dev_set_drvdata()
at the same time.

Signed-off-by: Guiting Shen <[email protected]>
---
drivers/mfd/88pm80x.c | 1 -
drivers/mfd/88pm860x-core.c | 1 -
drivers/mfd/aat2870-core.c | 2 --
drivers/mfd/lm3533-core.c | 2 --
drivers/mfd/max8907.c | 2 --
drivers/mfd/max8925-i2c.c | 1 -
drivers/mfd/wm8400-core.c | 2 --
drivers/mfd/wm8994-core.c | 2 --
8 files changed, 13 deletions(-)

diff --git a/drivers/mfd/88pm80x.c b/drivers/mfd/88pm80x.c
index ac4f08565f29..bbc1a87f0c8f 100644
--- a/drivers/mfd/88pm80x.c
+++ b/drivers/mfd/88pm80x.c
@@ -74,7 +74,6 @@ int pm80x_init(struct i2c_client *client)
chip->irq = client->irq;

chip->dev = &client->dev;
- dev_set_drvdata(chip->dev, chip);
i2c_set_clientdata(chip->client, chip);

ret = regmap_read(chip->regmap, PM80X_CHIP_ID, &val);
diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c
index aabac37c3502..26d1ffefadc1 100644
--- a/drivers/mfd/88pm860x-core.c
+++ b/drivers/mfd/88pm860x-core.c
@@ -1166,7 +1166,6 @@ static int pm860x_probe(struct i2c_client *client)
chip->client = client;
i2c_set_clientdata(client, chip);
chip->dev = &client->dev;
- dev_set_drvdata(chip->dev, chip);

/*
* Both client and companion client shares same platform driver.
diff --git a/drivers/mfd/aat2870-core.c b/drivers/mfd/aat2870-core.c
index f253da5b246b..5ff0f1ed7a15 100644
--- a/drivers/mfd/aat2870-core.c
+++ b/drivers/mfd/aat2870-core.c
@@ -345,8 +345,6 @@ static int aat2870_i2c_probe(struct i2c_client *client)
return -ENOMEM;

aat2870->dev = &client->dev;
- dev_set_drvdata(aat2870->dev, aat2870);
-
aat2870->client = client;
i2c_set_clientdata(client, aat2870);

diff --git a/drivers/mfd/lm3533-core.c b/drivers/mfd/lm3533-core.c
index 946f94f3a3c3..03830aa4979a 100644
--- a/drivers/mfd/lm3533-core.c
+++ b/drivers/mfd/lm3533-core.c
@@ -485,8 +485,6 @@ static int lm3533_device_init(struct lm3533 *lm3533)

lm3533->gpio_hwen = pdata->gpio_hwen;

- dev_set_drvdata(lm3533->dev, lm3533);
-
if (gpio_is_valid(lm3533->gpio_hwen)) {
ret = devm_gpio_request_one(lm3533->dev, lm3533->gpio_hwen,
GPIOF_OUT_INIT_LOW, "lm3533-hwen");
diff --git a/drivers/mfd/max8907.c b/drivers/mfd/max8907.c
index a69b865c6eac..0b8f6c298f97 100644
--- a/drivers/mfd/max8907.c
+++ b/drivers/mfd/max8907.c
@@ -201,8 +201,6 @@ static int max8907_i2c_probe(struct i2c_client *i2c)
}

max8907->dev = &i2c->dev;
- dev_set_drvdata(max8907->dev, max8907);
-
max8907->i2c_gen = i2c;
i2c_set_clientdata(i2c, max8907);
max8907->regmap_gen = devm_regmap_init_i2c(i2c,
diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
index 4057fd15c29e..c8761003c716 100644
--- a/drivers/mfd/max8925-i2c.c
+++ b/drivers/mfd/max8925-i2c.c
@@ -172,7 +172,6 @@ static int max8925_probe(struct i2c_client *client)
chip->i2c = client;
chip->dev = &client->dev;
i2c_set_clientdata(client, chip);
- dev_set_drvdata(chip->dev, chip);
mutex_init(&chip->io_lock);

chip->rtc = i2c_new_dummy_device(chip->i2c->adapter, RTC_I2C_ADDR);
diff --git a/drivers/mfd/wm8400-core.c b/drivers/mfd/wm8400-core.c
index 5e1599ac9abc..b572966e1ff6 100644
--- a/drivers/mfd/wm8400-core.c
+++ b/drivers/mfd/wm8400-core.c
@@ -54,8 +54,6 @@ static int wm8400_init(struct wm8400 *wm8400,
unsigned int reg;
int ret;

- dev_set_drvdata(wm8400->dev, wm8400);
-
/* Check that this is actually a WM8400 */
ret = regmap_read(wm8400->regmap, WM8400_RESET_ID, &reg);
if (ret != 0) {
diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c
index c419ab0c0eae..1b769ac3e53b 100644
--- a/drivers/mfd/wm8994-core.c
+++ b/drivers/mfd/wm8994-core.c
@@ -320,8 +320,6 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
if (ret != 0)
return ret;

- dev_set_drvdata(wm8994->dev, wm8994);
-
/* Add the on-chip regulators first for bootstrapping */
ret = mfd_add_devices(wm8994->dev, 0,
wm8994_regulator_devs,
--
2.34.1


2023-03-29 07:24:15

by Johan Hovold

[permalink] [raw]
Subject: Re: [PATCH] mfd:i2c: remove redundant dev_set_drvdata() function

On Wed, Mar 29, 2023 at 01:57:24PM +0800, Guiting Shen wrote:
> the i2c_set_clientdata() is the inline function which is
> complemented by the dev_set_drvdata() internally. Do not
> need to use the i2c_set_clientdata() and dev_set_drvdata()
> at the same time.

In the future please break your commit messages at 72 columns or so (not
60).

Also the Subject should have a space after each colon (or that should
have been a slash, but in this case you should probably just drop the
i2c bit) and it's really not the function that is redundant but the fact
that it is called. Perhaps something like:

mfd: remove redundant dev_set_drvdata() from i2c drivers

> Signed-off-by: Guiting Shen <[email protected]>
> ---
> drivers/mfd/88pm80x.c | 1 -
> drivers/mfd/88pm860x-core.c | 1 -
> drivers/mfd/aat2870-core.c | 2 --
> drivers/mfd/lm3533-core.c | 2 --
> drivers/mfd/max8907.c | 2 --
> drivers/mfd/max8925-i2c.c | 1 -
> drivers/mfd/wm8400-core.c | 2 --
> drivers/mfd/wm8994-core.c | 2 --
> 8 files changed, 13 deletions(-)

Looks good to me otherwise:

Reviewed-by: Johan Hovold <[email protected]>

Johan