* [PATCH 1/1] power: supply: cpcap-battery: improve handling of 3rd party batteries.
@ 2020-10-31 11:56 Carl Philipp Klemm
2020-11-10 13:40 ` Tony Lindgren
0 siblings, 1 reply; 2+ messages in thread
From: Carl Philipp Klemm @ 2020-10-31 11:56 UTC (permalink / raw)
To: sre; +Cc: linux-omap
Adds a module option to ignore a missing temerature sensor. Usefull for
3rd party batteries.
Signed-off-by: Carl Philipp Klemm <carl@uvos.xyz>
---
diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c
index 3be76cd7584a..8b7978b065df 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>
@@ -162,6 +163,9 @@ static const struct cpcap_battery_capacity cpcap_battery_cap[] = {
#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)
@@ -205,7 +209,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;
@@ -558,7 +562,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;
@@ -658,6 +662,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:
--
Carl Philipp Klemm <philipp@uvos.xyz> <carl@uvos.xyz>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] power: supply: cpcap-battery: improve handling of 3rd party batteries.
2020-10-31 11:56 [PATCH 1/1] power: supply: cpcap-battery: improve handling of 3rd party batteries Carl Philipp Klemm
@ 2020-11-10 13:40 ` Tony Lindgren
0 siblings, 0 replies; 2+ messages in thread
From: Tony Lindgren @ 2020-11-10 13:40 UTC (permalink / raw)
To: Carl Philipp Klemm; +Cc: sre, linux-omap
* Carl Philipp Klemm <philipp@uvos.xyz> [201031 11:57]:
> Adds a module option to ignore a missing temerature sensor. Usefull for
> 3rd party batteries.
Looks OK to me:
Acked-by: Tony Lindgren <tony@atomide.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-10 13:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-31 11:56 [PATCH 1/1] power: supply: cpcap-battery: improve handling of 3rd party batteries Carl Philipp Klemm
2020-11-10 13:40 ` Tony Lindgren
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.