Skip to content

Commit 58797ab

Browse files
t-8chsre
authored andcommitted
power: supply: core: constify power_supply_battery_info::resist_table
The power supply core never modifies the resist table. Reflect this in the API, so drivers can mark their static tables as const. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20241005-power-supply-battery-const-v1-1-c1f721927048@weissschuh.net Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
1 parent 9852d85 commit 58797ab

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/power/supply/power_supply_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ int power_supply_get_battery_info(struct power_supply *psy,
798798
goto out_ret_pointer;
799799

800800
info->resist_table_size = len / (2 * sizeof(__be32));
801-
resist_table = info->resist_table = devm_kcalloc(&psy->dev,
801+
info->resist_table = resist_table = devm_kcalloc(&psy->dev,
802802
info->resist_table_size,
803803
sizeof(*resist_table),
804804
GFP_KERNEL);
@@ -982,7 +982,7 @@ EXPORT_SYMBOL_GPL(power_supply_battery_info_get_prop);
982982
*
983983
* Return: the battery internal resistance percent
984984
*/
985-
int power_supply_temp2resist_simple(struct power_supply_resistance_temp_table *table,
985+
int power_supply_temp2resist_simple(const struct power_supply_resistance_temp_table *table,
986986
int table_len, int temp)
987987
{
988988
int i, high, low;

include/linux/power_supply.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ struct power_supply_battery_info {
752752
int temp_max;
753753
struct power_supply_battery_ocv_table *ocv_table[POWER_SUPPLY_OCV_TEMP_MAX];
754754
int ocv_table_size[POWER_SUPPLY_OCV_TEMP_MAX];
755-
struct power_supply_resistance_temp_table *resist_table;
755+
const struct power_supply_resistance_temp_table *resist_table;
756756
int resist_table_size;
757757
const struct power_supply_vbat_ri_table *vbat2ri_discharging;
758758
int vbat2ri_discharging_size;
@@ -805,7 +805,7 @@ power_supply_find_ocv2cap_table(struct power_supply_battery_info *info,
805805
extern int power_supply_batinfo_ocv2cap(struct power_supply_battery_info *info,
806806
int ocv, int temp);
807807
extern int
808-
power_supply_temp2resist_simple(struct power_supply_resistance_temp_table *table,
808+
power_supply_temp2resist_simple(const struct power_supply_resistance_temp_table *table,
809809
int table_len, int temp);
810810
extern int power_supply_vbat2ri(struct power_supply_battery_info *info,
811811
int vbat_uv, bool charging);

0 commit comments

Comments
 (0)