Skip to content

Commit 8a74a53

Browse files
tititiou36linusw
authored andcommitted
pinctrl: meson: Constify some structures
The following structures are not modified in these drivers. - struct meson_bank - struct meson_pmx_bank - struct meson_pmx_func - struct meson_pmx_group - struct meson_pinctrl_data - struct meson_axg_pmx_data 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 22242 248 0 22490 57da drivers/pinctrl/meson/pinctrl-amlogic-c3.o 34638 248 0 34886 8846 drivers/pinctrl/meson/pinctrl-amlogic-t7.o 25137 232 0 25369 6319 drivers/pinctrl/meson/pinctrl-meson8b.o 29604 232 0 29836 748c drivers/pinctrl/meson/pinctrl-meson8.o 3070 324 0 3394 d42 drivers/pinctrl/meson/pinctrl-meson8-pmx.o 18725 248 0 18973 4a1d drivers/pinctrl/meson/pinctrl-meson-a1.o 23539 248 0 23787 5ceb drivers/pinctrl/meson/pinctrl-meson-axg.o 2470 120 0 2590 a1e drivers/pinctrl/meson/pinctrl-meson-axg-pmx.o 30101 256 0 30357 7695 drivers/pinctrl/meson/pinctrl-meson-g12a.o 23688 248 0 23936 5d80 drivers/pinctrl/meson/pinctrl-meson-gxbb.o 22416 248 0 22664 5888 drivers/pinctrl/meson/pinctrl-meson-gxl.o 20507 1132 48 21687 54b7 drivers/pinctrl/meson/pinctrl-meson.o 24820 248 0 25068 61ec drivers/pinctrl/meson/pinctrl-meson-s4.o Signed-off-by: Christophe JAILLET <[email protected]> Reviewed-by: Jerome Brunet <[email protected]> Tested-by: Jerome Brunet <[email protected]> Link: https://lore.kernel.org/f74e326bd7d48003c06219545bad7c2ef1a84bf8.1723053850.git.christophe.jaillet@wanadoo.fr Signed-off-by: Linus Walleij <[email protected]>
1 parent 69c6343 commit 8a74a53

15 files changed

+107
-106
lines changed

drivers/pinctrl/meson/pinctrl-amlogic-c3.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ static const unsigned int spi_a_mosi_a_pins[] = { GPIOA_3 };
375375
static const unsigned int gen_clk_a4_pins[] = { GPIOA_4 };
376376
static const unsigned int clk12_24_a_pins[] = { GPIOA_5 };
377377

