mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] Remove regmap_config struct from allocated data
@ 2026-08-04 11:46 Link Mauve
  2026-08-04 11:46 ` [PATCH 1/3] media: rtl2832: make regmap_config static const Link Mauve
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Link Mauve @ 2026-08-04 11:46 UTC (permalink / raw)
  To: linux-media
  Cc: Link Mauve, Sakari Ailus, Mauro Carvalho Chehab, Hans Verkuil,
	Bradford Love, Kees Cook, Uwe Kleine-König (The Capable Hub),
	Deepanshu Kartikey, linux-kernel

This is a follow-up for eeafd9e12144fb6249e1510f9db8a4aaf8155a0a, after
which I found a bunch of regmap_config structs defined inside of other
structs, even though they either completely static (in which case I put
them in .rodata), or needed only a single dynamic argument (in which
case I put them on the stack of the function using it).

I found only these three instances in the media subsystem, which removes
192 bytes from the allocation of each of these driver instances.

Link Mauve (3):
  media: rtl2832: make regmap_config static const
  media: m88ds3103: make regmap_config static const
  media: ts2020: put regmap_config on the stack

 drivers/media/dvb-frontends/m88ds3103.c      |  9 +++++----
 drivers/media/dvb-frontends/m88ds3103_priv.h |  1 -
 drivers/media/dvb-frontends/rtl2832.c        | 18 ++++++++++--------
 drivers/media/dvb-frontends/rtl2832_priv.h   |  1 -
 drivers/media/dvb-frontends/ts2020.c         | 15 ++++++++-------
 5 files changed, 23 insertions(+), 21 deletions(-)


base-commit: 9a4cdc958dd79fc6c3b20b51a10debec6ca09fec
-- 
2.55.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] media: rtl2832: make regmap_config static const
  2026-08-04 11:46 [PATCH 0/3] Remove regmap_config struct from allocated data Link Mauve
@ 2026-08-04 11:46 ` Link Mauve
  2026-08-04 11:46 ` [PATCH 2/3] media: m88ds3103: " Link Mauve
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Link Mauve @ 2026-08-04 11:46 UTC (permalink / raw)
  To: linux-media
  Cc: Link Mauve, Sakari Ailus, Mauro Carvalho Chehab, Hans Verkuil,
	Bradford Love, Kees Cook, Uwe Kleine-König (The Capable Hub),
	Deepanshu Kartikey, linux-kernel

This struct was previously carried over in the rtl2832_dev struct, even
though it was used only once at probe-time, using purely static data.

This reduces the size of the rtl2832_dev struct by 192 B, by putting it
in the .rodata section instead.

Signed-off-by: Link Mauve <linkmauve@linkmauve.fr>
---
 drivers/media/dvb-frontends/rtl2832.c      | 18 ++++++++++--------
 drivers/media/dvb-frontends/rtl2832_priv.h |  1 -
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/media/dvb-frontends/rtl2832.c b/drivers/media/dvb-frontends/rtl2832.c
index b31cdb44b383..6f359036862a 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -1039,6 +1039,15 @@ static int rtl2832_probe(struct i2c_client *client)
 			.range_max        = 5 * 0x100,
 		},
 	};
+	static const struct regmap_config regmap_config = {
+		.reg_bits	= 8,
+		.val_bits	= 8,
+		.volatile_reg	= rtl2832_volatile_reg,
+		.max_register	= 5 * 0x100,
+		.ranges		= regmap_range_cfg,
+		.num_ranges	= ARRAY_SIZE(regmap_range_cfg),
+		.cache_type	= REGCACHE_NONE,
+	};
 
 	dev_dbg(&client->dev, "\n");
 
@@ -1056,14 +1065,7 @@ static int rtl2832_probe(struct i2c_client *client)
 	dev->sleeping = true;
 	INIT_DELAYED_WORK(&dev->i2c_gate_work, rtl2832_i2c_gate_work);
 	/* create regmap */
-	dev->regmap_config.reg_bits =  8;
-	dev->regmap_config.val_bits =  8;
-	dev->regmap_config.volatile_reg = rtl2832_volatile_reg;
-	dev->regmap_config.max_register = 5 * 0x100;
-	dev->regmap_config.ranges = regmap_range_cfg;
-	dev->regmap_config.num_ranges = ARRAY_SIZE(regmap_range_cfg);
-	dev->regmap_config.cache_type = REGCACHE_NONE;
-	dev->regmap = regmap_init_i2c(client, &dev->regmap_config);
+	dev->regmap = regmap_init_i2c(client, &regmap_config);
 	if (IS_ERR(dev->regmap)) {
 		ret = PTR_ERR(dev->regmap);
 		goto err_kfree;
diff --git a/drivers/media/dvb-frontends/rtl2832_priv.h b/drivers/media/dvb-frontends/rtl2832_priv.h
index f11ba038d5f0..8cf3266e14b0 100644
--- a/drivers/media/dvb-frontends/rtl2832_priv.h
+++ b/drivers/media/dvb-frontends/rtl2832_priv.h
@@ -20,7 +20,6 @@
 struct rtl2832_dev {
 	struct rtl2832_platform_data *pdata;
 	struct i2c_client *client;
-	struct regmap_config regmap_config;
 	struct regmap *regmap;
 	struct i2c_mux_core *muxc;
 	struct dvb_frontend fe;
-- 
2.55.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/3] media: m88ds3103: make regmap_config static const
  2026-08-04 11:46 [PATCH 0/3] Remove regmap_config struct from allocated data Link Mauve
  2026-08-04 11:46 ` [PATCH 1/3] media: rtl2832: make regmap_config static const Link Mauve
