public inbox for linux-hwmon@vger.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Tom Levens <tom.levens@cern.ch>
Cc: Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Jean Delvare <jdelvare@suse.com>,
	Mike Looijmans <mike.looijmans@topic.nl>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-hwmon@vger.kernel.org
Subject: Re: [v3,1/3] hwmon: ltc2990: refactor value conversion
Date: Sat, 8 Jul 2017 08:45:15 -0700	[thread overview]
Message-ID: <20170708154515.GA6358@roeck-us.net> (raw)
In-Reply-To: <1499056140-6064-1-git-send-email-tom.levens@cern.ch>

On Mon, Jul 03, 2017 at 06:28:58AM +0200, Tom Levens wrote:
> Conversion from raw values to signed integers has been refactored using
> bitops.h. This also fixes a bug where negative temperatures were
> converted incorrectly.
> 

Documentation/process/submitting-patches.rst, chapter 2: "Solve only one
problem per patch.".

I can understand the urge to merge two sets of changes here. However,
that creates a problem for me: The fix should be applied to stable kernels,
but not the refactoring.

Please split the patch in two, one for the bug fix and one for the
refactoring.

Thanks,
Guenter

> Signed-off-by: Tom Levens <tom.levens@cern.ch>
> ---
>  drivers/hwmon/ltc2990.c | 18 ++++--------------
>  1 file changed, 4 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/hwmon/ltc2990.c b/drivers/hwmon/ltc2990.c
> index 8f8fe05..e320d21 100644
> --- a/drivers/hwmon/ltc2990.c
> +++ b/drivers/hwmon/ltc2990.c
> @@ -11,6 +11,7 @@
>   * the chip's internal temperature and Vcc power supply voltage.
>   */
>  
> +#include <linux/bitops.h>
>  #include <linux/err.h>
>  #include <linux/hwmon.h>
>  #include <linux/hwmon-sysfs.h>
> @@ -34,15 +35,6 @@
>  #define LTC2990_CONTROL_MODE_CURRENT	0x06
>  #define LTC2990_CONTROL_MODE_VOLTAGE	0x07
>  
> -/* convert raw register value to sign-extended integer in 16-bit range */
> -static int ltc2990_voltage_to_int(int raw)
> -{
> -	if (raw & BIT(14))
> -		return -(0x4000 - (raw & 0x3FFF)) << 2;
> -	else
> -		return (raw & 0x3FFF) << 2;
> -}
> -
>  /* Return the converted value from the given register in uV or mC */
>  static int ltc2990_get_value(struct i2c_client *i2c, u8 reg, int *result)
>  {
> @@ -55,18 +47,16 @@ static int ltc2990_get_value(struct i2c_client *i2c, u8 reg, int *result)
>  	switch (reg) {
>  	case LTC2990_TINT_MSB:
>  		/* internal temp, 0.0625 degrees/LSB, 13-bit  */
> -		val = (val & 0x1FFF) << 3;
> -		*result = (val * 1000) >> 7;
> +		*result = sign_extend32(val, 12) * 1000 / 16;
>  		break;
>  	case LTC2990_V1_MSB:
>  	case LTC2990_V3_MSB:
>  		 /* Vx-Vy, 19.42uV/LSB. Depends on mode. */
> -		*result = ltc2990_voltage_to_int(val) * 1942 / (4 * 100);
> +		*result = sign_extend32(val, 14) * 1942 / 100;
>  		break;
>  	case LTC2990_VCC_MSB:
>  		/* Vcc, 305.18μV/LSB, 2.5V offset */
> -		*result = (ltc2990_voltage_to_int(val) * 30518 /
> -			   (4 * 100 * 1000)) + 2500;
> +		*result = sign_extend32(val, 14) * 30518 / (100 * 1000) + 2500;
>  		break;
>  	default:
>  		return -EINVAL; /* won't happen, keep compiler happy */

  parent reply	other threads:[~2017-07-08 15:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-03  4:28 [PATCH v3 1/3] hwmon: ltc2990: refactor value conversion Tom Levens
2017-07-03  4:28 ` [PATCH v3 2/3] hwmon: ltc2990: add devicetree binding Tom Levens
2017-07-07 14:24   ` Rob Herring
2017-07-03  4:29 ` [PATCH v3 3/3] hwmon: ltc2990: support all measurement modes Tom Levens
2017-07-03  6:29   ` Mike Looijmans
2017-07-03 17:09     ` Guenter Roeck
2017-07-11 22:00       ` Tom Levens
2017-07-04 22:45   ` kbuild test robot
2017-07-08 15:45 ` Guenter Roeck [this message]
2017-07-11 22:03   ` [v3,1/3] hwmon: ltc2990: refactor value conversion Tom Levens
2017-07-12  0:39     ` Guenter Roeck

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=20170708154515.GA6358@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=devicetree@vger.kernel.org \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mike.looijmans@topic.nl \
    --cc=robh+dt@kernel.org \
    --cc=tom.levens@cern.ch \
    /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