Skip to content

Commit e3407cc

Browse files
tititiou36storulf
authored andcommitted
pmdomain: amlogic: Constify some structures
Most structures in this driver are not modified. Constifying these structures moves some data to a read-only section, so increase overall security, especially when the structure holds some function pointers. (This is the case for see meson_ee_pwrc_domain_desc) On a x86_64, with allmodconfig, as an example: Before: ====== text data bss dec hex filename 8924 3832 0 12756 31d4 drivers/pmdomain/amlogic/meson-ee-pwrc.o After: ===== text data bss dec hex filename 12396 336 0 12732 31bc drivers/pmdomain/amlogic/meson-ee-pwrc.o Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Link: https://lore.kernel.org/r/edc560afe2a8763c93341d161daeb8b33ba606c6.1746199917.git.christophe.jaillet@wanadoo.fr Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent f80fa80 commit e3407cc

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

drivers/pmdomain/amlogic/meson-ee-pwrc.c

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -69,27 +69,27 @@ struct meson_ee_pwrc_domain_desc {
6969
char *name;
7070
unsigned int reset_names_count;
7171
unsigned int clk_names_count;
72-
struct meson_ee_pwrc_top_domain *top_pd;
72+
const struct meson_ee_pwrc_top_domain *top_pd;
7373
unsigned int mem_pd_count;
74-
struct meson_ee_pwrc_mem_domain *mem_pd;
74+
const struct meson_ee_pwrc_mem_domain *mem_pd;
7575
bool (*is_powered_off)(struct meson_ee_pwrc_domain *pwrc_domain);
7676
};
7777

7878
struct meson_ee_pwrc_domain_data {
7979
unsigned int count;
80-
struct meson_ee_pwrc_domain_desc *domains;
80+
const struct meson_ee_pwrc_domain_desc *domains;
8181
};
8282

8383
/* TOP Power Domains */
8484

