diff mbox

[v2] hwmon: (amc6821) sign extension temperature

Message ID 1479529238-9927-1-git-send-email-matthew.weber@rockwellcollins.com (mailing list archive)
State Accepted
Headers show

Commit Message

Matt Weber Nov. 19, 2016, 4:20 a.m. UTC
From: Jared Bents <jared.bents@rockwellcollins.com>

Converts the unsigned temperature values from the i2c read
to be sign extended as defined in the datasheet so that
negative temperatures are properly read.

Signed-off-by: Jared Bents <jared.bents@rockwellcollins.com>
Signed-off-by: Matt Weber <matthew.weber@rockwellcollins.com>
---
v1 -> v2
 - checkpatch cleanup, removed space between cast
   and function call.  truncated line over 80chars

---
 drivers/hwmon/amc6821.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Guenter Roeck Nov. 19, 2016, 4:25 p.m. UTC | #1
On Fri, Nov 18, 2016 at 10:20:38PM -0600, Matt Weber wrote:
> From: Jared Bents <jared.bents@rockwellcollins.com>
> 
> Converts the unsigned temperature values from the i2c read
> to be sign extended as defined in the datasheet so that
> negative temperatures are properly read.
> 
> Signed-off-by: Jared Bents <jared.bents@rockwellcollins.com>
> Signed-off-by: Matt Weber <matthew.weber@rockwellcollins.com>

Applied.

Guenter

> ---
> v1 -> v2
>  - checkpatch cleanup, removed space between cast
>    and function call.  truncated line over 80chars
> 
> ---
>  drivers/hwmon/amc6821.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/amc6821.c b/drivers/hwmon/amc6821.c
> index 12e851a..eb53e0b 100644
> --- a/drivers/hwmon/amc6821.c
> +++ b/drivers/hwmon/amc6821.c
> @@ -188,7 +188,8 @@ static struct amc6821_data *amc6821_update_device(struct device *dev)
>  			!data->valid) {
>  
>  		for (i = 0; i < TEMP_IDX_LEN; i++)
> -			data->temp[i] = i2c_smbus_read_byte_data(client,
> +			data->temp[i] = (int8_t)i2c_smbus_read_byte_data(
> +				client,
>  				temp_reg[i]);
>  
>  		data->stat1 = i2c_smbus_read_byte_data(client,
--
To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/hwmon/amc6821.c b/drivers/hwmon/amc6821.c
index 12e851a..eb53e0b 100644
--- a/drivers/hwmon/amc6821.c
+++ b/drivers/hwmon/amc6821.c
@@ -188,7 +188,8 @@  static struct amc6821_data *amc6821_update_device(struct device *dev)
 			!data->valid) {
 
 		for (i = 0; i < TEMP_IDX_LEN; i++)
-			data->temp[i] = i2c_smbus_read_byte_data(client,
+			data->temp[i] = (int8_t)i2c_smbus_read_byte_data(
+				client,
 				temp_reg[i]);
 
 		data->stat1 = i2c_smbus_read_byte_data(client,