Commit 0b209ec8 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Sebastian Reichel

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

'struct power_supply_maintenance_charge_table' is not modified in this
driver.

Constifying this structure 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
   4055	   4584	      0	   8639	   21bf	drivers/power/supply/samsung-sdi-battery.o

After:
=====
$ size drivers/power/supply/samsung-sdi-battery.o
   text	   data	    bss	    dec	    hex	filename
   4087	   4552	      0	   8639	   21bf	drivers/power/supply/samsung-sdi-battery.o
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/6caafd0ac2556a40405273b1a4badc508ea8e9b0.1719125040.git.christophe.jaillet@wanadoo.frSigned-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent 5d55721d
...@@ -1225,8 +1225,8 @@ static bool ab8500_chargalg_time_to_restart(struct ab8500_chargalg *di) ...@@ -1225,8 +1225,8 @@ static bool ab8500_chargalg_time_to_restart(struct ab8500_chargalg *di)
*/ */
static void ab8500_chargalg_algorithm(struct ab8500_chargalg *di) static void ab8500_chargalg_algorithm(struct ab8500_chargalg *di)
{ {
const struct power_supply_maintenance_charge_table *mt;
struct power_supply_battery_info *bi = di->bm->bi; struct power_supply_battery_info *bi = di->bm->bi;
struct power_supply_maintenance_charge_table *mt;
int charger_status; int charger_status;
int ret; int ret;
......
...@@ -1072,7 +1072,7 @@ int power_supply_vbat2ri(struct power_supply_battery_info *info, ...@@ -1072,7 +1072,7 @@ int power_supply_vbat2ri(struct power_supply_battery_info *info,
} }
EXPORT_SYMBOL_GPL(power_supply_vbat2ri); EXPORT_SYMBOL_GPL(power_supply_vbat2ri);
struct power_supply_maintenance_charge_table * const struct power_supply_maintenance_charge_table *
power_supply_get_maintenance_charging_setting(struct power_supply_battery_info *info, power_supply_get_maintenance_charging_setting(struct power_supply_battery_info *info,
int index) int index)
{ {
......
...@@ -613,7 +613,7 @@ static struct power_supply_battery_ocv_table samsung_ocv_cap_eb585157lu[] = { ...@@ -613,7 +613,7 @@ static struct power_supply_battery_ocv_table samsung_ocv_cap_eb585157lu[] = {
{ .ocv = 3300000, .capacity = 0}, { .ocv = 3300000, .capacity = 0},
}; };
static struct power_supply_maintenance_charge_table samsung_maint_charge_table[] = { static const struct power_supply_maintenance_charge_table samsung_maint_charge_table[] = {
{ {
/* Maintenance charging phase A, 60 hours */ /* Maintenance charging phase A, 60 hours */
.charge_current_max_ua = 600000, .charge_current_max_ua = 600000,
......
...@@ -736,7 +736,7 @@ struct power_supply_battery_info { ...@@ -736,7 +736,7 @@ struct power_supply_battery_info {
int overvoltage_limit_uv; int overvoltage_limit_uv;
int constant_charge_current_max_ua; int constant_charge_current_max_ua;
int constant_charge_voltage_max_uv; int constant_charge_voltage_max_uv;
struct power_supply_maintenance_charge_table *maintenance_charge; const struct power_supply_maintenance_charge_table *maintenance_charge;
int maintenance_charge_size; int maintenance_charge_size;
int alert_low_temp_charge_current_ua; int alert_low_temp_charge_current_ua;
int alert_low_temp_charge_voltage_uv; int alert_low_temp_charge_voltage_uv;
...@@ -810,7 +810,7 @@ power_supply_temp2resist_simple(struct power_supply_resistance_temp_table *table ...@@ -810,7 +810,7 @@ power_supply_temp2resist_simple(struct power_supply_resistance_temp_table *table
int table_len, int temp); int table_len, int temp);
extern int power_supply_vbat2ri(struct power_supply_battery_info *info, extern int power_supply_vbat2ri(struct power_supply_battery_info *info,
int vbat_uv, bool charging); int vbat_uv, bool charging);
extern struct power_supply_maintenance_charge_table * extern const struct power_supply_maintenance_charge_table *
power_supply_get_maintenance_charging_setting(struct power_supply_battery_info *info, int index); power_supply_get_maintenance_charging_setting(struct power_supply_battery_info *info, int index);
extern bool power_supply_battery_bti_in_range(struct power_supply_battery_info *info, extern bool power_supply_battery_bti_in_range(struct power_supply_battery_info *info,
int resistance); int resistance);
...@@ -824,7 +824,7 @@ extern int power_supply_set_battery_charged(struct power_supply *psy); ...@@ -824,7 +824,7 @@ extern int power_supply_set_battery_charged(struct power_supply *psy);
static inline bool static inline bool
power_supply_supports_maintenance_charging(struct power_supply_battery_info *info) power_supply_supports_maintenance_charging(struct power_supply_battery_info *info)
{ {
struct power_supply_maintenance_charge_table *mt; const struct power_supply_maintenance_charge_table *mt;
mt = power_supply_get_maintenance_charging_setting(info, 0); mt = power_supply_get_maintenance_charging_setting(info, 0);
......
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