Skip to contentSkip to conversation

media: Constify struct regmap_config

PATCH In review Javier Carrasco 3 participants 5 messages Jul 5, 2024 – Aug 7, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover media: Constify struct regmap_config

This series adds the const modifier to the remaining regmap_config structs under media/ that are effectively used as const (i.e., only read after their declaration), but kept as writtable data.

---
Javier Carrasco (2):
media: i2c: tvp5150: Constify struct regmap_config
media: platform: allegro-dvt: Constify struct regmap_config

 drivers/media/i2c/tvp5150.c                       | 2 +-
 drivers/media/platform/allegro-dvt/allegro-core.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

---
base-commit: 0b58e108042b0ed28a71cd7edf5175999955b233
change-id: 20240705-media-const-regmap_config-958dfd37063c

Best regards,

Signature · 1 line
Javier Carrasco <[email protected]>
#1 lore raw

PATCH 1/2 media: i2c: tvp5150: Constify struct regmap_config

tvp5150_config is not modified and can be declared as const to move its data to a read-only section.

---
 drivers/media/i2c/tvp5150.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/tvp5150.c +1 -1
index 64b91aa3c82a..3205ecd60281 100644
@@ -1812,7 +1812,7 @@ static const struct regmap_access_table tvp5150_readable_table = {
 	.n_yes_ranges = ARRAY_SIZE(tvp5150_readable_ranges),
 };
 
-static struct regmap_config tvp5150_config = {
+static const struct regmap_config tvp5150_config = {
 	.reg_bits = 8,
 	.val_bits = 8,
 	.max_register = 0xff,
Signature · 1 line
2.40.1
#2 lore raw

Re: [PATCH 1/2] media: i2c: tvp5150: Constify struct regmap_config

Quoted 2 lines · Javier Carrasco

tvp5150_config is not modified and can be declared as const to move its data to a read-only section.

This is a duplicate of:

https://patchwork.linuxtv.org/project/linux-media/patch/119b3ec62e6305c83ffadc7f40cbda9fc3d5be11.1714893773.git.christophe.jaillet@wanadoo.fr/

I'll take that one since that also constifies i2c_vbi_ram_value.

Regards,

Hans

Quoted 20 lines
---
 drivers/media/i2c/tvp5150.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/tvp5150.c +1 -1
index 64b91aa3c82a..3205ecd60281 100644
@@ -1812,7 +1812,7 @@ static const struct regmap_access_table tvp5150_readable_table = {
 	.n_yes_ranges = ARRAY_SIZE(tvp5150_readable_ranges),
 };
 
-static struct regmap_config tvp5150_config = {
+static const struct regmap_config tvp5150_config = {
 	.reg_bits = 8,
 	.val_bits = 8,
 	.max_register = 0xff,
#3 lore raw

PATCH 2/2 media: platform: allegro-dvt: Constify struct regmap_config

In reply to Javier Carrasco

allegro_regmap_config and allegro_sram_config are not modified and can be declared as const to move their data to a read-only section.

---
 drivers/media/platform/allegro-dvt/allegro-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/allegro-dvt/allegro-core.c +2 -2
index da61f9beb6b4..1a19fef62e81 100644
@@ -179,7 +179,7 @@ struct allegro_dev {
 	struct list_head channels;
 };
 
-static struct regmap_config allegro_regmap_config = {
+static const struct regmap_config allegro_regmap_config = {
 	.name = "regmap",
 	.reg_bits = 32,
 	.val_bits = 32,
@@ -188,7 +188,7 @@ static struct regmap_config allegro_regmap_config = {
 	.cache_type = REGCACHE_NONE,
 };
 
-static struct regmap_config allegro_sram_config = {
+static const struct regmap_config allegro_sram_config = {
 	.name = "sram",
 	.reg_bits = 32,
 	.val_bits = 32,
Signature · 1 line
2.40.1
maintainer
#4 lore raw

Re: [PATCH 2/2] media: platform: allegro-dvt: Constify struct regmap_config

Quoted 2 lines · Javier Carrasco

allegro_regmap_config and allegro_sram_config are not modified and can be declared as const to move their data to a read-only section.

Christophe sent a similar patch [0] before, which already has my Reviewed-by.

Michael

[0[ https://lore.kernel.org/linux-media/01b9b16b2f86f4d16d9871a29dcda9245512a1f7.1714894086.git.christophe.jaillet@wanadoo.fr/

Quoted 33 lines
---
 drivers/media/platform/allegro-dvt/allegro-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/allegro-dvt/allegro-core.c +2 -2
index da61f9beb6b4..1a19fef62e81 100644
@@ -179,7 +179,7 @@ struct allegro_dev {
 	struct list_head channels;
 };
 
-static struct regmap_config allegro_regmap_config = {
+static const struct regmap_config allegro_regmap_config = {
 	.name = "regmap",
 	.reg_bits = 32,
 	.val_bits = 32,
@@ -188,7 +188,7 @@ static struct regmap_config allegro_regmap_config = {
 	.cache_type = REGCACHE_NONE,
 };
 
-static struct regmap_config allegro_sram_config = {
+static const struct regmap_config allegro_sram_config = {
 	.name = "sram",
 	.reg_bits = 32,
 	.val_bits = 32,
Signature · 2 lines
-- 
2.40.1