diff options
author | Christophe JAILLET <christophe.jaillet@wanadoo.fr> | 2025-04-04 19:27:38 +0200 |
---|---|---|
committer | Sebastian Reichel <sebastian.reichel@collabora.com> | 2025-04-28 02:07:06 +0200 |
commit | 883730c192b5cf9d72cabefd83bfb3dcd1aadb6f (patch) | |
tree | eea21304048cc1195ad386640ec527021e83d74c | |
parent | afe5301bfbaa0692811da3ba5f8769f599f7ff3f (diff) |
power: supply: wm831x: Constify struct chg_map and some arrays
'struct chg_map' is not modified in this driver.
Constifying these structures moves some data to a read-only section, so
increase overall security.
While at it, also constify a few other arrays.
On a x86_64, with allmodconfig, as an example:
Before:
======
text data bss dec hex filename
14263 1744 0 16007 3e87 drivers/power/supply/wm831x_power.o
After:
=====
text data bss dec hex filename
14695 1288 0 15983 3e6f drivers/power/supply/wm831x_power.o
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/0edde57b691db7f920d121fdbd5ebc3fb24f30f1.1743787625.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
-rw-r--r-- | drivers/power/supply/wm831x_power.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/power/supply/wm831x_power.c b/drivers/power/supply/wm831x_power.c index 538055b29dec..6acdba7885ca 100644 --- a/drivers/power/supply/wm831x_power.c +++ b/drivers/power/supply/wm831x_power.c @@ -89,7 +89,7 @@ static int wm831x_wall_get_prop(struct power_supply *psy, return ret; } -static enum power_supply_property wm831x_wall_props[] = { +static const enum power_supply_property wm831x_wall_props[] = { POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_VOLTAGE_NOW, }; @@ -120,7 +120,7 @@ static int wm831x_usb_get_prop(struct power_supply *psy, return ret; } -static enum power_supply_property wm831x_usb_props[] = { +static const enum power_supply_property wm831x_usb_props[] = { POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_VOLTAGE_NOW, }; @@ -171,21 +171,21 @@ struct chg_map { int reg_val; }; -static struct chg_map trickle_ilims[] = { +static const struct chg_map trickle_ilims[] = { { 50, 0 << WM831X_CHG_TRKL_ILIM_SHIFT }, { 100, 1 << WM831X_CHG_TRKL_ILIM_SHIFT }, { 150, 2 << WM831X_CHG_TRKL_ILIM_SHIFT }, { 200, 3 << WM831X_CHG_TRKL_ILIM_SHIFT }, }; -static struct chg_map vsels[] = { +static const struct chg_map vsels[] = { { 4050, 0 << WM831X_CHG_VSEL_SHIFT }, { 4100, 1 << WM831X_CHG_VSEL_SHIFT }, { 4150, 2 << WM831X_CHG_VSEL_SHIFT }, { 4200, 3 << WM831X_CHG_VSEL_SHIFT }, }; -static struct chg_map fast_ilims[] = { +static const struct chg_map fast_ilims[] = { { 0, 0 << WM831X_CHG_FAST_ILIM_SHIFT }, { 50, 1 << WM831X_CHG_FAST_ILIM_SHIFT }, { 100, 2 << WM831X_CHG_FAST_ILIM_SHIFT }, @@ -204,7 +204,7 @@ static struct chg_map fast_ilims[] = { { 1000, 15 << WM831X_CHG_FAST_ILIM_SHIFT }, }; -static struct chg_map eoc_iterms[] = { +static const struct chg_map eoc_iterms[] = { { 20, 0 << WM831X_CHG_ITERM_SHIFT }, { 30, 1 << WM831X_CHG_ITERM_SHIFT }, { 40, 2 << WM831X_CHG_ITERM_SHIFT }, @@ -215,7 +215,7 @@ static struct chg_map eoc_iterms[] = { { 90, 7 << WM831X_CHG_ITERM_SHIFT }, }; -static struct chg_map chg_times[] = { +static const struct chg_map chg_times[] = { { 60, 0 << WM831X_CHG_TIME_SHIFT }, { 90, 1 << WM831X_CHG_TIME_SHIFT }, { 120, 2 << WM831X_CHG_TIME_SHIFT }, @@ -235,7 +235,7 @@ static struct chg_map chg_times[] = { }; static void wm831x_battery_apply_config(struct wm831x *wm831x, - struct chg_map *map, int count, int val, + const struct chg_map *map, int count, int val, int *reg, const char *name, const char *units) { @@ -462,7 +462,7 @@ static int wm831x_bat_get_prop(struct power_supply *psy, return ret; } -static enum power_supply_property wm831x_bat_props[] = { +static const enum power_supply_property wm831x_bat_props[] = { POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_VOLTAGE_NOW, @@ -470,7 +470,7 @@ static enum power_supply_property wm831x_bat_props[] = { POWER_SUPPLY_PROP_CHARGE_TYPE, }; -static const char *wm831x_bat_irqs[] = { +static const char * const wm831x_bat_irqs[] = { "BATT HOT", "BATT COLD", "BATT FAIL", |