@ 2026-08-04 11:46 ` Link Mauve
  2026-08-04 11:46 ` [PATCH 3/3] media: ts2020: put regmap_config on the stack Link Mauve
  2026-09-20 16:31 ` [PATCH 0/3] Remove regmap_config struct from allocated data Link Mauve
  3 siblings, 0 replies; 6+ messages in thread
From: Link Mauve @ 2026-08-04 11:46 UTC (permalink / raw)
  To: linux-media
  Cc: Link Mauve, Sakari Ailus, Mauro Carvalho Chehab, Hans Verkuil,
	Bradford Love, Kees Cook, Uwe Kleine-König (The Capable Hub),
	Deepanshu Kartikey, linux-kernel

This struct was previously carried over in the m88ds3103_dev struct,
even though it was used only once at probe-time.

This reduces the size of the m88ds3103_dev struct by 192 B, by putting
it in the .rodata section instead.

This regmap_config previously set lock_arg, but without either lock or
unlock callbacks this argument was unused.

Signed-off-by: Link Mauve <linkmauve@linkmauve.fr>
---
 drivers/media/dvb-frontends/m88ds3103.c      | 9 +++++----
 drivers/media/dvb-frontends/m88ds3103_priv.h | 1 -
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c
index d79b88848a8c..d3a69a8ec3f6 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -2045,6 +2045,10 @@ static int m88ds3103_probe(struct i2c_client *client)
 	struct m88ds3103_platform_data *pdata = client->dev.platform_data;
 	int ret;
 	unsigned int utmp;
+	static const struct regmap_config regmap_config = {
+		.reg_bits = 8,
+		.val_bits = 8,
+	};
 
 	dev = kzalloc_obj(*dev);
 	if (!dev) {
@@ -2067,10 +2071,7 @@ static int m88ds3103_probe(struct i2c_client *client)
 	dev->config.lnb_en_pol = pdata->lnb_en_pol;
 	dev->cfg = &dev->config;
 	/* create regmap */
-	dev->regmap_config.reg_bits = 8;
-	dev->regmap_config.val_bits = 8;
-	dev->regmap_config.lock_arg = dev;
-	dev->regmap = devm_regmap_init_i2c(client, &dev->regmap_config);
+	dev->regmap = devm_regmap_init_i2c(client, &regmap_config);
 	if (IS_ERR(dev->regmap)) {
 		ret = PTR_ERR(dev->regmap);
 		goto err_kfree;
diff --git a/drivers/media/dvb-frontends/m88ds3103_priv.h b/drivers/media/dvb-frontends/m88ds3103_priv.h
index d7d16e7904da..a29ba664377b 100644
--- a/drivers/media/dvb-frontends/m88ds3103_priv.h
+++ b/drivers/media/dvb-frontends/m88ds3103_priv.h
@@ -33,7 +33,6 @@
 struct m88ds3103_dev {
 	struct i2c_client *client;
 	struct i2c_client *dt_client;
-	struct regmap_config regmap_config;
 	struct regmap *regmap;
 	struct m88ds3103_config config;
 	const struct m88ds3103_config *cfg;
-- 
2.55.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/3] media: ts2020: put regmap_config on the stack
  2026-08-04 11:46 [PATCH 0/3] Remove regmap_config struct from allocated data Link Mauve
  2026-08-04 11:46 ` [PATCH 1/3] media: rtl2832: make regmap_config static const Link Mauve
  2026-08-04 11:46 ` [PATCH 2/3] media: m88ds3103: " Link Mauve
@ 2026-08-04 11:46 ` Link Mauve
  2026-09-20 19:46   ` Uwe Kleine-König
  2026-09-20 16:31 ` [PATCH 0/3] Remove regmap_config struct from allocated data Link Mauve
  3 siblings, 1 reply; 6+ messages in thread
