diff options
author | Carl Philipp Klemm <philipp@uvos.xyz> | 2020-10-31 12:56:50 +0100 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2020-12-30 00:40:22 +0100 |
commit | 34fb2a952ba80cab5e331b52ae524b6b71f45cb5 (patch) | |
tree | cf9951bd80b4557c21dab5fdb220b7cb0ad1ffbd /drivers/power/supply/cpcap-battery.c | |
parent | 1027a42c25cbf8cfc4ade6503c5110aae04866af (diff) |
power: supply: cpcap-battery: improve handling of 3rd party batteries.
Adds a module option to ignore a missing temperature sensor.
Useful for 3rd party batteries.
Signed-off-by: Carl Philipp Klemm <carl@uvos.xyz>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power/supply/cpcap-battery.c')
-rw-r--r-- | drivers/power/supply/cpcap-battery.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c index 295611b3b15e..6745a32ca099 100644 --- a/drivers/power/supply/cpcap-battery.c +++ b/drivers/power/supply/cpcap-battery.c @@ -28,6 +28,7 @@ #include <linux/power_supply.h> #include <linux/reboot.h> #include <linux/regmap.h> +#include <linux/moduleparam.h> #include <linux/iio/consumer.h> #include <linux/iio/types.h> @@ -138,6 +139,9 @@ struct cpcap_battery_ddata { #define CPCAP_NO_BATTERY -400 +static bool ignore_temperature_probe; +module_param(ignore_temperature_probe, bool, 0660); + static struct cpcap_battery_state_data * cpcap_battery_get_state(struct cpcap_battery_ddata *ddata, enum cpcap_battery_state state) @@ -169,7 +173,8 @@ static int cpcap_charger_battery_temperature(struct cpcap_battery_ddata *ddata, channel = ddata->channels[CPCAP_BATTERY_IIO_BATTDET]; error = iio_read_channel_processed(channel, value); if (error < 0) { - dev_warn(ddata->dev, "%s failed: %i\n", __func__, error); + if (!ignore_temperature_probe) + dev_warn(ddata->dev, "%s failed: %i\n", __func__, error); *value = CPCAP_NO_BATTERY; return error; @@ -450,7 +455,7 @@ static int cpcap_battery_get_property(struct power_supply *psy, switch (psp) { case POWER_SUPPLY_PROP_PRESENT: - if (latest->temperature > CPCAP_NO_BATTERY) + if (latest->temperature > CPCAP_NO_BATTERY || ignore_temperature_probe) val->intval = 1; else val->intval = 0; @@ -536,6 +541,8 @@ static int cpcap_battery_get_property(struct power_supply *psy, val->intval = POWER_SUPPLY_SCOPE_SYSTEM; break; case POWER_SUPPLY_PROP_TEMP: + if (ignore_temperature_probe) + return -ENODATA; val->intval = latest->temperature; break; default: |