Linux IIO development
 help / color / mirror / Atom feed
From: Vasileios Amoiridis <vassilisamir@gmail.com>
To: jic23@kernel.org
Cc: dpfrey@gmail.com, himanshujha199640@gmail.com, lars@metafoo.de,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	mike.looijmans@topic.nl, vassilisamir@gmail.com
Subject: [PATCH v3 03/15] iio: chemical: bme680: Drop unnecessary casts and correct adc data types
Date: Mon, 10 Jun 2024 01:38:14 +0200	[thread overview]
Message-ID: <20240609233826.330516-4-vassilisamir@gmail.com> (raw)
In-Reply-To: <20240609233826.330516-1-vassilisamir@gmail.com>

Delete any redundant casts in the code and use unsigned integers for the
raw adc values.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
---
 drivers/iio/chemical/bme680_core.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c
index c1a9ead1397e..577237d4c9f3 100644
--- a/drivers/iio/chemical/bme680_core.c
+++ b/drivers/iio/chemical/bme680_core.c
@@ -335,7 +335,7 @@ static int bme680_read_calib(struct bme680_data *data,
  * output value of "3233" represents 32.33 DegC.
  */
 static s16 bme680_compensate_temp(struct bme680_data *data,
-				  s32 adc_temp)
+				  u32 adc_temp)
 {
 	struct bme680_calib *calib = &data->bme680;
 	s64 var1, var2, var3;
@@ -345,7 +345,7 @@ static s16 bme680_compensate_temp(struct bme680_data *data,
 	if (!calib->par_t2)
 		bme680_read_calib(data, calib);
 
-	var1 = (adc_temp >> 3) - ((s32)calib->par_t1 << 1);
+	var1 = ((s32)adc_temp >> 3) - ((s32)calib->par_t1 << 1);
 	var2 = (var1 * calib->par_t2) >> 11;
 	var3 = ((var1 >> 1) * (var1 >> 1)) >> 12;
 	var3 = (var3 * ((s32)calib->par_t3 << 4)) >> 14;
@@ -410,9 +410,9 @@ static u32 bme680_compensate_humid(struct bme680_data *data,
 	s32 var1, var2, var3, var4, var5, var6, temp_scaled, calc_hum;
 
 	temp_scaled = (data->t_fine * 5 + 128) >> 8;
-	var1 = (adc_humid - ((s32) ((s32) calib->par_h1 * 16))) -
-		(((temp_scaled * (s32) calib->par_h3) / 100) >> 1);
-	var2 = ((s32) calib->par_h2 *
+	var1 = (adc_humid - (((s32)calib->par_h1 * 16))) -
+		(((temp_scaled * calib->par_h3) / 100) >> 1);
+	var2 = (calib->par_h2 *
 		(((temp_scaled * calib->par_h4) / 100) +
 		 (((temp_scaled * ((temp_scaled * calib->par_h5) / 100))
 		   >> 6) / 100) + (1 << 14))) >> 10;
@@ -654,7 +654,7 @@ static int bme680_read_temp(struct bme680_data *data, int *val)
 	struct device *dev = regmap_get_device(data->regmap);
 	int ret;
 	__be32 tmp = 0;
-	s32 adc_temp;
+	u32 adc_temp;
 	s16 comp_temp;
 
 	/* set forced mode to trigger measurement */
@@ -700,7 +700,7 @@ static int bme680_read_press(struct bme680_data *data,
 	struct device *dev = regmap_get_device(data->regmap);
 	int ret;
 	__be32 tmp = 0;
-	s32 adc_press;
+	u32 adc_press;
 
 	/* Read and compensate temperature to get a reading of t_fine */
 	ret = bme680_read_temp(data, NULL);
@@ -732,7 +732,7 @@ static int bme680_read_humid(struct bme680_data *data,
 	struct device *dev = regmap_get_device(data->regmap);
 	int ret;
 	__be16 tmp = 0;
-	s32 adc_humidity;
+	u16 adc_humidity;
 	u32 comp_humidity;
 
 	/* Read and compensate temperature to get a reading of t_fine */
-- 
2.25.1


  parent reply	other threads:[~2024-06-09 23:38 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-09 23:38 [PATCH v3 00/15] iio: chemical: bme680: Driver cleanup Vasileios Amoiridis
2024-06-09 23:38 ` [PATCH v3 01/15] iio: chemical: bme680: Fix read/write ops to device by adding mutexes Vasileios Amoiridis
2024-06-09 23:38 ` [PATCH v3 02/15] iio: chemical: bme680: Fix typo in define Vasileios Amoiridis
2024-06-09 23:38 ` Vasileios Amoiridis [this message]
2024-06-09 23:38 ` [PATCH v3 04/15] iio: chemical: bme680: Remove remaining ACPI-only stuff Vasileios Amoiridis
2024-06-09 23:38 ` [PATCH v3 05/15] iio: chemical: bme680: Sort headers alphabetically Vasileios Amoiridis
2024-06-09 23:38 ` [PATCH v3 06/15] iio: chemical: bme680: Remove duplicate register read Vasileios Amoiridis
2024-06-09 23:38 ` [PATCH v3 07/15] iio: chemical: bme680: Use bulk reads for calibration data Vasileios Amoiridis
2024-06-09 23:38 ` [PATCH v3 08/15] iio: chemical: bme680: Allocate IIO device before chip initialization Vasileios Amoiridis
2024-06-09 23:38 ` [PATCH v3 09/15] iio: chemical: bme680: Add read buffers in read/write buffer union Vasileios Amoiridis
2024-06-09 23:38 ` [PATCH v3 10/15] iio: chemical: bme680: Make error checks consistent Vasileios Amoiridis
2024-06-09 23:38 ` [PATCH v3 11/15] iio: chemical: bme680: Modify startup procedure Vasileios Amoiridis
2024-06-09 23:38 ` [PATCH v3 12/15] iio: chemical: bme680: Move probe errors to dev_err_probe() Vasileios Amoiridis
2024-06-09 23:38 ` [PATCH v3 13/15] iio: chemical: bme680: Remove redundant gas configuration Vasileios Amoiridis
2024-06-09 23:38 ` [PATCH v3 14/15] iio: chemical: bme680: Move forced mode setup in ->read_raw() Vasileios Amoiridis
2024-06-09 23:38 ` [PATCH v3 15/15] iio: chemical: bme680: Refactorize reading functions Vasileios Amoiridis
2024-06-30 20:26 ` [PATCH v3 00/15] iio: chemical: bme680: Driver cleanup Vasileios Amoiridis
2024-07-01 12:44   ` Jonathan Cameron
2024-07-01 17:00     ` Vasileios Amoiridis
2024-07-07 16:41       ` Jonathan Cameron

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=20240609233826.330516-4-vassilisamir@gmail.com \
    --to=vassilisamir@gmail.com \
    --cc=dpfrey@gmail.com \
    --cc=himanshujha199640@gmail.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mike.looijmans@topic.nl \
    /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