Re: [PATCH] i2c: mux: ltc4306: Simplify probe()

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

 



Hi Biju,

On Sun, Jul 16, 2023 at 8:51 PM Biju Das <biju.das.jz@xxxxxxxxxxxxxx> wrote:
> The ltc4306_id[].driver_data could store a pointer to the chips,
> like for DT-based matching, making I2C and DT-based matching
> more similar.
>
> After that, we can 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@xxxxxxxxxxxxxx>

Thanks for your patch!

Reviewed-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>

A suggestion for improvement (which can be a separate patch, as it would
touch ltc4306_of_match[] too) below.

> --- a/drivers/i2c/muxes/i2c-mux-ltc4306.c
> +++ b/drivers/i2c/muxes/i2c-mux-ltc4306.c
> @@ -192,8 +192,8 @@ static int ltc4306_deselect_mux(struct i2c_mux_core *muxc, u32 chan)
>  }
>
>  static const struct i2c_device_id ltc4306_id[] = {
> -       { "ltc4305", ltc_4305 },
> -       { "ltc4306", ltc_4306 },
> +       { "ltc4305", .driver_data = (kernel_ulong_t)&chips[ltc_4305] },
> +       { "ltc4306", .driver_data = (kernel_ulong_t)&chips[ltc_4306] },

As after this the ltc_type enum values are used only for hardcoded
indexing inside the chips array, you can get rid of them by splitting
the array in individual variables, shortening the lines above
(and in ltc4306_of_match[] below) in the process.

>         { }
>  };
>  MODULE_DEVICE_TABLE(i2c, ltc4306_id);

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 Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux