Skip to contentSkip to conversation

pinctrl/actions: Constify static variables

PATCH In review Rikard Falkeborn 3 participants 6 messages Aug 30, 2020 – Sep 12, 2020

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

cover pinctrl/actions: Constify static variables

Constify a couple of static variables which are not modified to allow the compiler to put them in read-only memory. Patch 1/3 is probably the most important one since those structs contain function pointer. The patches are independent, and can be applied in any order. Compile-tested only.

Rikard Falkeborn (3):
pinctrl: actions: pinctrl-owl: Constify owl_pinctrl_ops and
owl_pinmux_ops
pinctrl: actions: pinctrl-s700: Constify s700_padinfo[]
pinctrl: actions: pinctrl-s900: Constify s900_padinfo[]

 drivers/pinctrl/actions/pinctrl-owl.c  | 4 ++--
 drivers/pinctrl/actions/pinctrl-s700.c | 2 +-
 drivers/pinctrl/actions/pinctrl-s900.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.28.0
#1 lore raw

PATCH 1/3 pinctrl: actions: pinctrl-owl: Constify owl_pinctrl_ops and owl_pinmux_ops

The only usage of owl_pinctrl_ops and owl_pinmux_ops is to assign their addresses to the pctlops and the pmxops fields in the pinctrl_desc struct, which are const pointers. Make them const to allow the compiler to put them in read-only memory.

---
 drivers/pinctrl/actions/pinctrl-owl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pinctrl/actions/pinctrl-owl.c +2 -2
index 7efdfb4f3e9b..903a4baf3846 100644
@@ -125,7 +125,7 @@ static void owl_pin_dbg_show(struct pinctrl_dev *pctrldev,
 	seq_printf(s, "%s", dev_name(pctrl->dev));
 }
 
-static struct pinctrl_ops owl_pinctrl_ops = {
+static const struct pinctrl_ops owl_pinctrl_ops = {
 	.get_groups_count = owl_get_groups_count,
 	.get_group_name = owl_get_group_name,
 	.get_group_pins = owl_get_group_pins,
@@ -212,7 +212,7 @@ static int owl_set_mux(struct pinctrl_dev *pctrldev,
 	return 0;
 }
 
-static struct pinmux_ops owl_pinmux_ops = {
+static const struct pinmux_ops owl_pinmux_ops = {
 	.get_functions_count = owl_get_funcs_count,
 	.get_function_name = owl_get_func_name,
 	.get_function_groups = owl_get_func_groups,
Signature · 1 line
2.28.0
#2 lore raw

PATCH 2/3 pinctrl: actions: pinctrl-s700: Constify s700_padinfo[]

In reply to Rikard Falkeborn

The only usage of s700_padinfo[] is to assign it to the padinfo field in the owl_pinctrl_soc_data struct, which is a const pointer. Make it const to allow the compiler to put it in read-only memory.

---
 drivers/pinctrl/actions/pinctrl-s700.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/actions/pinctrl-s700.c +1 -1
index f579a6593f37..fd00940a5799 100644
@@ -1685,7 +1685,7 @@ static PAD_PULLCTL_CONF(I2C2_SDATA, 2, 8, 1);
 static PAD_PULLCTL_CONF(I2C2_SCLK, 2, 7, 1);
 
 /* Pad info table for the pinmux subsystem */
-static struct owl_padinfo s700_padinfo[NUM_PADS] = {
+static const struct owl_padinfo s700_padinfo[NUM_PADS] = {
 	[ETH_TXD0] = PAD_INFO_ST(ETH_TXD0),
 	[ETH_TXD1] = PAD_INFO_ST(ETH_TXD1),
 	[ETH_TXEN] = PAD_INFO_ST(ETH_TXEN),
Signature · 1 line
2.28.0
#3 lore raw

PATCH 3/3 pinctrl: actions: pinctrl-s900: Constify s900_padinfo[]

In reply to Rikard Falkeborn

The only usage of s900_padinfo[] is to assign it to the padinfo field in the owl_pinctrl_soc_data struct, which is a const pointer. Make it const to allow the compiler to put it in read-only memory.

---
 drivers/pinctrl/actions/pinctrl-s900.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/actions/pinctrl-s900.c +1 -1
index 9492b86852e7..811249a8011e 100644
@@ -1556,7 +1556,7 @@ static PAD_ST_CONF(I2S_BCLK0, 1, 1, 1);
 static PAD_ST_CONF(I2S_MCLK0, 1, 0, 1);
 
 /* Pad info table */
-static struct owl_padinfo s900_padinfo[NUM_PADS] = {
+static const struct owl_padinfo s900_padinfo[NUM_PADS] = {
 	[ETH_TXD0] = PAD_INFO_ST(ETH_TXD0),
 	[ETH_TXD1] = PAD_INFO_ST(ETH_TXD1),
 	[ETH_TXEN] = PAD_INFO_ST(ETH_TXEN),
Signature · 1 line
2.28.0
Reviewed-by on the v1 series
#4 lore raw
In reply to Rikard Falkeborn
Quoted 6 lines · Rikard Falkeborn

Constify a couple of static variables which are not modified to allow the compiler to put them in read-only memory. Patch 1/3 is probably the most important one since those structs contain function pointer. The patches are independent, and can be applied in any order. Compile-tested only.

For the series,

Thanks,
Mani

Quoted 14 lines

Rikard Falkeborn (3):
pinctrl: actions: pinctrl-owl: Constify owl_pinctrl_ops and
owl_pinmux_ops
pinctrl: actions: pinctrl-s700: Constify s700_padinfo[]
pinctrl: actions: pinctrl-s900: Constify s900_padinfo[]

 drivers/pinctrl/actions/pinctrl-owl.c  | 4 ++--
 drivers/pinctrl/actions/pinctrl-s700.c | 2 +-
 drivers/pinctrl/actions/pinctrl-s900.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.28.0
#5 lore raw
In reply to Rikard Falkeborn
Quoted 11 lines · Rikard Falkeborn

Constify a couple of static variables which are not modified to allow the compiler to put them in read-only memory. Patch 1/3 is probably the most important one since those structs contain function pointer. The patches are independent, and can be applied in any order. Compile-tested only.

Rikard Falkeborn (3):
pinctrl: actions: pinctrl-owl: Constify owl_pinctrl_ops and
owl_pinmux_ops
pinctrl: actions: pinctrl-s700: Constify s700_padinfo[]
pinctrl: actions: pinctrl-s900: Constify s900_padinfo[]

Patch series applied,
thanks!

Yours,
Linus Walleij