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

From: Link Mauve

Date: Mon Sep 21 2026 - 13:24:35 EST


On Sun, Sep 20, 2026 at 09:46:42PM +0200, Uwe Kleine-König wrote:
> Hello,
>
> On Tue, Aug 04, 2026 at 01:46:23PM +0200, Link Mauve wrote:
> > diff --git a/drivers/media/dvb-frontends/ts2020.c b/drivers/media/dvb-frontends/ts2020.c
> > index 8775083f4dd6..27f096ce522e 100644
> > --- a/drivers/media/dvb-frontends/ts2020.c
> > +++ b/drivers/media/dvb-frontends/ts2020.c
> > @@ -18,7 +18,6 @@
> > struct ts2020_priv {
> > struct i2c_client *client;
> > struct mutex regmap_mutex;
> > - struct regmap_config regmap_config;
> > struct regmap *regmap;
> > struct dvb_frontend *fe;
> > struct delayed_work stat_work;
> > @@ -559,6 +558,12 @@ static int ts2020_probe(struct i2c_client *client)
> > u8 u8tmp;
> > unsigned int utmp;
> > char *chip_str;
> > + struct regmap_config regmap_config = {
> > + .reg_bits = 8,
> > + .val_bits = 8,
> > + .lock = ts2020_regmap_lock,
> > + .unlock = ts2020_regmap_unlock,
> > + };
> >
> > if (!pdata) {
> > dev_err(&client->dev, "platform data is mandatory\n");
> > @@ -574,12 +579,8 @@ static int ts2020_probe(struct i2c_client *client)
> >
> > /* create regmap */
> > mutex_init(&dev->regmap_mutex);
> > - dev->regmap_config.reg_bits = 8;
> > - dev->regmap_config.val_bits = 8;
> > - dev->regmap_config.lock = ts2020_regmap_lock;
> > - dev->regmap_config.unlock = ts2020_regmap_unlock;
> > - dev->regmap_config.lock_arg = dev;
> > - dev->regmap = regmap_init_i2c(client, &dev->regmap_config);
> > + regmap_config.lock_arg = dev;
>
> 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.

>
> With or without that approach:
>
> Acked-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxx>

Thanks!

>
> Best regards
> Uwe

--
Link Mauve