2023-09-23 17:49:52

by Biju Das

[permalink] [raw]
Subject: [PATCH v4 0/4] Simplify obtaining I2C match data

This patch series aims to simplify obtaining I2C match data.

This patch series is only compile tested.

v4:
* Added as a series
* Updated commit header for all patches
* Updated commit description for patch#1.


Biju Das (4):
mfd: arizona-i2c: Simplify obtaining I2C match data
mfd: madera-i2c: Simplify obtaining I2C match data
mfd: max77541: Simplify obtaining I2C match data
mfd: max8998: Simplify obtaining I2C match data and drop
max8998_i2c_get_driver_data()

drivers/mfd/arizona-i2c.c | 11 ++---------
drivers/mfd/madera-i2c.c | 9 +--------
drivers/mfd/max77541.c | 6 +-----
drivers/mfd/max8998.c | 12 +-----------
4 files changed, 5 insertions(+), 33 deletions(-)

--
2.25.1


2023-09-23 17:49:58

by Biju Das

[permalink] [raw]
Subject: [PATCH v4 3/4] mfd: max77541: Simplify obtaining I2C match data

Simplify probe() by replacing device_get_match_data() and ID lookup for
retrieving match data by i2c_get_match_data().

Signed-off-by: Biju Das <[email protected]>
---
Note:
This patch is only compile tested.

v3->v4:
* Updated commit header.
v2->v3:
* Restored OF table.
v1->v2:
* Restored error code -EINVAL.
---
drivers/mfd/max77541.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/mfd/max77541.c b/drivers/mfd/max77541.c
index 10c2e274b4af..d77c31c86e43 100644
--- a/drivers/mfd/max77541.c
+++ b/drivers/mfd/max77541.c
@@ -162,7 +162,6 @@ static int max77541_pmic_setup(struct device *dev)

