Re: [PATCH RFC/RFT] iio: imu: lsm6dsx: Use i2c_get_match_data()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Biju,

On Sat, Aug 12, 2023 at 10:32 AM Biju Das <biju.das.jz@xxxxxxxxxxxxxx> wrote:
> Replace device_get_match_data() and id lookup for retrieving match data
> by i2c_get_match_data() by converting enum->pointer for data in the
> match table.
>
> Signed-off-by: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>

Thanks for your patch!

> index 911444ec57c0..a2def435c9c2 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
> @@ -16,6 +16,30 @@
>
>  #include "st_lsm6dsx.h"
>
> +static const int lsm6ds3 = ST_LSM6DS3_ID;
> +static const int lsm6ds3h = ST_LSM6DS3H_ID;

As these are single values, not structures with multiple members,
I see not much value in adding all these variables, which increases
kernel size...

> @@ -23,12 +47,10 @@ static const struct regmap_config st_lsm6dsx_i2c_regmap_config = {
>
>  static int st_lsm6dsx_i2c_probe(struct i2c_client *client)
>  {
> -       int hw_id;
> +       const int *hw_id;
>         struct regmap *regmap;
>
> -       hw_id = (kernel_ulong_t)device_get_match_data(&client->dev);
> -       if (!hw_id)
> -               hw_id = i2c_client_get_device_id(client)->driver_data;
> +       hw_id = i2c_get_match_data(client);
>         if (!hw_id)
>                 return -EINVAL;

So just

    -        hw_id = (kernel_ulong_t)device_get_match_data(&client->dev);
    -       if (!hw_id)
    -               hw_id = i2c_client_get_device_id(client)->driver_data;
    +        hw_id = (kernel_ulong_t)i2c_get_match_data(client);

and be done with it?

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

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



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux