linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Liam Breck <liam@networkimprov.net>, Sebastian Reichel <sre@kernel.org>
Cc: Tony Lindgren <tony@atomide.com>,
	linux-pm@vger.kernel.org, Liam Breck <kernel@networkimprov.net>
Subject: Re: [PATCH v1 3/7] power: power_supply_core: Add *_battery_info fields for pre- and end-charge current
Date: Wed, 22 Mar 2017 13:12:23 +0100	[thread overview]
Message-ID: <f49f1ca7-8882-65b8-485c-126189069ed8@redhat.com> (raw)
In-Reply-To: <20170321220921.5834-4-liam@networkimprov.net>

Hi,

On 21-03-17 23:09, Liam Breck wrote:
> From: Liam Breck <kernel@networkimprov.net>
>
> Battery chargers use precharge_current_ua and endcharge_current_ua
> at the beginning and end of a charging cycle. These values are set
> according to battery capacity.
>
> Depends-on: https://patchwork.kernel.org/patch/9633613/
> Signed-off-by: Liam Breck <kernel@networkimprov.net>
> ---
>  drivers/power/supply/power_supply_core.c | 6 ++++++
>  include/linux/power_supply.h             | 5 +++++
>  2 files changed, 11 insertions(+)
>
> diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
> index 61e20b1..17088c5 100644
> --- a/drivers/power/supply/power_supply_core.c
> +++ b/drivers/power/supply/power_supply_core.c
> @@ -498,6 +498,8 @@ int power_supply_get_battery_info(struct power_supply *psy,
>  	info->energy_full_design_uwh = -EINVAL;
>  	info->charge_full_design_uah = -EINVAL;
>  	info->voltage_min_design_uv  = -EINVAL;
> +	info->precharge_current_ua   = -EINVAL;
> +	info->endcharge_current_ua   = -EINVAL;
>
>  	if (!psy->of_node) {
>  		dev_warn(&psy->dev, "%s currently only supports devicetree\n",
> @@ -527,6 +529,10 @@ int power_supply_get_battery_info(struct power_supply *psy,
>  			     &info->charge_full_design_uah);
>  	of_property_read_u32(battery_np, "voltage-min-design-microvolt",
>  			     &info->voltage_min_design_uv);
> +	of_property_read_u32(battery_np, "precharge-current-microamp",
> +			     &info->precharge_current_ua);
> +	of_property_read_u32(battery_np, "endcharge-current-microamp",
> +			     &info->endcharge_current_ua);
>
>  	return 0;
>  }
> diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
> index e84f1d3..864214c 100644
> --- a/include/linux/power_supply.h
> +++ b/include/linux/power_supply.h
> @@ -152,6 +152,9 @@ enum power_supply_property {
>  	POWER_SUPPLY_PROP_MODEL_NAME,
>  	POWER_SUPPLY_PROP_MANUFACTURER,
>  	POWER_SUPPLY_PROP_SERIAL_NUMBER,
> +/* where to place these? inserting above causes sysfs errors */
> +	POWER_SUPPLY_PROP_PRECHARGE_CURRENT,
> +	POWER_SUPPLY_PROP_ENDCHARGE_CURRENT,
>  };
>
>  enum power_supply_type {

Ok, I just checked this and power_supply_sysfs.c contains the following:

static ssize_t power_supply_show_property(struct device *dev,
                                           struct device_attribute *attr,
                                           char *buf) {
	<snip special handling of some options>

         else if (off >= POWER_SUPPLY_PROP_MODEL_NAME)
                 return sprintf(buf, "%s\n", value.strval);

	return sprintf(buf, "%d\n", value.intval);
}

So since the options you are adding are integer options they
should be above POWER_SUPPLY_PROP_MODEL_NAME, note there
are comments in the enum stating this:

enum power_supply_property {
         /* Properties of type `int' */
         POWER_SUPPLY_PROP_STATUS = 0,
<snip>
         /* Properties of type `const char *' */
         POWER_SUPPLY_PROP_MODEL_NAME,
         POWER_SUPPLY_PROP_MANUFACTURER,
         POWER_SUPPLY_PROP_SERIAL_NUMBER,
};

And you also need to update the power_supply_attrs[]
array in drivers/power/supply/power_supply_sysfs.c

I guess missing the latter is what was causing you to see
issues with the sorting order.

Regards,

Hans


> @@ -301,6 +304,8 @@ struct power_supply_battery_info {
>  	int energy_full_design_uwh;	/* microWatt-hours */
>  	int charge_full_design_uah;	/* microAmp-hours */
>  	int voltage_min_design_uv;	/* microVolts */
> +	int precharge_current_ua;	/* microAmps */
> +	int endcharge_current_ua;       /* microAmps */
>  };
>
>  extern struct atomic_notifier_head power_supply_notifier;
>

  reply	other threads:[~2017-03-22 12:12 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-21 22:09 [PATCH v1 0/7] BQ24190 support for power_supply_battery_info and DT binding Liam Breck
2017-03-21 22:09 ` [PATCH v1 1/7] devicetree: power: battery: Add properties for pre-charge and end-charge current Liam Breck
2017-03-24  9:01   ` Sebastian Reichel
2017-03-25  0:34     ` Liam Breck
2017-03-29  0:43       ` Rob Herring
     [not found]   ` <20170321220921.5834-2-liam-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org>
2017-03-22 12:04     ` Hans de Goede
2017-03-29  0:39     ` Rob Herring
2017-03-29  1:42       ` Liam Breck
2017-03-21 22:09 ` [PATCH v1 2/7] devicetree: power: Add docs for TI BQ24190 battery charger Liam Breck
     [not found]   ` <20170321220921.5834-3-liam-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org>
2017-03-22 12:04     ` Hans de Goede
2017-03-29  0:47     ` Rob Herring
2017-03-29  1:48       ` Liam Breck
2017-03-24  9:00   ` Sebastian Reichel
2017-03-21 22:09 ` [PATCH v1 3/7] power: power_supply_core: Add *_battery_info fields for pre- and end-charge current Liam Breck
2017-03-22 12:12   ` Hans de Goede [this message]
2017-03-24  9:07   ` Sebastian Reichel
2017-03-21 22:09 ` [PATCH v1 4/7] power: bq24190_charger: Uniform pm_runtime_get() failure handling Liam Breck
2017-03-22 12:14   ` Hans de Goede
2017-03-22 15:35   ` Tony Lindgren
2017-03-24  9:13   ` Sebastian Reichel
2017-03-21 22:09 ` [PATCH v1 5/7] power: bq24190_charger: Reorder init sequence in probe() Liam Breck
2017-03-22 12:14   ` Hans de Goede
2017-03-22 15:36     ` Tony Lindgren
2017-03-21 22:09 ` [PATCH v1 6/7] power: bq24190_charger: Add power_supply_battery_info and devicetree support Liam Breck
2017-03-22 12:15   ` Hans de Goede
2017-03-24  9:20   ` Sebastian Reichel
2017-03-21 22:09 ` [PATCH v1 7/7] power: bq24190_charger: Set bq24190-battery device .type=unknown Liam Breck
2017-03-22 12:25   ` Hans de Goede
2017-03-22 13:15     ` Hans de Goede
2017-03-22 13:37       ` Liam Breck
2017-03-22 14:41         ` Hans de Goede
2017-03-22 18:33           ` Liam Breck
2017-03-23  8:18             ` Hans de Goede
2017-03-23  8:55               ` Liam Breck
2017-03-22 13:22     ` Liam Breck
2017-03-23 10:52   ` Sebastian Reichel
2017-03-23 11:31     ` Liam Breck
2017-03-23 13:37       ` Sebastian Reichel
2017-03-23 19:05         ` Liam Breck
2017-03-23 20:47     ` Liam Breck
2017-03-24  9:39       ` Sebastian Reichel
2017-03-24 10:44         ` Liam Breck
2017-03-24 11:22           ` Sebastian Reichel
2017-03-24 11:56             ` Liam Breck
2017-03-29 14:12               ` Sebastian Reichel
2017-04-14 22:43     ` Liam Breck

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=f49f1ca7-8882-65b8-485c-126189069ed8@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=kernel@networkimprov.net \
    --cc=liam@networkimprov.net \
    --cc=linux-pm@vger.kernel.org \
    --cc=sre@kernel.org \
    --cc=tony@atomide.com \
    /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).