Skip to contentSkip to conversation

net: constify struct regmap_bus/regmap_config

PATCH Applied Javier Carrasco 5 participants 10 messages Jul 3, 2024 – Jul 6, 2024

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

cover net: constify struct regmap_bus/regmap_config

This series adds the const modifier to the remaining regmap_bus and regmap_config structs within the net subsystem that are effectively used as const (i.e., only read after their declaration), but kept as writtable data.

---
Javier Carrasco (4):
net: dsa: qca8k: constify struct regmap_config
net: ti: icss-iep: constify struct regmap_config
net: encx24j600: constify struct regmap_bus/regmap_config
net: dsa: ar9331: constify struct regmap_bus

 drivers/net/dsa/qca/ar9331.c                       | 2 +-
 drivers/net/dsa/qca/qca8k-8xxx.c                   | 2 +-
 drivers/net/ethernet/microchip/encx24j600-regmap.c | 6 +++---
 drivers/net/ethernet/ti/icssg/icss_iep.c           | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

---
base-commit: 0b58e108042b0ed28a71cd7edf5175999955b233
change-id: 20240703-net-const-regmap-1c1e64e2c30a

Best regards,

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

PATCH 1/4 net: dsa: qca8k: constify struct regmap_config

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

---
 drivers/net/dsa/qca/qca8k-8xxx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/qca/qca8k-8xxx.c +1 -1
index b3c27cf538e8..f8d8c70642c4 100644
@@ -565,7 +565,7 @@ qca8k_regmap_update_bits(void *ctx, uint32_t reg, uint32_t mask, uint32_t write_
 	return qca8k_regmap_update_bits_mii(priv, reg, mask, write_val);
 }
 
-static struct regmap_config qca8k_regmap_config = {
+static const struct regmap_config qca8k_regmap_config = {
 	.reg_bits = 16,
 	.val_bits = 32,
 	.reg_stride = 4,
Signature · 1 line
2.40.1
#3 lore raw

PATCH 2/4 net: ti: icss-iep: constify struct regmap_config

In reply to Javier Carrasco

am654_icss_iep_regmap_config is only assigned to a pointer that passes the data as read-only.

Add the const modifier to the struct and pointer to move the data to a read-only section.

---
 drivers/net/ethernet/ti/icssg/icss_iep.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/ti/icssg/icss_iep.c +2 -2
index 003668dee738..75c294ce6fb6 100644
@@ -95,7 +95,7 @@ enum {
  * @flags: Flags to represent IEP properties
  */
 struct icss_iep_plat_data {
-	struct regmap_config *config;
+	const struct regmap_config *config;
 	u32 reg_offs[ICSS_IEP_MAX_REGS];
 	u32 flags;
 };
@@ -952,7 +952,7 @@ static int icss_iep_regmap_read(void *context, unsigned int reg,
 	return 0;
 }
 
-static struct regmap_config am654_icss_iep_regmap_config = {
+static const struct regmap_config am654_icss_iep_regmap_config = {
 	.name = "icss iep",
 	.reg_stride = 1,
 	.reg_write = icss_iep_regmap_write,
Signature · 1 line
2.40.1
reviewer Reviewed-by on v1 2/4
#5 lore raw

Re: [PATCH 2/4] net: ti: icss-iep: constify struct regmap_config

In reply to Javier Carrasco
Quoted 7 lines · Javier Carrasco

am654_icss_iep_regmap_config is only assigned to a pointer that passes the data as read-only.

Add the const modifier to the struct and pointer to move the data to a read-only section.

Signature · 2 lines
Thanks and Regards,
Danish
#6 lore raw

PATCH 3/4 net: encx24j600: constify struct regmap_bus/regmap_config

In reply to Javier Carrasco

regmap_encx24j600, phycfg and phymap_encx24j600 are not modified and can be declared as const to move their data to a read-only section.

---
 drivers/net/ethernet/microchip/encx24j600-regmap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/microchip/encx24j600-regmap.c +3 -3
index 3885d6fbace1..26b00e66d912 100644
@@ -474,13 +474,13 @@ static struct regmap_config regcfg = {
 	.unlock = regmap_unlock_mutex,
 };
 
-static struct regmap_bus regmap_encx24j600 = {
+static const struct regmap_bus regmap_encx24j600 = {
 	.write = regmap_encx24j600_write,
 	.read = regmap_encx24j600_read,
 	.reg_update_bits = regmap_encx24j600_reg_update_bits,
 };
 
-static struct regmap_config phycfg = {
+static const struct regmap_config phycfg = {
 	.name = "phy",
 	.reg_bits = 8,
 	.val_bits = 16,
@@ -492,7 +492,7 @@ static struct regmap_config phycfg = {
 	.volatile_reg = encx24j600_phymap_volatile,
 };
 
-static struct regmap_bus phymap_encx24j600 = {
+static const struct regmap_bus phymap_encx24j600 = {
 	.reg_write = regmap_encx24j600_phy_reg_write,
 	.reg_read = regmap_encx24j600_phy_reg_read,
 };
Signature · 1 line
2.40.1
#7 lore raw

PATCH 4/4 net: dsa: ar9331: constify struct regmap_bus

In reply to Javier Carrasco

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

---
 drivers/net/dsa/qca/ar9331.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/qca/ar9331.c +1 -1
index 968cb81088bf..e9f2c67bc15f 100644
@@ -1021,7 +1021,7 @@ static const struct regmap_config ar9331_mdio_regmap_config = {
 	.cache_type = REGCACHE_MAPLE,
 };
 
-static struct regmap_bus ar9331_sw_bus = {
+static const struct regmap_bus ar9331_sw_bus = {
 	.reg_format_endian_default = REGMAP_ENDIAN_NATIVE,
 	.val_format_endian_default = REGMAP_ENDIAN_NATIVE,
 	.read = ar9331_mdio_read,
Signature · 1 line
2.40.1
#9 lore raw
In reply to Javier Carrasco
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Wed, 03 Jul 2024 23:46:32 +0200 you wrote:

This series adds the const modifier to the remaining regmap_bus and regmap_config structs within the net subsystem that are effectively used as const (i.e., only read after their declaration), but kept as writtable data.

[...]

Here is the summary with links:
- [1/4] net: dsa: qca8k: constify struct regmap_config

    https://git.kernel.org/netdev/net-next/c/8dfbb068a4e1
  - [2/4] net: ti: icss-iep: constify struct regmap_config
    https://git.kernel.org/netdev/net-next/c/7f805f6396d4
  - [3/4] net: encx24j600: constify struct regmap_bus/regmap_config
    https://git.kernel.org/netdev/net-next/c/9969163c4472
  - [4/4] net: dsa: ar9331: constify struct regmap_bus
    https://git.kernel.org/netdev/net-next/c/3b05c7995cae

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html