lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250515174416.0d5c49cc@jic23-huawei>
Date: Thu, 15 May 2025 17:44:16 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Tóth János via B4 Relay
 <devnull+gomba007.gmail.com@...nel.org>
Cc: gomba007@...il.com, Lars-Peter Clausen <lars@...afoo.de>, Rob Herring
 <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley
 <conor+dt@...nel.org>, linux-iio@...r.kernel.org,
 devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 2/2] iio: chemical: Add driver for SEN0322

On Tue, 06 May 2025 11:01:16 +0200
Tóth János via B4 Relay <devnull+gomba007.gmail.com@...nel.org> wrote:

> From: Tóth János <gomba007@...il.com>
> 
> Add support for the DFRobot SEN0322 oxygen sensor.
> 
> To instantiate (assuming device is connected to I2C-2):
> 	echo 'sen0322 0x73' > /sys/class/i2c-dev/i2c-2/device/new_device
> 
> To get the oxygen concentration (assuming device is iio:device0) multiply
> the values read from:
> 	/sys/bus/iio/devices/iio:device0/in_concentration_raw
> 	/sys/bus/iio/devices/iio:device0/in_concentration_scale
> 
> Datasheet: https://wiki.dfrobot.com/Gravity_I2C_Oxygen_Sensor_SKU_SEN0322
> 
Datasheet is a tag so no blank line here.

> Signed-off-by: Tóth János <gomba007@...il.com>

Will shortly appear in the testing branch of iio.git.  I'll push it out
as togreg once it's had minimal 0-day build coverage.

Applied with this diff:
diff --git a/drivers/iio/chemical/sen0322.c b/drivers/iio/chemical/sen0322.c
index 088f8947083e..96c6fc1203ad 100644
--- a/drivers/iio/chemical/sen0322.c
+++ b/drivers/iio/chemical/sen0322.c
@@ -28,7 +28,7 @@ struct sen0322 {
 
 static int sen0322_read_data(struct sen0322 *sen0322)
 {
-       u8 data[3] = { 0 };
+       u8 data[3] = { };
        int ret;
 
        ret = regmap_bulk_read(sen0322->regmap, SEN0322_REG_DATA, data,
@@ -42,9 +42,7 @@ static int sen0322_read_data(struct sen0322 *sen0322)
         * but it is multiplied by 100 here to avoid floating-point math
         * and the scale is divided by 100 to compensate this.
         */
-       ret = data[0] * 100 + data[1] * 10 + data[2];
-
-       return ret;
+       return data[0] * 100 + data[1] * 10 + data[2];
 }
 
 static int sen0322_read_scale(struct sen0322 *sen0322, int *num, int *den)


> +
> +static int sen0322_read_data(struct sen0322 *sen0322)
> +{
> +	u8 data[3] = { 0 };
Slight preference for { };

> +	int ret;
> +
> +	ret = regmap_bulk_read(sen0322->regmap, SEN0322_REG_DATA, data,
> +			       sizeof(data));
> +	if (ret < 0)
regmap is always 0 or < 0 so checking just if (ret) is cleaner.
> +		return ret;
> +
> +	/*
> +	 * The actual value in the registers is:
> +	 *	val = data[0] + data[1] / 10 + data[2] / 100
> +	 * but it is multiplied by 100 here to avoid floating-point math
> +	 * and the scale is divided by 100 to compensate this.
> +	 */
> +	ret = data[0] * 100 + data[1] * 10 + data[2];

return data[0] ...

If nothing else comes up I'll fix this.

> +
> +	return ret;
> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