linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	clang-built-linux@googlegroups.com
Subject: Re: [PATCH v4 1/4] power: supply: core: tabularize HWMON temperature labels
Date: Sun, 3 May 2020 00:24:23 +0200	[thread overview]
Message-ID: <20200502222423.5xevejzk5pgwgyiy@earth.universe> (raw)
In-Reply-To: <79bec8125df260bdae294345bd7773dc3dd9c434.1588345420.git.mirq-linux@rere.qmqm.pl>

[-- Attachment #1: Type: text/plain, Size: 1819 bytes --]

Hi,

On Fri, May 01, 2020 at 05:11:18PM +0200, Michał Mirosław wrote:
> Rework power_supply_hwmon_read_string() to check it's parameters.
> This allows to extend it later with labels for other types of
> measurements.
> 
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
> v2: split from fix temperature labels
> v3: remove power_supply_hwmon_read_string() parameter checks
>     as it is internal API (suggested by Guenter Roeck)
> v4: remove unreachable() as it triggers compiler bugs
> ---

Thanks, queued.

-- Sebastian

>  drivers/power/supply/power_supply_hwmon.c | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/power/supply/power_supply_hwmon.c b/drivers/power/supply/power_supply_hwmon.c
> index af72e5693f65..f5d538485aaa 100644
> --- a/drivers/power/supply/power_supply_hwmon.c
> +++ b/drivers/power/supply/power_supply_hwmon.c
> @@ -13,6 +13,11 @@ struct power_supply_hwmon {
>  	unsigned long *props;
>  };
>  
> +static const char *const ps_temp_label[] = {
> +	"temp",
> +	"ambient temp",
> +};
> +
>  static int power_supply_hwmon_in_to_property(u32 attr)
>  {
>  	switch (attr) {
> @@ -180,7 +185,20 @@ static int power_supply_hwmon_read_string(struct device *dev,
>  					  u32 attr, int channel,
>  					  const char **str)
>  {
> -	*str = channel ? "temp ambient" : "temp";
> +	switch (type) {
> +	case hwmon_temp:
> +		*str = ps_temp_label[channel];
> +		break;
> +	default:
> +		/* unreachable, but see:
> +		 * gcc bug #51513 [1] and clang bug #978 [2]
> +		 *
> +		 * [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51513
> +		 * [2] https://github.com/ClangBuiltLinux/linux/issues/978
> +		 */
> +		break;
> +	}
> +
>  	return 0;
>  }
>  
> -- 
> 2.20.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2020-05-02 22:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-01 15:11 [PATCH v4 0/4] power: supply: core: extend with new properties Michał Mirosław
2020-05-01 15:11 ` [PATCH v4 1/4] power: supply: core: tabularize HWMON temperature labels Michał Mirosław
2020-05-02 22:24   ` Sebastian Reichel [this message]
2020-05-01 15:11 ` [PATCH v4 2/4] power: supply: core: add input voltage/current measurements Michał Mirosław
2020-05-02 22:23   ` Sebastian Reichel
2020-05-02 22:45     ` Michał Mirosław
2020-05-02 23:11       ` Michał Mirosław
2020-05-03  0:09         ` Sebastian Reichel
2020-05-01 15:11 ` [PATCH v4 4/4] power: supply: core: document measurement points Michał Mirosław
2020-05-01 15:11 ` [PATCH v4 3/4] power: supply: core: add output voltage measurements Michał Mirosław

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=20200502222423.5xevejzk5pgwgyiy@earth.universe \
    --to=sebastian.reichel@collabora.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mirq-linux@rere.qmqm.pl \
    /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).