2020-06-09 20:37:52

by Tim Wawrzynczak

[permalink] [raw]
Subject: [PATCH 1/2] power: supply: Add new power supply prop for date of manufacture

The Smart Battery Specification v1.1 defines Manufacture Date as one of
its availabe registers. This patch adds this as a property so that
power_supply drivers can support the property and report it in syfs.

Signed-off-by: Tim Wawrzynczak <[email protected]>
Change-Id: I90bf8c67b0cd531f2155404424a98302a1c931d6
---
drivers/power/supply/power_supply_sysfs.c | 3 ++-
include/linux/power_supply.h | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
index f37ad4eae60b9..ac6d9992a8675 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -171,7 +171,7 @@ static ssize_t power_supply_show_property(struct device *dev,
ret = sprintf(buf, "%s\n",
power_supply_scope_text[value.intval]);
break;
- case POWER_SUPPLY_PROP_MODEL_NAME ... POWER_SUPPLY_PROP_SERIAL_NUMBER:
+ case POWER_SUPPLY_PROP_MODEL_NAME ... POWER_SUPPLY_PROP_MANUFACTURE_DATE:
ret = sprintf(buf, "%s\n", value.strval);
break;
default:
@@ -310,6 +310,7 @@ static struct device_attribute power_supply_attrs[] = {
POWER_SUPPLY_ATTR(model_name),
POWER_SUPPLY_ATTR(manufacturer),
POWER_SUPPLY_ATTR(serial_number),
+ POWER_SUPPLY_ATTR(manufacture_date),
};

static struct attribute *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 28413f737e7d0..67839bb0a46b6 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -162,6 +162,7 @@ enum power_supply_property {
POWER_SUPPLY_PROP_MODEL_NAME,
POWER_SUPPLY_PROP_MANUFACTURER,
POWER_SUPPLY_PROP_SERIAL_NUMBER,
+ POWER_SUPPLY_PROP_MANUFACTURE_DATE,
};

enum power_supply_type {
--
2.26.2


2020-06-09 23:33:48

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH 1/2] power: supply: Add new power supply prop for date of manufacture

Hi,

Support for SBS battery manufacturer date is part of power-supply's
pull request for v5.8 with a different API allowing other batteries
to expose less precise information:

https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git/commit/?h=for-next&id=feabe49e46bb556b8d43e28d4a0d459940f7a5cb
https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git/commit/?h=for-next&id=7721c2fd2668c751f9ba33b35db08b86293869e5

-- Sebastian

On Tue, Jun 09, 2020 at 01:22:36PM -0600, Tim Wawrzynczak wrote:
> The Smart Battery Specification v1.1 defines Manufacture Date as one of
> its availabe registers. This patch adds this as a property so that
> power_supply drivers can support the property and report it in syfs.
>
> Signed-off-by: Tim Wawrzynczak <[email protected]>
> Change-Id: I90bf8c67b0cd531f2155404424a98302a1c931d6
> ---
> drivers/power/supply/power_supply_sysfs.c | 3 ++-
> include/linux/power_supply.h | 1 +
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
> index f37ad4eae60b9..ac6d9992a8675 100644
> --- a/drivers/power/supply/power_supply_sysfs.c
> +++ b/drivers/power/supply/power_supply_sysfs.c
> @@ -171,7 +171,7 @@ static ssize_t power_supply_show_property(struct device *dev,
> ret = sprintf(buf, "%s\n",
> power_supply_scope_text[value.intval]);
> break;
> - case POWER_SUPPLY_PROP_MODEL_NAME ... POWER_SUPPLY_PROP_SERIAL_NUMBER:
> + case POWER_SUPPLY_PROP_MODEL_NAME ... POWER_SUPPLY_PROP_MANUFACTURE_DATE:
> ret = sprintf(buf, "%s\n", value.strval);
> break;
> default:
> @@ -310,6 +310,7 @@ static struct device_attribute power_supply_attrs[] = {
> POWER_SUPPLY_ATTR(model_name),
> POWER_SUPPLY_ATTR(manufacturer),
> POWER_SUPPLY_ATTR(serial_number),
> + POWER_SUPPLY_ATTR(manufacture_date),
> };
>
> static struct attribute *
> diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
> index 28413f737e7d0..67839bb0a46b6 100644
> --- a/include/linux/power_supply.h
> +++ b/include/linux/power_supply.h
> @@ -162,6 +162,7 @@ enum power_supply_property {
> POWER_SUPPLY_PROP_MODEL_NAME,
> POWER_SUPPLY_PROP_MANUFACTURER,
> POWER_SUPPLY_PROP_SERIAL_NUMBER,
> + POWER_SUPPLY_PROP_MANUFACTURE_DATE,
> };
>
> enum power_supply_type {
> --
> 2.26.2
>


Attachments:
(No filename) (2.40 kB)
signature.asc (849.00 B)
Download all attachments