Commit cfff1997 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Rafael J. Wysocki

ACPI: PMIC: Constify struct pmic_table

'struct pmic_table' is not modified in these drivers.

Constifying this structure moves some data to a read-only section, so
increase overall security.

On a x86_64, with allmodconfig, as an example:
Before:
======
   text	   data	    bss	    dec	    hex	filename
   3811	    786	      0	   4597	   11f5	drivers/acpi/pmic/intel_pmic_xpower.o

   text	   data	    bss	    dec	    hex	filename
   4147	    450	      0	   4597	   11f5	drivers/acpi/pmic/intel_pmic_xpower.o
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://patch.msgid.link/a6c9b1bcdf259adabbcaf91183d3f5ab87a98600.1719644292.git.christophe.jaillet@wanadoo.frReviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent f42cfd5c
...@@ -31,7 +31,7 @@ struct intel_pmic_opregion { ...@@ -31,7 +31,7 @@ struct intel_pmic_opregion {
static struct intel_pmic_opregion *intel_pmic_opregion; static struct intel_pmic_opregion *intel_pmic_opregion;
static int pmic_get_reg_bit(int address, struct pmic_table *table, static int pmic_get_reg_bit(int address, const struct pmic_table *table,
int count, int *reg, int *bit) int count, int *reg, int *bit)
{ {
int i; int i;
......
...@@ -21,9 +21,9 @@ struct intel_pmic_opregion_data { ...@@ -21,9 +21,9 @@ struct intel_pmic_opregion_data {
u32 reg_address, u32 value, u32 mask); u32 reg_address, u32 value, u32 mask);
int (*lpat_raw_to_temp)(struct acpi_lpat_conversion_table *lpat_table, int (*lpat_raw_to_temp)(struct acpi_lpat_conversion_table *lpat_table,
int raw); int raw);
struct pmic_table *power_table; const struct pmic_table *power_table;
int power_table_count; int power_table_count;
struct pmic_table *thermal_table; const struct pmic_table *thermal_table;
int thermal_table_count; int thermal_table_count;
/* For generic exec_mipi_pmic_seq_element handling */ /* For generic exec_mipi_pmic_seq_element handling */
int pmic_i2c_address; int pmic_i2c_address;
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#define VSWITCH1_OUTPUT BIT(4) #define VSWITCH1_OUTPUT BIT(4)
#define VUSBPHY_CHARGE BIT(1) #define VUSBPHY_CHARGE BIT(1)
static struct pmic_table power_table[] = { static const struct pmic_table power_table[] = {
{ {
.address = 0x0, .address = 0x0,
.reg = 0x63, .reg = 0x63,
...@@ -177,7 +177,7 @@ static struct pmic_table power_table[] = { ...@@ -177,7 +177,7 @@ static struct pmic_table power_table[] = {
} /* MOFF -> MODEMCTRL Bit 0 */ } /* MOFF -> MODEMCTRL Bit 0 */
}; };
static struct pmic_table thermal_table[] = { static const struct pmic_table thermal_table[] = {
{ {
.address = 0x00, .address = 0x00,
.reg = 0x4F39 .reg = 0x4F39
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#define PMIC_A0LOCK_REG 0xc5 #define PMIC_A0LOCK_REG 0xc5
static struct pmic_table power_table[] = { static const struct pmic_table power_table[] = {
/* { /* {
.address = 0x00, .address = 0x00,
.reg = ??, .reg = ??,
...@@ -134,7 +134,7 @@ static struct pmic_table power_table[] = { ...@@ -134,7 +134,7 @@ static struct pmic_table power_table[] = {
}, /* V105 -> V1P05S, L2 SRAM */ }, /* V105 -> V1P05S, L2 SRAM */
}; };
static struct pmic_table thermal_table[] = { static const struct pmic_table thermal_table[] = {
{ {
.address = 0x00, .address = 0x00,
.reg = 0x75 .reg = 0x75
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#define CHTDC_TI_BPTHERM 0x58 #define CHTDC_TI_BPTHERM 0x58
#define CHTDC_TI_GPADC 0x5a #define CHTDC_TI_GPADC 0x5a
static struct pmic_table chtdc_ti_power_table[] = { static const struct pmic_table chtdc_ti_power_table[] = {
{ .address = 0x00, .reg = 0x41 }, /* LDO1 */ { .address = 0x00, .reg = 0x41 }, /* LDO1 */
{ .address = 0x04, .reg = 0x42 }, /* LDO2 */ { .address = 0x04, .reg = 0x42 }, /* LDO2 */
{ .address = 0x08, .reg = 0x43 }, /* LDO3 */ { .address = 0x08, .reg = 0x43 }, /* LDO3 */
...@@ -39,7 +39,7 @@ static struct pmic_table chtdc_ti_power_table[] = { ...@@ -39,7 +39,7 @@ static struct pmic_table chtdc_ti_power_table[] = {
{ .address = 0x30, .reg = 0x4e }, /* LD14 */ { .address = 0x30, .reg = 0x4e }, /* LD14 */
}; };
static struct pmic_table chtdc_ti_thermal_table[] = { static const struct pmic_table chtdc_ti_thermal_table[] = {
{ {
.address = 0x00, .address = 0x00,
.reg = CHTDC_TI_GPADC .reg = CHTDC_TI_GPADC
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
* "regulator: whiskey_cove: implements Whiskey Cove pmic VRF support" * "regulator: whiskey_cove: implements Whiskey Cove pmic VRF support"
* https://github.com/intel-aero/meta-intel-aero/blob/master/recipes-kernel/linux/linux-yocto/0019-regulator-whiskey_cove-implements-WhiskeyCove-pmic-V.patch * https://github.com/intel-aero/meta-intel-aero/blob/master/recipes-kernel/linux/linux-yocto/0019-regulator-whiskey_cove-implements-WhiskeyCove-pmic-V.patch
*/ */
static struct pmic_table power_table[] = { static const struct pmic_table power_table[] = {
{ {
.address = 0x0, .address = 0x0,
.reg = CHT_WC_V1P8A_CTRL, .reg = CHT_WC_V1P8A_CTRL,
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#define AXP288_ADC_TS_CURRENT_ON_ONDEMAND (2 << 0) #define AXP288_ADC_TS_CURRENT_ON_ONDEMAND (2 << 0)
#define AXP288_ADC_TS_CURRENT_ON (3 << 0) #define AXP288_ADC_TS_CURRENT_ON (3 << 0)
static struct pmic_table power_table[] = { static const struct pmic_table power_table[] = {
{ {
.address = 0x00, .address = 0x00,
.reg = 0x13, .reg = 0x13,
...@@ -129,7 +129,7 @@ static struct pmic_table power_table[] = { ...@@ -129,7 +129,7 @@ static struct pmic_table power_table[] = {
}; };
/* TMP0 - TMP5 are the same, all from GPADC */ /* TMP0 - TMP5 are the same, all from GPADC */
static struct pmic_table thermal_table[] = { static const struct pmic_table thermal_table[] = {
{ {
.address = 0x00, .address = 0x00,
.reg = XPOWER_GPADC_LOW .reg = XPOWER_GPADC_LOW
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment