Commit 5d55721d authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Sebastian Reichel

power: supply: samsung-sdi-battery: Constify struct power_supply_vbat_ri_table

'struct power_supply_vbat_ri_table' are not modified in this driver.

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

In order to do it, some code also needs to be adjusted to this new const
qualifier.

On a x86_64, with allmodconfig:
Before:
======
$ size drivers/power/supply/samsung-sdi-battery.o
   text	   data	    bss	    dec	    hex	filename
    955	   7664	      0	   8619	   21ab	drivers/power/supply/samsung-sdi-battery.o

After:
=====
$ size drivers/power/supply/samsung-sdi-battery.o
   text	   data	    bss	    dec	    hex	filename
   4055	   4584	      0	   8639	   21bf	drivers/power/supply/samsung-sdi-battery.o
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/d01818abd880bf435d1106a9a6cc11a7a8a3e661.1719125040.git.christophe.jaillet@wanadoo.frSigned-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent db9cc848
...@@ -1024,7 +1024,7 @@ EXPORT_SYMBOL_GPL(power_supply_temp2resist_simple); ...@@ -1024,7 +1024,7 @@ EXPORT_SYMBOL_GPL(power_supply_temp2resist_simple);
int power_supply_vbat2ri(struct power_supply_battery_info *info, int power_supply_vbat2ri(struct power_supply_battery_info *info,
int vbat_uv, bool charging) int vbat_uv, bool charging)
{ {
struct power_supply_vbat_ri_table *vbat2ri; const struct power_supply_vbat_ri_table *vbat2ri;
int table_len; int table_len;
int i, high, low; int i, high, low;
......
...@@ -25,7 +25,7 @@ struct samsung_sdi_battery { ...@@ -25,7 +25,7 @@ struct samsung_sdi_battery {
* tables apply depending on whether we are charging or not. * tables apply depending on whether we are charging or not.
*/ */
static struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb_l1m7flu[] = { static const struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb_l1m7flu[] = {
{ .vbat_uv = 4240000, .ri_uohm = 160000 }, { .vbat_uv = 4240000, .ri_uohm = 160000 },
{ .vbat_uv = 4210000, .ri_uohm = 179000 }, { .vbat_uv = 4210000, .ri_uohm = 179000 },
{ .vbat_uv = 4180000, .ri_uohm = 183000 }, { .vbat_uv = 4180000, .ri_uohm = 183000 },
...@@ -53,7 +53,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb_l1m7flu ...@@ -53,7 +53,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb_l1m7flu
{ .vbat_uv = 3300000, .ri_uohm = 339000 }, { .vbat_uv = 3300000, .ri_uohm = 339000 },
}; };
static struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb_l1m7flu[] = { static const struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb_l1m7flu[] = {
{ .vbat_uv = 4302000, .ri_uohm = 230000 }, { .vbat_uv = 4302000, .ri_uohm = 230000 },
{ .vbat_uv = 4276000, .ri_uohm = 345000 }, { .vbat_uv = 4276000, .ri_uohm = 345000 },
{ .vbat_uv = 4227000, .ri_uohm = 345000 }, { .vbat_uv = 4227000, .ri_uohm = 345000 },
...@@ -73,7 +73,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb_l1m7flu[] ...@@ -73,7 +73,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb_l1m7flu[]
{ .vbat_uv = 3590000, .ri_uohm = 164000 }, { .vbat_uv = 3590000, .ri_uohm = 164000 },
}; };
static struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb425161la[] = { static const struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb425161la[] = {
{ .vbat_uv = 4240000, .ri_uohm = 160000 }, { .vbat_uv = 4240000, .ri_uohm = 160000 },
{ .vbat_uv = 4210000, .ri_uohm = 179000 }, { .vbat_uv = 4210000, .ri_uohm = 179000 },
{ .vbat_uv = 4180000, .ri_uohm = 183000 }, { .vbat_uv = 4180000, .ri_uohm = 183000 },
...@@ -105,7 +105,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb425161la ...@@ -105,7 +105,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb425161la
{ .vbat_uv = 3300000, .ri_uohm = 339000 }, { .vbat_uv = 3300000, .ri_uohm = 339000 },
}; };
static struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb425161la[] = { static const struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb425161la[] = {
{ .vbat_uv = 4345000, .ri_uohm = 230000 }, { .vbat_uv = 4345000, .ri_uohm = 230000 },
{ .vbat_uv = 4329000, .ri_uohm = 238000 }, { .vbat_uv = 4329000, .ri_uohm = 238000 },
{ .vbat_uv = 4314000, .ri_uohm = 225000 }, { .vbat_uv = 4314000, .ri_uohm = 225000 },
...@@ -182,7 +182,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb425161la[] ...@@ -182,7 +182,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb425161la[]
{ .vbat_uv = 3590000, .ri_uohm = 164000 }, { .vbat_uv = 3590000, .ri_uohm = 164000 },
}; };
static struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb425161lu[] = { static const struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb425161lu[] = {
{ .vbat_uv = 4240000, .ri_uohm = 160000 }, { .vbat_uv = 4240000, .ri_uohm = 160000 },
{ .vbat_uv = 4210000, .ri_uohm = 179000 }, { .vbat_uv = 4210000, .ri_uohm = 179000 },
{ .vbat_uv = 4180000, .ri_uohm = 183000 }, { .vbat_uv = 4180000, .ri_uohm = 183000 },
...@@ -214,7 +214,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb425161lu ...@@ -214,7 +214,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb425161lu
{ .vbat_uv = 3300000, .ri_uohm = 339000 }, { .vbat_uv = 3300000, .ri_uohm = 339000 },
}; };
static struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb425161lu[] = { static const struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb425161lu[] = {
{ .vbat_uv = 4346000, .ri_uohm = 293000 }, { .vbat_uv = 4346000, .ri_uohm = 293000 },
{ .vbat_uv = 4336000, .ri_uohm = 290000 }, { .vbat_uv = 4336000, .ri_uohm = 290000 },
{ .vbat_uv = 4315000, .ri_uohm = 274000 }, { .vbat_uv = 4315000, .ri_uohm = 274000 },
...@@ -244,7 +244,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb425161lu[] ...@@ -244,7 +244,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb425161lu[]
{ .vbat_uv = 3590000, .ri_uohm = 164000 }, { .vbat_uv = 3590000, .ri_uohm = 164000 },
}; };
static struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb485159lu[] = { static const struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb485159lu[] = {
{ .vbat_uv = 4240000, .ri_uohm = 160000 }, { .vbat_uv = 4240000, .ri_uohm = 160000 },
{ .vbat_uv = 4210000, .ri_uohm = 179000 }, { .vbat_uv = 4210000, .ri_uohm = 179000 },
{ .vbat_uv = 4180000, .ri_uohm = 183000 }, { .vbat_uv = 4180000, .ri_uohm = 183000 },
...@@ -271,7 +271,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb485159lu ...@@ -271,7 +271,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb485159lu
{ .vbat_uv = 3300000, .ri_uohm = 339000 }, { .vbat_uv = 3300000, .ri_uohm = 339000 },
}; };
static struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb485159lu[] = { static const struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb485159lu[] = {
{ .vbat_uv = 4302000, .ri_uohm = 200000 }, { .vbat_uv = 4302000, .ri_uohm = 200000 },
{ .vbat_uv = 4258000, .ri_uohm = 206000 }, { .vbat_uv = 4258000, .ri_uohm = 206000 },
{ .vbat_uv = 4200000, .ri_uohm = 231000 }, { .vbat_uv = 4200000, .ri_uohm = 231000 },
...@@ -291,7 +291,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb485159lu[] ...@@ -291,7 +291,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb485159lu[]
{ .vbat_uv = 3590000, .ri_uohm = 164000 }, { .vbat_uv = 3590000, .ri_uohm = 164000 },
}; };
static struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb535151vu[] = { static const struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb535151vu[] = {
{ .vbat_uv = 4071000, .ri_uohm = 158000 }, { .vbat_uv = 4071000, .ri_uohm = 158000 },
{ .vbat_uv = 4019000, .ri_uohm = 187000 }, { .vbat_uv = 4019000, .ri_uohm = 187000 },
{ .vbat_uv = 3951000, .ri_uohm = 191000 }, { .vbat_uv = 3951000, .ri_uohm = 191000 },
...@@ -311,7 +311,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb535151vu ...@@ -311,7 +311,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb535151vu
{ .vbat_uv = 3280000, .ri_uohm = 250000 }, { .vbat_uv = 3280000, .ri_uohm = 250000 },
}; };
static struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb535151vu[] = { static const struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb535151vu[] = {
{ .vbat_uv = 4190000, .ri_uohm = 214000 }, { .vbat_uv = 4190000, .ri_uohm = 214000 },
{ .vbat_uv = 4159000, .ri_uohm = 252000 }, { .vbat_uv = 4159000, .ri_uohm = 252000 },
{ .vbat_uv = 4121000, .ri_uohm = 245000 }, { .vbat_uv = 4121000, .ri_uohm = 245000 },
...@@ -331,7 +331,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb535151vu[] ...@@ -331,7 +331,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb535151vu[]
{ .vbat_uv = 3510000, .ri_uohm = 228000 }, { .vbat_uv = 3510000, .ri_uohm = 228000 },
}; };
static struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb585157lu[] = { static const struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb585157lu[] = {
{ .vbat_uv = 4194000, .ri_uohm = 121000 }, { .vbat_uv = 4194000, .ri_uohm = 121000 },
{ .vbat_uv = 4169000, .ri_uohm = 188000 }, { .vbat_uv = 4169000, .ri_uohm = 188000 },
{ .vbat_uv = 4136000, .ri_uohm = 173000 }, { .vbat_uv = 4136000, .ri_uohm = 173000 },
...@@ -401,7 +401,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb585157lu ...@@ -401,7 +401,7 @@ static struct power_supply_vbat_ri_table samsung_vbat2res_discharging_eb585157lu
{ .vbat_uv = 3161000, .ri_uohm = 452000 }, { .vbat_uv = 3161000, .ri_uohm = 452000 },
}; };
static struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb585157lu[] = { static const struct power_supply_vbat_ri_table samsung_vbat2res_charging_eb585157lu[] = {
{ .vbat_uv = 4360000, .ri_uohm = 128000 }, { .vbat_uv = 4360000, .ri_uohm = 128000 },
{ .vbat_uv = 4325000, .ri_uohm = 130000 }, { .vbat_uv = 4325000, .ri_uohm = 130000 },
{ .vbat_uv = 4316000, .ri_uohm = 148000 }, { .vbat_uv = 4316000, .ri_uohm = 148000 },
......
...@@ -755,9 +755,9 @@ struct power_supply_battery_info { ...@@ -755,9 +755,9 @@ struct power_supply_battery_info {
int ocv_table_size[POWER_SUPPLY_OCV_TEMP_MAX]; int ocv_table_size[POWER_SUPPLY_OCV_TEMP_MAX];
struct power_supply_resistance_temp_table *resist_table; struct power_supply_resistance_temp_table *resist_table;
int resist_table_size; int resist_table_size;
struct power_supply_vbat_ri_table *vbat2ri_discharging; const struct power_supply_vbat_ri_table *vbat2ri_discharging;
int vbat2ri_discharging_size; int vbat2ri_discharging_size;
struct power_supply_vbat_ri_table *vbat2ri_charging; const struct power_supply_vbat_ri_table *vbat2ri_charging;
int vbat2ri_charging_size; int vbat2ri_charging_size;
int bti_resistance_ohm; int bti_resistance_ohm;
int bti_resistance_tolerance; int bti_resistance_tolerance;
......
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