Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp3915304imb; Wed, 6 Mar 2019 00:16:57 -0800 (PST) X-Google-Smtp-Source: APXvYqzumPfXHgzVhz5JUCclih6wtpfSJgGMC4YVNQkpYdF7+oIAvoJDS+KxZKzO2MiQjjKtlCxB X-Received: by 2002:a63:2d43:: with SMTP id t64mr5140770pgt.155.1551860216928; Wed, 06 Mar 2019 00:16:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551860216; cv=none; d=google.com; s=arc-20160816; b=gJwyZWOePxp+sZF3Yv9vKE4zH3h3LqkmqqT3hjG3fZNdygVtLbBzKYbEsngDcE80g5 y5LTvtPyt5MF/yzWVe2+dhBJdeLZxbdfZnE6Z0W8Ca1+vIwQOTxDHwM5UGTUtsaYPdzR tJkLAojPDOfxISLihk8nfCaL8gQekXW/uVkxGNqbQebiW28n2ln4RE7oMG5N9rG9VfTA O/C3rXGm+FgtXYLHORPTS39iPIJ2pvUn3YwXWHpNJjnqtraG2fb9npypTrz6xNHqmgcj pnD7yfwDSutXTZhtvOruJ/egAX5GnRsVG6rG8IrJJ03RsmB6mxLythNQGyiGDR+p1kue 2jOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:references:message-id:date :subject:cc:to:from; bh=OwaJDi4eSgGOPajQ5rGMSaS2G5W7RTjZIHXwmADWCHs=; b=saWPzzSjIcN4M/9sr6c8K305E90Bz29JRSrGCIEbN50hneuM62nCPoTPbKEcCsaWOj +ccPRaqmFOPjO0AWBaw19ZCubW/xRwvSHy+ZY/PF5c8Tjg4cA/No3tlwaUO7uaYWNTk9 R12SwMvfbvGy7YOW80jlPKuOrwJ+yoQl9sNk7mreEtMHN3zG2rId3a8Ao/bpc0TOTgSg yKoK/Z64p6XWiO8y3xHuUEwmlFYexezFCTYVYfasD2e0nYEwEaDiwpjjiTVAqkpumwf2 K8dPptfy1WXqT1wXJ6xhoo6cyRhx5EznXNgu8LsdjoWIcLivUkyxVpG7SCG0zNZhiNOn KBXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si918124plw.207.2019.03.06.00.16.42; Wed, 06 Mar 2019 00:16:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729214AbfCFHb5 (ORCPT + 99 others); Wed, 6 Mar 2019 02:31:57 -0500 Received: from jax4mhob24.registeredsite.com ([64.69.218.112]:50768 "EHLO jax4mhob24.registeredsite.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728438AbfCFHb4 (ORCPT ); Wed, 6 Mar 2019 02:31:56 -0500 Received: from mailpod.hostingplatform.com ([10.30.71.203]) by jax4mhob24.registeredsite.com (8.14.4/8.14.4) with ESMTP id x267Vrkn133180 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 6 Mar 2019 02:31:54 -0500 Received: (qmail 3948 invoked by uid 0); 6 Mar 2019 07:31:53 -0000 X-TCPREMOTEIP: 81.173.50.109 X-Authenticated-UID: mike@milosoftware.com Received: from unknown (HELO mikebuntu.TOPIC.LOCAL) (mike@milosoftware.com@81.173.50.109) by 0 with ESMTPA; 6 Mar 2019 07:31:53 -0000 From: Mike Looijmans To: linux-iio@vger.kernel.org, himanshujha199640@gmail.com Cc: linux-kernel@vger.kernel.org, jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, dpfrey@gmail.com, colin.king@canonical.com, Mike Looijmans Subject: [PATCH v3 1/2] iio/chemical/bme680: Report temperature in millidegrees Date: Wed, 6 Mar 2019 08:31:47 +0100 Message-Id: <1551857508-4254-1-git-send-email-mike.looijmans@topic.nl> X-Mailer: git-send-email 1.9.1 References: <1550238475-25698-1-git-send-email-mike.looijmans@topic.nl> In-Reply-To: <1550238475-25698-1-git-send-email-mike.looijmans@topic.nl> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The standard unit for temperature is millidegrees Celcius. Adapt the driver to report in millidegrees instead of degrees. Signed-off-by: Mike Looijmans --- v2: Remove unused 'addr7' variable v3: Split patch into temperature and SPI drivers/iio/chemical/bme680_core.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c index 70c1fe4..fefe32b 100644 --- a/drivers/iio/chemical/bme680_core.c +++ b/drivers/iio/chemical/bme680_core.c @@ -583,8 +583,7 @@ static int bme680_gas_config(struct bme680_data *data) return ret; } -static int bme680_read_temp(struct bme680_data *data, - int *val, int *val2) +static int bme680_read_temp(struct bme680_data *data, int *val) { struct device *dev = regmap_get_device(data->regmap); int ret; @@ -617,10 +616,9 @@ static int bme680_read_temp(struct bme680_data *data, * compensate_press/compensate_humid to get compensated * pressure/humidity readings. */ - if (val && val2) { - *val = comp_temp; - *val2 = 100; - return IIO_VAL_FRACTIONAL; + if (val) { + *val = comp_temp * 10; /* Centidegrees to millidegrees */ + return IIO_VAL_INT; } return ret; @@ -635,7 +633,7 @@ static int bme680_read_press(struct bme680_data *data, s32 adc_press; /* Read and compensate temperature to get a reading of t_fine */ - ret = bme680_read_temp(data, NULL, NULL); + ret = bme680_read_temp(data, NULL); if (ret < 0) return ret; @@ -668,7 +666,7 @@ static int bme680_read_humid(struct bme680_data *data, u32 comp_humidity; /* Read and compensate temperature to get a reading of t_fine */ - ret = bme680_read_temp(data, NULL, NULL); + ret = bme680_read_temp(data, NULL); if (ret < 0) return ret; @@ -761,7 +759,7 @@ static int bme680_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_PROCESSED: switch (chan->type) { case IIO_TEMP: - return bme680_read_temp(data, val, val2); + return bme680_read_temp(data, val); case IIO_PRESSURE: return bme680_read_press(data, val, val2); case IIO_HUMIDITYRELATIVE: -- 1.9.1