378-
static struct meson_pmx_group c3_periphs_groups[] = {
378+
static const struct meson_pmx_group c3_periphs_groups[] = {
379379
GPIO_GROUP(GPIOE_0),
380380
GPIO_GROUP(GPIOE_1),
381381
GPIO_GROUP(GPIOE_2),
@@ -987,7 +987,7 @@ static const char * const lcd_groups[] = {
987987
"lcd_clk_a", "lcd_clk_x", "lcd_hs", "lcd_vs",
988988
};
989989

990-
static struct meson_pmx_func c3_periphs_functions[] = {
990+
static const struct meson_pmx_func c3_periphs_functions[] = {
991991
FUNCTION(gpio_periphs),
992992
FUNCTION(uart_a),
993993
FUNCTION(uart_b),
@@ -1036,7 +1036,7 @@ static struct meson_pmx_func c3_periphs_functions[] = {
10361036
FUNCTION(lcd),
10371037
};
10381038

1039-
static struct meson_bank c3_periphs_banks[] = {
1039+
static const struct meson_bank c3_periphs_banks[] = {
10401040
/* name first last irq pullen pull dir out in ds */
10411041
BANK_DS("X", GPIOX_0, GPIOX_13, 40, 53,
10421042
0x03, 0, 0x04, 0, 0x02, 0, 0x01, 0, 0x00, 0, 0x07, 0),
@@ -1054,7 +1054,7 @@ static struct meson_bank c3_periphs_banks[] = {
10541054
0x73, 0, 0x74, 0, 0x72, 0, 0x71, 0, 0x70, 0, 0x77, 0),
10551055
};
10561056

1057-
static struct meson_pmx_bank c3_periphs_pmx_banks[] = {
1057+
static const struct meson_pmx_bank c3_periphs_pmx_banks[] = {
10581058
/* name first last reg offset */
10591059
BANK_PMX("B", GPIOB_0, GPIOB_14, 0x00, 0),
10601060
BANK_PMX("X", GPIOX_0, GPIOX_13, 0x03, 0),
@@ -1065,12 +1065,12 @@ static struct meson_pmx_bank c3_periphs_pmx_banks[] = {
10651065
BANK_PMX("TEST_N", GPIO_TEST_N, GPIO_TEST_N, 0x02, 0),
10661066
};
10671067

1068-
static struct meson_axg_pmx_data c3_periphs_pmx_banks_data = {
1068+
static const struct meson_axg_pmx_data c3_periphs_pmx_banks_data = {
10691069
.pmx_banks = c3_periphs_pmx_banks,
10701070
.num_pmx_banks = ARRAY_SIZE(c3_periphs_pmx_banks),
10711071
};
10721072

1073-
static struct meson_pinctrl_data c3_periphs_pinctrl_data = {
1073+
static const struct meson_pinctrl_data c3_periphs_pinctrl_data = {
10741074
.name = "periphs-banks",
10751075
.pins = c3_periphs_pins,
10761076
.groups = c3_periphs_groups,

drivers/pinctrl/meson/pinctrl-amlogic-t7.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ static const unsigned int i2c0_sck_h_pins[] = { GPIOH_7 };
535535
/* Bank H func3 */
536536
static const unsigned int pcieck_reqn_h_pins[] = { GPIOH_2 };
537537

538-
static struct meson_pmx_group t7_periphs_groups[] = {
538+
static const struct meson_pmx_group t7_periphs_groups[] = {
539539
GPIO_GROUP(GPIOB_0),
540540
GPIO_GROUP(GPIOB_1),
541541
GPIO_GROUP(GPIOB_2),
@@ -1443,7 +1443,7 @@ static const char * const mic_mute_groups[] = {
14431443
"mic_mute_key", "mic_mute_led",
14441444
};
14451445

1446-
static struct meson_pmx_func t7_periphs_functions[] = {
1446+
static const struct meson_pmx_func t7_periphs_functions[] = {
14471447
FUNCTION(gpio_periphs),
14481448
FUNCTION(emmc),
14491449
FUNCTION(nor),
@@ -1524,7 +1524,7 @@ static struct meson_pmx_func t7_periphs_functions[] = {
15241524
FUNCTION(mic_mute),
15251525
};
15261526

1527-
static struct meson_bank t7_periphs_banks[] = {
1527+
static const struct meson_bank t7_periphs_banks[] = {
15281528
/* name first last irq pullen pull dir out in ds */
15291529
BANK_DS("D", GPIOD_0, GPIOD_12, 57, 69,
15301530
0x03, 0, 0x04, 0, 0x02, 0, 0x01, 0, 0x00, 0, 0x07, 0),
@@ -1552,7 +1552,7 @@ static struct meson_bank t7_periphs_banks[] = {
15521552
0x83, 0, 0x84, 0, 0x82, 0, 0x81, 0, 0x80, 0, 0x87, 0),
15531553
};
15541554

1555-
static struct meson_pmx_bank t7_periphs_pmx_banks[] = {
1555+
static const struct meson_pmx_bank t7_periphs_pmx_banks[] = {
15561556
/* name first last reg offset */
15571557
BANK_PMX("D", GPIOD_0, GPIOD_12, 0x0a, 0),
15581558
BANK_PMX("E", GPIOE_0, GPIOE_6, 0x0c, 0),
@@ -1568,12 +1568,12 @@ static struct meson_pmx_bank t7_periphs_pmx_banks[] = {
15681568
BANK_PMX("TEST_N", GPIO_TEST_N, GPIO_TEST_N, 0x09, 0),
15691569
};
15701570

1571-
static struct meson_axg_pmx_data t7_periphs_pmx_banks_data = {
1571+
static const struct meson_axg_pmx_data t7_periphs_pmx_banks_data = {
15721572
.pmx_banks = t7_periphs_pmx_banks,
15731573
.num_pmx_banks = ARRAY_SIZE(t7_periphs_pmx_banks),
15741574
};
15751575

1576-
static struct meson_pinctrl_data t7_periphs_pinctrl_data = {
1576+
static const struct meson_pinctrl_data t7_periphs_pinctrl_data = {
15771577
.name = "periphs-banks",
15781578
.pins = t7_periphs_pins,
15791579
.groups = t7_periphs_groups,

drivers/pinctrl/meson/pinctrl-meson-a1.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ static const unsigned int tst_out11_pins[] = { GPIOA_11 };
339339
static const unsigned int mute_key_pins[] = { GPIOA_4 };
340340
static const unsigned int mute_en_pins[] = { GPIOA_5 };
341341

342-
static struct meson_pmx_group meson_a1_periphs_groups[] = {
342+
static const struct meson_pmx_group meson_a1_periphs_groups[] = {
343343
GPIO_GROUP(GPIOP_0),
344344
GPIO_GROUP(GPIOP_1),
345345
GPIO_GROUP(GPIOP_2),
@@ -832,7 +832,7 @@ static const char * const mute_groups[] = {
832832
"mute_key", "mute_en",
833833
};
834834

835-
static struct meson_pmx_func meson_a1_periphs_functions[] = {
835+
static const struct meson_pmx_func meson_a1_periphs_functions[] = {
836836
FUNCTION(gpio_periphs),
837837
FUNCTION(psram),
838838
FUNCTION(pwm_a),
@@ -875,7 +875,7 @@ static struct meson_pmx_func meson_a1_periphs_functions[] = {
875875
FUNCTION(mute),
876876
};
877877

878-
static struct meson_bank meson_a1_periphs_banks[] = {
878+
static const struct meson_bank meson_a1_periphs_banks[] = {
879879
/* name first last irq pullen pull dir out in ds*/
880880
BANK_DS("P", GPIOP_0, GPIOP_12, 0, 12, 0x3, 0, 0x4, 0,
881881
0x2, 0, 0x1, 0, 0x0, 0, 0x5, 0),
@@ -889,7 +889,7 @@ static struct meson_bank meson_a1_periphs_banks[] = {
889889
0x42, 0, 0x41, 0, 0x40, 0, 0x45, 0),
890890
};
891891

892-
static struct meson_pmx_bank meson_a1_periphs_pmx_banks[] = {
892+
static const struct meson_pmx_bank meson_a1_periphs_pmx_banks[] = {
893893
/* name first lask reg offset */
894894
BANK_PMX("P", GPIOP_0, GPIOP_12, 0x0, 0),
895895
BANK_PMX("B", GPIOB_0, GPIOB_6, 0x2, 0),
@@ -898,12 +898,12 @@ static struct meson_pmx_bank meson_a1_periphs_pmx_banks[] = {
898898
BANK_PMX("A", GPIOA_0, GPIOA_11, 0x8, 0),
899899
};
900900

901-
static struct meson_axg_pmx_data meson_a1_periphs_pmx_banks_data = {
901+
static const struct meson_axg_pmx_data meson_a1_periphs_pmx_banks_data = {
902902
.pmx_banks = meson_a1_periphs_pmx_banks,
903903
.num_pmx_banks = ARRAY_SIZE(meson_a1_periphs_pmx_banks),
904904
};
905905

906-
static struct meson_pinctrl_data meson_a1_periphs_pinctrl_data = {
906+
static const struct meson_pinctrl_data meson_a1_periphs_pinctrl_data = {
907907
.name = "periphs-banks",
908908
.pins = meson_a1_periphs_pins,
909909
.groups = meson_a1_periphs_groups,

drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727

2828
static int meson_axg_pmx_get_bank(struct meson_pinctrl *pc,
2929
unsigned int pin,
30-
struct meson_pmx_bank **bank)
30+
const struct meson_pmx_bank **bank)
3131
{
3232
int i;
33-
struct meson_axg_pmx_data *pmx = pc->data->pmx_data;
33+
const struct meson_axg_pmx_data *pmx = pc->data->pmx_data;
3434

3535
for (i = 0; i < pmx->num_pmx_banks; i++)
3636
if (pin >= pmx->pmx_banks[i].first &&
@@ -42,7 +42,7 @@ static int meson_axg_pmx_get_bank(struct meson_pinctrl *pc,
4242
return -EINVAL;
4343
}
4444

45-
static int meson_pmx_calc_reg_and_offset(struct meson_pmx_bank *bank,
45+
static int meson_pmx_calc_reg_and_offset(const struct meson_pmx_bank *bank,
4646
unsigned int pin, unsigned int *reg,
4747
unsigned int *offset)
4848
{
@@ -59,10 +59,10 @@ static int meson_pmx_calc_reg_and_offset(struct meson_pmx_bank *bank,
5959
static int meson_axg_pmx_update_function(struct meson_pinctrl *pc,
6060
unsigned int pin, unsigned int func)
6161
{
62+
const struct meson_pmx_bank *bank;
6263
int ret;
6364
int reg;
6465
int offset;
65-
struct meson_pmx_bank *bank;
6666

6767
ret = meson_axg_pmx_get_bank(pc, pin, &bank);
6868
if (ret)
@@ -82,8 +82,8 @@ static int meson_axg_pmx_set_mux(struct pinctrl_dev *pcdev,
8282
int i;
8383
int ret;
8484
struct meson_pinctrl *pc = pinctrl_dev_get_drvdata(pcdev);
85-
struct meson_pmx_func *func = &pc->data->funcs[func_num];
86-
struct meson_pmx_group *group = &pc->data->groups[group_num];
85+
const struct meson_pmx_func *func = &pc->data->funcs[func_num];
86+
const struct meson_pmx_group *group = &pc->data->groups[group_num];
8787
struct meson_pmx_axg_data *pmx_data =
8888
(struct meson_pmx_axg_data *)group->data;
8989

drivers/pinctrl/meson/pinctrl-meson-axg-pmx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct meson_pmx_bank {
1717
};
1818

1919
struct meson_axg_pmx_data {
20-
struct meson_pmx_bank *pmx_banks;
20+
const struct meson_pmx_bank *pmx_banks;
2121
unsigned int num_pmx_banks;
2222
};
2323

drivers/pinctrl/meson/pinctrl-meson-axg.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ static const unsigned int tdmb_dout2_pins[] = {GPIOA_12};
352352
static const unsigned int tdmb_din3_pins[] = {GPIOA_13};
353353
static const unsigned int tdmb_dout3_pins[] = {GPIOA_13};
354354

355-
static struct meson_pmx_group meson_axg_periphs_groups[] = {
355+
static const struct meson_pmx_group meson_axg_periphs_groups[] = {
356356
GPIO_GROUP(GPIOZ_0),
357357
GPIO_GROUP(GPIOZ_1),
358358
GPIO_GROUP(GPIOZ_2),
@@ -675,7 +675,7 @@ static const unsigned int jtag_ao_tms_pins[] = {GPIOAO_7};
675675
/* gen_clk */
676676
static const unsigned int gen_clk_ee_pins[] = {GPIOAO_13};
677677

678-
static struct meson_pmx_group meson_axg_aobus_groups[] = {
678+
static const struct meson_pmx_group meson_axg_aobus_groups[] = {
679679
GPIO_GROUP(GPIOAO_0),
680680
GPIO_GROUP(GPIOAO_1),
681681
GPIO_GROUP(GPIOAO_2),
@@ -955,7 +955,7 @@ static const char * const gen_clk_ee_groups[] = {
955955
"gen_clk_ee",
956956
};
957957

958-
static struct meson_pmx_func meson_axg_periphs_functions[] = {
958+
static const struct meson_pmx_func meson_axg_periphs_functions[] = {
959959
FUNCTION(gpio_periphs),
960960
FUNCTION(emmc),
961961
FUNCTION(nor),
@@ -987,7 +987,7 @@ static struct meson_pmx_func meson_axg_periphs_functions[] = {
987987
FUNCTION(tdmc),
988988
};
989989

990-
static struct meson_pmx_func meson_axg_aobus_functions[] = {
990+
static const struct meson_pmx_func meson_axg_aobus_functions[] = {
991991
FUNCTION(gpio_aobus),
992992
FUNCTION(uart_ao_a),
993993
FUNCTION(uart_ao_b),
@@ -1003,7 +1003,7 @@ static struct meson_pmx_func meson_axg_aobus_functions[] = {
10031003
FUNCTION(gen_clk_ee),
10041004
};
10051005

1006-
static struct meson_bank meson_axg_periphs_banks[] = {
1006+
static const struct meson_bank meson_axg_periphs_banks[] = {
10071007
/* name first last irq pullen pull dir out in */
10081008
BANK("Z", GPIOZ_0, GPIOZ_10, 14, 24, 3, 0, 3, 0, 9, 0, 10, 0, 11, 0),
10091009
BANK("BOOT", BOOT_0, BOOT_14, 25, 39, 4, 0, 4, 0, 12, 0, 13, 0, 14, 0),
@@ -1012,12 +1012,12 @@ static struct meson_bank meson_axg_periphs_banks[] = {
10121012
BANK("Y", GPIOY_0, GPIOY_15, 84, 99, 1, 0, 1, 0, 3, 0, 4, 0, 5, 0),
10131013
};
10141014

1015-
static struct meson_bank meson_axg_aobus_banks[] = {
1015+
static const struct meson_bank meson_axg_aobus_banks[] = {
10161016
/* name first last irq pullen pull dir out in */
10171017
BANK("AO", GPIOAO_0, GPIOAO_13, 0, 13, 0, 16, 0, 0, 0, 0, 0, 16, 1, 0),
10181018
};
10191019

1020-
static struct meson_pmx_bank meson_axg_periphs_pmx_banks[] = {
1020+
static const struct meson_pmx_bank meson_axg_periphs_pmx_banks[] = {
10211021
/* name first lask reg offset */
10221022
BANK_PMX("Z", GPIOZ_0, GPIOZ_10, 0x2, 0),
10231023
BANK_PMX("BOOT", BOOT_0, BOOT_14, 0x0, 0),
@@ -1026,21 +1026,21 @@ static struct meson_pmx_bank meson_axg_periphs_pmx_banks[] = {
10261026
BANK_PMX("Y", GPIOY_0, GPIOY_15, 0x8, 0),
10271027
};
10281028

1029-
static struct meson_axg_pmx_data meson_axg_periphs_pmx_banks_data = {
1029+
static const struct meson_axg_pmx_data meson_axg_periphs_pmx_banks_data = {
10301030
.pmx_banks = meson_axg_periphs_pmx_banks,
10311031
.num_pmx_banks = ARRAY_SIZE(meson_axg_periphs_pmx_banks),
10321032
};
10331033

1034-
static struct meson_pmx_bank meson_axg_aobus_pmx_banks[] = {
1034+
static const struct meson_pmx_bank meson_axg_aobus_pmx_banks[] = {
10351035
BANK_PMX("AO", GPIOAO_0, GPIOAO_13, 0x0, 0),
10361036
};
10371037

1038-
static struct meson_axg_pmx_data meson_axg_aobus_pmx_banks_data = {
1038+
static const struct meson_axg_pmx_data meson_axg_aobus_pmx_banks_data = {
10391039
.pmx_banks = meson_axg_aobus_pmx_banks,
10401040
.num_pmx_banks = ARRAY_SIZE(meson_axg_aobus_pmx_banks),
10411041
};
10421042

1043-
static struct meson_pinctrl_data meson_axg_periphs_pinctrl_data = {
1043+
static const struct meson_pinctrl_data meson_axg_periphs_pinctrl_data = {
10441044
.name = "periphs-banks",
10451045
.pins = meson_axg_periphs_pins,
10461046
.groups = meson_axg_periphs_groups,
@@ -1054,7 +1054,7 @@ static struct meson_pinctrl_data meson_axg_periphs_pinctrl_data = {
10541054
.pmx_data = &meson_axg_periphs_pmx_banks_data,
10551055
};
10561056

1057-
static struct meson_pinctrl_data meson_axg_aobus_pinctrl_data = {
1057+
static const struct meson_pinctrl_data meson_axg_aobus_pinctrl_data = {
10581058
.name = "aobus-banks",
10591059
.pins = meson_axg_aobus_pins,
10601060
.groups = meson_axg_aobus_groups,

0 commit comments

Comments
 (0)