Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <christophe.jaillet@wanadoo.fr>
Link: https://patch.msgid.link/1446fb1938f3f38115be3e53f5dda3c8bb0ba5a1.1748103005.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Christophe JAILLET and committed by
Mark Brown
c266209e 19272b37

+30 -30
+30 -30
drivers/regulator/tps6594-regulator.c
··· 56 56 unsigned long event; 57 57 }; 58 58 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[] = { 60 60 { TPS6594_IRQ_NAME_VCCA_OV, "VCCA", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 61 61 { TPS6594_IRQ_NAME_VCCA_UV, "VCCA", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE }, 62 62 { TPS6594_IRQ_NAME_VMON1_OV, "VMON1", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, ··· 69 69 REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 70 70 }; 71 71 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[] = { 73 73 { TPS65224_IRQ_NAME_VCCA_UVOV, "VCCA", "voltage out of range", 74 74 REGULATOR_EVENT_REGULATION_OUT }, 75 75 { TPS65224_IRQ_NAME_VMON1_UVOV, "VMON1", "voltage out of range", ··· 80 80 81 81 struct tps6594_regulator_irq_data { 82 82 struct device *dev; 83 - struct tps6594_regulator_irq_type *type; 83 + const struct tps6594_regulator_irq_type *type; 84 84 struct regulator_dev *rdev; 85 85 }; 86 86 87 87 struct tps6594_ext_regulator_irq_data { 88 88 struct device *dev; 89 - struct tps6594_regulator_irq_type *type; 89 + const struct tps6594_regulator_irq_type *type; 90 90 }; 91 91 92 92 #define TPS6594_REGULATOR(_name, _of, _id, _type, _ops, _n, _vr, _vm, _er, \ ··· 262 262 4, 0, 0, NULL, 0, 0), 263 263 }; 264 264 265 - static struct tps6594_regulator_irq_type tps6594_buck1_irq_types[] = { 265 + static const struct tps6594_regulator_irq_type tps6594_buck1_irq_types[] = { 266 266 { TPS6594_IRQ_NAME_BUCK1_OV, "BUCK1", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 267 267 { TPS6594_IRQ_NAME_BUCK1_UV, "BUCK1", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE }, 268 268 { TPS6594_IRQ_NAME_BUCK1_SC, "BUCK1", "short circuit", REGULATOR_EVENT_REGULATION_OUT }, ··· 270 270 REGULATOR_EVENT_OVER_CURRENT }, 271 271 }; 272 272 273 - static struct tps6594_regulator_irq_type tps6594_buck2_irq_types[] = { 273 + static const struct tps6594_regulator_irq_type tps6594_buck2_irq_types[] = { 274 274 { TPS6594_IRQ_NAME_BUCK2_OV, "BUCK2", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 275 275 { TPS6594_IRQ_NAME_BUCK2_UV, "BUCK2", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE }, 276 276 { TPS6594_IRQ_NAME_BUCK2_SC, "BUCK2", "short circuit", REGULATOR_EVENT_REGULATION_OUT }, ··· 278 278 REGULATOR_EVENT_OVER_CURRENT }, 279 279 }; 280 280 281 - static struct tps6594_regulator_irq_type tps6594_buck3_irq_types[] = { 281 + static const struct tps6594_regulator_irq_type tps6594_buck3_irq_types[] = { 282 282 { TPS6594_IRQ_NAME_BUCK3_OV, "BUCK3", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 283 283 { TPS6594_IRQ_NAME_BUCK3_UV, "BUCK3", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE }, 284 284 { TPS6594_IRQ_NAME_BUCK3_SC, "BUCK3", "short circuit", REGULATOR_EVENT_REGULATION_OUT }, ··· 286 286 REGULATOR_EVENT_OVER_CURRENT }, 287 287 }; 288 288 289 - static struct tps6594_regulator_irq_type tps6594_buck4_irq_types[] = { 289 + static const struct tps6594_regulator_irq_type tps6594_buck4_irq_types[] = { 290 290 { TPS6594_IRQ_NAME_BUCK4_OV, "BUCK4", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 291 291 { TPS6594_IRQ_NAME_BUCK4_UV, "BUCK4", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE }, 292 292 { TPS6594_IRQ_NAME_BUCK4_SC, "BUCK4", "short circuit", REGULATOR_EVENT_REGULATION_OUT }, ··· 294 294 REGULATOR_EVENT_OVER_CURRENT }, 295 295 }; 296 296 297 - static struct tps6594_regulator_irq_type tps6594_buck5_irq_types[] = { 297 + static const struct tps6594_regulator_irq_type tps6594_buck5_irq_types[] = { 298 298 { TPS6594_IRQ_NAME_BUCK5_OV, "BUCK5", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 299 299 { TPS6594_IRQ_NAME_BUCK5_UV, "BUCK5", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE }, 300 300 { TPS6594_IRQ_NAME_BUCK5_SC, "BUCK5", "short circuit", REGULATOR_EVENT_REGULATION_OUT }, ··· 302 302 REGULATOR_EVENT_OVER_CURRENT }, 303 303 }; 304 304 305 - static struct tps6594_regulator_irq_type tps6594_ldo1_irq_types[] = { 305 + static const struct tps6594_regulator_irq_type tps6594_ldo1_irq_types[] = { 306 306 { TPS6594_IRQ_NAME_LDO1_OV, "LDO1", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 307 307 { TPS6594_IRQ_NAME_LDO1_UV, "LDO1", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE }, 308 308 { TPS6594_IRQ_NAME_LDO1_SC, "LDO1", "short circuit", REGULATOR_EVENT_REGULATION_OUT }, ··· 310 310 REGULATOR_EVENT_OVER_CURRENT }, 311 311 }; 312 312 313 - static struct tps6594_regulator_irq_type tps6594_ldo2_irq_types[] = { 313 + static const struct tps6594_regulator_irq_type tps6594_ldo2_irq_types[] = { 314 314 { TPS6594_IRQ_NAME_LDO2_OV, "LDO2", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 315 315 { TPS6594_IRQ_NAME_LDO2_UV, "LDO2", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE }, 316 316 { TPS6594_IRQ_NAME_LDO2_SC, "LDO2", "short circuit", REGULATOR_EVENT_REGULATION_OUT }, ··· 318 318 REGULATOR_EVENT_OVER_CURRENT }, 319 319 }; 320 320 321 - static struct tps6594_regulator_irq_type tps6594_ldo3_irq_types[] = { 321 + static const struct tps6594_regulator_irq_type tps6594_ldo3_irq_types[] = { 322 322 { TPS6594_IRQ_NAME_LDO3_OV, "LDO3", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 323 323 { TPS6594_IRQ_NAME_LDO3_UV, "LDO3", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE }, 324 324 { TPS6594_IRQ_NAME_LDO3_SC, "LDO3", "short circuit", REGULATOR_EVENT_REGULATION_OUT }, ··· 326 326 REGULATOR_EVENT_OVER_CURRENT }, 327 327 }; 328 328 329 - static struct tps6594_regulator_irq_type tps6594_ldo4_irq_types[] = { 329 + static const struct tps6594_regulator_irq_type tps6594_ldo4_irq_types[] = { 330 330 { TPS6594_IRQ_NAME_LDO4_OV, "LDO4", "overvoltage", REGULATOR_EVENT_OVER_VOLTAGE_WARN }, 331 331 { TPS6594_IRQ_NAME_LDO4_UV, "LDO4", "undervoltage", REGULATOR_EVENT_UNDER_VOLTAGE }, 332 332 { TPS6594_IRQ_NAME_LDO4_SC, "LDO4", "short circuit", REGULATOR_EVENT_REGULATION_OUT }, ··· 334 334 REGULATOR_EVENT_OVER_CURRENT }, 335 335 }; 336 336 337 - static struct tps6594_regulator_irq_type tps65224_buck1_irq_types[] = { 337 + static const struct tps6594_regulator_irq_type tps65224_buck1_irq_types[] = { 338 338 { TPS65224_IRQ_NAME_BUCK1_UVOV, "BUCK1", "voltage out of range", 339 339 REGULATOR_EVENT_REGULATION_OUT }, 340 340 }; 341 341 342 - static struct tps6594_regulator_irq_type tps65224_buck2_irq_types[] = { 342 + static const struct tps6594_regulator_irq_type tps65224_buck2_irq_types[] = { 343 343 { TPS65224_IRQ_NAME_BUCK2_UVOV, "BUCK2", "voltage out of range", 344 344 REGULATOR_EVENT_REGULATION_OUT }, 345 345 }; 346 346 347 - static struct tps6594_regulator_irq_type tps65224_buck3_irq_types[] = { 347 + static const struct tps6594_regulator_irq_type tps65224_buck3_irq_types[] = { 348 348 { TPS65224_IRQ_NAME_BUCK3_UVOV, "BUCK3", "voltage out of range", 349 349 REGULATOR_EVENT_REGULATION_OUT }, 350 350 }; 351 351 352 - static struct tps6594_regulator_irq_type tps65224_buck4_irq_types[] = { 352 + static const struct tps6594_regulator_irq_type tps65224_buck4_irq_types[] = { 353 353 { TPS65224_IRQ_NAME_BUCK4_UVOV, "BUCK4", "voltage out of range", 354 354 REGULATOR_EVENT_REGULATION_OUT }, 355 355 }; 356 356 357 - static struct tps6594_regulator_irq_type tps65224_ldo1_irq_types[] = { 357 + static const struct tps6594_regulator_irq_type tps65224_ldo1_irq_types[] = { 358 358 { TPS65224_IRQ_NAME_LDO1_UVOV, "LDO1", "voltage out of range", 359 359 REGULATOR_EVENT_REGULATION_OUT }, 360 360 }; 361 361 362 - static struct tps6594_regulator_irq_type tps65224_ldo2_irq_types[] = { 362 + static const struct tps6594_regulator_irq_type tps65224_ldo2_irq_types[] = { 363 363 { TPS65224_IRQ_NAME_LDO2_UVOV, "LDO2", "voltage out of range", 364 364 REGULATOR_EVENT_REGULATION_OUT }, 365 365 }; 366 366 367 - static struct tps6594_regulator_irq_type tps65224_ldo3_irq_types[] = { 367 + static const struct tps6594_regulator_irq_type tps65224_ldo3_irq_types[] = { 368 368 { TPS65224_IRQ_NAME_LDO3_UVOV, "LDO3", "voltage out of range", 369 369 REGULATOR_EVENT_REGULATION_OUT }, 370 370 }; 371 371 372 - static struct tps6594_regulator_irq_type *tps6594_bucks_irq_types[] = { 372 + static const struct tps6594_regulator_irq_type *tps6594_bucks_irq_types[] = { 373 373 tps6594_buck1_irq_types, 374 374 tps6594_buck2_irq_types, 375 375 tps6594_buck3_irq_types, ··· 377 377 tps6594_buck5_irq_types, 378 378 }; 379 379 380 - static struct tps6594_regulator_irq_type *tps6594_ldos_irq_types[] = { 380 + static const struct tps6594_regulator_irq_type *tps6594_ldos_irq_types[] = { 381 381 tps6594_ldo1_irq_types, 382 382 tps6594_ldo2_irq_types, 383 383 tps6594_ldo3_irq_types, 384 384 tps6594_ldo4_irq_types, 385 385 }; 386 386 387 - static struct tps6594_regulator_irq_type *tps65224_bucks_irq_types[] = { 387 + static const struct tps6594_regulator_irq_type *tps65224_bucks_irq_types[] = { 388 388 tps65224_buck1_irq_types, 389 389 tps65224_buck2_irq_types, 390 390 tps65224_buck3_irq_types, 391 391 tps65224_buck4_irq_types, 392 392 }; 393 393 394 - static struct tps6594_regulator_irq_type *tps65224_ldos_irq_types[] = { 394 + static const struct tps6594_regulator_irq_type *tps65224_ldos_irq_types[] = { 395 395 tps65224_ldo1_irq_types, 396 396 tps65224_ldo2_irq_types, 397 397 tps65224_ldo3_irq_types, ··· 516 516 static int tps6594_request_reg_irqs(struct platform_device *pdev, 517 517 struct regulator_dev *rdev, 518 518 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, 520 520 size_t interrupt_cnt, 521 521 int *irq_idx) 522 522 { 523 - struct tps6594_regulator_irq_type *irq_type; 523 + const struct tps6594_regulator_irq_type *irq_type; 524 524 struct tps6594 *tps = dev_get_drvdata(pdev->dev.parent); 525 525 size_t j; 526 526 int irq; ··· 558 558 struct regulator_config config = {}; 559 559 struct tps6594_regulator_irq_data *irq_data; 560 560 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; 563 563 bool buck_configured[BUCK_NB] = { false }; 564 564 bool buck_multi[MULTI_PHASE_NB] = { false }; 565 565 ··· 573 573 unsigned int irq_count; 574 574 unsigned int multi_phase_cnt; 575 575 size_t reg_irq_nb; 576 - struct tps6594_regulator_irq_type **bucks_irq_types; 576 + const struct tps6594_regulator_irq_type **bucks_irq_types; 577 577 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; 579 579 const struct regulator_desc *ldo_regs; 580 580 size_t interrupt_count; 581 581