85-
static struct meson_ee_pwrc_top_domain gx_pwrc_vpu = {
85+
static const struct meson_ee_pwrc_top_domain gx_pwrc_vpu = {
8686
.sleep_reg = GX_AO_RTI_GEN_PWR_SLEEP0,
8787
.sleep_mask = BIT(8),
8888
.iso_reg = GX_AO_RTI_GEN_PWR_SLEEP0,
8989
.iso_mask = BIT(9),
9090
};
9191

92-
static struct meson_ee_pwrc_top_domain meson8_pwrc_vpu = {
92+
static const struct meson_ee_pwrc_top_domain meson8_pwrc_vpu = {
9393
.sleep_reg = MESON8_AO_RTI_GEN_PWR_SLEEP0,
9494
.sleep_mask = BIT(8),
9595
.iso_reg = MESON8_AO_RTI_GEN_PWR_SLEEP0,
@@ -104,20 +104,20 @@ static struct meson_ee_pwrc_top_domain meson8_pwrc_vpu = {
104104
.iso_mask = BIT(__bit), \
105105
}
106106

107-
static struct meson_ee_pwrc_top_domain sm1_pwrc_vpu = SM1_EE_PD(8);
108-
static struct meson_ee_pwrc_top_domain sm1_pwrc_nna = SM1_EE_PD(16);
109-
static struct meson_ee_pwrc_top_domain sm1_pwrc_usb = SM1_EE_PD(17);
110-
static struct meson_ee_pwrc_top_domain sm1_pwrc_pci = SM1_EE_PD(18);
111-
static struct meson_ee_pwrc_top_domain sm1_pwrc_ge2d = SM1_EE_PD(19);
107+
static const struct meson_ee_pwrc_top_domain sm1_pwrc_vpu = SM1_EE_PD(8);
108+
static const struct meson_ee_pwrc_top_domain sm1_pwrc_nna = SM1_EE_PD(16);
109+
static const struct meson_ee_pwrc_top_domain sm1_pwrc_usb = SM1_EE_PD(17);
110+
static const struct meson_ee_pwrc_top_domain sm1_pwrc_pci = SM1_EE_PD(18);
111+
static const struct meson_ee_pwrc_top_domain sm1_pwrc_ge2d = SM1_EE_PD(19);
112112

113-
static struct meson_ee_pwrc_top_domain g12a_pwrc_nna = {
113+
static const struct meson_ee_pwrc_top_domain g12a_pwrc_nna = {
114114
.sleep_reg = GX_AO_RTI_GEN_PWR_SLEEP0,
115115
.sleep_mask = BIT(16) | BIT(17),
116116
.iso_reg = GX_AO_RTI_GEN_PWR_ISO0,
117117
.iso_mask = BIT(16) | BIT(17),
118118
};
119119

120-
static struct meson_ee_pwrc_top_domain g12a_pwrc_isp = {
120+
static const struct meson_ee_pwrc_top_domain g12a_pwrc_isp = {
121121
.sleep_reg = GX_AO_RTI_GEN_PWR_SLEEP0,
122122
.sleep_mask = BIT(18) | BIT(19),
123123
.iso_reg = GX_AO_RTI_GEN_PWR_ISO0,
@@ -154,39 +154,39 @@ static struct meson_ee_pwrc_top_domain g12a_pwrc_isp = {
154154
{ __reg, BIT(14) }, \
155155
{ __reg, BIT(15) }
156156

157-
static struct meson_ee_pwrc_mem_domain axg_pwrc_mem_vpu[] = {
157+
static const struct meson_ee_pwrc_mem_domain axg_pwrc_mem_vpu[] = {
158158
VPU_MEMPD(HHI_VPU_MEM_PD_REG0),
159159
VPU_HHI_MEMPD(HHI_MEM_PD_REG0),
160160
};
161161

162-
static struct meson_ee_pwrc_mem_domain g12a_pwrc_mem_vpu[] = {
162+
static const struct meson_ee_pwrc_mem_domain g12a_pwrc_mem_vpu[] = {
163163
VPU_MEMPD(HHI_VPU_MEM_PD_REG0),
164164
VPU_MEMPD(HHI_VPU_MEM_PD_REG1),
165165
VPU_MEMPD(HHI_VPU_MEM_PD_REG2),
166166
VPU_HHI_MEMPD(HHI_MEM_PD_REG0),
167167
};
168168

169-
static struct meson_ee_pwrc_mem_domain gxbb_pwrc_mem_vpu[] = {
169+
static const struct meson_ee_pwrc_mem_domain gxbb_pwrc_mem_vpu[] = {
170170
VPU_MEMPD(HHI_VPU_MEM_PD_REG0),
171171
VPU_MEMPD(HHI_VPU_MEM_PD_REG1),
172172
VPU_HHI_MEMPD(HHI_MEM_PD_REG0),
173173
};
174174

175-
static struct meson_ee_pwrc_mem_domain meson_pwrc_mem_eth[] = {
175+
static const struct meson_ee_pwrc_mem_domain meson_pwrc_mem_eth[] = {
176176
{ HHI_MEM_PD_REG0, GENMASK(3, 2) },
177177
};
178178

179-
static struct meson_ee_pwrc_mem_domain meson8_pwrc_audio_dsp_mem[] = {
179+
static const struct meson_ee_pwrc_mem_domain meson8_pwrc_audio_dsp_mem[] = {
180180
{ HHI_MEM_PD_REG0, GENMASK(1, 0) },
181181
};
182182

183-
static struct meson_ee_pwrc_mem_domain meson8_pwrc_mem_vpu[] = {
183+
static const struct meson_ee_pwrc_mem_domain meson8_pwrc_mem_vpu[] = {
184184
VPU_MEMPD(HHI_VPU_MEM_PD_REG0),
185185
VPU_MEMPD(HHI_VPU_MEM_PD_REG1),
186186
VPU_HHI_MEMPD(HHI_MEM_PD_REG0),
187187
};
188188

189-
static struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_vpu[] = {
189+
static const struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_vpu[] = {
190190
VPU_MEMPD(HHI_VPU_MEM_PD_REG0),
191191
VPU_MEMPD(HHI_VPU_MEM_PD_REG1),
192192
VPU_MEMPD(HHI_VPU_MEM_PD_REG2),
@@ -198,28 +198,28 @@ static struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_vpu[] = {
198198
VPU_HHI_MEMPD(HHI_MEM_PD_REG0),
199199
};
200200

201-
static struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_nna[] = {
201+
static const struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_nna[] = {
202202
{ HHI_NANOQ_MEM_PD_REG0, 0xff },
203203
{ HHI_NANOQ_MEM_PD_REG1, 0xff },
204204
};
205205

206-
static struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_usb[] = {
206+
static const struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_usb[] = {
207207
{ HHI_MEM_PD_REG0, GENMASK(31, 30) },
208208
};
209209

210-
static struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_pcie[] = {
210+
static const struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_pcie[] = {
211211
{ HHI_MEM_PD_REG0, GENMASK(29, 26) },
212212
};
213213

214-
static struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_ge2d[] = {
214+
static const struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_ge2d[] = {
215215
{ HHI_MEM_PD_REG0, GENMASK(25, 18) },
216216
};
217217

218-
static struct meson_ee_pwrc_mem_domain axg_pwrc_mem_audio[] = {
218+
static const struct meson_ee_pwrc_mem_domain axg_pwrc_mem_audio[] = {
219219
{ HHI_MEM_PD_REG0, GENMASK(5, 4) },
220220
};
221221

222-
static struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_audio[] = {
222+
static const struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_audio[] = {
223223
{ HHI_MEM_PD_REG0, GENMASK(5, 4) },
224224
{ HHI_AUDIO_MEM_PD_REG0, GENMASK(1, 0) },
225225
{ HHI_AUDIO_MEM_PD_REG0, GENMASK(3, 2) },
@@ -235,12 +235,12 @@ static struct meson_ee_pwrc_mem_domain sm1_pwrc_mem_audio[] = {
235235
{ HHI_AUDIO_MEM_PD_REG0, GENMASK(27, 26) },
236236
};
237237

238-
static struct meson_ee_pwrc_mem_domain g12a_pwrc_mem_nna[] = {
238+
static const struct meson_ee_pwrc_mem_domain g12a_pwrc_mem_nna[] = {
239239
{ G12A_HHI_NANOQ_MEM_PD_REG0, GENMASK(31, 0) },
240240
{ G12A_HHI_NANOQ_MEM_PD_REG1, GENMASK(31, 0) },
241241
};
242242

243-
static struct meson_ee_pwrc_mem_domain g12a_pwrc_mem_isp[] = {
243+
static const struct meson_ee_pwrc_mem_domain g12a_pwrc_mem_isp[] = {
244244
{ G12A_HHI_ISP_MEM_PD_REG0, GENMASK(31, 0) },
245245
{ G12A_HHI_ISP_MEM_PD_REG1, GENMASK(31, 0) },
246246
};
@@ -270,14 +270,14 @@ static struct meson_ee_pwrc_mem_domain g12a_pwrc_mem_isp[] = {
270270

271271
static bool pwrc_ee_is_powered_off(struct meson_ee_pwrc_domain *pwrc_domain);
272272

273-
static struct meson_ee_pwrc_domain_desc axg_pwrc_domains[] = {
273+
static const struct meson_ee_pwrc_domain_desc axg_pwrc_domains[] = {
274274
[PWRC_AXG_VPU_ID] = VPU_PD("VPU", &gx_pwrc_vpu, axg_pwrc_mem_vpu,
275275
pwrc_ee_is_powered_off, 5, 2),
276276
[PWRC_AXG_ETHERNET_MEM_ID] = MEM_PD("ETH", meson_pwrc_mem_eth),
277277
[PWRC_AXG_AUDIO_ID] = MEM_PD("AUDIO", axg_pwrc_mem_audio),
278278
};
279279

280-
static struct meson_ee_pwrc_domain_desc g12a_pwrc_domains[] = {
280+
static const struct meson_ee_pwrc_domain_desc g12a_pwrc_domains[] = {
281281
[PWRC_G12A_VPU_ID] = VPU_PD("VPU", &gx_pwrc_vpu, g12a_pwrc_mem_vpu,
282282
pwrc_ee_is_powered_off, 11, 2),
283283
[PWRC_G12A_ETH_ID] = MEM_PD("ETH", meson_pwrc_mem_eth),
@@ -287,13 +287,13 @@ static struct meson_ee_pwrc_domain_desc g12a_pwrc_domains[] = {
287287
pwrc_ee_is_powered_off),
288288
};
289289

290-
static struct meson_ee_pwrc_domain_desc gxbb_pwrc_domains[] = {
290+
static const struct meson_ee_pwrc_domain_desc gxbb_pwrc_domains[] = {
291291
[PWRC_GXBB_VPU_ID] = VPU_PD("VPU", &gx_pwrc_vpu, gxbb_pwrc_mem_vpu,
292292
pwrc_ee_is_powered_off, 12, 2),
293293
[PWRC_GXBB_ETHERNET_MEM_ID] = MEM_PD("ETH", meson_pwrc_mem_eth),
294294
};
295295

296-
static struct meson_ee_pwrc_domain_desc meson8_pwrc_domains[] = {
296+
static const struct meson_ee_pwrc_domain_desc meson8_pwrc_domains[] = {
297297
[PWRC_MESON8_VPU_ID] = VPU_PD("VPU", &meson8_pwrc_vpu,
298298
meson8_pwrc_mem_vpu,
299299
pwrc_ee_is_powered_off, 0, 1),
@@ -303,7 +303,7 @@ static struct meson_ee_pwrc_domain_desc meson8_pwrc_domains[] = {
303303
meson8_pwrc_audio_dsp_mem),
304304
};
305305

306-
static struct meson_ee_pwrc_domain_desc meson8b_pwrc_domains[] = {
306+
static const struct meson_ee_pwrc_domain_desc meson8b_pwrc_domains[] = {
307307
[PWRC_MESON8_VPU_ID] = VPU_PD("VPU", &meson8_pwrc_vpu,
308308
meson8_pwrc_mem_vpu,
309309
pwrc_ee_is_powered_off, 11, 1),
@@ -313,7 +313,7 @@ static struct meson_ee_pwrc_domain_desc meson8b_pwrc_domains[] = {
313313
meson8_pwrc_audio_dsp_mem),
314314
};
315315

316-
static struct meson_ee_pwrc_domain_desc sm1_pwrc_domains[] = {
316+
static const struct meson_ee_pwrc_domain_desc sm1_pwrc_domains[] = {
317317
[PWRC_SM1_VPU_ID] = VPU_PD("VPU", &sm1_pwrc_vpu, sm1_pwrc_mem_vpu,
318318
pwrc_ee_is_powered_off, 11, 2),
319319
[PWRC_SM1_NNA_ID] = TOP_PD("NNA", &sm1_pwrc_nna, sm1_pwrc_mem_nna,
@@ -576,32 +576,32 @@ static void meson_ee_pwrc_shutdown(struct platform_device *pdev)
576576
}
577577
}
578578

579-
static struct meson_ee_pwrc_domain_data meson_ee_g12a_pwrc_data = {
579+
static const struct meson_ee_pwrc_domain_data meson_ee_g12a_pwrc_data = {
580580
.count = ARRAY_SIZE(g12a_pwrc_domains),
581581
.domains = g12a_pwrc_domains,
582582
};
583583

584-
static struct meson_ee_pwrc_domain_data meson_ee_axg_pwrc_data = {
584+
static const struct meson_ee_pwrc_domain_data meson_ee_axg_pwrc_data = {
585585
.count = ARRAY_SIZE(axg_pwrc_domains),
586586
.domains = axg_pwrc_domains,
587587
};
588588

589-
static struct meson_ee_pwrc_domain_data meson_ee_gxbb_pwrc_data = {
589+
static const struct meson_ee_pwrc_domain_data meson_ee_gxbb_pwrc_data = {
590590
.count = ARRAY_SIZE(gxbb_pwrc_domains),
591591
.domains = gxbb_pwrc_domains,
592592
};
593593

594-
static struct meson_ee_pwrc_domain_data meson_ee_m8_pwrc_data = {
594+
static const struct meson_ee_pwrc_domain_data meson_ee_m8_pwrc_data = {
595595
.count = ARRAY_SIZE(meson8_pwrc_domains),
596596
.domains = meson8_pwrc_domains,
597597
};
598598

599-
static struct meson_ee_pwrc_domain_data meson_ee_m8b_pwrc_data = {
599+
static const struct meson_ee_pwrc_domain_data meson_ee_m8b_pwrc_data = {
600600
.count = ARRAY_SIZE(meson8b_pwrc_domains),
601601
.domains = meson8b_pwrc_domains,
602602
};
603603

604-
static struct meson_ee_pwrc_domain_data meson_ee_sm1_pwrc_data = {
604+
static const struct meson_ee_pwrc_domain_data meson_ee_sm1_pwrc_data = {
605605
.count = ARRAY_SIZE(sm1_pwrc_domains),
606606
.domains = sm1_pwrc_domains,
607607
};

0 commit comments

Comments
 (0)