Use i2c_get_match_data()
Subsystems (5)
cover Use i2c_get_match_data()
Use i2c_get_match_data() to get match data for I2C, ACPI and DT-based matching.
This patch series is only compile tested.
Biju Das (4):
iio: accel: adxl355: Simplify probe()
iio: accel: adxl313: Use i2c_get_match_data
iio: potentiometer: mcp4531: Use i2c_get_match_data
iio: potentiometer: mcp4018: Use i2c_get_match_data
drivers/iio/accel/adxl313_i2c.c | 4 ++-- drivers/iio/accel/adxl355_i2c.c | 15 +++------------ drivers/iio/potentiometer/mcp4018.c | 4 ++-- drivers/iio/potentiometer/mcp4531.c | 4 ++-- 4 files changed, 9 insertions(+), 18 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/4 iio: accel: adxl355: Simplify probe()
Simplify the probe() by replacing of_device_get_match_data() and i2c_match_id() by i2c_get_match_data() as we have similar I2C and DT-based matching table.
--- drivers/iio/accel/adxl355_i2c.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)
drivers/iio/accel/adxl355_i2c.c +3 -12
@@ -24,19 +24,10 @@ static int adxl355_i2c_probe(struct i2c_client *client) {struct regmap *regmap;const struct adxl355_chip_info *chip_data; -const struct i2c_device_id *adxl355; - chip_data =device_get_match_data (&client->dev); -if (!chip_data) { - adxl355 =to_i2c_driver (client->dev.driver)->id_table; -if (!adxl355) -return -EINVAL ; - - chip_data = (void *)i2c_match_id (adxl355, client)->driver_data; - -if (!chip_data) -return -EINVAL ; - } + chip_data =i2c_get_match_data (client); +if (!chip_data) +return -ENODEV ; regmap =devm_regmap_init_i2c (client, &adxl355_i2c_regmap_config);if (IS_ERR (regmap)) {
Signature · 1 line
2.25.1
Re: [PATCH 1/4] iio: accel: adxl355: Simplify probe()
Quoted 5 lines · Biju Das
Simplify the
probe()by replacingof_device_get_match_data()andi2c_match_id()byi2c_get_match_data()as we have similar I2C and DT-based matching table.Signed-off-by Biju Das <[email protected]>
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH 1/4] iio: accel: adxl355: Simplify probe()
In reply to Biju DasQuoted 38 lines · Biju Das
Simplify the
probe()by replacingof_device_get_match_data()andi2c_match_id()byi2c_get_match_data()as we have similar I2C and DT-based matching table.Signed-off-by Biju Das <[email protected]>--- drivers/iio/accel/adxl355_i2c.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)drivers/iio/accel/adxl355_i2c.c +3
-13@@ -24,19 +24,10 @@ static int adxl355_i2c_probe(struct i2c_client *client) {struct regmap *regmap;const struct adxl355_chip_info *chip_data; -const struct i2c_device_id *adxl355; - chip_data =device_get_match_data (&client->dev); -if (!chip_data) { - adxl355 =to_i2c_driver (client->dev.driver)->id_table; -if (!adxl355) -return -EINVAL ; - - chip_data = (void *)i2c_match_id (adxl355, client)->driver_data; - -if (!chip_data) -return -EINVAL ; - } + chip_data =i2c_get_match_data (client); +if (!chip_data) +return -ENODEV ; regmap =devm_regmap_init_i2c (client, &adxl355_i2c_regmap_config);if (IS_ERR (regmap)) { --
Quoted 2 lines
2.25.1
Jonathan Cameron
maintainerRe: [PATCH 1/4] iio: accel: adxl355: Simplify probe()
In reply to Biju DasQuoted 5 lines · On Sun, 16 Jul 2023 18:52:15 +0100 Biju Das <[email protected]> wrote:
Simplify the
probe()by replacingof_device_get_match_data()andi2c_match_id()byi2c_get_match_data()as we have similar I2C and DT-based matching table.Signed-off-by Biju Das <[email protected]>
Applied to the togreg branch of iio.git, initially pushed out as testing for 0-day to take a look at.
Thanks,
Jonathan
Quoted 31 lines
--- drivers/iio/accel/adxl355_i2c.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)drivers/iio/accel/adxl355_i2c.c +3
-12@@ -24,19 +24,10 @@ static int adxl355_i2c_probe(struct i2c_client *client) {struct regmap *regmap;const struct adxl355_chip_info *chip_data; -const struct i2c_device_id *adxl355; - chip_data =device_get_match_data (&client->dev); -if (!chip_data) { - adxl355 =to_i2c_driver (client->dev.driver)->id_table; -if (!adxl355) -return -EINVAL ; - - chip_data = (void *)i2c_match_id (adxl355, client)->driver_data; - -if (!chip_data) -return -EINVAL ; - } + chip_data =i2c_get_match_data (client); +if (!chip_data) +return -ENODEV ; regmap =devm_regmap_init_i2c (client, &adxl355_i2c_regmap_config);if (IS_ERR (regmap)) {
PATCH 2/4 iio: accel: adxl313: Use i2c_get_match_data
In reply to Biju DasReplace of_device_get_match_data() and i2c_match_id() by i2c_get_match _data() as we have similar I2C and DT-based matching table.
--- drivers/iio/accel/adxl313_i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/accel/adxl313_i2c.c +2 -2
@@ -65,9 +65,9 @@ static int adxl313_i2c_probe(struct i2c_client *client)* Retrieves device specific data as a pointer to a * adxl313_chip_info structure */ - chip_data =device_get_match_data (&client->dev); + chip_data =i2c_get_match_data (client);if (!chip_data) - chip_data = (const struct adxl313_chip_info *)i2c_match_id (adxl313_i2c_id, client)->driver_data; +return -ENODEV ; regmap =devm_regmap_init_i2c (client, &adxl31x_i2c_regmap_config[chip_data->type]);
Signature · 1 line
2.25.1
Re: [PATCH 2/4] iio: accel: adxl313: Use i2c_get_match_data
Quoted 4 lines · Biju Das
Replace
of_device_get_match_data()andi2c_match_id()byi2c_get_match_data()as we have similar I2C and DT-based matching table.Signed-off-by Biju Das <[email protected]>
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Jonathan Cameron
maintainerRe: [PATCH 2/4] iio: accel: adxl313: Use i2c_get_match_data
In reply to Biju DasQuoted 14 lines · On Sun, 16 Jul 2023 18:52:16 +0100 Biju Das <[email protected]> wrote:
Replace
of_device_get_match_data()andi2c_match_id()byi2c_get_match_data()as we have similar I2C and DT-based matching table.Signed-off-by Biju Das <[email protected]>--- drivers/iio/accel/adxl313_i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/iio/accel/adxl313_i2c.c +0
-0@@ -65,9 +65,9 @@ static int adxl313_i2c_probe(struct i2c_client *client)* Retrieves device specific data as a pointer to a
drivers/iio/accel/adxl313_i2c.c static int adxl313_i2c_probe(struct i2c_client *client) · line 73
Quoted 10 lines
drivers/iio/accel/adxl313_i2c.c +2
-2* adxl313_chip_info structure */ - chip_data =device_get_match_data (&client->dev); + chip_data =i2c_get_match_data (client);if (!chip_data) - chip_data = (const struct adxl313_chip_info *)i2c_match_id (adxl313_i2c_id, client)->driver_data; +return -ENODEV ; regmap =devm_regmap_init_i2c (client, &adxl31x_i2c_regmap_config[chip_data->type]);
This driver looks buggy:
static const struct i2c_device_id adxl313_i2c_id[] = {
{ .name = "adxl312", .driver_data = (kernel_ulong_t)&adxl31x_chip_info[ADXL312] },
{ .name = "adxl313", .driver_data = (kernel_ulong_t)&adxl31x_chip_info[ADXL312] },
{ .name = "adxl314", .driver_data = (kernel_ulong_t)&adxl31x_chip_info[ADXL312] },
{ }
};MODULE_DEVICE_TABLE(i2c, adxl313_i2c_id);
static const struct of_device_id adxl313_of_match[] = {
{ .compatible = "adi,adxl312", .data = &adxl31x_chip_info[ADXL312] },
{ .compatible = "adi,adxl313", .data = &adxl31x_chip_info[ADXL313] },
{ .compatible = "adi,adxl314", .data = &adxl31x_chip_info[ADXL314] },
{ }
};Odd that the i2c_device_id table always uses ADXL312
That would only have previously applied if we failed to match on the of one (which only happens in somewhat obscure cases)
Can we fix that first then apply this cleanup on top?
Thanks,
Jonathan
RE: [PATCH 2/4] iio: accel: adxl313: Use i2c_get_match_data
Hi Jonathan Cameron,
Quoted 68 lines
-----Original Message-----
From: Jonathan Cameron <[email protected]>
Sent: Saturday, July 22, 2023 5:29 PM
To: Biju Das <[email protected]>
Cc: Lars-Peter Clausen <[email protected]>; Michael Hennerich <[email protected]>; Lucas Stankus <[email protected]>; [email protected]; Geert Uytterhoeven <[email protected]>; Prabhakar Mahadev Lad <[email protected]>; linux-renesas- [email protected]
Subject: Re: [PATCH 2/4] iio: accel: adxl313: Usei2c_get_match_datadrivers/iio/accel/adxl313_i2c.c static int adxl313_i2c_probe(struct i2c_client
Quoted 14 lines · On Sun, 16 Jul 2023 18:52:16 +0100 Biju Das <[email protected]> wrote:
Replace
of_device_get_match_data()andi2c_match_id()byi2c_get_match_data()as we have similar I2C and DT-based matching table.Signed-off-by Biju Das <[email protected]>--- drivers/iio/accel/adxl313_i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/iio/accel/adxl313_i2c.cindex524327ea3663..6d252190207b100644drivers/iio/accel/adxl313_i2c.c +0
-0@@ -65,9 +65,9 @@ static int adxl313_i2c_probe(struct i2c_client*client)
drivers/iio/accel/adxl313_i2c.c static int adxl313_i2c_probe(struct i2c_client *client)
Quoted 7 lines
drivers/iio/accel/adxl313_i2c.c +1
-2* Retrieves device specific data as a pointer to a * adxl313_chip_info structure */ - chip_data =device_get_match_data (&client->dev); + chip_data =i2c_get_match_data (client);if (!chip_data) - chip_data = (const struct adxl313_chip_info*)i2c_match_id(adxl313_i2c_id, client)->driver_data;
Quoted 5 lines
drivers/iio/accel/adxl313_i2c.c +1
-0+return -ENODEV ; regmap =devm_regmap_init_i2c (client, &adxl31x_i2c_regmap_config[chip_data-type]);
This driver looks buggy:
static const struct i2c_device_id adxl313_i2c_id[] = { { .name = "adxl312", .driver_data = (kernel_ulong_t)&adxl31x_chip_info[ADXL312] }, { .name = "adxl313", .driver_data = (kernel_ulong_t)&adxl31x_chip_info[ADXL312] }, { .name = "adxl314", .driver_data = (kernel_ulong_t)&adxl31x_chip_info[ADXL312] }, { } };
MODULE_DEVICE_TABLE(i2c, adxl313_i2c_id);static const struct of_device_id adxl313_of_match[] = { { .compatible = "adi,adxl312", .data = &adxl31x_chip_info[ADXL312] }, { .compatible = "adi,adxl313", .data = &adxl31x_chip_info[ADXL313] }, { .compatible = "adi,adxl314", .data = &adxl31x_chip_info[ADXL314] }, { } };
Quoted 6 lines
Odd that the
i2c_device_idtable always uses ADXL312That would only have previously applied if we failed to match on the of one (which only happens in somewhat obscure cases)
Can we fix that first then apply this cleanup on top?
Sure. Will send V2.
Cheers,
Biju
PATCH 3/4 iio: potentiometer: mcp4531: Use i2c_get_match_data
In reply to Biju DasReplace of_device_get_match_data() and i2c_match_id() by i2c_get_match _data() as we have similar I2C and DT-based matching table.
--- drivers/iio/potentiometer/mcp4531.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/potentiometer/mcp4531.c +2 -2
@@ -368,9 +368,9 @@ static int mcp4531_probe(struct i2c_client *client)i2c_set_clientdata (client, indio_dev); data->client = client; - data->cfg =device_get_match_data (dev); + data->cfg =i2c_get_match_data (client);if (!data->cfg) - data->cfg = &mcp4531_cfg[i2c_match_id (mcp4531_id, client)->driver_data]; +return -ENODEV ; indio_dev->info = &mcp4531_info; indio_dev->channels = mcp4531_channels;
Signature · 1 line
2.25.1
RE: [PATCH 3/4] iio: potentiometer: mcp4531: Use i2c_get_match_data
Hi all,
I would like to drop this patch, as this driver does not have similar I2C and DT-based matching table.
Cheers,
Biju
Quoted 38 lines
-----Original Message-----
From: Biju Das <[email protected]>
Sent: Sunday, July 16, 2023 6:52 PM
To: Peter Rosin <[email protected]>; Jonathan Cameron <[email protected]>
Cc: Biju Das <[email protected]>; Lars-Peter Clausen <[email protected]>; [email protected]; Geert Uytterhoeven <[email protected]>; Prabhakar Mahadev Lad <prabhakar.mahadev- [email protected]>; [email protected]
Subject: [PATCH 3/4] iio: potentiometer: mcp4531: Usei2c_get_match_dataReplace
of_device_get_match_data()andi2c_match_id()byi2c_get_match_data()as we have similar I2C and DT-based matching table.Signed-off-by Biju Das <[email protected]>--- drivers/iio/potentiometer/mcp4531.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/iio/potentiometer/mcp4531.c +2
-2@@ -368,9 +368,9 @@ static int mcp4531_probe(struct i2c_client *client)i2c_set_clientdata (client, indio_dev); data->client = client; - data->cfg =device_get_match_data (dev); + data->cfg =i2c_get_match_data (client);if (!data->cfg) - data->cfg = &mcp4531_cfg[i2c_match_id (mcp4531_id, client)- >driver_data]; +return -ENODEV ; indio_dev->info = &mcp4531_info;
indio_dev->channels=mcp4531_channels;
--
2.25.1
PATCH 4/4 iio: potentiometer: mcp4018: Use i2c_get_match_data
In reply to Biju DasReplace of_device_get_match_data() and i2c_match_id() by i2c_get_match _data() as we have similar I2C and DT-based matching table.
--- drivers/iio/potentiometer/mcp4018.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/potentiometer/mcp4018.c +2 -2
@@ -157,9 +157,9 @@ static int mcp4018_probe(struct i2c_client *client)i2c_set_clientdata (client, indio_dev); data->client = client; - data->cfg =device_get_match_data (dev); + data->cfg =i2c_get_match_data (dev);if (!data->cfg) - data->cfg = &mcp4018_cfg[i2c_match_id (mcp4018_id, client)->driver_data]; +return -ENODEV ; indio_dev->info = &mcp4018_info; indio_dev->channels = &mcp4018_channel;
Signature · 1 line
2.25.1
RE: [PATCH 4/4] iio: potentiometer: mcp4018: Use i2c_get_match_data
Hi All,
I would like to drop this patch, as this driver does not have similar I2C and DT-based matching table.
Cheers,
Biju
Quoted 38 lines
-----Original Message-----
From: Biju Das <[email protected]>
Sent: Sunday, July 16, 2023 6:52 PM
To: Peter Rosin <[email protected]>; Jonathan Cameron <[email protected]>
Cc: Biju Das <[email protected]>; Lars-Peter Clausen <[email protected]>; [email protected]; Geert Uytterhoeven <[email protected]>; Prabhakar Mahadev Lad <prabhakar.mahadev- [email protected]>; [email protected]
Subject: [PATCH 4/4] iio: potentiometer: mcp4018: Usei2c_get_match_dataReplace
of_device_get_match_data()andi2c_match_id()byi2c_get_match_data()as we have similar I2C and DT-based matching table.Signed-off-by Biju Das <[email protected]>--- drivers/iio/potentiometer/mcp4018.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/iio/potentiometer/mcp4018.c +2
-2@@ -157,9 +157,9 @@ static int mcp4018_probe(struct i2c_client *client)i2c_set_clientdata (client, indio_dev); data->client = client; - data->cfg =device_get_match_data (dev); + data->cfg =i2c_get_match_data (dev);if (!data->cfg) - data->cfg = &mcp4018_cfg[i2c_match_id (mcp4018_id, client)- >driver_data]; +return -ENODEV ; indio_dev->info = &mcp4018_info;
indio_dev->channels=&mcp4018_channel;
--
2.25.1
Jonathan Cameron
maintainerRe: [PATCH 4/4] iio: potentiometer: mcp4018: Use i2c_get_match_data
Quoted 4 lines · On Sun, 16 Jul 2023 18:10:13 +0000 Biju Das <[email protected]> wrote:
Hi All,
I would like to drop this patch, as this driver does not have similar I2C and DT-based matching table.
Could make it so they do ;)
Jonathan
Quoted 43 lines
Cheers,
BijuQuoted 38 lines
-----Original Message-----
From: Biju Das <[email protected]>
Sent: Sunday, July 16, 2023 6:52 PM
To: Peter Rosin <[email protected]>; Jonathan Cameron <[email protected]>
Cc: Biju Das <[email protected]>; Lars-Peter Clausen <[email protected]>; [email protected]; Geert Uytterhoeven <[email protected]>; Prabhakar Mahadev Lad <prabhakar.mahadev- [email protected]>; [email protected]
Subject: [PATCH 4/4] iio: potentiometer: mcp4018: Usei2c_get_match_dataReplace
of_device_get_match_data()andi2c_match_id()byi2c_get_match_data()as we have similar I2C and DT-based matching table.Signed-off-by Biju Das <[email protected]>--- drivers/iio/potentiometer/mcp4018.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/iio/potentiometer/mcp4018.c +2
-2@@ -157,9 +157,9 @@ static int mcp4018_probe(struct i2c_client *client)i2c_set_clientdata (client, indio_dev); data->client = client; - data->cfg =device_get_match_data (dev); + data->cfg =i2c_get_match_data (dev);if (!data->cfg) - data->cfg = &mcp4018_cfg[i2c_match_id (mcp4018_id, client)- >driver_data]; +return -ENODEV ; indio_dev->info = &mcp4018_info;
indio_dev->channels=&mcp4018_channel;
--
2.25.1
RE: [PATCH 4/4] iio: potentiometer: mcp4018: Use i2c_get_match_data
Hi Jonathan Cameron,
Thanks for the feedback.
Quoted 14 lines
-----Original Message-----
From: Jonathan Cameron <[email protected]>
Sent: Thursday, July 20, 2023 8:17 PM
To: Biju Das <[email protected]>
Cc: Peter Rosin <[email protected]>; Lars-Peter Clausen <[email protected]>; [email protected]; Geert Uytterhoeven <[email protected]>; Prabhakar Mahadev Lad <[email protected]>; linux- [email protected]
Subject: Re: [PATCH 4/4] iio: potentiometer: mcp4018: Usei2c_get_match_dataOn Sun, 16 Jul 2023 18:10:13 +0000
Biju Das <[email protected]> wrote:
Quoted 6 lines
Quoted 4 lines
Hi All,
I would like to drop this patch, as this driver does not have similar I2C and DT-based matching table.
Could make it so they do ;)
OK, will create separate patch for similar I2C and DT-based matching table and will send V2 for this driver.
Cheers,
Biju
Quoted 48 lines
Quoted 26 lines
Cheers,
BijuQuoted 21 lines
-----Original Message-----
From: Biju Das <[email protected]>
Sent: Sunday, July 16, 2023 6:52 PM
To: Peter Rosin <[email protected]>; Jonathan Cameron <[email protected]>
Cc: Biju Das <[email protected]>; Lars-Peter Clausen <[email protected]>; [email protected]; Geert Uytterhoeven <[email protected]>; Prabhakar Mahadev Lad <prabhakar.mahadev- [email protected]>; [email protected]
Subject: [PATCH 4/4] iio: potentiometer: mcp4018: Usei2c_get_match_dataReplace
of_device_get_match_data()andi2c_match_id()byi2c_get_match_data()as we have similar I2C and DT-based matching table.Signed-off-by Biju Das <[email protected]>--- drivers/iio/potentiometer/mcp4018.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Quoted 6 lines
drivers/iio/potentiometer/mcp4018.c static int mcp4018_probe(struct i2c_client
Quoted 6 lines
drivers/iio/potentiometer/mcp4018.c +0
-0@@ -157,9 +157,9 @@ static int mcp4018_probe(struct i2c_client*client)
Quoted 15 lines
Quoted 14 lines
drivers/iio/potentiometer/mcp4018.c +2
-2i2c_set_clientdata (client, indio_dev); data->client = client; - data->cfg =device_get_match_data (dev); + data->cfg =i2c_get_match_data (dev);if (!data->cfg) - data->cfg = &mcp4018_cfg[i2c_match_id (mcp4018_id, client)- >driver_data]; +return -ENODEV ; indio_dev->info = &mcp4018_info;
indio_dev->channels=&mcp4018_channel;
--
2.25.1