Skip to content

Commit c266209

Browse files
tititiou36broonie
authored andcommitted
regulator: tps6594-regulator: Constify struct tps6594_regulator_irq_type
'struct tps6594_regulator_irq_type' are not modified in this driver. Constifying this structure moves some data to a read-only section, so increases overall security. On a x86_64, with allmodconfig, as an example: Before: ====== text data bss dec hex filename 25645 14480 64 40189 9cfd drivers/regulator/tps6594-regulator.o After: ===== text data bss dec hex filename 27949 12176 64 40189 9cfd drivers/regulator/tps6594-regulator.o Signed-off-by: Christophe JAILLET <[email protected]> Link: https://patch.msgid.link/1446fb1938f3f38115be3e53f5dda3c8bb0ba5a1.1748103005.git.christophe.jaillet@wanadoo.fr Signed-off-by: Mark Brown <[email protected]>
1 parent 19272b3 commit c266209

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

drivers/regulator/tps6594-regulator.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct tps6594_regulator_irq_type {
5656
unsigned long event;
5757
};
5858

59-
static struct tps6594_regulator_irq_type tps6594_ext_regulator_irq_types[] = {
59+
static const struct tps6594_regulator_irq_type tps6594_ext_regulator_irq_types[] = {
6060
{ TPS6594_IRQ_NAME_VCCA_OV, "VCCA", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
6161
{ TPS6594_IRQ_NAME_VCCA_UV, "VCCA", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE },
6262
{ TPS6594_IRQ_NAME_VMON1_OV, "VMON1", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
@@ -69,7 +69,7 @@ static struct tps6594_regulator_irq_type tps6594_ext_regulator_irq_types[] = {
6969
REGULATOR_EVENT_OVER_VOLTAGE_WARN },
7070
};
7171

72-
static struct tps6594_regulator_irq_type tps65224_ext_regulator_irq_types[] = {
72+
static const struct tps6594_regulator_irq_type tps65224_ext_regulator_irq_types[] = {
7373
{ TPS65224_IRQ_NAME_VCCA_UVOV, "VCCA", "voltage out of range",
7474
REGULATOR_EVENT_REGULATION_OUT },
7575
{ TPS65224_IRQ_NAME_VMON1_UVOV, "VMON1", "voltage out of range",
@@ -80,13 +80,13 @@ static struct tps6594_regulator_irq_type tps65224_ext_regulator_irq_types[] = {
8080

8181
struct tps6594_regulator_irq_data {
8282
struct device *dev;
83-
struct tps6594_regulator_irq_type *type;
83+
const struct tps6594_regulator_irq_type *type;
8484
struct regulator_dev *rdev;
8585
};
8686

8787
struct tps6594_ext_regulator_irq_data {
8888
struct device *dev;
89-
struct tps6594_regulator_irq_type *type;
89+
const struct tps6594_regulator_irq_type *type;
9090
};
9191

9292
#define TPS6594_REGULATOR(_name, _of, _id, _type, _ops, _n, _vr, _vm, _er, \
@@ -262,136 +262,136 @@ static const struct regulator_desc tps65224_buck_regs[] = {
262262
4, 0, 0, NULL, 0, 0),
263263
};
264264

265-
static struct tps6594_regulator_irq_type tps6594_buck1_irq_types[] = {
265+
static const struct tps6594_regulator_irq_type tps6594_buck1_irq_types[] = {
266266
{ TPS6594_IRQ_NAME_BUCK1_OV, "BUCK1", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
267267
{ TPS6594_IRQ_NAME_BUCK1_UV, "BUCK1", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE },
268268
{ TPS6594_IRQ_NAME_BUCK1_SC, "BUCK1", "short circuit", REGULATOR_EVENT_REGULATION_OUT },
269269
{ TPS6594_IRQ_NAME_BUCK1_ILIM, "BUCK1", "reach ilim, overcurrent",
270270
REGULATOR_EVENT_OVER_CURRENT },
271271
};
272272

273-
static struct tps6594_regulator_irq_type tps6594_buck2_irq_types[] = {
273+
static const struct tps6594_regulator_irq_type tps6594_buck2_irq_types[] = {
274274
{ TPS6594_IRQ_NAME_BUCK2_OV, "BUCK2", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
275275
{ TPS6594_IRQ_NAME_BUCK2_UV, "BUCK2", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE },
276276
{ TPS6594_IRQ_NAME_BUCK2_SC, "BUCK2", "short circuit", REGULATOR_EVENT_REGULATION_OUT },
277277
{ TPS6594_IRQ_NAME_BUCK2_ILIM, "BUCK2", "reach ilim, overcurrent",
278278
REGULATOR_EVENT_OVER_CURRENT },
279279
};
280280

281-
static struct tps6594_regulator_irq_type tps6594_buck3_irq_types[] = {
281+
static const struct tps6594_regulator_irq_type tps6594_buck3_irq_types[] = {
282282
{ TPS6594_IRQ_NAME_BUCK3_OV, "BUCK3", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
283283
{ TPS6594_IRQ_NAME_BUCK3_UV, "BUCK3", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE },
284284
{ TPS6594_IRQ_NAME_BUCK3_SC, "BUCK3", "short circuit", REGULATOR_EVENT_REGULATION_OUT },
285285
{ TPS6594_IRQ_NAME_BUCK3_ILIM, "BUCK3", "reach ilim, overcurrent",
286286
REGULATOR_EVENT_OVER_CURRENT },
287287
};
288288

289-
static struct tps6594_regulator_irq_type tps6594_buck4_irq_types[] = {
289+
static const struct tps6594_regulator_irq_type tps6594_buck4_irq_types[] = {
290290
{ TPS6594_IRQ_NAME_BUCK4_OV, "BUCK4", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
291291
{ TPS6594_IRQ_NAME_BUCK4_UV, "BUCK4", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE },
292292
{ TPS6594_IRQ_NAME_BUCK4_SC, "BUCK4", "short circuit", REGULATOR_EVENT_REGULATION_OUT },
293293
{ TPS6594_IRQ_NAME_BUCK4_ILIM, "BUCK4", "reach ilim, overcurrent",
294294
REGULATOR_EVENT_OVER_CURRENT },
295295
};
296296

297-
static struct tps6594_regulator_irq_type tps6594_buck5_irq_types[] = {
297+
static const struct tps6594_regulator_irq_type tps6594_buck5_irq_types[] = {
298298
{ TPS6594_IRQ_NAME_BUCK5_OV, "BUCK5", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
299299
{ TPS6594_IRQ_NAME_BUCK5_UV, "BUCK5", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE },
300300
{ TPS6594_IRQ_NAME_BUCK5_SC, "BUCK5", "short circuit", REGULATOR_EVENT_REGULATION_OUT },
301301
{ TPS6594_IRQ_NAME_BUCK5_ILIM, "BUCK5", "reach ilim, overcurrent",
302302
REGULATOR_EVENT_OVER_CURRENT },
303303
};
304304

305-
static struct tps6594_regulator_irq_type tps6594_ldo1_irq_types[] = {
305+
static const struct tps6594_regulator_irq_type tps6594_ldo1_irq_types[] = {
306306
{ TPS6594_IRQ_NAME_LDO1_OV, "LDO1", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
307307
{ TPS6594_IRQ_NAME_LDO1_UV, "LDO1", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE },
308308
{ TPS6594_IRQ_NAME_LDO1_SC, "LDO1", "short circuit", REGULATOR_EVENT_REGULATION_OUT },
309309
{ TPS6594_IRQ_NAME_LDO1_ILIM, "LDO1", "reach ilim, overcurrent",
310310
REGULATOR_EVENT_OVER_CURRENT },
311311
};
312312

313-
static struct tps6594_regulator_irq_type tps6594_ldo2_irq_types[] = {
313+
static const struct tps6594_regulator_irq_type tps6594_ldo2_irq_types[] = {
314314
{ TPS6594_IRQ_NAME_LDO2_OV, "LDO2", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
315315
{ TPS6594_IRQ_NAME_LDO2_UV, "LDO2", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE },
316316
{ TPS6594_IRQ_NAME_LDO2_SC, "LDO2", "short circuit", REGULATOR_EVENT_REGULATION_OUT },
317317
{ TPS6594_IRQ_NAME_LDO2_ILIM, "LDO2", "reach ilim, overcurrent",
318318
REGULATOR_EVENT_OVER_CURRENT },
319319
};
320320

321-
static struct tps6594_regulator_irq_type tps6594_ldo3_irq_types[] = {
321+
static const struct tps6594_regulator_irq_type tps6594_ldo3_irq_types[] = {
322322
{ TPS6594_IRQ_NAME_LDO3_OV, "LDO3", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
323323
{ TPS6594_IRQ_NAME_LDO3_UV, "LDO3", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE },
324324
{ TPS6594_IRQ_NAME_LDO3_SC, "LDO3", "short circuit", REGULATOR_EVENT_REGULATION_OUT },
325325
{ TPS6594_IRQ_NAME_LDO3_ILIM, "LDO3", "reach ilim, overcurrent",
326326
REGULATOR_EVENT_OVER_CURRENT },
327327
};
328328

329-
static struct tps6594_regulator_irq_type tps6594_ldo4_irq_types[] = {
329+
static const struct tps6594_regulator_irq_type tps6594_ldo4_irq_types[] = {
330330
{ TPS6594_IRQ_NAME_LDO4_OV, "LDO4", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN },
331331
{ TPS6594_IRQ_NAME_LDO4_UV, "LDO4", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE },
332332
{ TPS6594_IRQ_NAME_LDO4_SC, "LDO4", "short circuit", REGULATOR_EVENT_REGULATION_OUT },
333333
{ TPS6594_IRQ_NAME_LDO4_ILIM, "LDO4", "reach ilim, overcurrent",
334334
REGULATOR_EVENT_OVER_CURRENT },
335335
};
336336

337-
static struct tps6594_regulator_irq_type tps65224_buck1_irq_types[] = {
337+
static const struct tps6594_regulator_irq_type tps65224_buck1_irq_types[] = {
338338
{ TPS65224_IRQ_NAME_BUCK1_UVOV, "BUCK1", "voltage out of range",
339339
REGULATOR_EVENT_REGULATION_OUT },
340340
};
341341

342-
static struct tps6594_regulator_irq_type tps65224_buck2_irq_types[] = {
342+
static const struct tps6594_regulator_irq_type tps65224_buck2_irq_types[] = {
343343
{ TPS65224_IRQ_NAME_BUCK2_UVOV, "BUCK2", "voltage out of range",
344344
REGULATOR_EVENT_REGULATION_OUT },
345345
};
346346

347-
static struct tps6594_regulator_irq_type tps65224_buck3_irq_types[] = {
347+
static const struct tps6594_regulator_irq_type tps65224_buck3_irq_types[] = {
348348
{ TPS65224_IRQ_NAME_BUCK3_UVOV, "BUCK3", "voltage out of range",
349349
REGULATOR_EVENT_REGULATION_OUT },
350350
};
351351

352-
static struct tps6594_regulator_irq_type tps65224_buck4_irq_types[] = {
352+
static const struct tps6594_regulator_irq_type tps65224_buck4_irq_types[] = {
353353
{ TPS65224_IRQ_NAME_BUCK4_UVOV, "BUCK4", "voltage out of range",
354354
REGULATOR_EVENT_REGULATION_OUT },
355355
};
356356

357-
static struct tps6594_regulator_irq_type tps65224_ldo1_irq_types[] = {
357+
static const struct tps6594_regulator_irq_type tps65224_ldo1_irq_types[] = {
358358
{ TPS65224_IRQ_NAME_LDO1_UVOV, "LDO1", "voltage out of range",
359359
REGULATOR_EVENT_REGULATION_OUT },
360360
};
361361

362-
static struct tps6594_regulator_irq_type tps65224_ldo2_irq_types[] = {
362+
static const struct tps6594_regulator_irq_type tps65224_ldo2_irq_types[] = {
363363
{ TPS65224_IRQ_NAME_LDO2_UVOV, "LDO2", "voltage out of range",
364364
REGULATOR_EVENT_REGULATION_OUT },
365365
};
366366

367-
static struct tps6594_regulator_irq_type tps65224_ldo3_irq_types[] = {
367+
static const struct tps6594_regulator_irq_type tps65224_ldo3_irq_types[] = {
368368
{ TPS65224_IRQ_NAME_LDO3_UVOV, "LDO3", "voltage out of range",
369369
REGULATOR_EVENT_REGULATION_OUT },
370370
};
371371

372-
static struct tps6594_regulator_irq_type *tps6594_bucks_irq_types[] = {
372+
static const struct tps6594_regulator_irq_type *tps6594_bucks_irq_types[] = {
373373
tps6594_buck1_irq_types,
374374
tps6594_buck2_irq_types,
375375
tps6594_buck3_irq_types,
376376
tps6594_buck4_irq_types,
377377
tps6594_buck5_irq_types,
378378
};
379379

380-
static struct tps6594_regulator_irq_type *tps6594_ldos_irq_types[] = {
380+
static const struct tps6594_regulator_irq_type *tps6594_ldos_irq_types[] = {
381381
tps6594_ldo1_irq_types,
382382
tps6594_ldo2_irq_types,
383383
tps6594_ldo3_irq_types,
384384
tps6594_ldo4_irq_types,
385385
};
386386

387-
static struct tps6594_regulator_irq_type *tps65224_bucks_irq_types[] = {
387+
static const struct tps6594_regulator_irq_type *tps65224_bucks_irq_types[] = {
388388
tps65224_buck1_irq_types,
389389
tps65224_buck2_irq_types,
390390
tps65224_buck3_irq_types,
391391
tps65224_buck4_irq_types,
392392
};
393393

394-
static struct tps6594_regulator_irq_type *tps65224_ldos_irq_types[] = {
394+
static const struct tps6594_regulator_irq_type *tps65224_ldos_irq_types[] = {
395395
tps65224_ldo1_irq_types,
396396
tps65224_ldo2_irq_types,
397397
tps65224_ldo3_irq_types,
@@ -516,11 +516,11 @@ static irqreturn_t tps6594_regulator_irq_handler(int irq, void *data)
516516
static int tps6594_request_reg_irqs(struct platform_device *pdev,
517517
struct regulator_dev *rdev,
518518
struct tps6594_regulator_irq_data *irq_data,
519-
struct tps6594_regulator_irq_type *regs_irq_types,
519+
const struct tps6594_regulator_irq_type *regs_irq_types,
520520
size_t interrupt_cnt,
521521
int *irq_idx)
522522
{
523-
struct tps6594_regulator_irq_type *irq_type;
523+
const struct tps6594_regulator_irq_type *irq_type;
524524
struct tps6594 *tps = dev_get_drvdata(pdev->dev.parent);
525525
size_t j;
526526
int irq;
@@ -558,8 +558,8 @@ static int tps6594_regulator_probe(struct platform_device *pdev)
558558
struct regulator_config config = {};
559559
struct tps6594_regulator_irq_data *irq_data;
560560
struct tps6594_ext_regulator_irq_data *irq_ext_reg_data;
561-
struct tps6594_regulator_irq_type *irq_type;
562-
struct tps6594_regulator_irq_type *irq_types;
561+
const struct tps6594_regulator_irq_type *irq_type;
562+
const struct tps6594_regulator_irq_type *irq_types;
563563
bool buck_configured[BUCK_NB] = { false };
564564
bool buck_multi[MULTI_PHASE_NB] = { false };
565565

@@ -573,9 +573,9 @@ static int tps6594_regulator_probe(struct platform_device *pdev)
573573
unsigned int irq_count;
574574
unsigned int multi_phase_cnt;
575575
size_t reg_irq_nb;
576-
struct tps6594_regulator_irq_type **bucks_irq_types;
576+
const struct tps6594_regulator_irq_type **bucks_irq_types;
577577
const struct regulator_desc *multi_regs;
578-
struct tps6594_regulator_irq_type **ldos_irq_types;
578+
const struct tps6594_regulator_irq_type **ldos_irq_types;
579579
const struct regulator_desc *ldo_regs;
580580
size_t interrupt_count;
581581

0 commit comments

Comments
 (0)