devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Dannenberg <dannenberg@ti.com>
To: Laurentiu Palcu <laurentiu.palcu@intel.com>
Cc: "Andrew F. Davis" <afd@ti.com>,
	Sebastian Reichel <sre@kernel.org>,
	Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Krzysztof Kozlowski <k.kozlowski.k@gmail.com>,
	linux-pm@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 02/13] power: bq24257: Add dead battery reporting
Date: Fri, 4 Sep 2015 10:08:38 -0500	[thread overview]
Message-ID: <20150904150838.GA28221@borg> (raw)
In-Reply-To: <20150904132805.GA22335@lpalcu-desk>

On Fri, Sep 04, 2015 at 04:28:05PM +0300, Laurentiu Palcu wrote:
> On Tue, Sep 01, 2015 at 04:16:26PM -0500, Andrew F. Davis wrote:
> > On 09/01/2015 04:04 PM, Andreas Dannenberg wrote:
> > >>>  drivers/power/bq24257_charger.c | 4 ++++
> > >>>  1 file changed, 4 insertions(+)
> > >>>
> > >>>diff --git a/drivers/power/bq24257_charger.c b/drivers/power/bq24257_charger.c
> > >>>index db81356..0b34528 100644
> > >>>--- a/drivers/power/bq24257_charger.c
> > >>>+++ b/drivers/power/bq24257_charger.c
> > >>>@@ -274,6 +274,10 @@ static int bq24257_power_supply_get_property(struct power_supply *psy,
> > >>>  			val->intval = POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE;
> > >>>  			break;
> > >>>
> > >>>+		case FAULT_NO_BAT:
> > >>>+			val->intval = POWER_SUPPLY_HEALTH_DEAD;
> > >>>+			break;
> > >>>+
> > >>
> > >>I think the best thing to do would be to return -ENODEV as suggested by
> > >>power_supply_sysfs.c:305. Also you should probably add the POWER_SUPPLY_PROP_PRESENT
> > >>property check and set intval to 0 when there is no battery.
> > >
> > >Good find with -ENODEV. However in this case here the power supply is
> > >really a combination of a charger and a battery (which could be split
> > >out accordingly but that's a different story). If I were to report
> > >-ENODEV I would basically say the entire power supply is gone which is
> > >not correct IMHO. Even with a missing battery a system is typically
> > >functional as it gets powered through USB and the charger IC is still
> > >there and functioning. So I think I would either leave the reporting
> > >as *_DEAD or skip the patch. I'm curious if there are additional
> > >opinions.
> > >
> > 
> > It looks like returning -ENODEV for one property would not mark the whole
> > device gone, just POWER_SUPPLY_PROP_HEALTH, but I guess that depends on
> > what user-space does with the info. I would think that this is what
> > POWER_SUPPLY_PROP_PRESENT is for but different drivers seem to use it for
> > different things. Anyway, reporting DEAD for a missing battery is probably
> > not the most correct option, maybe drop the patch ( for the cat's sake :) ).
> I'm also in favor of dropping this patch for the same reasons. Also,
> since the latest phones/tablets do not allow battery removal, it's
> highly unlikely we'll even hit this case nowadays. Perhaps, we could use

Hi Laurentiu, ok I'll drop it. Understood about the unlikeliness of a
battery removal for most devices using LiIon during runtime but a more
granular reporting would help in case there is an issue with the HW
itself (loose contact, manufacturing defect in the battery, etc.)

> DEAD if the battery did not charge and the safety timer expired?
> But, if one alters iilimit and sets a limit that's too low for the
> battery to charge in time, that doesn't mean the battery is dead... :/

Yeah unless there is a specific register bit or some very specific
guidance in a device datasheet as how to detect a truly dead battery I
would be a bit hesitant trying to interpret device register values to
derive to such a conclusion. Sometimes algorithms which seem simple are
only simple because one doesn't consider all the corner cases initially
:)

> That's the main reason I'm so reluctant on having properties like charge
> current, charge voltage, or even input current limit, writable in
> sysfs.

Agreed from a safety perspective. And if someone really wants to play
with fire (pun intended) they can always change the driver in their own
copy of the Kernel.

--
Andreas Dannenberg
Texas Instruments Inc


  reply	other threads:[~2015-09-04 15:08 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-01  2:10 [PATCH 00/13] power: bq24257: Add support for bq24250/bq24251 Andreas Dannenberg
2015-09-01  2:10 ` [PATCH 01/13] power: bq24257: Add bit definition for temp sense enable Andreas Dannenberg
2015-09-01 19:42   ` Andrew F. Davis
2015-09-01  2:10 ` [PATCH 02/13] power: bq24257: Add dead battery reporting Andreas Dannenberg
2015-09-01 19:33   ` Andrew F. Davis
2015-09-01 21:04     ` Andreas Dannenberg
2015-09-01 21:16       ` Andrew F. Davis
2015-09-04 13:28         ` Laurentiu Palcu
2015-09-04 15:08           ` Andreas Dannenberg [this message]
2015-09-01  2:10 ` [PATCH 04/13] power: bq24257: Allow manual setting of input current limit Andreas Dannenberg
2015-09-01 19:59   ` Andrew F. Davis
2015-09-02  8:23   ` Laurentiu Palcu
2015-09-01  2:10 ` [PATCH 05/13] power: bq24257: Add SW-based approach for Power Good determination Andreas Dannenberg
2015-09-01 20:01   ` Andrew F. Davis
     [not found]   ` <1441073435-12349-6-git-send-email-dannenberg-l0cyMroinI0@public.gmane.org>
2015-09-02  8:29     ` Laurentiu Palcu
2015-09-01  2:10 ` [PATCH 06/13] power: bq24257: Add over voltage protection setting support Andreas Dannenberg
2015-09-01 20:10   ` Andrew F. Davis
2015-09-01  2:10 ` [PATCH 07/13] power: bq24257: Add VINDPM voltage threshold " Andreas Dannenberg
2015-09-01 20:48   ` Andrew F. Davis
2015-09-01  2:10 ` [PATCH 08/13] power: bq24257: Extend scope of mutex protection Andreas Dannenberg
2015-09-01 20:34   ` Andrew F. Davis
2015-09-01 22:15     ` Andreas Dannenberg
2015-09-01  2:10 ` [PATCH 09/13] power: bq24257: Add charge type setting support Andreas Dannenberg
2015-09-01  2:10 ` [PATCH 10/13] power: bq24257: Add in_ilimit " Andreas Dannenberg
2015-09-01  2:10 ` [PATCH 11/13] power: bq24257: Add various device-specific sysfs properties Andreas Dannenberg
2015-09-01  2:10 ` [PATCH 12/13] power: bq24257: Add platform data based initialization Andreas Dannenberg
2015-09-01  2:10 ` [PATCH 13/13] dt: power: bq24257-charger: Cover additional devices Andreas Dannenberg
     [not found]   ` <1441073435-12349-14-git-send-email-dannenberg-l0cyMroinI0@public.gmane.org>
2015-09-02  5:24     ` Krzysztof Kozlowski
2015-09-02 14:03       ` Andreas Dannenberg
2015-09-03  1:31         ` Krzysztof Kozlowski
2015-09-03  1:47           ` Andreas Dannenberg
2015-09-03  1:57             ` Krzysztof Kozlowski
2015-09-03 16:09               ` Andreas Dannenberg
2015-09-03 23:50                 ` Krzysztof Kozlowski
     [not found] ` <1441073435-12349-1-git-send-email-dannenberg-l0cyMroinI0@public.gmane.org>
2015-09-01  2:10   ` [PATCH 03/13] power: bq24257: Add basic support for bq24250/bq24251 Andreas Dannenberg
2015-09-01 19:48     ` Andrew F. Davis
2015-09-01 21:24       ` Andreas Dannenberg
     [not found]     ` <1441073435-12349-4-git-send-email-dannenberg-l0cyMroinI0@public.gmane.org>
2015-09-02  8:19       ` Laurentiu Palcu
2015-09-02 14:16         ` Andreas Dannenberg
2015-09-02  8:07   ` [PATCH 00/13] power: bq24257: Add " Laurentiu Palcu
2015-09-02 14:09     ` Andreas Dannenberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150904150838.GA28221@borg \
    --to=dannenberg@ti.com \
    --cc=afd@ti.com \
    --cc=dbaryshkov@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dwmw2@infradead.org \
    --cc=k.kozlowski.k@gmail.com \
    --cc=laurentiu.palcu@intel.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).