From: Link Mauve @ 2026-08-04 11:46 UTC (permalink / raw)
  To: linux-media
  Cc: Link Mauve, Sakari Ailus, Mauro Carvalho Chehab, Hans Verkuil,
	Bradford Love, Kees Cook, Uwe Kleine-König (The Capable Hub),
	Deepanshu Kartikey, linux-kernel

This struct was previously carried over in the ts2020_priv struct, even
though it was used only once at probe-time.

This reduces the size of the ts2020_priv struct by 192 B, at the cost of
moving it onto the stack of ts2020_probe().

Signed-off-by: Link Mauve <linkmauve@linkmauve.fr>
---
 drivers/media/dvb-frontends/ts2020.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

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;
+	dev->regmap = regmap_init_i2c(client, &regmap_config);
 	if (IS_ERR(dev->regmap)) {
 		ret = PTR_ERR(dev->regmap);
 		goto err_kfree;
-- 
2.55.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] Remove regmap_config struct from allocated data
  2026-08-04 11:46 [PATCH 0/3] Remove regmap_config struct from allocated data Link Mauve
                   ` (2 preceding siblings ...)
  2026-08-04 11:46 ` [PATCH 3/3] media: ts2020: put regmap_config on the stack Link Mauve
@ 2026-09-20 16:31 ` Link Mauve
  3 siblings, 0 replies; 6+ messages in thread
From: Link Mauve @ 2026-09-20 16:31 UTC (permalink / raw)
  To: Link Mauve
  Cc: linux-media, Sakari Ailus, Mauro Carvalho Chehab, Hans Verkuil,
	Bradford Love, Kees Cook, Uwe Kleine-König (The Capable Hub),
	Deepanshu Kartikey, linux-kernel

Hi,

Is there any interest in this series?  I know it doesn’t improve much,
but it should be easy enough to review.

On Tue, Aug 04, 2026 at 01:46:20PM +0200, Link Mauve wrote:
> This is a follow-up for eeafd9e12144fb6249e1510f9db8a4aaf8155a0a, after
> which I found a bunch of regmap_config structs defined inside of other
> structs, even though they either completely static (in which case I put
> them in .rodata), or needed only a single dynamic argument (in which
> case I put them on the stack of the function using it).
> 
> I found only these three instances in the media subsystem, which removes
> 192 bytes from the allocation of each of these driver instances.
> 
> Link Mauve (3):
>   media: rtl2832: make regmap_config static const
>   media: m88ds3103: make regmap_config static const
>   media: ts2020: put regmap_config on the stack
> 
>  drivers/media/dvb-frontends/m88ds3103.c      |  9 +++++----
>  drivers/media/dvb-frontends/m88ds3103_priv.h |  1 -
>  drivers/media/dvb-frontends/rtl2832.c        | 18 ++++++++++--------
>  drivers/media/dvb-frontends/rtl2832_priv.h   |  1 -
>  drivers/media/dvb-frontends/ts2020.c         | 15 ++++++++-------
>  5 files changed, 23 insertions(+), 21 deletions(-)
> 
> 
> base-commit: 9a4cdc958dd79fc6c3b20b51a10debec6ca09fec
> -- 
> 2.55.0
> 

-- 
Link Mauve

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] media: ts2020: put regmap_config on the stack
  2026-08-04 11:46 ` [PATCH 3/3] media: ts2020: put regmap_config on the stack Link Mauve
@ 2026-09-20 19:46   ` Uwe Kleine-König
  0 siblings, 0 replies; 6+ messages in thread
From: Uwe Kleine-König @ 2026-09-20 19:46 UTC (permalink / raw)
  To: Link Mauve
  Cc: linux-media, Sakari Ailus, Mauro Carvalho Chehab, Hans Verkuil,
	Bradford Love, Kees Cook, Deepanshu Kartikey, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1802 bytes --]

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);

With or without that approach:

Acked-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-09-20 19:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-04 11:46 [PATCH 0/3] Remove regmap_config struct from allocated data Link Mauve
2026-08-04 11:46 ` [PATCH 1/3] media: rtl2832: make regmap_config static const Link Mauve
2026-08-04 11:46 ` [PATCH 2/3] media: m88ds3103: " Link Mauve
2026-08-04 11:46 ` [PATCH 3/3] media: ts2020: put regmap_config on the stack Link Mauve
2026-09-20 19:46   ` Uwe Kleine-König
2026-09-20 16:31 ` [PATCH 0/3] Remove regmap_config struct from allocated data Link Mauve

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®