Commit 883730c1 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Sebastian Reichel
Browse files

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: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/0edde57b691db7f920d121fdbd5ebc3fb24f30f1.1743787625.git.christophe.jaillet@wanadoo.fr


Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent afe5301b
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -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",