Skip to contentSkip to conversation

power: supply: sysfs: Add manufacturing_date,first_usage_date

PATCH shichunyong 2 participants 2 messages Jan 10, 2025 – Jan 16, 2025 Power supply

lore
Share & tools
lore
#0 lore raw

Please help to review, thanks.

-----Original Message-----
From: shichunyong 00013399
Sent: 2024-12-19 17:52
To: '[email protected]' <[email protected]>
Cc: '[email protected]' <[email protected]>; yuanzhen 00013066 <[email protected]>; yangyunmeng 00013317 <[email protected]>; gongxi 00013624 <[email protected]>; yuxuesong 00013800 <[email protected]>
Subject: [PATCH] power: supply: sysfs: Add manufacturing_date,first_usage_date

manufacturing_date/first_usage_date/state_of_health are the battery data required by EU regulations that are accessible for end-users.

manufacturing_date is the date of manufacturing of the battery. first_usage_date is the date of first use of the battery after the set-up of the device by the first user.
Both dates are the seconds since the epoch (1970-01-01 UTC). state_of_health(SoH) is a figure of merit of the condition of a battery, compared to its ideal conditions. The unit of SoH is percent (100% = the battery's conditions match the battery's specifications).

---
 drivers/power/supply/power_supply_sysfs.c | 3 +++
 include/linux/power_supply.h              | 3 +++
 2 files changed, 6 insertions(+)
drivers/power/supply/power_supply_sysfs.c +3 -0
index 571de43fcca9..0550073224f2 100644
@@ -217,6 +217,9 @@ static struct power_supply_attr power_supply_attrs[] __ro_after_init = {
 	POWER_SUPPLY_ATTR(MANUFACTURE_YEAR),
 	POWER_SUPPLY_ATTR(MANUFACTURE_MONTH),
 	POWER_SUPPLY_ATTR(MANUFACTURE_DAY),
+	POWER_SUPPLY_ATTR(MANUFACTURING_DATE),
+	POWER_SUPPLY_ATTR(FIRST_USAGE_DATE),
+	POWER_SUPPLY_ATTR(STATE_OF_HEALTH),
 	/* Properties of type `const char *' */
 	POWER_SUPPLY_ATTR(MODEL_NAME),
 	POWER_SUPPLY_ATTR(MANUFACTURER),
include/linux/power_supply.h +3 -0
index b98106e1a90f..c8d8a8bfbf9f 100644
@@ -170,6 +170,9 @@ enum power_supply_property {
 	POWER_SUPPLY_PROP_MANUFACTURE_YEAR,
 	POWER_SUPPLY_PROP_MANUFACTURE_MONTH,
 	POWER_SUPPLY_PROP_MANUFACTURE_DAY,
+	POWER_SUPPLY_PROP_MANUFACTURING_DATE,
+	POWER_SUPPLY_PROP_FIRST_USAGE_DATE,
+	POWER_SUPPLY_PROP_STATE_OF_HEALTH,
 	/* Properties of type `const char *' */
 	POWER_SUPPLY_PROP_MODEL_NAME,
 	POWER_SUPPLY_PROP_MANUFACTURER,
Signature · 1 line
2.17.1
#1 lore raw

Hi,

Quoted 1 line · shichunyong

Please help to review, thanks.

1. Don't top post, see Documentation/process/submitting-patches.rst and Documentation/process/2.Process.rst.

2. The manufacturing date is already exposable via MANUFACTURE_YEAR + MANUFACTURE_MONTH + MANUFACTURE_DAY properties. It's even visible in the patch context. There is no need for a new property, just use the existing ABI.

3. You did not update Documentation/ABI/testing/sysfs-class-power, which is required for any property added to the power-supply class

4. You are missing a user. If you want to add new power-supply properties you need to either update an existing driver, so that it makes use of the new properties, or submit a new driver using them.

Greetings,

-- Sebastian

Quoted 55 lines

-----Original Message-----
From: shichunyong 00013399
Sent: 2024-12-19 17:52
To: '[email protected]' <[email protected]>
Cc: '[email protected]' <[email protected]>; yuanzhen 00013066 <[email protected]>; yangyunmeng 00013317 <[email protected]>; gongxi 00013624 <[email protected]>; yuxuesong 00013800 <[email protected]>
Subject: [PATCH] power: supply: sysfs: Add manufacturing_date,first_usage_date

manufacturing_date/first_usage_date/state_of_health are the battery data required by EU regulations that are accessible for end-users.

manufacturing_date is the date of manufacturing of the battery. first_usage_date is the date of first use of the battery after the set-up of the device by the first user.
Both dates are the seconds since the epoch (1970-01-01 UTC). state_of_health(SoH) is a figure of merit of the condition of a battery, compared to its ideal conditions. The unit of SoH is percent (100% = the battery's conditions match the battery's specifications).

---
 drivers/power/supply/power_supply_sysfs.c | 3 +++
 include/linux/power_supply.h              | 3 +++
 2 files changed, 6 insertions(+)
drivers/power/supply/power_supply_sysfs.c +3 -0
index 571de43fcca9..0550073224f2 100644
@@ -217,6 +217,9 @@ static struct power_supply_attr power_supply_attrs[] __ro_after_init = {
 	POWER_SUPPLY_ATTR(MANUFACTURE_YEAR),
 	POWER_SUPPLY_ATTR(MANUFACTURE_MONTH),
 	POWER_SUPPLY_ATTR(MANUFACTURE_DAY),
+	POWER_SUPPLY_ATTR(MANUFACTURING_DATE),
+	POWER_SUPPLY_ATTR(FIRST_USAGE_DATE),
+	POWER_SUPPLY_ATTR(STATE_OF_HEALTH),
 	/* Properties of type `const char *' */
 	POWER_SUPPLY_ATTR(MODEL_NAME),
 	POWER_SUPPLY_ATTR(MANUFACTURER),
include/linux/power_supply.h +3 -0
index b98106e1a90f..c8d8a8bfbf9f 100644
@@ -170,6 +170,9 @@ enum power_supply_property {
 	POWER_SUPPLY_PROP_MANUFACTURE_YEAR,
 	POWER_SUPPLY_PROP_MANUFACTURE_MONTH,
 	POWER_SUPPLY_PROP_MANUFACTURE_DAY,
+	POWER_SUPPLY_PROP_MANUFACTURING_DATE,
+	POWER_SUPPLY_PROP_FIRST_USAGE_DATE,
+	POWER_SUPPLY_PROP_STATE_OF_HEALTH,
 	/* Properties of type `const char *' */
 	POWER_SUPPLY_PROP_MODEL_NAME,
 	POWER_SUPPLY_PROP_MANUFACTURER,
Signature · 1 line
2.17.1