Commit 71c2cc5c authored by Ricardo B. Marliere's avatar Ricardo B. Marliere Committed by Sebastian Reichel
Browse files

power: supply: core: make power_supply_class constant



Since commit 43a7206b ("driver core: class: make class_register() take
a const *"), the driver core allows for struct class to be in read-only
memory, so move the power_supply_class structure to be declared at build
time placing it into read-only memory, instead of having to be dynamically
allocated at boot time.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarRicardo B. Marliere <ricardo@marliere.net>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20240301-class_cleanup-power-v1-1-97e0b7bf9c94@marliere.net


Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent 9a451f1b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -617,7 +617,7 @@ static int ab8500_btemp_get_ext_psy_data(struct device *dev, void *data)
 */
static void ab8500_btemp_external_power_changed(struct power_supply *psy)
{
	class_for_each_device(power_supply_class, NULL, psy,
	class_for_each_device(&power_supply_class, NULL, psy,
			      ab8500_btemp_get_ext_psy_data);
}

+1 −1
Original line number Diff line number Diff line
@@ -1231,7 +1231,7 @@ static void ab8500_chargalg_algorithm(struct ab8500_chargalg *di)
	int ret;

	/* Collect data from all power_supply class devices */
	class_for_each_device(power_supply_class, NULL,
	class_for_each_device(&power_supply_class, NULL,
		di->chargalg_psy, ab8500_chargalg_get_ext_psy_data);

	ab8500_chargalg_end_of_charge(di);
+1 −1
Original line number Diff line number Diff line
@@ -1949,7 +1949,7 @@ static void ab8500_charger_check_vbat_work(struct work_struct *work)
	struct ab8500_charger *di = container_of(work,
		struct ab8500_charger, check_vbat_work.work);

	class_for_each_device(power_supply_class, NULL,
	class_for_each_device(&power_supply_class, NULL,
			      &di->usb_chg, ab8500_charger_get_ext_psy_data);

	/* First run old_vbat is 0. */
+1 −1
Original line number Diff line number Diff line
@@ -2407,7 +2407,7 @@ static int ab8500_fg_init_hw_registers(struct ab8500_fg *di)
 */
static void ab8500_fg_external_power_changed(struct power_supply *psy)
{
	class_for_each_device(power_supply_class, NULL, psy,
	class_for_each_device(&power_supply_class, NULL, psy,
			      ab8500_fg_get_ext_psy_data);
}

+1 −1
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ static void find_main_battery(void)
	main_battery = NULL;
	bp.main = main_battery;

	error = class_for_each_device(power_supply_class, NULL, &bp,
	error = class_for_each_device(&power_supply_class, NULL, &bp,
				      __find_main_battery);
	if (error) {
		main_battery = bp.main;
Loading