diff mbox series

[v2,1/4] power: supply: core: Add additional health status values

Message ID 20250429003606.303870-1-W_Armin@gmx.de
State New
Headers show
Series [v2,1/4] power: supply: core: Add additional health status values | expand

Commit Message

Armin Wolf April 29, 2025, 12:36 a.m. UTC
Some batteries can signal when an internal fuse was blown. In such a
case POWER_SUPPLY_HEALTH_DEAD is too vague for userspace applications
to perform meaningful diagnostics.

Additionally some batteries can also signal when some of their
internal cells are imbalanced. In such a case returning
POWER_SUPPLY_HEALTH_UNSPEC_FAILURE is again too vague for userspace
applications to perform meaningful diagnostics.

Add new health status values for both cases.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
Changes since v1:
 - rename "Fuse blown" to "Blown fuse"
 - rename "Cell imbalanced" to "Cell imbalance"
---
 Documentation/ABI/testing/sysfs-class-power | 2 +-
 drivers/power/supply/power_supply_sysfs.c   | 2 ++
 include/linux/power_supply.h                | 2 ++
 3 files changed, 5 insertions(+), 1 deletion(-)

Comments

Ilpo Järvinen May 5, 2025, 12:22 p.m. UTC | #1
On Wed, 30 Apr 2025, Sebastian Reichel wrote:
> On Tue, Apr 29, 2025 at 02:36:03AM +0200, Armin Wolf wrote:
> > Some batteries can signal when an internal fuse was blown. In such a
> > case POWER_SUPPLY_HEALTH_DEAD is too vague for userspace applications
> > to perform meaningful diagnostics.
> > 
> > Additionally some batteries can also signal when some of their
> > internal cells are imbalanced. In such a case returning
> > POWER_SUPPLY_HEALTH_UNSPEC_FAILURE is again too vague for userspace
> > applications to perform meaningful diagnostics.
> > 
> > Add new health status values for both cases.
> > 
> > Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> 
> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

Hi Sebastian,

Is it okay with you I take this through pdx86 tree?

--
 i.