static int max77541_probe(struct i2c_client *client)
{
- const struct i2c_device_id *id = i2c_client_get_device_id(client);
struct device *dev = &client->dev;
struct max77541 *max77541;

@@ -173,10 +172,7 @@ static int max77541_probe(struct i2c_client *client)
i2c_set_clientdata(client, max77541);
max77541->i2c = client;

- max77541->id = (uintptr_t)device_get_match_data(dev);
- if (!max77541->id)
- max77541->id = (enum max7754x_ids)id->driver_data;
-
+ max77541->id = (uintptr_t)i2c_get_match_data(client);
if (!max77541->id)
return -EINVAL;

--
2.25.1

2023-09-23 17:49:59

by Biju Das

[permalink] [raw]
Subject: [PATCH v4 1/4] mfd: arizona-i2c: Simplify obtaining I2C match data

Simplify probe() by replacing device_get_match_data() and ID lookup for
retrieving match data by i2c_get_match_data(). After this drop
intializing the variable type.

Signed-off-by: Biju Das <[email protected]>
Acked-by: Charles Keepax <[email protected]>
Tested-by: Charles Keepax <[email protected]>
---
Note:
This patch is only compile tested.

v3->v4:
* Updated commit header and description.
v2->v3:
* Used uintptr_t for enum casting.
v1->v2:
* Added Ack and Tested-by tag from Charles Keepax
* Dropped unnecessary blank line before switch statement.
---
drivers/mfd/arizona-i2c.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/arizona-i2c.c b/drivers/mfd/arizona-i2c.c
index 9b7183ffc928..10e76fc8f12e 100644
--- a/drivers/mfd/arizona-i2c.c
+++ b/drivers/mfd/arizona-i2c.c
@@ -22,19 +22,12 @@

static int arizona_i2c_probe(struct i2c_client *i2c)
{
- const struct i2c_device_id *id = i2c_client_get_device_id(i2c);
- const void *match_data;
struct arizona *arizona;
const struct regmap_config *regmap_config = NULL;
- unsigned long type = 0;
+ unsigned long type;
int ret;

- match_data = device_get_match_data(&i2c->dev);
- if (match_data)
- type = (unsigned long)match_data;
- else if (id)
- type = id->driver_data;
-
+ type = (uintptr_t)i2c_get_match_data(i2c);
switch (type) {
case WM5102:
if (IS_ENABLED(CONFIG_MFD_WM5102))
--
2.25.1

2023-09-23 17:50:04

by Biju Das

[permalink] [raw]
Subject: [PATCH v4 4/4] mfd: max8998: Simplify obtaining I2C match data and drop max8998_i2c_get_driver_data()

Simplify probe() by using i2c_get_match_data() instead of
max8998_i2c_get_driver_data() for retrieving match data from
OF/ID tables.

Signed-off-by: Biju Das <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
---
Note:
This patch is only compile tested.

v3->v4:
* Updated commit header.
V2->v3:
* Added Rb tag from Andy.
v1->v2:
* Used uintptr_t for enum casting.
---
drivers/mfd/max8998.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/mfd/max8998.c b/drivers/mfd/max8998.c
index 4cc426a6c767..6ba27171da28 100644
--- a/drivers/mfd/max8998.c
+++ b/drivers/mfd/max8998.c
@@ -152,18 +152,8 @@ static struct max8998_platform_data *max8998_i2c_parse_dt_pdata(
return pd;
}

-static inline unsigned long max8998_i2c_get_driver_data(struct i2c_client *i2c,
- const struct i2c_device_id *id)
-{
- if (i2c->dev.of_node)
- return (unsigned long)of_device_get_match_data(&i2c->dev);
-
- return id->driver_data;
-}
-
static int max8998_i2c_probe(struct i2c_client *i2c)
{
- const struct i2c_device_id *id = i2c_client_get_device_id(i2c);
struct max8998_platform_data *pdata = dev_get_platdata(&i2c->dev);
struct max8998_dev *max8998;
int ret = 0;
@@ -183,7 +173,7 @@ static int max8998_i2c_probe(struct i2c_client *i2c)
max8998->dev = &i2c->dev;
max8998->i2c = i2c;
max8998->irq = i2c->irq;
- max8998->type = max8998_i2c_get_driver_data(i2c, id);
+ max8998->type = (uintptr_t)i2c_get_match_data(i2c);
max8998->pdata = pdata;
if (pdata) {
max8998->ono = pdata->ono;
--
2.25.1

2023-09-23 17:50:23

by Biju Das

[permalink] [raw]
Subject: [PATCH v4 2/4] mfd: madera-i2c: Simplify obtaining I2C match data

Simplify probe() by replacing of_device_get_match_data() and ID lookup for
retrieving match data by i2c_get_match_data().

Signed-off-by: Biju Das <[email protected]>
Acked-by: Charles Keepax <[email protected]>
---
Note:
This patch is only compile tested.

v3->v4:
* Updated commit header.
v2->v3:
* Used uintptr_t for enum casting.
v1->v2:
* Added Ack tag from Charles Keepax.
* Dropped blank line before switch statement.
---
drivers/mfd/madera-i2c.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/mfd/madera-i2c.c b/drivers/mfd/madera-i2c.c
index a404ea26bc79..0986e4a99f4a 100644
--- a/drivers/mfd/madera-i2c.c
+++ b/drivers/mfd/madera-i2c.c
@@ -18,21 +18,14 @@

static int madera_i2c_probe(struct i2c_client *i2c)
{
- const struct i2c_device_id *id = i2c_client_get_device_id(i2c);
struct madera *madera;
const struct regmap_config *regmap_16bit_config = NULL;
const struct regmap_config *regmap_32bit_config = NULL;
- const void *of_data;
unsigned long type;
const char *name;
int ret;

- of_data = of_device_get_match_data(&i2c->dev);
- if (of_data)
- type = (unsigned long)of_data;
- else
- type = id->driver_data;
-
+ type = (uintptr_t)i2c_get_match_data(i2c);
switch (type) {
case CS47L15:
if (IS_ENABLED(CONFIG_MFD_CS47L15)) {
--
2.25.1

2023-09-28 13:26:30

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH v4 0/4] Simplify obtaining I2C match data

On Sat, 23 Sep 2023 18:49:24 +0100, Biju Das wrote:
> This patch series aims to simplify obtaining I2C match data.
>
> This patch series is only compile tested.
>
> v4:
> * Added as a series
> * Updated commit header for all patches
> * Updated commit description for patch#1.
>
> [...]

Applied, thanks!

[1/4] mfd: arizona-i2c: Simplify obtaining I2C match data
commit: 33b5b46a3bd2664a32568f7df2c7b5fd9d2873ae
[2/4] mfd: madera-i2c: Simplify obtaining I2C match data
commit: 7a6ff7d69d9921d269b796ca0c2a96717563fe84
[3/4] mfd: max77541: Simplify obtaining I2C match data
commit: 9abf37d4bbb20d6fb6e15a73d8e8247c8e791f46
[4/4] mfd: max8998: Simplify obtaining I2C match data and drop max8998_i2c_get_driver_data()
commit: 36270a2599628fbd8052b3d9241f4a4b02faea7c

--
Lee Jones [李琼斯]