Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753261AbaFGUrK (ORCPT ); Sat, 7 Jun 2014 16:47:10 -0400 Received: from mail-wi0-f179.google.com ([209.85.212.179]:58997 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752927AbaFGUrI (ORCPT ); Sat, 7 Jun 2014 16:47:08 -0400 From: Fabio Baltieri To: Guenter Roeck , Jean Delvare Cc: Lothar Felten , lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org, Fabio Baltieri Subject: [PATCH] hwmon: (ina2xx) Change register cache to signed Date: Sat, 7 Jun 2014 21:47:01 +0100 Message-Id: <1402174021-25857-1-git-send-email-fabio.baltieri@gmail.com> X-Mailer: git-send-email 1.8.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All devices supported by the ina2xx driver are bidirectional and reports the measured value as a signed 16 bit, but the current driver implementation caches the number as an u16, leading to an incorrect sign extension when reporting to the userspace in ina2xx_get_value(). This patch fixes the problem by using a s16 instead, and has been tested on an INA219. Signed-off-by: Fabio Baltieri --- drivers/hwmon/ina2xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c index 93d26e8..d994280 100644 --- a/drivers/hwmon/ina2xx.c +++ b/drivers/hwmon/ina2xx.c @@ -86,7 +86,7 @@ struct ina2xx_data { unsigned long last_updated; int kind; - u16 regs[INA2XX_MAX_REGISTERS]; + s16 regs[INA2XX_MAX_REGISTERS]; }; static const struct ina2xx_config ina2xx_config[] = { -- 1.8.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/