> 
> -- Sebastian
> 
> > ---
> > Changes since v1:
> >  - rename "Fuse blown" to "Blown fuse"
> >  - rename "Cell imbalanced" to "Cell imbalance"
> > ---
> >  Documentation/ABI/testing/sysfs-class-power | 2 +-
> >  drivers/power/supply/power_supply_sysfs.c   | 2 ++
> >  include/linux/power_supply.h                | 2 ++
> >  3 files changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power
> > index 2a5c1a09a28f..be8be54b183d 100644
> > --- a/Documentation/ABI/testing/sysfs-class-power
> > +++ b/Documentation/ABI/testing/sysfs-class-power
> > @@ -456,7 +456,7 @@ Description:
> >  			      "Over voltage", "Under voltage", "Unspecified failure", "Cold",
> >  			      "Watchdog timer expire", "Safety timer expire",
> >  			      "Over current", "Calibration required", "Warm",
> > -			      "Cool", "Hot", "No battery"
> > +			      "Cool", "Hot", "No battery", "Blown fuse", "Cell imbalance"
> >  
> >  What:		/sys/class/power_supply/<supply_name>/precharge_current
> >  Date:		June 2017
> > diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
> > index edb058c19c9c..2703ed1dd943 100644
> > --- a/drivers/power/supply/power_supply_sysfs.c
> > +++ b/drivers/power/supply/power_supply_sysfs.c
> > @@ -110,6 +110,8 @@ static const char * const POWER_SUPPLY_HEALTH_TEXT[] = {
> >  	[POWER_SUPPLY_HEALTH_COOL]		    = "Cool",
> >  	[POWER_SUPPLY_HEALTH_HOT]		    = "Hot",
> >  	[POWER_SUPPLY_HEALTH_NO_BATTERY]	    = "No battery",
> > +	[POWER_SUPPLY_HEALTH_BLOWN_FUSE]	    = "Blown fuse",
> > +	[POWER_SUPPLY_HEALTH_CELL_IMBALANCE]	    = "Cell imbalance",
> >  };
> >  
> >  static const char * const POWER_SUPPLY_TECHNOLOGY_TEXT[] = {
> > diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
> > index 888824592953..69df3a452918 100644
> > --- a/include/linux/power_supply.h
> > +++ b/include/linux/power_supply.h
> > @@ -71,6 +71,8 @@ enum {
> >  	POWER_SUPPLY_HEALTH_COOL,
> >  	POWER_SUPPLY_HEALTH_HOT,
> >  	POWER_SUPPLY_HEALTH_NO_BATTERY,
> > +	POWER_SUPPLY_HEALTH_BLOWN_FUSE,
> > +	POWER_SUPPLY_HEALTH_CELL_IMBALANCE,
> >  };
> >  
> >  enum {
> > -- 
> > 2.39.5
> > 
>
Sebastian Reichel May 11, 2025, 10:22 p.m. UTC | #2
Hi,

On Fri, May 09, 2025 at 01:09:43PM +0300, Ilpo Järvinen wrote:
> On Mon, 5 May 2025, Ilpo Järvinen wrote:
> > On Wed, 30 Apr 2025, Sebastian Reichel wrote:
> > > On Tue, Apr 29, 2025 at 02:36:03AM +0200, Armin Wolf wrote:
> > > > Some batteries can signal when an internal fuse was blown. In such a
> > > > case POWER_SUPPLY_HEALTH_DEAD is too vague for userspace applications
> > > > to perform meaningful diagnostics.
> > > > 
> > > > Additionally some batteries can also signal when some of their
> > > > internal cells are imbalanced. In such a case returning
> > > > POWER_SUPPLY_HEALTH_UNSPEC_FAILURE is again too vague for userspace
> > > > applications to perform meaningful diagnostics.
> > > > 
> > > > Add new health status values for both cases.
> > > > 
> > > > Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> > > 
> > > Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> > 
> > Hi Sebastian,
> > 
> > Is it okay with you I take this through pdx86 tree?
> 
> Ping?

I just checked and that's fine. I don't expect any merge issues.

Greetings,

-- Sebastian

> 
> -- 
>  i.
> 
> > 
> > --
> >  i.
> > 
> > > 
> > > -- Sebastian
> > > 
> > > > ---
> > > > Changes since v1:
> > > >  - rename "Fuse blown" to "Blown fuse"
> > > >  - rename "Cell imbalanced" to "Cell imbalance"
> > > > ---
> > > >  Documentation/ABI/testing/sysfs-class-power | 2 +-
> > > >  drivers/power/supply/power_supply_sysfs.c   | 2 ++
> > > >  include/linux/power_supply.h                | 2 ++
> > > >  3 files changed, 5 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power
> > > > index 2a5c1a09a28f..be8be54b183d 100644
> > > > --- a/Documentation/ABI/testing/sysfs-class-power
> > > > +++ b/Documentation/ABI/testing/sysfs-class-power
> > > > @@ -456,7 +456,7 @@ Description:
> > > >  			      "Over voltage", "Under voltage", "Unspecified failure", "Cold",
> > > >  			      "Watchdog timer expire", "Safety timer expire",
> > > >  			      "Over current", "Calibration required", "Warm",
> > > > -			      "Cool", "Hot", "No battery"
> > > > +			      "Cool", "Hot", "No battery", "Blown fuse", "Cell imbalance"
> > > >  
> > > >  What:		/sys/class/power_supply/<supply_name>/precharge_current
> > > >  Date:		June 2017
> > > > diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
> > > > index edb058c19c9c..2703ed1dd943 100644
> > > > --- a/drivers/power/supply/power_supply_sysfs.c
> > > > +++ b/drivers/power/supply/power_supply_sysfs.c
> > > > @@ -110,6 +110,8 @@ static const char * const POWER_SUPPLY_HEALTH_TEXT[] = {
> > > >  	[POWER_SUPPLY_HEALTH_COOL]		    = "Cool",
> > > >  	[POWER_SUPPLY_HEALTH_HOT]		    = "Hot",
> > > >  	[POWER_SUPPLY_HEALTH_NO_BATTERY]	    = "No battery",
> > > > +	[POWER_SUPPLY_HEALTH_BLOWN_FUSE]	    = "Blown fuse",
> > > > +	[POWER_SUPPLY_HEALTH_CELL_IMBALANCE]	    = "Cell imbalance",
> > > >  };
> > > >  
> > > >  static const char * const POWER_SUPPLY_TECHNOLOGY_TEXT[] = {
> > > > diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
> > > > index 888824592953..69df3a452918 100644
> > > > --- a/include/linux/power_supply.h
> > > > +++ b/include/linux/power_supply.h
> > > > @@ -71,6 +71,8 @@ enum {
> > > >  	POWER_SUPPLY_HEALTH_COOL,
> > > >  	POWER_SUPPLY_HEALTH_HOT,
> > > >  	POWER_SUPPLY_HEALTH_NO_BATTERY,
> > > > +	POWER_SUPPLY_HEALTH_BLOWN_FUSE,
> > > > +	POWER_SUPPLY_HEALTH_CELL_IMBALANCE,
> > > >  };
> > > >  
> > > >  enum {
> > > > -- 
> > > > 2.39.5
> > > > 
> > > 
> >
Ilpo Järvinen May 11, 2025, 10:32 p.m. UTC | #3
On Tue, 29 Apr 2025 02:36:03 +0200, Armin Wolf wrote:

> Some batteries can signal when an internal fuse was blown. In such a
> case POWER_SUPPLY_HEALTH_DEAD is too vague for userspace applications
> to perform meaningful diagnostics.
> 
> Additionally some batteries can also signal when some of their
> internal cells are imbalanced. In such a case returning
> POWER_SUPPLY_HEALTH_UNSPEC_FAILURE is again too vague for userspace
> applications to perform meaningful diagnostics.
> 
> [...]


Thank you for your contribution, it has been applied to my local
review-ilpo-next branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-next branch only once I've pushed my
local branch there, which might take a while.

The list of commits applied:
[1/4] power: supply: core: Add additional health status values
      commit: e6b07a34038716e010d9fd1ac74c1d84a501f369
[2/4] platform/x86: dell-ddv: Implement the battery matching algorithm
      commit: 52e59cf1332dc4da5aecaa64c20f4a9f902e3186
[3/4] platform/x86: dell-ddv: Expose the battery manufacture date to userspace
      commit: 366a50722c7071120a494aaf91c9193922e3d8f6
[4/4] platform/x86: dell-ddv: Expose the battery health to userspace
      commit: d5251eef71bab8bd0b9ea3fe0005ad3d2553c3bb

--
 i.
Armin Wolf May 11, 2025, 10:33 p.m. UTC | #4
Am 12.05.25 um 00:32 schrieb Ilpo Järvinen:

> On Tue, 29 Apr 2025 02:36:03 +0200, Armin Wolf wrote:
>
>> Some batteries can signal when an internal fuse was blown. In such a
>> case POWER_SUPPLY_HEALTH_DEAD is too vague for userspace applications
>> to perform meaningful diagnostics.
>>
>> Additionally some batteries can also signal when some of their
>> internal cells are imbalanced. In such a case returning
>> POWER_SUPPLY_HEALTH_UNSPEC_FAILURE is again too vague for userspace
>> applications to perform meaningful diagnostics.
>>
>> [...]
>
> Thank you for your contribution, it has been applied to my local
> review-ilpo-next branch. Note it will show up in the public
> platform-drivers-x86/review-ilpo-next branch only once I've pushed my
> local branch there, which might take a while.

Thank you :)

> The list of commits applied:
> [1/4] power: supply: core: Add additional health status values
>        commit: e6b07a34038716e010d9fd1ac74c1d84a501f369
> [2/4] platform/x86: dell-ddv: Implement the battery matching algorithm
>        commit: 52e59cf1332dc4da5aecaa64c20f4a9f902e3186
> [3/4] platform/x86: dell-ddv: Expose the battery manufacture date to userspace
>        commit: 366a50722c7071120a494aaf91c9193922e3d8f6
> [4/4] platform/x86: dell-ddv: Expose the battery health to userspace
>        commit: d5251eef71bab8bd0b9ea3fe0005ad3d2553c3bb
>
> --
>   i.
>
diff mbox series

Patch

diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power
index 2a5c1a09a28f..be8be54b183d 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -456,7 +456,7 @@  Description:
 			      "Over voltage", "Under voltage", "Unspecified failure", "Cold",
 			      "Watchdog timer expire", "Safety timer expire",
 			      "Over current", "Calibration required", "Warm",
-			      "Cool", "Hot", "No battery"
+			      "Cool", "Hot", "No battery", "Blown fuse", "Cell imbalance"
 
 What:		/sys/class/power_supply/<supply_name>/precharge_current
 Date:		June 2017
diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
index edb058c19c9c..2703ed1dd943 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -110,6 +110,8 @@  static const char * const POWER_SUPPLY_HEALTH_TEXT[] = {
 	[POWER_SUPPLY_HEALTH_COOL]		    = "Cool",
 	[POWER_SUPPLY_HEALTH_HOT]		    = "Hot",
 	[POWER_SUPPLY_HEALTH_NO_BATTERY]	    = "No battery",
+	[POWER_SUPPLY_HEALTH_BLOWN_FUSE]	    = "Blown fuse",
+	[POWER_SUPPLY_HEALTH_CELL_IMBALANCE]	    = "Cell imbalance",
 };
 
 static const char * const POWER_SUPPLY_TECHNOLOGY_TEXT[] = {
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 888824592953..69df3a452918 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -71,6 +71,8 @@  enum {
 	POWER_SUPPLY_HEALTH_COOL,
 	POWER_SUPPLY_HEALTH_HOT,
 	POWER_SUPPLY_HEALTH_NO_BATTERY,
+	POWER_SUPPLY_HEALTH_BLOWN_FUSE,
+	POWER_SUPPLY_HEALTH_CELL_IMBALANCE,
 };
 
 enum {