pinctrl: meson: Constify some structure
Subsystems (4)
cover pinctrl: meson: Constify some structure
These 3 patches constify some structures in order to move some data to a read-only section, so increase overall security.
It is splitted in 3 to ease review.
Patch 1: struct meson_pmx_group and meson_pmx_func patch 2: struct meson_bank
patch 3: struct meson_pmx_bank
All patches are only compile tested.
In order to compile them, I update Kconfig to add some "| COMPILE_TEST" on depends line.
Should it be useful, I can send a patch to add it, but I don't think it would be that useful.
On a x86_64, with allmodconfig:
Before:
======
text data bss dec hex filename
10818 11696 0 22514 57f2 drivers/pinctrl/meson/pinctrl-amlogic-c3.o 17198 17680 0 34878 883e drivers/pinctrl/meson/pinctrl-amlogic-t7.o 14161 11200 0 25361 6311 drivers/pinctrl/meson/pinctrl-meson8b.o 17348 12512 0 29860 74a4 drivers/pinctrl/meson/pinctrl-meson8.o 3070 324 0 3394 d42 drivers/pinctrl/meson/pinctrl-meson8-pmx.o 9317 9648 0 18965 4a15 drivers/pinctrl/meson/pinctrl-meson-a1.o 12115 11664 0 23779 5ce3 drivers/pinctrl/meson/pinctrl-meson-axg.o 2470 120 0 2590 a1e drivers/pinctrl/meson/pinctrl-meson-axg-pmx.o 15125 15224 0 30349 768d drivers/pinctrl/meson/pinctrl-meson-g12a.o 13800 10160 0 23960 5d98 drivers/pinctrl/meson/pinctrl-meson-gxbb.o 13040 9648 0 22688 58a0 drivers/pinctrl/meson/pinctrl-meson-gxl.o 20507 1132 48 21687 54b7 drivers/pinctrl/meson/pinctrl-meson.o 12212 12880 0 25092 6204 drivers/pinctrl/meson/pinctrl-meson-s4.o
After:
=====
text data bss dec hex filename
22114 384 0 22498 57e2 drivers/pinctrl/meson/pinctrl-amlogic-c3.o 34510 384 0 34894 884e drivers/pinctrl/meson/pinctrl-amlogic-t7.o 24945 440 0 25385 6329 drivers/pinctrl/meson/pinctrl-meson8b.o 29412 440 0 29852 749c drivers/pinctrl/meson/pinctrl-meson8.o 3070 324 0 3394 d42 drivers/pinctrl/meson/pinctrl-meson8-pmx.o 18597 384 0 18981 4a25 drivers/pinctrl/meson/pinctrl-meson-a1.o 23315 496 0 23811 5d03 drivers/pinctrl/meson/pinctrl-meson-axg.o 2470 120 0 2590 a1e drivers/pinctrl/meson/pinctrl-meson-axg-pmx.o 29877 504 0 30381 76ad drivers/pinctrl/meson/pinctrl-meson-g12a.o 23496 456 0 23952 5d90 drivers/pinctrl/meson/pinctrl-meson-gxbb.o 22224 456 0 22680 5898 drivers/pinctrl/meson/pinctrl-meson-gxl.o 20507 1132 48 21687 54b7 drivers/pinctrl/meson/pinctrl-meson.o 24692 384 0 25076 61f4 drivers/pinctrl/meson/pinctrl-meson-s4.o
Christophe JAILLET (3):
pinctrl: meson: Constify struct meson_pmx_group and meson_pmx_func
pinctrl: meson: Constify struct meson_bank
pinctrl: meson: Constify struct meson_pmx_bank
drivers/pinctrl/meson/pinctrl-amlogic-c3.c | 8 +++--- drivers/pinctrl/meson/pinctrl-amlogic-t7.c | 8 +++--- drivers/pinctrl/meson/pinctrl-meson-a1.c | 8 +++--- drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c | 12 ++++----- drivers/pinctrl/meson/pinctrl-meson-axg-pmx.h | 2 +- drivers/pinctrl/meson/pinctrl-meson-axg.c | 16 ++++++------ drivers/pinctrl/meson/pinctrl-meson-g12a.c | 16 ++++++------ drivers/pinctrl/meson/pinctrl-meson-gxbb.c | 12 ++++----- drivers/pinctrl/meson/pinctrl-meson-gxl.c | 12 ++++----- drivers/pinctrl/meson/pinctrl-meson-s4.c | 8 +++--- drivers/pinctrl/meson/pinctrl-meson.c | 25 ++++++++++--------- drivers/pinctrl/meson/pinctrl-meson.h | 6 ++--- drivers/pinctrl/meson/pinctrl-meson8-pmx.c | 6 ++--- drivers/pinctrl/meson/pinctrl-meson8.c | 12 ++++----- drivers/pinctrl/meson/pinctrl-meson8b.c | 12 ++++----- 15 files changed, 82 insertions(+), 81 deletions(-)
Signature · 1 line
2.45.2
PATCH 1/3 pinctrl: meson: Constify struct meson_pmx_group and meson_pmx_func
'struct meson_pmx_group' and 'struct meson_pmx_func' are not modified in these drivers.
Constifying these structures moves some data to a read-only section, so increase overall security.
On a x86_64, with allmodconfig:
Before:
======
text data bss dec hex filename
10818 11696 0 22514 57f2 drivers/pinctrl/meson/pinctrl-amlogic-c3.o 17198 17680 0 34878 883e drivers/pinctrl/meson/pinctrl-amlogic-t7.o 14161 11200 0 25361 6311 drivers/pinctrl/meson/pinctrl-meson8b.o 17348 12512 0 29860 74a4 drivers/pinctrl/meson/pinctrl-meson8.o 3070 324 0 3394 d42 drivers/pinctrl/meson/pinctrl-meson8-pmx.o 9317 9648 0 18965 4a15 drivers/pinctrl/meson/pinctrl-meson-a1.o 12115 11664 0 23779 5ce3 drivers/pinctrl/meson/pinctrl-meson-axg.o 2470 120 0 2590 a1e drivers/pinctrl/meson/pinctrl-meson-axg-pmx.o 15125 15224 0 30349 768d drivers/pinctrl/meson/pinctrl-meson-g12a.o 13800 10160 0 23960 5d98 drivers/pinctrl/meson/pinctrl-meson-gxbb.o 13040 9648 0 22688 58a0 drivers/pinctrl/meson/pinctrl-meson-gxl.o 20507 1132 48 21687 54b7 drivers/pinctrl/meson/pinctrl-meson.o 12212 12880 0 25092 6204 drivers/pinctrl/meson/pinctrl-meson-s4.o
After:
=====
text data bss dec hex filename 21410 1096 0 22506 57ea drivers/pinctrl/meson/pinctrl-amlogic-c3.o 33358 1552 0 34910 885e drivers/pinctrl/meson/pinctrl-amlogic-t7.o 24049 1336 0 25385 6329 drivers/pinctrl/meson/pinctrl-meson8b.o 28804 1048 0 29852 749c drivers/pinctrl/meson/pinctrl-meson8.o 3070 324 0 3394 d42 drivers/pinctrl/meson/pinctrl-meson8-pmx.o 18085 888 0 18973 4a1d drivers/pinctrl/meson/pinctrl-meson-a1.o 22675 1112 0 23787 5ceb drivers/pinctrl/meson/pinctrl-meson-axg.o 2470 120 0 2590 a1e drivers/pinctrl/meson/pinctrl-meson-axg-pmx.o 29045 1320 0 30365 769d drivers/pinctrl/meson/pinctrl-meson-g12a.o 22824 1136 0 23960 5d98 drivers/pinctrl/meson/pinctrl-meson-gxbb.o 21616 1064 0 22680 5898 drivers/pinctrl/meson/pinctrl-meson-gxl.o 20507 1132 48 21687 54b7 drivers/pinctrl/meson/pinctrl-meson.o 23924 1168 0 25092 6204 drivers/pinctrl/meson/pinctrl-meson-s4.o
---
Compile tested-only.
--- drivers/pinctrl/meson/pinctrl-amlogic-c3.c | 4 ++-- drivers/pinctrl/meson/pinctrl-amlogic-t7.c | 4 ++-- drivers/pinctrl/meson/pinctrl-meson-a1.c | 4 ++-- drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c | 4 ++-- drivers/pinctrl/meson/pinctrl-meson-axg.c | 8 ++++---- drivers/pinctrl/meson/pinctrl-meson-g12a.c | 8 ++++---- drivers/pinctrl/meson/pinctrl-meson-gxbb.c | 8 ++++---- drivers/pinctrl/meson/pinctrl-meson-gxl.c | 8 ++++---- drivers/pinctrl/meson/pinctrl-meson-s4.c | 4 ++-- drivers/pinctrl/meson/pinctrl-meson.c | 2 +- drivers/pinctrl/meson/pinctrl-meson.h | 4 ++-- drivers/pinctrl/meson/pinctrl-meson8-pmx.c | 6 +++--- drivers/pinctrl/meson/pinctrl-meson8.c | 8 ++++---- drivers/pinctrl/meson/pinctrl-meson8b.c | 8 ++++---- 14 files changed, 40 insertions(+), 40 deletions(-)
drivers/pinctrl/meson/pinctrl-amlogic-c3.c +2 -2
@@ -375,7 +375,7 @@ static const unsigned int spi_a_mosi_a_pins[] = { GPIOA_3 };static const unsigned int gen_clk_a4_pins[] = {GPIOA_4 };static const unsigned int clk12_24_a_pins[] = {GPIOA_5 }; -static struct meson_pmx_group c3_periphs_groups[] = { +static const struct meson_pmx_group c3_periphs_groups[] = {GPIO_GROUP (GPIOE_0 ),GPIO_GROUP (GPIOE_1 ),GPIO_GROUP (GPIOE_2 ),
@@ -987,7 +987,7 @@ static const char * const lcd_groups[] = { "lcd_clk_a", "lcd_clk_x", "lcd_hs", "lcd_vs", }; -static struct meson_pmx_func c3_periphs_functions[] = { +static const struct meson_pmx_func c3_periphs_functions[] = {FUNCTION (gpio_periphs),FUNCTION (uart_a),FUNCTION (uart_b),
drivers/pinctrl/meson/pinctrl-amlogic-t7.c +2 -2
@@ -535,7 +535,7 @@ static const unsigned int i2c0_sck_h_pins[] = { GPIOH_7 };/* Bank H func3 */ static const unsigned int pcieck_reqn_h_pins[] = {GPIOH_2 }; -static struct meson_pmx_group t7_periphs_groups[] = { +static const struct meson_pmx_group t7_periphs_groups[] = {GPIO_GROUP (GPIOB_0 ),GPIO_GROUP (GPIOB_1 ),GPIO_GROUP (GPIOB_2 ),
@@ -1443,7 +1443,7 @@ static const char * const mic_mute_groups[] = { "mic_mute_key", "mic_mute_led", }; -static struct meson_pmx_func t7_periphs_functions[] = { +static const struct meson_pmx_func t7_periphs_functions[] = {FUNCTION (gpio_periphs),FUNCTION (emmc),FUNCTION (nor),
drivers/pinctrl/meson/pinctrl-meson-a1.c +2 -2
@@ -339,7 +339,7 @@ static const unsigned int tst_out11_pins[] = { GPIOA_11 };static const unsigned int mute_key_pins[] = {GPIOA_4 };static const unsigned int mute_en_pins[] = {GPIOA_5 }; -static struct meson_pmx_group meson_a1_periphs_groups[] = { +static const struct meson_pmx_group meson_a1_periphs_groups[] = {GPIO_GROUP (GPIOP_0 ),GPIO_GROUP (GPIOP_1 ),GPIO_GROUP (GPIOP_2 ),
@@ -832,7 +832,7 @@ static const char * const mute_groups[] = { "mute_key", "mute_en", }; -static struct meson_pmx_func meson_a1_periphs_functions[] = { +static const struct meson_pmx_func meson_a1_periphs_functions[] = {FUNCTION (gpio_periphs),FUNCTION (psram),FUNCTION (pwm_a),
drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c +2 -2
@@ -82,8 +82,8 @@ static int meson_axg_pmx_set_mux(struct pinctrl_dev *pcdev,int i;int ret;struct meson_pinctrl *pc =pinctrl_dev_get_drvdata (pcdev); -struct meson_pmx_func *func = &pc->data->funcs[func_num]; -struct meson_pmx_group *group = &pc->data->groups[group_num]; +const struct meson_pmx_func *func = &pc->data->funcs[func_num]; +const struct meson_pmx_group *group = &pc->data->groups[group_num];struct meson_pmx_axg_data *pmx_data = (struct meson_pmx_axg_data *)group->data;
drivers/pinctrl/meson/pinctrl-meson-axg.c +4 -4
@@ -352,7 +352,7 @@ static const unsigned int tdmb_dout2_pins[] = {GPIOA_12};static const unsigned int tdmb_din3_pins[] = {GPIOA_13 };static const unsigned int tdmb_dout3_pins[] = {GPIOA_13 }; -static struct meson_pmx_group meson_axg_periphs_groups[] = { +static const struct meson_pmx_group meson_axg_periphs_groups[] = {GPIO_GROUP (GPIOZ_0 ),GPIO_GROUP (GPIOZ_1 ),GPIO_GROUP (GPIOZ_2 ),
@@ -675,7 +675,7 @@ static const unsigned int jtag_ao_tms_pins[] = {GPIOAO_7};/* gen_clk */ static const unsigned int gen_clk_ee_pins[] = {GPIOAO_13 }; -static struct meson_pmx_group meson_axg_aobus_groups[] = { +static const struct meson_pmx_group meson_axg_aobus_groups[] = {GPIO_GROUP (GPIOAO_0 ),GPIO_GROUP (GPIOAO_1 ),GPIO_GROUP (GPIOAO_2 ),
@@ -955,7 +955,7 @@ static const char * const gen_clk_ee_groups[] = { "gen_clk_ee", }; -static struct meson_pmx_func meson_axg_periphs_functions[] = { +static const struct meson_pmx_func meson_axg_periphs_functions[] = {FUNCTION (gpio_periphs),FUNCTION (emmc),FUNCTION (nor),
@@ -987,7 +987,7 @@ static struct meson_pmx_func meson_axg_periphs_functions[] = { FUNCTION(tdmc), }; -static struct meson_pmx_func meson_axg_aobus_functions[] = { +static const struct meson_pmx_func meson_axg_aobus_functions[] = {FUNCTION (gpio_aobus),FUNCTION (uart_ao_a),FUNCTION (uart_ao_b),
drivers/pinctrl/meson/pinctrl-meson-g12a.c +4 -4
@@ -436,7 +436,7 @@ static const unsigned int tdm_c_dout1_z_pins[] = { GPIOZ_3 };static const unsigned int tdm_c_dout2_z_pins[] = {GPIOZ_4 };static const unsigned int tdm_c_dout3_z_pins[] = {GPIOZ_5 }; -static struct meson_pmx_group meson_g12a_periphs_groups[] = { +static const struct meson_pmx_group meson_g12a_periphs_groups[] = {GPIO_GROUP (GPIOZ_0 ),GPIO_GROUP (GPIOZ_1 ),GPIO_GROUP (GPIOZ_2 ),
@@ -860,7 +860,7 @@ static const unsigned int tdm_ao_b_dout2_pins[] = { GPIOAO_6 };/* mclk0_ao */ static const unsigned int mclk0_ao_pins[] = {GPIOAO_9 }; -static struct meson_pmx_group meson_g12a_aobus_groups[] = { +static const struct meson_pmx_group meson_g12a_aobus_groups[] = {GPIO_GROUP (GPIOAO_0 ),GPIO_GROUP (GPIOAO_1 ),GPIO_GROUP (GPIOAO_2 ),
@@ -1253,7 +1253,7 @@ static const char * const mclk0_ao_groups[] = { "mclk0_ao", }; -static struct meson_pmx_func meson_g12a_periphs_functions[] = { +static const struct meson_pmx_func meson_g12a_periphs_functions[] = {FUNCTION (gpio_periphs),FUNCTION (emmc),FUNCTION (nor),
@@ -1295,7 +1295,7 @@ static struct meson_pmx_func meson_g12a_periphs_functions[] = { FUNCTION(tdm_c), }; -static struct meson_pmx_func meson_g12a_aobus_functions[] = { +static const struct meson_pmx_func meson_g12a_aobus_functions[] = {FUNCTION (gpio_aobus),FUNCTION (uart_ao_a),FUNCTION (uart_ao_b),
drivers/pinctrl/meson/pinctrl-meson-gxbb.c +4 -4
@@ -307,7 +307,7 @@ static const unsigned int spdif_out_ao_13_pins[] = { GPIOAO_13 };static const unsigned int ao_cec_pins[] = {GPIOAO_12 };static const unsigned int ee_cec_pins[] = {GPIOAO_12 }; -static struct meson_pmx_group meson_gxbb_periphs_groups[] = { +static const struct meson_pmx_group meson_gxbb_periphs_groups[] = {GPIO_GROUP (GPIOZ_0 ),GPIO_GROUP (GPIOZ_1 ),GPIO_GROUP (GPIOZ_2 ),
@@ -541,7 +541,7 @@ static struct meson_pmx_group meson_gxbb_periphs_groups[] = { GROUP(sdcard_clk, 2, 11), }; -static struct meson_pmx_group meson_gxbb_aobus_groups[] = { +static const struct meson_pmx_group meson_gxbb_aobus_groups[] = {GPIO_GROUP (GPIOAO_0 ),GPIO_GROUP (GPIOAO_1 ),GPIO_GROUP (GPIOAO_2 ),
@@ -798,7 +798,7 @@ static const char * const cec_ao_groups[] = { "ao_cec", "ee_cec", }; -static struct meson_pmx_func meson_gxbb_periphs_functions[] = { +static const struct meson_pmx_func meson_gxbb_periphs_functions[] = {FUNCTION (gpio_periphs),FUNCTION (emmc),FUNCTION (nor),
@@ -829,7 +829,7 @@ static struct meson_pmx_func meson_gxbb_periphs_functions[] = { FUNCTION(tsin_b), }; -static struct meson_pmx_func meson_gxbb_aobus_functions[] = { +static const struct meson_pmx_func meson_gxbb_aobus_functions[] = {FUNCTION (gpio_aobus),FUNCTION (uart_ao),FUNCTION (uart_ao_b),
drivers/pinctrl/meson/pinctrl-meson-gxl.c +4 -4
@@ -301,7 +301,7 @@ static const unsigned int spdif_out_ao_9_pins[] = { GPIOAO_9 };static const unsigned int ao_cec_pins[] = {GPIOAO_8 };static const unsigned int ee_cec_pins[] = {GPIOAO_8 }; -static struct meson_pmx_group meson_gxl_periphs_groups[] = { +static const struct meson_pmx_group meson_gxl_periphs_groups[] = {GPIO_GROUP (GPIOZ_0 ),GPIO_GROUP (GPIOZ_1 ),GPIO_GROUP (GPIOZ_2 ),
@@ -527,7 +527,7 @@ static struct meson_pmx_group meson_gxl_periphs_groups[] = { GROUP(pwm_f_clk, 8, 30), }; -static struct meson_pmx_group meson_gxl_aobus_groups[] = { +static const struct meson_pmx_group meson_gxl_aobus_groups[] = {GPIO_GROUP (GPIOAO_0 ),GPIO_GROUP (GPIOAO_1 ),GPIO_GROUP (GPIOAO_2 ),
@@ -763,7 +763,7 @@ static const char * const cec_ao_groups[] = { "ao_cec", "ee_cec", }; -static struct meson_pmx_func meson_gxl_periphs_functions[] = { +static const struct meson_pmx_func meson_gxl_periphs_functions[] = {FUNCTION (gpio_periphs),FUNCTION (emmc),FUNCTION (nor),
@@ -793,7 +793,7 @@ static struct meson_pmx_func meson_gxl_periphs_functions[] = { FUNCTION(tsin_b), }; -static struct meson_pmx_func meson_gxl_aobus_functions[] = { +static const struct meson_pmx_func meson_gxl_aobus_functions[] = {FUNCTION (gpio_aobus),FUNCTION (uart_ao),FUNCTION (uart_ao_b),
drivers/pinctrl/meson/pinctrl-meson-s4.c +2 -2
@@ -411,7 +411,7 @@ static const unsigned int s2_demod_gpio0_pins[] = { GPIOZ_12 };static const unsigned int gen_clk_z9_pins[] = {GPIOZ_9 };static const unsigned int gen_clk_z12_pins[] = {GPIOZ_12 }; -static struct meson_pmx_group meson_s4_periphs_groups[] = { +static const struct meson_pmx_group meson_s4_periphs_groups[] = {GPIO_GROUP (GPIOE_0 ),GPIO_GROUP (GPIOE_1 ),
@@ -1100,7 +1100,7 @@ static const char * const s2_demod_groups[] = { "s2_demod_gpio3", "s2_demod_gpio2", "s2_demod_gpio1", "s2_demod_gpio0", }; -static struct meson_pmx_func meson_s4_periphs_functions[] = { +static const struct meson_pmx_func meson_s4_periphs_functions[] = {FUNCTION (gpio_periphs),FUNCTION (i2c0),FUNCTION (i2c1),
drivers/pinctrl/meson/pinctrl-meson.c +1 -1
@@ -528,7 +528,7 @@ static int meson_pinconf_group_set(struct pinctrl_dev *pcdev, unsigned long *configs, unsigned num_configs) {struct meson_pinctrl *pc =pinctrl_dev_get_drvdata (pcdev); -struct meson_pmx_group *group = &pc->data->groups[num_group]; +const struct meson_pmx_group *group = &pc->data->groups[num_group];int i;dev_dbg (pc->dev,"set pinconf for group %s\n" , group->name);
drivers/pinctrl/meson/pinctrl-meson.h +2 -2
@@ -110,8 +110,8 @@ struct meson_bank {struct meson_pinctrl_data {const char *name;const struct pinctrl_pin_desc *pins; -struct meson_pmx_group *groups; -struct meson_pmx_func *funcs; +const struct meson_pmx_group *groups; +const struct meson_pmx_func *funcs;unsigned int num_pins;unsigned int num_groups;unsigned int num_funcs;
drivers/pinctrl/meson/pinctrl-meson8-pmx.c +3 -3
@@ -32,7 +32,7 @@static void meson8_pmx_disable_other_groups (struct meson_pinctrl *pc,unsigned int pin,int sel_group) { -struct meson_pmx_group *group; +const struct meson_pmx_group *group;struct meson8_pmx_data *pmx_data;int i, j;
@@ -57,8 +57,8 @@ static int meson8_pmx_set_mux(struct pinctrl_dev *pcdev, unsigned func_num, unsigned group_num) {struct meson_pinctrl *pc =pinctrl_dev_get_drvdata (pcdev); -struct meson_pmx_func *func = &pc->data->funcs[func_num]; -struct meson_pmx_group *group = &pc->data->groups[group_num]; +const struct meson_pmx_func *func = &pc->data->funcs[func_num]; +const struct meson_pmx_group *group = &pc->data->groups[group_num];struct meson8_pmx_data *pmx_data = (struct meson8_pmx_data *)group->data;int i, ret =0 ;
drivers/pinctrl/meson/pinctrl-meson8.c +4 -4
@@ -405,7 +405,7 @@ static const unsigned int i2s_out_ch01_ao_pins[] = { GPIOAO_11 };static const unsigned int hdmi_cec_ao_pins[] = {GPIOAO_12 }; -static struct meson_pmx_group meson8_cbus_groups[] = { +static const struct meson_pmx_group meson8_cbus_groups[] = {GPIO_GROUP (GPIOX_0 ),GPIO_GROUP (GPIOX_1 ),GPIO_GROUP (GPIOX_2 ),
@@ -745,7 +745,7 @@ static struct meson_pmx_group meson8_cbus_groups[] = { GROUP(sdxc_cmd_b, 2, 4), }; -static struct meson_pmx_group meson8_aobus_groups[] = { +static const struct meson_pmx_group meson8_aobus_groups[] = {GPIO_GROUP (GPIOAO_0 ),GPIO_GROUP (GPIOAO_1 ),GPIO_GROUP (GPIOAO_2 ),
@@ -1015,7 +1015,7 @@ static const char * const hdmi_cec_ao_groups[] = {"hdmi_cec_ao" }; -static struct meson_pmx_func meson8_cbus_functions[] = { +static const struct meson_pmx_func meson8_cbus_functions[] = {FUNCTION (gpio_periphs),FUNCTION (sd_a),FUNCTION (sdxc_a),
@@ -1051,7 +1051,7 @@ static struct meson_pmx_func meson8_cbus_functions[] = { FUNCTION(spdif), }; -static struct meson_pmx_func meson8_aobus_functions[] = { +static const struct meson_pmx_func meson8_aobus_functions[] = {FUNCTION (gpio_aobus),FUNCTION (uart_ao),FUNCTION (remote),
drivers/pinctrl/meson/pinctrl-meson8b.c +4 -4
@@ -349,7 +349,7 @@ static const unsigned int eth_ref_clk_pins[] = { DIF_3_N };static const unsigned int eth_mdc_pins[] = {DIF_4_P };static const unsigned int eth_mdio_en_pins[] = {DIF_4_N }; -static struct meson_pmx_group meson8b_cbus_groups[] = { +static const struct meson_pmx_group meson8b_cbus_groups[] = {GPIO_GROUP (GPIOX_0 ),GPIO_GROUP (GPIOX_1 ),GPIO_GROUP (GPIOX_2 ),
@@ -603,7 +603,7 @@ static struct meson_pmx_group meson8b_cbus_groups[] = { GROUP(eth_rxd2, 7, 23), }; -static struct meson_pmx_group meson8b_aobus_groups[] = { +static const struct meson_pmx_group meson8b_aobus_groups[] = {GPIO_GROUP (GPIOAO_0 ),GPIO_GROUP (GPIOAO_1 ),GPIO_GROUP (GPIOAO_2 ),
@@ -869,7 +869,7 @@ static const char * const tsin_b_groups[] = {"tsin_d0_b" ,"tsin_clk_b" ,"tsin_sop_b" ,"tsin_d_valid_b" }; -static struct meson_pmx_func meson8b_cbus_functions[] = { +static const struct meson_pmx_func meson8b_cbus_functions[] = {FUNCTION (gpio_periphs),FUNCTION (sd_a), FUNCTION(sdxc_a),
@@ -903,7 +903,7 @@ static struct meson_pmx_func meson8b_cbus_functions[] = { FUNCTION(clk_24m), }; -static struct meson_pmx_func meson8b_aobus_functions[] = { +static const struct meson_pmx_func meson8b_aobus_functions[] = {FUNCTION (gpio_aobus),FUNCTION (uart_ao),FUNCTION (uart_ao_b),
Signature · 1 line
2.45.2
PATCH 2/3 pinctrl: meson: Constify struct meson_bank
In reply to Christophe JAILLET'struct meson_bank' are not modified in these drivers.
Constifying these structures moves some data to a read-only section, so increase overall security.
On a x86_64, with allmodconfig:
Before:
======
text data bss dec hex filename 21410 1096 0 22506 57ea drivers/pinctrl/meson/pinctrl-amlogic-c3.o 33358 1552 0 34910 885e drivers/pinctrl/meson/pinctrl-amlogic-t7.o 24049 1336 0 25385 6329 drivers/pinctrl/meson/pinctrl-meson8b.o 28804 1048 0 29852 749c drivers/pinctrl/meson/pinctrl-meson8.o 3070 324 0 3394 d42 drivers/pinctrl/meson/pinctrl-meson8-pmx.o 18085 888 0 18973 4a1d drivers/pinctrl/meson/pinctrl-meson-a1.o 22675 1112 0 23787 5ceb drivers/pinctrl/meson/pinctrl-meson-axg.o 2470 120 0 2590 a1e drivers/pinctrl/meson/pinctrl-meson-axg-pmx.o 29045 1320 0 30365 769d drivers/pinctrl/meson/pinctrl-meson-g12a.o 22824 1136 0 23960 5d98 drivers/pinctrl/meson/pinctrl-meson-gxbb.o 21616 1064 0 22680 5898 drivers/pinctrl/meson/pinctrl-meson-gxl.o 20507 1132 48 21687 54b7 drivers/pinctrl/meson/pinctrl-meson.o 23924 1168 0 25092 6204 drivers/pinctrl/meson/pinctrl-meson-s4.o
After:
=====
21922 568 0 22490 57da drivers/pinctrl/meson/pinctrl-amlogic-c3.o 34222 688 0 34910 885e drivers/pinctrl/meson/pinctrl-amlogic-t7.o 24945 440 0 25385 6329 drivers/pinctrl/meson/pinctrl-meson8b.o 29412 440 0 29852 749c drivers/pinctrl/meson/pinctrl-meson8.o 3070 324 0 3394 d42 drivers/pinctrl/meson/pinctrl-meson8-pmx.o 18469 520 0 18989 4a2d drivers/pinctrl/meson/pinctrl-meson-a1.o 23155 648 0 23803 5cfb drivers/pinctrl/meson/pinctrl-meson-axg.o 2470 120 0 2590 a1e drivers/pinctrl/meson/pinctrl-meson-axg-pmx.o 29653 712 0 30365 769d drivers/pinctrl/meson/pinctrl-meson-g12a.o 23496 456 0 23952 5d90 drivers/pinctrl/meson/pinctrl-meson-gxbb.o 22224 456 0 22680 5898 drivers/pinctrl/meson/pinctrl-meson-gxl.o 20507 1132 48 21687 54b7 drivers/pinctrl/meson/pinctrl-meson.o 24500 592 0 25092 6204 drivers/pinctrl/meson/pinctrl-meson-s4.o
---
Compile tested-only.
--- drivers/pinctrl/meson/pinctrl-amlogic-c3.c | 2 +- drivers/pinctrl/meson/pinctrl-amlogic-t7.c | 2 +- drivers/pinctrl/meson/pinctrl-meson-a1.c | 2 +- drivers/pinctrl/meson/pinctrl-meson-axg.c | 4 ++-- drivers/pinctrl/meson/pinctrl-meson-g12a.c | 4 ++-- drivers/pinctrl/meson/pinctrl-meson-gxbb.c | 4 ++-- drivers/pinctrl/meson/pinctrl-meson-gxl.c | 4 ++-- drivers/pinctrl/meson/pinctrl-meson-s4.c | 2 +- drivers/pinctrl/meson/pinctrl-meson.c | 23 +++++++++++----------- drivers/pinctrl/meson/pinctrl-meson.h | 2 +- drivers/pinctrl/meson/pinctrl-meson8.c | 4 ++-- drivers/pinctrl/meson/pinctrl-meson8b.c | 4 ++-- 12 files changed, 29 insertions(+), 28 deletions(-)
drivers/pinctrl/meson/pinctrl-amlogic-c3.c +1 -1
@@ -1036,7 +1036,7 @@ static const struct meson_pmx_func c3_periphs_functions[] = { FUNCTION(lcd), }; -static struct meson_bank c3_periphs_banks[] = { +static const struct meson_bank c3_periphs_banks[] = {/* name first last irq pullen pull dir out in ds */ BANK_DS ("X" ,GPIOX_0 ,GPIOX_13 ,40 ,53 ,0x03 ,0 ,0x04 ,0 ,0x02 ,0 ,0x01 ,0 ,0x00 ,0 ,0x07 ,0 ),
drivers/pinctrl/meson/pinctrl-amlogic-t7.c +1 -1
@@ -1524,7 +1524,7 @@ static const struct meson_pmx_func t7_periphs_functions[] = { FUNCTION(mic_mute), }; -static struct meson_bank t7_periphs_banks[] = { +static const struct meson_bank t7_periphs_banks[] = {/* name first last irq pullen pull dir out in ds */ BANK_DS ("D" ,GPIOD_0 ,GPIOD_12 ,57 ,69 ,0x03 ,0 ,0x04 ,0 ,0x02 ,0 ,0x01 ,0 ,0x00 ,0 ,0x07 ,0 ),
drivers/pinctrl/meson/pinctrl-meson-a1.c +1 -1
@@ -875,7 +875,7 @@ static const struct meson_pmx_func meson_a1_periphs_functions[] = { FUNCTION(mute), }; -static struct meson_bank meson_a1_periphs_banks[] = { +static const struct meson_bank meson_a1_periphs_banks[] = {/* name first last irq pullen pull dir out in ds*/ BANK_DS ("P" ,GPIOP_0 ,GPIOP_12 ,0 ,12 ,0x3 ,0 ,0x4 ,0 ,0x2 ,0 ,0x1 ,0 ,0x0 ,0 ,0x5 ,0 ),
drivers/pinctrl/meson/pinctrl-meson-axg.c +2 -2
@@ -1003,7 +1003,7 @@ static const struct meson_pmx_func meson_axg_aobus_functions[] = { FUNCTION(gen_clk_ee), }; -static struct meson_bank meson_axg_periphs_banks[] = { +static const struct meson_bank meson_axg_periphs_banks[] = {/* name first last irq pullen pull dir out in */ BANK ("Z" ,GPIOZ_0 ,GPIOZ_10 ,14 ,24 ,3 ,0 ,3 ,0 ,9 ,0 ,10 ,0 ,11 ,0 ),BANK ("BOOT" ,BOOT_0 ,BOOT_14 ,25 ,39 ,4 ,0 ,4 ,0 ,12 ,0 ,13 ,0 ,14 ,0 ),
@@ -1012,7 +1012,7 @@ static struct meson_bank meson_axg_periphs_banks[] = { BANK("Y", GPIOY_0, GPIOY_15, 84, 99, 1, 0, 1, 0, 3, 0, 4, 0, 5, 0), }; -static struct meson_bank meson_axg_aobus_banks[] = { +static const struct meson_bank meson_axg_aobus_banks[] = {/* name first last irq pullen pull dir out in */ BANK ("AO" ,GPIOAO_0 ,GPIOAO_13 ,0 ,13 ,0 ,16 ,0 ,0 ,0 ,0 ,0 ,16 ,1 ,0 ), };
drivers/pinctrl/meson/pinctrl-meson-g12a.c +2 -2
@@ -1317,7 +1317,7 @@ static const struct meson_pmx_func meson_g12a_aobus_functions[] = { FUNCTION(mclk0_ao), }; -static struct meson_bank meson_g12a_periphs_banks[] = { +static const struct meson_bank meson_g12a_periphs_banks[] = {/* name first last irq pullen pull dir out in ds */ BANK_DS ("Z" ,GPIOZ_0 ,GPIOZ_15 ,IRQID_GPIOZ_0 ,IRQID_GPIOZ_15 ,4 ,0 ,4 ,0 ,12 ,0 ,13 ,0 ,14 ,0 ,5 ,0 ),
@@ -1333,7 +1333,7 @@ static struct meson_bank meson_g12a_periphs_banks[] = { 2, 0, 2, 0, 6, 0, 7, 0, 8, 0, 2, 0), }; -static struct meson_bank meson_g12a_aobus_banks[] = { +static const struct meson_bank meson_g12a_aobus_banks[] = {/* name first last irq pullen pull dir out in ds */ BANK_DS ("AO" ,GPIOAO_0 ,GPIOAO_11 ,IRQID_GPIOAO_0 ,IRQID_GPIOAO_11 ,3 ,0 ,2 ,0 ,0 ,0 ,4 ,0 ,1 ,0 ,0 ,0 ),
drivers/pinctrl/meson/pinctrl-meson-gxbb.c +2 -2
@@ -845,7 +845,7 @@ static const struct meson_pmx_func meson_gxbb_aobus_functions[] = { FUNCTION(cec_ao), }; -static struct meson_bank meson_gxbb_periphs_banks[] = { +static const struct meson_bank meson_gxbb_periphs_banks[] = {/* name first last irq pullen pull dir out in */ BANK ("X" ,GPIOX_0 ,GPIOX_22 ,106 ,128 ,4 ,0 ,4 ,0 ,12 ,0 ,13 ,0 ,14 ,0 ),BANK ("Y" ,GPIOY_0 ,GPIOY_16 ,89 ,105 ,1 ,0 ,1 ,0 ,3 ,0 ,4 ,0 ,5 ,0 ),
@@ -857,7 +857,7 @@ static struct meson_bank meson_gxbb_periphs_banks[] = { BANK("CLK", GPIOCLK_0, GPIOCLK_3, 129, 132, 3, 28, 3, 28, 9, 28, 10, 28, 11, 28), }; -static struct meson_bank meson_gxbb_aobus_banks[] = { +static const struct meson_bank meson_gxbb_aobus_banks[] = {/* name first last irq pullen pull dir out in */ BANK ("AO" ,GPIOAO_0 ,GPIOAO_13 ,0 ,13 ,0 ,16 ,0 ,0 ,0 ,0 ,0 ,16 ,1 ,0 ), };
drivers/pinctrl/meson/pinctrl-meson-gxl.c +2 -2
@@ -807,7 +807,7 @@ static const struct meson_pmx_func meson_gxl_aobus_functions[] = { FUNCTION(cec_ao), }; -static struct meson_bank meson_gxl_periphs_banks[] = { +static const struct meson_bank meson_gxl_periphs_banks[] = {/* name first last irq pullen pull dir out in */ BANK ("X" ,GPIOX_0 ,GPIOX_18 ,89 ,107 ,4 ,0 ,4 ,0 ,12 ,0 ,13 ,0 ,14 ,0 ),BANK ("DV" ,GPIODV_0 ,GPIODV_29 ,83 ,88 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,0 ,2 ,0 ),
@@ -818,7 +818,7 @@ static struct meson_bank meson_gxl_periphs_banks[] = { BANK("CLK", GPIOCLK_0, GPIOCLK_1, 108, 109, 3, 28, 3, 28, 9, 28, 10, 28, 11, 28), }; -static struct meson_bank meson_gxl_aobus_banks[] = { +static const struct meson_bank meson_gxl_aobus_banks[] = {/* name first last irq pullen pull dir out in */ BANK ("AO" ,GPIOAO_0 ,GPIOAO_9 ,0 ,9 ,0 ,16 ,0 ,0 ,0 ,0 ,0 ,16 ,1 ,0 ), };
drivers/pinctrl/meson/pinctrl-meson-s4.c +1 -1
@@ -1160,7 +1160,7 @@ static const struct meson_pmx_func meson_s4_periphs_functions[] = { FUNCTION(s2_demod), }; -static struct meson_bank meson_s4_periphs_banks[] = { +static const struct meson_bank meson_s4_periphs_banks[] = {/* name first last irq pullen pull dir out in */ BANK_DS ("B" ,GPIOB_0 ,GPIOB_13 ,0 ,13 ,0x63 ,0 ,0x64 ,0 ,0x62 ,0 ,0x61 ,0 ,0x60 ,0 ,0x67 ,0 ),
drivers/pinctrl/meson/pinctrl-meson.c +12 -11
@@ -70,7 +70,7 @@ static const unsigned int meson_bit_strides[] = {* Return: 0 on success, a negative value on error */ static int meson_get_bank (struct meson_pinctrl *pc,unsigned int pin, -struct meson_bank **bank) +const struct meson_bank **bank) {int i;
@@ -94,11 +94,12 @@ static int meson_get_bank(struct meson_pinctrl *pc, unsigned int pin,* @reg: the computed register offset * @bit: the computed bit */ -static void meson_calc_reg_and_bit (struct meson_bank *bank,unsigned int pin, +static void meson_calc_reg_and_bit (const struct meson_bank *bank, +unsigned int pin,enum meson_reg_type reg_type,unsigned int *reg,unsigned int *bit) { -struct meson_reg_desc *desc = &bank->regs[reg_type]; +const struct meson_reg_desc *desc = &bank->regs[reg_type]; *bit = (desc->bit + pin - bank->first) * meson_bit_strides[reg_type]; *reg = (desc->reg + (*bit /32 )) *4 ;
@@ -181,7 +182,7 @@ static int meson_pinconf_set_gpio_bit(struct meson_pinctrl *pc, unsigned int reg_type, bool arg) { -struct meson_bank *bank; +const struct meson_bank *bank;unsigned int reg, bit;int ret;
@@ -198,7 +199,7 @@ static int meson_pinconf_get_gpio_bit(struct meson_pinctrl *pc, unsigned int pin, unsigned int reg_type) { -struct meson_bank *bank; +const struct meson_bank *bank;unsigned int reg, bit, val;int ret;
@@ -261,7 +262,7 @@ static int meson_pinconf_set_output_drive(struct meson_pinctrl *pc,static int meson_pinconf_disable_bias (struct meson_pinctrl *pc,unsigned int pin) { -struct meson_bank *bank; +const struct meson_bank *bank;unsigned int reg, bit =0 ;int ret;
@@ -280,7 +281,7 @@ static int meson_pinconf_disable_bias(struct meson_pinctrl *pc,static int meson_pinconf_enable_bias (struct meson_pinctrl *pc,unsigned int pin,bool pull_up) { -struct meson_bank *bank; +const struct meson_bank *bank;unsigned int reg, bit, val =0 ;int ret;
@@ -308,7 +309,7 @@ static int meson_pinconf_set_drive_strength(struct meson_pinctrl *pc, unsigned int pin, u16 drive_strength_ua) { -struct meson_bank *bank; +const struct meson_bank *bank;unsigned int reg, bit, ds_val;int ret;
@@ -399,7 +400,7 @@ static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin,static int meson_pinconf_get_pull (struct meson_pinctrl *pc,unsigned int pin) { -struct meson_bank *bank; +const struct meson_bank *bank;unsigned int reg, bit, val;int ret, conf;
@@ -435,7 +436,7 @@ static int meson_pinconf_get_drive_strength(struct meson_pinctrl *pc,unsigned int pin, u16 *drive_strength_ua) { - struct meson_bank *bank; + const struct meson_bank *bank;unsigned int reg, bit;unsigned int val;int ret;
@@ -587,8 +588,8 @@ static void meson_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)static int meson_gpio_get (struct gpio_chip *chip,unsigned gpio) {struct meson_pinctrl *pc =gpiochip_get_data (chip); +const struct meson_bank *bank;unsigned int reg, bit, val; -struct meson_bank *bank;int ret; ret =meson_get_bank (pc, gpio, &bank);
drivers/pinctrl/meson/pinctrl-meson.h +1 -1
@@ -115,7 +115,7 @@ struct meson_pinctrl_data {unsigned int num_pins;unsigned int num_groups;unsigned int num_funcs; -struct meson_bank *banks; +const struct meson_bank *banks;unsigned int num_banks;const struct pinmux_ops *pmx_ops;void *pmx_data;
drivers/pinctrl/meson/pinctrl-meson8.c +2 -2
@@ -1063,7 +1063,7 @@ static const struct meson_pmx_func meson8_aobus_functions[] = { FUNCTION(hdmi_cec_ao), }; -static struct meson_bank meson8_cbus_banks[] = { +static const struct meson_bank meson8_cbus_banks[] = {/* name first last irq pullen pull dir out in */ BANK ("X" ,GPIOX_0 ,GPIOX_21 ,112 ,133 ,4 ,0 ,4 ,0 ,0 ,0 ,1 ,0 ,2 ,0 ),BANK ("Y" ,GPIOY_0 ,GPIOY_16 ,95 ,111 ,3 ,0 ,3 ,0 ,3 ,0 ,4 ,0 ,5 ,0 ),
@@ -1074,7 +1074,7 @@ static struct meson_bank meson8_cbus_banks[] = { BANK("BOOT", BOOT_0, BOOT_18, 39, 57, 2, 0, 2, 0, 9, 0, 10, 0, 11, 0), }; -static struct meson_bank meson8_aobus_banks[] = { +static const struct meson_bank meson8_aobus_banks[] = {/* name first last irq pullen pull dir out in */ BANK ("AO" ,GPIOAO_0 ,GPIO_TEST_N ,0 ,13 ,0 ,16 ,0 ,0 ,0 ,0 ,0 ,16 ,1 ,0 ), };
drivers/pinctrl/meson/pinctrl-meson8b.c +2 -2
@@ -917,7 +917,7 @@ static const struct meson_pmx_func meson8b_aobus_functions[] = { FUNCTION(hdmi_cec), }; -static struct meson_bank meson8b_cbus_banks[] = { +static const struct meson_bank meson8b_cbus_banks[] = {/* name first last irq pullen pull dir out in */ BANK ("X0..11" ,GPIOX_0 ,GPIOX_11 ,97 ,108 ,4 ,0 ,4 ,0 ,0 ,0 ,1 ,0 ,2 ,0 ),BANK ("X16..21" ,GPIOX_16 ,GPIOX_21 ,113 ,118 ,4 ,16 ,4 ,16 ,0 ,16 ,1 ,16 ,2 ,16 ),
@@ -938,7 +938,7 @@ static struct meson_bank meson8b_cbus_banks[] = { BANK("DIF", DIF_0_P, DIF_4_N, -1, -1, 5, 8, 5, 8, 12, 12, 13, 12, 14, 12), }; -static struct meson_bank meson8b_aobus_banks[] = { +static const struct meson_bank meson8b_aobus_banks[] = {/* name first lastc irq pullen pull dir out in */ BANK ("AO" ,GPIOAO_0 ,GPIO_TEST_N ,0 ,13 ,0 ,16 ,0 ,0 ,0 ,0 ,0 ,16 ,1 ,0 ), };
Signature · 1 line
2.45.2
PATCH 3/3 pinctrl: meson: Constify struct meson_pmx_bank
In reply to Christophe JAILLET'struct meson_pmx_bank' are not modified in these drivers.
Constifying these structures moves some data to a read-only section, so increase overall security.
On a x86_64, with allmodconfig:
Before:
======
text data bss dec hex filename
21922 568 0 22490 57da drivers/pinctrl/meson/pinctrl-amlogic-c3.o 34222 688 0 34910 885e drivers/pinctrl/meson/pinctrl-amlogic-t7.o 24945 440 0 25385 6329 drivers/pinctrl/meson/pinctrl-meson8b.o 29412 440 0 29852 749c drivers/pinctrl/meson/pinctrl-meson8.o 3070 324 0 3394 d42 drivers/pinctrl/meson/pinctrl-meson8-pmx.o 18469 520 0 18989 4a2d drivers/pinctrl/meson/pinctrl-meson-a1.o 23155 648 0 23803 5cfb drivers/pinctrl/meson/pinctrl-meson-axg.o 2470 120 0 2590 a1e drivers/pinctrl/meson/pinctrl-meson-axg-pmx.o 29653 712 0 30365 769d drivers/pinctrl/meson/pinctrl-meson-g12a.o 23496 456 0 23952 5d90 drivers/pinctrl/meson/pinctrl-meson-gxbb.o 22224 456 0 22680 5898 drivers/pinctrl/meson/pinctrl-meson-gxl.o 20507 1132 48 21687 54b7 drivers/pinctrl/meson/pinctrl-meson.o 24500 592 0 25092 6204 drivers/pinctrl/meson/pinctrl-meson-s4.o
After:
=====
text data bss dec hex filename
22114 384 0 22498 57e2 drivers/pinctrl/meson/pinctrl-amlogic-c3.o 34510 384 0 34894 884e drivers/pinctrl/meson/pinctrl-amlogic-t7.o 24945 440 0 25385 6329 drivers/pinctrl/meson/pinctrl-meson8b.o 29412 440 0 29852 749c drivers/pinctrl/meson/pinctrl-meson8.o 3070 324 0 3394 d42 drivers/pinctrl/meson/pinctrl-meson8-pmx.o 18597 384 0 18981 4a25 drivers/pinctrl/meson/pinctrl-meson-a1.o 23315 496 0 23811 5d03 drivers/pinctrl/meson/pinctrl-meson-axg.o 2470 120 0 2590 a1e drivers/pinctrl/meson/pinctrl-meson-axg-pmx.o 29877 504 0 30381 76ad drivers/pinctrl/meson/pinctrl-meson-g12a.o 23496 456 0 23952 5d90 drivers/pinctrl/meson/pinctrl-meson-gxbb.o 22224 456 0 22680 5898 drivers/pinctrl/meson/pinctrl-meson-gxl.o 20507 1132 48 21687 54b7 drivers/pinctrl/meson/pinctrl-meson.o 24692 384 0 25076 61f4 drivers/pinctrl/meson/pinctrl-meson-s4.o
---
Compile tested-only.
--- drivers/pinctrl/meson/pinctrl-amlogic-c3.c | 2 +- drivers/pinctrl/meson/pinctrl-amlogic-t7.c | 2 +- drivers/pinctrl/meson/pinctrl-meson-a1.c | 2 +- drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c | 8 ++++---- drivers/pinctrl/meson/pinctrl-meson-axg-pmx.h | 2 +- drivers/pinctrl/meson/pinctrl-meson-axg.c | 4 ++-- drivers/pinctrl/meson/pinctrl-meson-g12a.c | 4 ++-- drivers/pinctrl/meson/pinctrl-meson-s4.c | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-)
drivers/pinctrl/meson/pinctrl-amlogic-c3.c +1 -1
@@ -1054,7 +1054,7 @@ static const struct meson_bank c3_periphs_banks[] = { 0x73, 0, 0x74, 0, 0x72, 0, 0x71, 0, 0x70, 0, 0x77, 0), }; -static struct meson_pmx_bank c3_periphs_pmx_banks[] = { +static const struct meson_pmx_bank c3_periphs_pmx_banks[] = {/* name first last reg offset */ BANK_PMX ("B" ,GPIOB_0 ,GPIOB_14 ,0x00 ,0 ),BANK_PMX ("X" ,GPIOX_0 ,GPIOX_13 ,0x03 ,0 ),
drivers/pinctrl/meson/pinctrl-amlogic-t7.c +1 -1
@@ -1552,7 +1552,7 @@ static const struct meson_bank t7_periphs_banks[] = { 0x83, 0, 0x84, 0, 0x82, 0, 0x81, 0, 0x80, 0, 0x87, 0), }; -static struct meson_pmx_bank t7_periphs_pmx_banks[] = { +static const struct meson_pmx_bank t7_periphs_pmx_banks[] = {/* name first last reg offset */ BANK_PMX ("D" ,GPIOD_0 ,GPIOD_12 ,0x0a ,0 ),BANK_PMX ("E" ,GPIOE_0 ,GPIOE_6 ,0x0c ,0 ),
drivers/pinctrl/meson/pinctrl-meson-a1.c +1 -1
@@ -889,7 +889,7 @@ static const struct meson_bank meson_a1_periphs_banks[] = { 0x42, 0, 0x41, 0, 0x40, 0, 0x45, 0), }; -static struct meson_pmx_bank meson_a1_periphs_pmx_banks[] = { +static const struct meson_pmx_bank meson_a1_periphs_pmx_banks[] = {/* name first lask reg offset */ BANK_PMX ("P" ,GPIOP_0 ,GPIOP_12 ,0x0 ,0 ),BANK_PMX ("B" ,GPIOB_0 ,GPIOB_6 ,0x2 ,0 ),
drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c +4 -4
@@ -27,10 +27,10 @@static int meson_axg_pmx_get_bank (struct meson_pinctrl *pc,unsigned int pin, -struct meson_pmx_bank **bank) +const struct meson_pmx_bank **bank) {int i; -struct meson_axg_pmx_data *pmx = pc->data->pmx_data; +const struct meson_axg_pmx_data *pmx = pc->data->pmx_data;for (i =0 ; i < pmx->num_pmx_banks; i++) if (pin >= pmx->pmx_banks[i].first &&
@@ -42,7 +42,7 @@ static int meson_axg_pmx_get_bank(struct meson_pinctrl *pc,return -EINVAL ; } -static int meson_pmx_calc_reg_and_offset (struct meson_pmx_bank *bank, +static int meson_pmx_calc_reg_and_offset (const struct meson_pmx_bank *bank,unsigned int pin,unsigned int *reg,unsigned int *offset) {
@@ -59,10 +59,10 @@ static int meson_pmx_calc_reg_and_offset(struct meson_pmx_bank *bank,static int meson_axg_pmx_update_function (struct meson_pinctrl *pc,unsigned int pin,unsigned int func) { +const struct meson_pmx_bank *bank;int ret;int reg;int offset; -struct meson_pmx_bank *bank; ret =meson_axg_pmx_get_bank (pc, pin, &bank);if (ret)
drivers/pinctrl/meson/pinctrl-meson-axg-pmx.h +1 -1
@@ -17,7 +17,7 @@ struct meson_pmx_bank { };struct meson_axg_pmx_data { -struct meson_pmx_bank *pmx_banks; +const struct meson_pmx_bank *pmx_banks;unsigned int num_pmx_banks; };
drivers/pinctrl/meson/pinctrl-meson-axg.c +2 -2
@@ -1017,7 +1017,7 @@ static const struct meson_bank meson_axg_aobus_banks[] = { BANK("AO", GPIOAO_0, GPIOAO_13, 0, 13, 0, 16, 0, 0, 0, 0, 0, 16, 1, 0), }; -static struct meson_pmx_bank meson_axg_periphs_pmx_banks[] = { +static const struct meson_pmx_bank meson_axg_periphs_pmx_banks[] = {/* name first lask reg offset */ BANK_PMX ("Z" ,GPIOZ_0 ,GPIOZ_10 ,0x2 ,0 ),BANK_PMX ("BOOT" ,BOOT_0 ,BOOT_14 ,0x0 ,0 ),
@@ -1031,7 +1031,7 @@ static struct meson_axg_pmx_data meson_axg_periphs_pmx_banks_data = { .num_pmx_banks = ARRAY_SIZE(meson_axg_periphs_pmx_banks), }; -static struct meson_pmx_bank meson_axg_aobus_pmx_banks[] = { +static const struct meson_pmx_bank meson_axg_aobus_pmx_banks[] = {BANK_PMX ("AO" ,GPIOAO_0 ,GPIOAO_13 ,0x0 ,0 ), };
drivers/pinctrl/meson/pinctrl-meson-g12a.c +2 -2
@@ -1342,7 +1342,7 @@ static const struct meson_bank meson_g12a_aobus_banks[] = { 3, 16, 2, 16, 0, 16, 4, 16, 1, 16, 1, 0), }; -static struct meson_pmx_bank meson_g12a_periphs_pmx_banks[] = { +static const struct meson_pmx_bank meson_g12a_periphs_pmx_banks[] = {/* name first last reg offset */ BANK_PMX ("Z" ,GPIOZ_0 ,GPIOZ_15 ,0x6 ,0 ),BANK_PMX ("H" ,GPIOH_0 ,GPIOH_8 ,0xb ,0 ),
@@ -1357,7 +1357,7 @@ static struct meson_axg_pmx_data meson_g12a_periphs_pmx_banks_data = { .num_pmx_banks = ARRAY_SIZE(meson_g12a_periphs_pmx_banks), }; -static struct meson_pmx_bank meson_g12a_aobus_pmx_banks[] = { +static const struct meson_pmx_bank meson_g12a_aobus_pmx_banks[] = {BANK_PMX ("AO" ,GPIOAO_0 ,GPIOAO_11 ,0x0 ,0 ),BANK_PMX ("E" ,GPIOE_0 ,GPIOE_2 ,0x1 ,16 ), };
drivers/pinctrl/meson/pinctrl-meson-s4.c +1 -1
@@ -1180,7 +1180,7 @@ static const struct meson_bank meson_s4_periphs_banks[] = { 0x83, 0, 0x84, 0, 0x82, 0, 0x81, 0, 0x80, 0, 0x87, 0), }; -static struct meson_pmx_bank meson_s4_periphs_pmx_banks[] = { +static const struct meson_pmx_bank meson_s4_periphs_pmx_banks[] = {/*name first lask reg offset*/ BANK_PMX ("B" ,GPIOB_0 ,GPIOB_13 ,0x00 ,0 ),BANK_PMX ("C" ,GPIOC_0 ,GPIOC_7 ,0x9 ,0 ),
Signature · 1 line
2.45.2
Quoted 4 lines · Christophe JAILLET
These 3 patches constify some structures in order to move some data to a read-only section, so increase overall security.
It is splitted in 3 to ease review.
I'm not entirely sure it eases review in this case. If a v2 is necessary, I think a single patch would be better.
Quoted 3 lines
Patch 1: struct
meson_pmx_groupandmeson_pmx_funcpatch 2: structmeson_bank
patch 3: structmeson_pmx_bank
Is there any reason for leaving out 'struct meson_pinctrl_data' and 'struct meson_axg_pmx_data' ? I don't think they get modified but maybe I missed it.
Quoted 2 lines
All patches are only compile tested.
Looks good anyway
On the vim3l:
Le 07/08/2024 à 16:14, Jerome Brunet a écrit :
Quoted 10 lines · Christophe JAILLET
Quoted 5 lines
These 3 patches constify some structures in order to move some data to a read-only section, so increase overall security.
It is splitted in 3 to ease review.
I'm not entirely sure it eases review in this case. If a v2 is necessary, I think a single patch would be better.
Quoted 7 lines
Quoted 3 lines
Patch 1: struct
meson_pmx_groupandmeson_pmx_funcpatch 2: structmeson_bank
patch 3: structmeson_pmx_bankIs there any reason for leaving out 'struct
meson_pinctrl_data' and 'structmeson_axg_pmx_data' ? I don't think they get modified but maybe I missed it.
No good reasons.
I'll send a v2 with everything constified all at once.
Should I take the R-b and T-b below, for the v2?
Thanks for the review and comment.
CJ
Quoted 11 lines
Quoted 3 lines
All patches are only compile tested.
Looks good anyway
Reviewed-by Jerome Brunet <[email protected]>On the vim3l:
Tested-by Jerome Brunet <[email protected]>
Jerome Brunet
reviewerQuoted 17 lines · Christophe JAILLET
Le 07/08/2024 à 16:14, Jerome Brunet a écrit :
Quoted 9 lines · Christophe JAILLET
Quoted 5 lines
These 3 patches constify some structures in order to move some data to a read-only section, so increase overall security.
It is splitted in 3 to ease review.
I'm not entirely sure it eases review in this case. If a v2 is necessary, I think a single patch would be better.
Quoted 6 lines
Quoted 3 lines
Patch 1: struct
meson_pmx_groupandmeson_pmx_funcpatch 2: structmeson_bank
patch 3: structmeson_pmx_bankIs there any reason for leaving out 'struct
meson_pinctrl_data' and 'structmeson_axg_pmx_data' ? I don't think they get modified but maybe I missed it.
Quoted 6 lines
No good reasons.
I'll send a v2 with everything constified all at once.
Should I take the R-b and T-b below, for the v2?
Leave them out. I'll test again and report.
Thanks for this
Quoted 13 lines
Thanks for the review and comment.
CJ
Quoted 8 lines
Quoted 3 lines
All patches are only compile tested.
Looks good anyway
Reviewed-by Jerome Brunet <[email protected]>On the vim3l:
Tested-by Jerome Brunet <[email protected]>
Signature · 1 line
Jerome