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

Configure Feed

Select the types of activity you want to include in your feed.

platform/x86: ideapad-laptop: Support multiple power_supply_ext definitions

Some recent devices supports more charge_types. To properly support
these device without breaking the existing ones, we need to define
multiple power_supply_ext for different GBMD/SBMC interface revisions.

No functional change intended.

Signed-off-by: Rong Zhang <i@rong.moe>
Link: https://patch.msgid.link/20251105182832.104946-4-i@rong.moe
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Rong Zhang and committed by
Ilpo Järvinen
5c54ece0 85901a0d

+23 -12
+23 -12
drivers/platform/x86/lenovo/ideapad-laptop.c
··· 168 168 struct ideapad_dytc_priv *dytc; 169 169 struct dentry *debug; 170 170 struct acpi_battery_hook battery_hook; 171 + const struct power_supply_ext *battery_ext; 171 172 unsigned long cfg; 172 173 unsigned long r_touchpad_val; 173 174 struct { ··· 2071 2070 POWER_SUPPLY_PROP_CHARGE_TYPES, 2072 2071 }; 2073 2072 2074 - static const struct power_supply_ext ideapad_battery_ext = { 2075 - .name = "ideapad_laptop", 2076 - .properties = ideapad_power_supply_props, 2077 - .num_properties = ARRAY_SIZE(ideapad_power_supply_props), 2078 - .charge_types = (BIT(POWER_SUPPLY_CHARGE_TYPE_STANDARD) | 2079 - BIT(POWER_SUPPLY_CHARGE_TYPE_LONGLIFE)), 2080 - .get_property = ideapad_psy_ext_get_prop, 2081 - .set_property = ideapad_psy_ext_set_prop, 2082 - .property_is_writeable = ideapad_psy_prop_is_writeable, 2083 - }; 2073 + #define DEFINE_IDEAPAD_POWER_SUPPLY_EXTENSION(_name, _charge_types) \ 2074 + static const struct power_supply_ext _name = { \ 2075 + .name = "ideapad_laptop", \ 2076 + .properties = ideapad_power_supply_props, \ 2077 + .num_properties = ARRAY_SIZE(ideapad_power_supply_props), \ 2078 + .charge_types = _charge_types, \ 2079 + .get_property = ideapad_psy_ext_get_prop, \ 2080 + .set_property = ideapad_psy_ext_set_prop, \ 2081 + .property_is_writeable = ideapad_psy_prop_is_writeable, \ 2082 + } 2083 + 2084 + DEFINE_IDEAPAD_POWER_SUPPLY_EXTENSION(ideapad_battery_ext_v1, 2085 + (BIT(POWER_SUPPLY_CHARGE_TYPE_STANDARD) | 2086 + BIT(POWER_SUPPLY_CHARGE_TYPE_LONGLIFE)) 2087 + ); 2084 2088 2085 2089 static int ideapad_battery_add(struct power_supply *battery, struct acpi_battery_hook *hook) 2086 2090 { 2087 2091 struct ideapad_private *priv = container_of(hook, struct ideapad_private, battery_hook); 2088 2092 2089 - return power_supply_register_extension(battery, &ideapad_battery_ext, 2093 + return power_supply_register_extension(battery, priv->battery_ext, 2090 2094 &priv->platform_device->dev, priv); 2091 2095 } 2092 2096 2093 2097 static int ideapad_battery_remove(struct power_supply *battery, 2094 2098 struct acpi_battery_hook *hook) 2095 2099 { 2096 - power_supply_unregister_extension(battery, &ideapad_battery_ext); 2100 + struct ideapad_private *priv = container_of(hook, struct ideapad_private, battery_hook); 2101 + 2102 + power_supply_unregister_extension(battery, priv->battery_ext); 2097 2103 2098 2104 return 0; 2099 2105 } ··· 2126 2118 2127 2119 if (acpi_has_method(handle, "GBMD") && acpi_has_method(handle, "SBMC")) { 2128 2120 priv->features.conservation_mode = true; 2121 + 2122 + priv->battery_ext = &ideapad_battery_ext_v1; 2123 + 2129 2124 priv->battery_hook.add_battery = ideapad_battery_add; 2130 2125 priv->battery_hook.remove_battery = ideapad_battery_remove; 2131 2126 priv->battery_hook.name = "Ideapad Battery Extension";