Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753903AbbDHP01 (ORCPT ); Wed, 8 Apr 2015 11:26:27 -0400 Received: from mga09.intel.com ([134.134.136.24]:54039 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753054AbbDHP0Z (ORCPT ); Wed, 8 Apr 2015 11:26:25 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,545,1422950400"; d="scan'208";a="478388735" From: Irina Tirdea To: Jonathan Cameron , Vlad Dogaru , linux-iio@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Hartmut Knaack , Irina Tirdea Subject: [PATCH] iio: pressure: bmp280: fix temp compensation Date: Wed, 8 Apr 2015 18:26:12 +0300 Message-Id: <1428506772-23710-1-git-send-email-irina.tirdea@intel.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1104 Lines: 32 Temperature reads on bmp280 device always return 0, due to a missing step in the compensation formula (data->tfine is never initialized). Initialize data->tfine value so we get correct temperature and pressure values. Signed-off-by: Irina Tirdea --- drivers/iio/pressure/bmp280.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/pressure/bmp280.c b/drivers/iio/pressure/bmp280.c index 7c623e2..a2602d8 100644 --- a/drivers/iio/pressure/bmp280.c +++ b/drivers/iio/pressure/bmp280.c @@ -172,6 +172,7 @@ static s32 bmp280_compensate_temp(struct bmp280_data *data, var2 = (((((adc_temp >> 4) - ((s32)le16_to_cpu(buf[T1]))) * ((adc_temp >> 4) - ((s32)le16_to_cpu(buf[T1])))) >> 12) * ((s32)(s16)le16_to_cpu(buf[T3]))) >> 14; + data->t_fine = var1 + var2; return (data->t_fine * 5 + 128) >> 8; } -- 1.9.1 -- 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/