Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

power: supply: core: constify power_supply_battery_info::ocv_table

The power supply core never modifies the ocv 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-5-c1f721927048@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

authored by

Thomas Weißschuh and committed by
Sebastian Reichel
ce20d5b9 840683c3

+7 -7
+4 -4
drivers/power/supply/power_supply_core.c
··· 777 777 tab_len = size / (2 * sizeof(__be32)); 778 778 info->ocv_table_size[index] = tab_len; 779 779 780 - table = info->ocv_table[index] = 780 + info->ocv_table[index] = table = 781 781 devm_kcalloc(&psy->dev, tab_len, sizeof(*table), GFP_KERNEL); 782 782 if (!info->ocv_table[index]) { 783 783 power_supply_put_battery_info(psy, info); ··· 1093 1093 * 1094 1094 * Return: the battery capacity. 1095 1095 */ 1096 - int power_supply_ocv2cap_simple(struct power_supply_battery_ocv_table *table, 1096 + int power_supply_ocv2cap_simple(const struct power_supply_battery_ocv_table *table, 1097 1097 int table_len, int ocv) 1098 1098 { 1099 1099 int i, high, low; ··· 1118 1118 } 1119 1119 EXPORT_SYMBOL_GPL(power_supply_ocv2cap_simple); 1120 1120 1121 - struct power_supply_battery_ocv_table * 1121 + const struct power_supply_battery_ocv_table * 1122 1122 power_supply_find_ocv2cap_table(struct power_supply_battery_info *info, 1123 1123 int temp, int *table_len) 1124 1124 { ··· 1149 1149 int power_supply_batinfo_ocv2cap(struct power_supply_battery_info *info, 1150 1150 int ocv, int temp) 1151 1151 { 1152 - struct power_supply_battery_ocv_table *table; 1152 + const struct power_supply_battery_ocv_table *table; 1153 1153 int table_len; 1154 1154 1155 1155 table = power_supply_find_ocv2cap_table(info, temp, &table_len);
+3 -3
include/linux/power_supply.h
··· 750 750 int temp_alert_max; 751 751 int temp_min; 752 752 int temp_max; 753 - struct power_supply_battery_ocv_table *ocv_table[POWER_SUPPLY_OCV_TEMP_MAX]; 753 + const struct power_supply_battery_ocv_table *ocv_table[POWER_SUPPLY_OCV_TEMP_MAX]; 754 754 int ocv_table_size[POWER_SUPPLY_OCV_TEMP_MAX]; 755 755 const struct power_supply_resistance_temp_table *resist_table; 756 756 int resist_table_size; ··· 797 797 extern int power_supply_battery_info_get_prop(struct power_supply_battery_info *info, 798 798 enum power_supply_property psp, 799 799 union power_supply_propval *val); 800 - extern int power_supply_ocv2cap_simple(struct power_supply_battery_ocv_table *table, 800 + extern int power_supply_ocv2cap_simple(const struct power_supply_battery_ocv_table *table, 801 801 int table_len, int ocv); 802 - extern struct power_supply_battery_ocv_table * 802 + extern const struct power_supply_battery_ocv_table * 803 803 power_supply_find_ocv2cap_table(struct power_supply_battery_info *info, 804 804 int temp, int *table_len); 805 805 extern int power_supply_batinfo_ocv2cap(struct power_supply_battery_info *info,