Re: [PATCH 3/3] media: ts2020: put regmap_config on the stack

From: Sakari Ailus

Date: Tue Sep 22 2026 - 04:17:12 EST


On Mon, Sep 21, 2026 at 08:45:49PM +0200, Uwe Kleine-König wrote:
> Hello,
>
> On Mon, Sep 21, 2026 at 07:00:55PM +0200, Link Mauve wrote:
> > On Sun, Sep 20, 2026 at 09:46:42PM +0200, Uwe Kleine-König wrote:
> > > If desired you can keep all the assignments here using:
> > >
> > > regmap_config = (typeof(regmap_config)){
> > > .reg_bits = 8,
> > > .val_bits = 8,
> > > .lock = ts2020_regmap_lock,
> > > .unlock = ts2020_regmap_unlock,
> > > .lock_arg = dev,
> > > };
> > >
> > > > + dev->regmap = regmap_init_i2c(client, &regmap_config);
> >
> > I think I still prefer my approach, there is very little usage of the
> > typeof() pattern in the kernel, the only benefit would be to keep
> > lock_arg in the same location as the rest of the initial values.
>
> If it's just the typeof you don't like, you can also use:
>
> regmap_config = (struct regmap_config){
> .reg_bits = 8,
> ...
> };
>

It's also possible to declare it here and so avoid the cast. The current
patch seems fine though, albeit the variable declarations don't remotely
look like a reverse Christmas tree (not that they did before it).

Reviewed-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>

--
Sakari Ailus