devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tom Levens <tom.levens@cern.ch>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Tom Levens <tom.levens@cern.ch>,
	jdelvare@suse.com, robh+dt@kernel.org, mark.rutland@arm.com,
	linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v2 1/3] hwmon: ltc2990: refactor value conversion
Date: Thu, 17 Nov 2016 17:23:53 +0100	[thread overview]
Message-ID: <alpine.LRH.2.20.1611171613250.12237@pcbe13573-vm.dyndns.cern.ch> (raw)
In-Reply-To: <86c28b4f-c78b-8d3e-5c48-fa42ca614ba4@roeck-us.net>

Hi Guenter,

Thanks for taking the time to review the patch.

On Thu, 17 Nov 2016, Guenter Roeck wrote:

> Hi Tom,
>
> On 11/17/2016 04:10 AM, Tom Levens wrote:
>>  Conversion from raw values to signed integers has been refactored using
>>  the macros in bitops.h.
>> 
> Please also mention that this fixes a bug in negative temperature 
> conversions.

Yes, of course, I will include the information in v3.

>
>>  Signed-off-by: Tom Levens <tom.levens@cern.ch>
>>  ---
>>   drivers/hwmon/ltc2990.c |   27 ++++++++++-----------------
>>   1 files changed, 10 insertions(+), 17 deletions(-)
>>
>>  diff --git a/drivers/hwmon/ltc2990.c b/drivers/hwmon/ltc2990.c
>>  index 8f8fe05..0ec4102 100644
>>  --- a/drivers/hwmon/ltc2990.c
>>  +++ b/drivers/hwmon/ltc2990.c
>>  @@ -9,8 +9,12 @@
>>    * This driver assumes the chip is wired as a dual current monitor, and
>>    * reports the voltage drop across two series resistors. It also reports
>>    * the chip's internal temperature and Vcc power supply voltage.
>>  + *
>>  + * Value conversion refactored
>>  + * by Tom Levens <tom.levens@cern.ch>
>
> Kind of unusual to do that for minor changes like this. Imagine if everyone would do that.
> The commit log is what gives you credit.

Good point, thanks for the hint. I will remove it from v3.

>>    */
>>
>>  +#include <linux/bitops.h>
>>   #include <linux/err.h>
>>   #include <linux/hwmon.h>
>>   #include <linux/hwmon-sysfs.h>
>>  @@ -34,19 +38,10 @@
>>   #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)
>>  +static int ltc2990_get_value(struct i2c_client *i2c, u8 reg, s32 *result)
>>  {
>>  -	int val;
>>  +	s32 val;
>
> Please just leave the variable type alone. it is also used for the return value
> from i2c_smbus_read_word_swapped(), which is an int, and changing it to s32 
> doesn't really make the code better.

According to i2c.h the return type for i2c_smbus_read_word_swapped() is 
s32, which is why I modified it here. But it could be changed back if you 
think it is better to leave it as an int.

> Can you send me a register map for the chip ? I would like to write a module test.

Here is an example register dump:

00 00 00 00
01 90 07 d0
2c cd 7d 80
7c 29 20 00

The expected values in this case are:

in0_input 	5000
in1_input	610
in2_input	3500
in3_input	-195
in4_input	-299
temp1_input 	25000
temp2_input 	125000
temp3_input	-40000
curr1_input	38840
curr2_input	-12428

Testing with lltc,mode set to <5>, <6> and <7> should give you all 
measurements.

> Thanks,
> Guenter

Cheers,

  reply	other threads:[~2016-11-17 16:23 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-17 12:10 [PATCH v2 1/3] hwmon: ltc2990: refactor value conversion Tom Levens
2016-11-17 12:10 ` [PATCH v2 2/3] hwmon: ltc2990: add devicetree binding Tom Levens
     [not found]   ` <1479384616-12479-2-git-send-email-tom.levens-vJEk5272eHo@public.gmane.org>
2016-11-18 14:50     ` Rob Herring
2016-11-18 15:36       ` Tom Levens
     [not found] ` <1479384616-12479-1-git-send-email-tom.levens-vJEk5272eHo@public.gmane.org>
2016-11-17 12:10   ` [PATCH v2 3/3] hwmon: ltc2990: support all measurement modes Tom Levens
     [not found]     ` <1479384616-12479-3-git-send-email-tom.levens-vJEk5272eHo@public.gmane.org>
2016-11-17 16:56       ` Guenter Roeck
2016-11-17 17:40         ` Mike Looijmans
2016-11-17 18:56           ` Guenter Roeck
2016-11-17 19:52             ` Mike Looijmans
2016-11-17 21:54               ` Guenter Roeck
2016-11-17 23:25                 ` Tom Levens
2016-11-17 23:40                   ` Guenter Roeck
     [not found]                     ` <20161117234024.GA26747-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2016-11-18 12:23                       ` Tom Levens
2016-11-18 14:16                         ` Guenter Roeck
     [not found]         ` <410de6c9-a13e-51f7-4d66-6f4e2537c574-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2017-06-28 14:24           ` Mike Looijmans
2017-06-28 15:01             ` Guenter Roeck
     [not found]               ` <20170628150130.GC30968-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2017-06-28 15:29                 ` Tom Levens
2017-06-28 16:00                   ` Guenter Roeck
     [not found]                     ` <20170628160048.GA8915-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2017-06-28 17:02                       ` Tom Levens
2017-06-28 17:33                         ` Mike Looijmans
     [not found]                           ` <abe96add-88fc-af6c-a5ed-330c7ae422b9-Oq418RWZeHk@public.gmane.org>
2017-06-28 17:55                             ` Guenter Roeck
2017-06-29  7:45                         ` Mike Looijmans
2017-06-29 11:46                           ` Tom Levens
2016-11-17 15:06 ` [PATCH v2 1/3] hwmon: ltc2990: refactor value conversion Guenter Roeck
2016-11-17 16:23   ` Tom Levens [this message]
2016-11-17 16:36     ` Guenter Roeck
2016-11-18  8:18       ` Tom Levens
2016-11-18 14:09         ` Guenter Roeck
2016-11-18 14:17           ` 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=alpine.LRH.2.20.1611171613250.12237@pcbe13573-vm.dyndns.cern.ch \
    --to=tom.levens@cern.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    /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).