Skip to content

Commit 10c1ea1

Browse files
tititiou36AngeloGioacchino Del Regno
authored andcommitted
soc: mediatek: pwrap: Constify some struct int[]
These arrays are not modified in this driver. Constifying this structure 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 45528 8532 16 54076 d33c drivers/soc/mediatek/mtk-pmic-wrap.o After: ===== text data bss dec hex filename 52664 1384 16 54064 d330 drivers/soc/mediatek/mtk-pmic-wrap.o Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/f1fea00fbaa0fea298bf67732e019f9cc5c407ab.1720331018.git.christophe.jaillet@wanadoo.fr Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
1 parent ded525f commit 10c1ea1

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

drivers/soc/mediatek/mtk-pmic-wrap.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ enum pwrap_regs {
483483
PWRAP_MSB_FIRST,
484484
};
485485

486-
static int mt2701_regs[] = {
486+
static const int mt2701_regs[] = {
487487
[PWRAP_MUX_SEL] = 0x0,
488488
[PWRAP_WRAP_EN] = 0x4,
489489
[PWRAP_DIO_EN] = 0x8,
@@ -569,7 +569,7 @@ static int mt2701_regs[] = {
569569
[PWRAP_ADC_RDATA_ADDR2] = 0x154,
570570
};
571571

572-
static int mt6765_regs[] = {
572+
static const int mt6765_regs[] = {
573573
[PWRAP_MUX_SEL] = 0x0,
574574
[PWRAP_WRAP_EN] = 0x4,
575575
[PWRAP_DIO_EN] = 0x8,
@@ -601,7 +601,7 @@ static int mt6765_regs[] = {
601601
[PWRAP_DCM_DBC_PRD] = 0x1E0,
602602
};
603603

604-
static int mt6779_regs[] = {
604+
static const int mt6779_regs[] = {
605605
[PWRAP_MUX_SEL] = 0x0,
606606
[PWRAP_WRAP_EN] = 0x4,
607607
[PWRAP_DIO_EN] = 0x8,
@@ -640,7 +640,7 @@ static int mt6779_regs[] = {
640640
[PWRAP_WACS2_VLDCLR] = 0xC28,
641641
};
642642

643-
static int mt6795_regs[] = {
643+
static const int mt6795_regs[] = {
644644
[PWRAP_MUX_SEL] = 0x0,
645645
[PWRAP_WRAP_EN] = 0x4,
646646
[PWRAP_DIO_EN] = 0x8,
@@ -725,7 +725,7 @@ static int mt6795_regs[] = {
725725
[PWRAP_EXT_CK] = 0x14c,
726726
};
727727

728-
static int mt6797_regs[] = {
728+
static const int mt6797_regs[] = {
729729
[PWRAP_MUX_SEL] = 0x0,
730730
[PWRAP_WRAP_EN] = 0x4,
731731
[PWRAP_DIO_EN] = 0x8,
@@ -758,7 +758,7 @@ static int mt6797_regs[] = {
758758
[PWRAP_DCM_DBC_PRD] = 0x1D4,
759759
};
760760

761-
static int mt6873_regs[] = {
761+
static const int mt6873_regs[] = {
762762
[PWRAP_INIT_DONE2] = 0x0,
763763
[PWRAP_TIMER_EN] = 0x3E0,
764764
[PWRAP_INT_EN] = 0x448,
@@ -769,7 +769,7 @@ static int mt6873_regs[] = {
769769
[PWRAP_WACS2_RDATA] = 0xCA8,
770770
};
771771

772-
static int mt7622_regs[] = {
772+
static const int mt7622_regs[] = {
773773
[PWRAP_MUX_SEL] = 0x0,
774774
[PWRAP_WRAP_EN] = 0x4,
775775
[PWRAP_DIO_EN] = 0x8,
@@ -881,7 +881,7 @@ static int mt7622_regs[] = {
881881
[PWRAP_SPI2_CTRL] = 0x244,
882882
};
883883

884-
static int mt8135_regs[] = {
884+
static const int mt8135_regs[] = {
885885
[PWRAP_MUX_SEL] = 0x0,
886886
[PWRAP_WRAP_EN] = 0x4,
887887
[PWRAP_DIO_EN] = 0x8,
@@ -954,7 +954,7 @@ static int mt8135_regs[] = {
954954
[PWRAP_DCM_DBC_PRD] = 0x160,
955955
};
956956

957-
static int mt8173_regs[] = {
957+
static const int mt8173_regs[] = {
958958
[PWRAP_MUX_SEL] = 0x0,
959959
[PWRAP_WRAP_EN] = 0x4,
960960
[PWRAP_DIO_EN] = 0x8,
@@ -1036,7 +1036,7 @@ static int mt8173_regs[] = {
10361036
[PWRAP_DCM_DBC_PRD] = 0x148,
10371037
};
10381038

1039-
static int mt8183_regs[] = {
1039+
static const int mt8183_regs[] = {
10401040
[PWRAP_MUX_SEL] = 0x0,
10411041
[PWRAP_WRAP_EN] = 0x4,
10421042
[PWRAP_DIO_EN] = 0x8,
@@ -1087,7 +1087,7 @@ static int mt8183_regs[] = {
10871087
[PWRAP_WACS2_VLDCLR] = 0xC28,
10881088
};
10891089

1090-
static int mt8195_regs[] = {
1090+
static const int mt8195_regs[] = {
10911091
[PWRAP_INIT_DONE2] = 0x0,
10921092
[PWRAP_STAUPD_CTRL] = 0x4C,
10931093
[PWRAP_TIMER_EN] = 0x3E4,
@@ -1104,7 +1104,7 @@ static int mt8195_regs[] = {
11041104
[PWRAP_WACS2_RDATA] = 0x8A8,
11051105
};
11061106

1107-
static int mt8365_regs[] = {
1107+
static const int mt8365_regs[] = {
11081108
[PWRAP_MUX_SEL] = 0x0,
11091109
[PWRAP_WRAP_EN] = 0x4,
11101110
[PWRAP_DIO_EN] = 0x8,
@@ -1166,7 +1166,7 @@ static int mt8365_regs[] = {
11661166
[PWRAP_WDT_SRC_EN_1] = 0xf8,
11671167
};
11681168

1169-
static int mt8516_regs[] = {
1169+
static const int mt8516_regs[] = {
11701170
[PWRAP_MUX_SEL] = 0x0,
11711171
[PWRAP_WRAP_EN] = 0x4,
11721172
[PWRAP_DIO_EN] = 0x8,
@@ -1251,7 +1251,7 @@ static int mt8516_regs[] = {
12511251
[PWRAP_MSB_FIRST] = 0x170,
12521252
};
12531253

1254-
static int mt8186_regs[] = {
1254+
static const int mt8186_regs[] = {
12551255
[PWRAP_MUX_SEL] = 0x0,
12561256
[PWRAP_WRAP_EN] = 0x4,
12571257
[PWRAP_DIO_EN] = 0x8,
@@ -1377,7 +1377,7 @@ struct pmic_wrapper {
13771377
};
13781378

13791379
struct pmic_wrapper_type {
1380-
int *regs;
1380+
const int *regs;
13811381
enum pwrap_type type;
13821382
u32 arb_en_all;
13831383
u32 int_en_all;

0 commit comments

Comments
 (0)