Message ID | 20230716175218.130557-2-biju.das.jz@bp.renesas.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | Use i2c_get_match_data() | expand |
On Sun, Jul 16, 2023 at 7:52 PM Biju Das <biju.das.jz@bp.renesas.com> wrote: > 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. > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Gr{oetje,eeting}s, Geert
On Sun, Jul 16, 2023 at 7:52 PM Biju Das <biju.das.jz@bp.renesas.com> wrote: > > 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. > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> > --- > drivers/iio/accel/adxl355_i2c.c | 15 +++------------ > 1 file changed, 3 insertions(+), 12 deletions(-) > > diff --git a/drivers/iio/accel/adxl355_i2c.c b/drivers/iio/accel/adxl355_i2c.c > index d5beea61479d..32398cde9608 100644 > --- a/drivers/iio/accel/adxl355_i2c.c > +++ b/drivers/iio/accel/adxl355_i2c.c > @@ -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)) { > -- > 2.25.1 > Reviewed-by: Puranjay Mohan <puranjay12@gmail.com>
On Sun, 16 Jul 2023 18:52:15 +0100 Biju Das <biju.das.jz@bp.renesas.com> wrote: > 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. > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Applied to the togreg branch of iio.git, initially pushed out as testing for 0-day to take a look at. Thanks, Jonathan > --- > drivers/iio/accel/adxl355_i2c.c | 15 +++------------ > 1 file changed, 3 insertions(+), 12 deletions(-) > > diff --git a/drivers/iio/accel/adxl355_i2c.c b/drivers/iio/accel/adxl355_i2c.c > index d5beea61479d..32398cde9608 100644 > --- a/drivers/iio/accel/adxl355_i2c.c > +++ b/drivers/iio/accel/adxl355_i2c.c > @@ -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)) {
diff --git a/drivers/iio/accel/adxl355_i2c.c b/drivers/iio/accel/adxl355_i2c.c index d5beea61479d..32398cde9608 100644 --- a/drivers/iio/accel/adxl355_i2c.c +++ b/drivers/iio/accel/adxl355_i2c.c @@ -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)) {
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. Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> --- drivers/iio/accel/adxl355_i2c.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)