add support for winsen MHZ19B CO2 sensor
Subsystems (3)
Gyeyoung Baek
maintainerv4 cover add support for winsen MHZ19B CO2 sensor
v4:
- Ensure buffer is aligned to the cacheline.
- Fix coding style overall.
v3:
- Add vin supply regulator.
- Drop custom ABI.
- Drop unnecessary mutex.
v2:
- Add ABI doc.
- Add complete struct to receive UART transmission successfully.
- Add undersigned as a maintainer for the WINSEN MHZ19B.
- Modify to comply with the IIO subsystem ABI as much as possible.
- Revise the coding style overall.
Gyeyoung Baek (4):
dt-bindings: add winsen to the vendor prefixes
dt-bindings: add device tree support for winsen MHZ19B CO2 sensor
iio: chemical: add support for winsen MHZ19B CO2 sensor
MAINTAINERS: Add WINSEN MHZ19B
.../bindings/iio/chemical/winsen,mhz19b.yaml | 33 ++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + MAINTAINERS | 6 + drivers/iio/chemical/Kconfig | 10 + drivers/iio/chemical/Makefile | 1 + drivers/iio/chemical/mhz19b.c | 307 ++++++++++++++++++ 6 files changed, 359 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/chemical/winsen,mhz19b.yaml create mode 100644 drivers/iio/chemical/mhz19b.c
Signature · 1 line
2.34.1
Gyeyoung Baek
maintainerPATCH v4 1/4 dt-bindings: add winsen to the vendor prefixes
Add winsen to the vendor prefixes.
--- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
@@ -1689,6 +1689,8 @@ patternProperties: description: Wingtech Technology Co., Ltd. "^winlink,.*": description: WinLink Co., Ltd + "^winsen,.*": + description: Winsen Corp. "^winstar,.*": description: Winstar Display Corp. "^wirelesstag,.*":
Signature · 1 line
2.34.1
Gyeyoung Baek
maintainerPATCH v4 2/4 dt-bindings: add device tree support for winsen MHZ19B CO2 sensor
In reply to Gyeyoung BaekAdd device tree support for winsen MHZ19B sensor.
--- .../bindings/iio/chemical/winsen,mhz19b.yaml | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/chemical/winsen,mhz19b.yaml
Documentation/devicetree/bindings/iio/chemical/winsen,mhz19b.yaml new file +33 -0
@@ -0,0 +1,33 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/chemical/winsen,mhz19b.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MHZ19B CO2 sensor + +maintainers: + - Gyeyoung Baek <[email protected]> + +properties: + compatible: + const: winsen,mhz19b + + vin-supply: + description: Regulator that provides power to the sensor + +required: + - compatible + - vin-supply + +additionalProperties: false + +examples: + - | + serial { + co2-sensor { + compatible = "winsen,mhz19b"; + vin-supply = <&vdd>; + }; + }; +...
Signature · 1 line
2.34.1
Gyeyoung Baek
maintainerPATCH v4 3/4 iio: chemical: add support for winsen MHZ19B CO2 sensor
In reply to Gyeyoung BaekAdd support for winsen MHZ19B CO2 sensor.
The datasheet is available at
--- drivers/iio/chemical/Kconfig | 10 ++ drivers/iio/chemical/Makefile | 1 + drivers/iio/chemical/mhz19b.c | 307 ++++++++++++++++++++++++++++++++++ 3 files changed, 318 insertions(+) create mode 100644 drivers/iio/chemical/mhz19b.c
drivers/iio/chemical/Kconfig +10 -0
@@ -237,4 +237,14 @@ config VZ89X Sensortech MiCS VZ89X VOC (Volatile Organic Compounds) sensors +config WINSEN_MHZ19B + tristate "Winsen MHZ19B CO2 sensor" + depends on SERIAL_DEV_BUS + help + Say Y here to build Serdev interface support for the Winsen + MHZ19B CO2 sensor. + + To compile this driver as a module, choose M here: the module will + be called mhz19b. + endmenu
drivers/iio/chemical/Makefile +1 -0
@@ -27,3 +27,4 @@ obj-$(CONFIG_SPS30) += sps30.o obj-$(CONFIG_SPS30_I2C) += sps30_i2c.o obj-$(CONFIG_SPS30_SERIAL) += sps30_serial.o obj-$(CONFIG_VZ89X) += vz89x.o +obj-$(CONFIG_WINSEN_MHZ19B) += mhz19b.o
drivers/iio/chemical/mhz19b.c new file +307 -0
307 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v4 3/4] iio: chemical: add support for winsen MHZ19B CO2 sensor
Quoted 5 lines · Gyeyoung Baek
Add support for winsen MHZ19B CO2 sensor.
The datasheet is available at
Instead, just make it Datasheet: tag.
Quoted 1 line
Should not be this blank line here.
Quoted 1 line
Signed-off-by Gyeyoung Baek <[email protected]>
...
drivers/iio/chemical/Makefile obj-$(CONFIG_SPS30) += sps30.o · line 30
Quoted 7 lines
drivers/iio/chemical/Makefile +1
-0@@ -27,3 +27,4 @@ obj-$(CONFIG_SPS30) += sps30.o obj-$(CONFIG_SPS30_I2C) += sps30_i2c.o obj-$(CONFIG_SPS30_SERIAL) += sps30_serial.o obj-$(CONFIG_VZ89X) += vz89x.o +obj-$(CONFIG_WINSEN_MHZ19B) += mhz19b.o
Preserve order.
...
Quoted 2 lines
+/*
+ * mh-z19b co2 sensor driver
Please, use the marketing name of the chip and we can spell CO₂.
Quoted 5 lines
+ * Copyright (c) 2025 Gyeyoung Baek <[email protected]>
+ *
+ * Datasheet:
+ * https://www.winsen-sensor.com/d/files/infrared-gas-sensor/mh-z19b-co2-ver1_0.pdf
+ */
...
drivers/iio/chemical/Makefile
Quoted 9 lines
drivers/iio/chemical/Makefile +9
-0+#include <linux/completion.h> +#include <linux/device.h> +#include <linux/iio/iio.h> +#include <linux/iio/sysfs.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/regulator/consumer.h> +#include <linux/serdev.h> +#include <linux/unaligned.h>
Semi-baked list, see below what's missing (actually a lot). I believe I already pointed that out.
...
Quoted 1 line
+#define
MHZ19B_SERDEV_TIMEOUTmsecs_to_jiffies(100)
Missing header for msec_to_jiffies().
...
Quoted 1 line
+ u8
buf_idx;
Needs types.h
...
drivers/iio/chemical/Makefile
Quoted 3 lines
drivers/iio/chemical/Makefile +3
-0+ switch (cmd) { + case MHZ19B_ABC_LOGIC_CMD: + cmd_buf[3] = (arg) ? 0xA0 : 0;
Unneeded parentheses.
Quoted 7 lines
drivers/iio/chemical/Makefile +7
-0+ break; + case MHZ19B_SPAN_POINT_CMD: + put_unaligned_be16(arg, &cmd_buf[3]); + break; + default: + break; + }
...
drivers/iio/chemical/Makefile
Quoted 3 lines
drivers/iio/chemical/Makefile +3
-0+ if (st->buf[8] != mhz19b_get_checksum(st->buf)) { + dev_err(dev, "checksum err"); + return -EINVAL;
Needs errno.h
Quoted 1 line
+ }
...
Quoted 1 line
+ ret =
kstrtobool(buf, &enable);
It's defined in kstrtox.h.
Quoted 2 lines
drivers/iio/chemical/Makefile +2
-0+ if (ret) + return ret;
...
Quoted 3 lines
+/*
+ * echo 0 >calibration_forced_value: zero point calibration
+ * (make sure the sensor has been worked under 400ppm for over 20 minutes.)
working
Quoted 2 lines
+ * echo [1000 1 5000] >
calibration_forced_value: span point calibration
+ * (make sure the sensor has been worked under a certain level co2 for over 20 minutes.)
working
It seems you ignored this comment from the previous review.
Quoted 1 line
+ */
...
drivers/iio/chemical/Makefile
Quoted 2 lines
drivers/iio/chemical/Makefile +2
-0+ if (ppm) { + if (!in_range(ppm, 1000, 4001)) {
Missing minmax.h.
The second parameter is length of the range.
drivers/iio/chemical/Makefile
Quoted 2 lines
drivers/iio/chemical/Makefile +2
-0+ dev_dbg(&indio_dev->dev, + "span point ppm should be 1000~5000");
The above range check doesn't agree with this message.
drivers/iio/chemical/Makefile
Quoted 6 lines
drivers/iio/chemical/Makefile +6
-0+ return -EINVAL; + } + + cmd = MHZ19B_SPAN_POINT_CMD; + } else + cmd = MHZ19B_ZERO_POINT_CMD;
Have you run checkpatch? This needs {} per Coding Style.
...
Quoted 1 line
+
memcpy(st->buf + st->buf_idx, data, len);
Requires string.h.
...
drivers/iio/chemical/Makefile
Quoted 3 lines
drivers/iio/chemical/Makefile +2
-0+ serdev_device_set_baudrate(serdev, 9600); +
Redundant blank line.
Quoted 1 line
+
serdev_device_set_flow_control(serdev, false);
...
Quoted 1 line
+
dev_set_drvdata(dev, indio_dev);
Is it really used?
...
Quoted 1 line
+
indio_dev->num_channels=ARRAY_SIZE(mhz19b_channels);
Needs array_size.h.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 3/4] iio: chemical: add support for winsen MHZ19B CO2 sensor
Quoted 1 line · Andy Shevchenko
On Sun, Apr 20, 2025 at 9:10 PM Gyeyoung Baek <[email protected]> wrote:
...
Quoted 9 lines
drivers/iio/chemical/Makefile obj-$(CONFIG_SPS30) += sps30.o · line 30
Quoted 7 lines
drivers/iio/chemical/Makefile +1
-0obj-$(CONFIG_SPS30_I2C) += sps30_i2c.o obj-$(CONFIG_SPS30_SERIAL) += sps30_serial.o obj-$(CONFIG_VZ89X) += vz89x.o +obj-$(CONFIG_WINSEN_MHZ19B) += mhz19b.oPreserve order.
Ah, I see it's ordered but by Kconfig, Why do you have WINSEN in the option and no such thing in the filename? I would drop that from the config option.
Jonathan, what do you think about this? Which order (in case of misalignment between module name and configuration option) should be taken?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerRe: [PATCH v4 3/4] iio: chemical: add support for winsen MHZ19B CO2 sensor
Quoted 16 lines · On Sun, 20 Apr 2025 22:23:57 +0300 Andy Shevchenko <[email protected]>…
Quoted 1 line · Andy Shevchenko
On Sun, Apr 20, 2025 at 9:10 PM Gyeyoung Baek <[email protected]> wrote:
...
Quoted 9 lines
drivers/iio/chemical/Makefile obj-$(CONFIG_SPS30) += sps30.o · line 30
Quoted 7 lines
drivers/iio/chemical/Makefile +1
-0obj-$(CONFIG_SPS30_I2C) += sps30_i2c.o obj-$(CONFIG_SPS30_SERIAL) += sps30_serial.o obj-$(CONFIG_VZ89X) += vz89x.o +obj-$(CONFIG_WINSEN_MHZ19B) += mhz19b.oPreserve order.
Quoted 8 lines
Ah, I see it's ordered but by
Kconfig, Why do you have WINSEN in the option and no such thing in the filename? I would drop that from the config option.Jonathan, what do you think about this? Which order (in case of misalignment between module name and configuration option) should be taken?
Hmm.. No idea. It think just dropping it from the CONFIG name is the right way to avoid the question ;)
Jonathan
Gyeyoung Baek
maintainerRe: [PATCH v4 3/4] iio: chemical: add support for winsen MHZ19B CO2 sensor
Hello Jonathan,
Quoted 24 lines · Jonathan Cameron
Quoted 20 lines · On Sun, 20 Apr 2025 22:23:57 +0300 Andy Shevchenko <[email protected]>…
Quoted 1 line · Andy Shevchenko
On Sun, Apr 20, 2025 at 9:10 PM Gyeyoung Baek <[email protected]> wrote:
...
Quoted 9 lines
drivers/iio/chemical/Makefile obj-$(CONFIG_SPS30) += sps30.o · line 30
Quoted 7 lines
drivers/iio/chemical/Makefile +1
-0obj-$(CONFIG_SPS30_I2C) += sps30_i2c.o obj-$(CONFIG_SPS30_SERIAL) += sps30_serial.o obj-$(CONFIG_VZ89X) += vz89x.o +obj-$(CONFIG_WINSEN_MHZ19B) += mhz19b.oPreserve order.
Ah, I see it's ordered but by
Kconfig, Why do you have WINSEN in the option and no such thing in the filename? I would drop that from the config option.
Quoted 7 lines
Quoted 4 lines
Jonathan, what do you think about this? Which order (in case of misalignment between module name and configuration option) should be taken?
Hmm.. No idea. It think just dropping it from the CONFIG name is the right way to avoid the question ;)
Thanks for your suggestion. I'll just drop that.
Thanks,
Gyeyoung
Gyeyoung Baek
maintainerRe: [PATCH v4 3/4] iio: chemical: add support for winsen MHZ19B CO2 sensor
In reply to Andy ShevchenkoHello Andy,
Quoted 15 lines · Andy Shevchenko
Quoted 1 line · Andy Shevchenko
On Sun, Apr 20, 2025 at 9:10 PM Gyeyoung Baek <[email protected]> wrote:
...
Quoted 8 lines
Quoted 7 lines
drivers/iio/chemical/Makefile +1
-0obj-$(CONFIG_SPS30_I2C) += sps30_i2c.o obj-$(CONFIG_SPS30_SERIAL) += sps30_serial.o obj-$(CONFIG_VZ89X) += vz89x.o +obj-$(CONFIG_WINSEN_MHZ19B) += mhz19b.o
Quoted 5 lines
Quoted 1 line
Preserve order.
Ah, I see it's ordered but by
Kconfig, Why do you have WINSEN in the option and no such thing in the filename? I would drop that from the config option.
I followed the 'vendor_device' naming pattern seen in examples like 'CONFIG_SENSEAIR_SUNRISE_CO2'
But I'll drop the vendor prefix in the next patch, thanks.
--
Regards,
Gyeyoung
Re: [PATCH v4 3/4] iio: chemical: add support for winsen MHZ19B CO2 sensor
Quoted 5 lines · Gyeyoung Baek
Quoted 3 lines · Andy Shevchenko
Quoted 1 line · Andy Shevchenko
On Sun, Apr 20, 2025 at 9:10 PM Gyeyoung Baek <[email protected]> wrote:
...
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
drivers/iio/chemical/Makefile +1
-0obj-$(CONFIG_SPS30_I2C) += sps30_i2c.o obj-$(CONFIG_SPS30_SERIAL) += sps30_serial.o obj-$(CONFIG_VZ89X) += vz89x.o +obj-$(CONFIG_WINSEN_MHZ19B) += mhz19b.o
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Preserve order.
Ah, I see it's ordered but by
Kconfig, Why do you have WINSEN in the option and no such thing in the filename? I would drop that from the config option.I followed the '
vendor_device' naming pattern seen in examples like 'CONFIG_SENSEAIR_SUNRISE_CO2'
Interesting... Now I understand why the above was pulled without any comment, because the vendor and device names start with the same letter 'S'!
Quoted 1 line
But I'll drop the vendor prefix in the next patch, thanks.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerRe: [PATCH v4 3/4] iio: chemical: add support for winsen MHZ19B CO2 sensor
Quoted 23 lines · On Tue, 22 Apr 2025 20:30:58 +0300 Andy Shevchenko <[email protected]>…
Quoted 5 lines · Gyeyoung Baek
Quoted 3 lines · Andy Shevchenko
Quoted 1 line · Andy Shevchenko
On Sun, Apr 20, 2025 at 9:10 PM Gyeyoung Baek <[email protected]> wrote:
...
Quoted 14 lines
Quoted 13 lines
Quoted 9 lines
drivers/iio/chemical/Makefile obj-$(CONFIG_SPS30) += sps30.o · line 30
Quoted 7 lines
drivers/iio/chemical/Makefile +1
-0obj-$(CONFIG_SPS30_I2C) += sps30_i2c.o obj-$(CONFIG_SPS30_SERIAL) += sps30_serial.o obj-$(CONFIG_VZ89X) += vz89x.o +obj-$(CONFIG_WINSEN_MHZ19B) += mhz19b.oPreserve order.
Ah, I see it's ordered but by
Kconfig, Why do you have WINSEN in the option and no such thing in the filename? I would drop that from the config option.
Quoted 5 lines
Quoted 2 lines
I followed the '
vendor_device' naming pattern seen in examples like 'CONFIG_SENSEAIR_SUNRISE_CO2'Interesting... Now I understand why the above was pulled without any comment, because the vendor and device names start with the same letter 'S'!
These vendor + driver things originally (IIRC) snuck in with driver moves from misc etc a long time ago and I've never really enforced having them or not properly since then :(
I prefer not having the company in these but it is a fairly random choice with little real justification either way.
Jonathan
Quoted 3 lines
Quoted 2 lines
But I'll drop the vendor prefix in the next patch, thanks.
Gyeyoung Baek
maintainerRe: [PATCH v4 3/4] iio: chemical: add support for winsen MHZ19B CO2 sensor
In reply to Andy ShevchenkoHello Andy, thanks for the review.
Quoted 5 lines · Andy Shevchenko
Quoted 2 lines · Gyeyoung Baek
Add support for winsen MHZ19B CO2 sensor.
Quoted 10 lines
Quoted 2 lines
The datasheet is available at
Instead, just make it Datasheet: tag.
Quoted 1 line
Should not be this blank line here.
Quoted 1 line
Signed-off-by Gyeyoung Baek <[email protected]>
Sorry, I now understand what you mean.
('Datasheet:' is a tag, not an explanation. So there should be no space between the tags.)
However, when I use the 'Datasheet:' tag, I get the following warning by checkpatch.pl.
Would it be OK? then I'll use 'Datasheet:' tag.
"WARNING: Unknown link reference 'Datasheet:', use 'Link:' or
'Closes:' instead
#8:
Datasheet:https://www.winsen-sensor.com/d/files/infrared-gas-sensor/mh-z19b-co2-ver1_0.pdf"
---
Quoted 4 lines
Quoted 4 lines
drivers/iio/chemical/mhz19b.c new file +4
-0+#include <linux/completion.h> +#include <linux/device.h> +#include <linux/iio/iio.h> +#include <linux/iio/sysfs.h>
Quoted 8 lines
drivers/iio/chemical/mhz19b.c line 19
Quoted 5 lines
drivers/iio/chemical/mhz19b.c new file +5
-0+#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/regulator/consumer.h> +#include <linux/serdev.h> +#include <linux/unaligned.h> Semi-baked list, see below what's missing (actually a lot). I believe I already pointed that out.
From the last review, I understood the two main points as:
(1) Avoid using large headers and explicitly include only the necessary ones.
(2) Reduce including headers as much as possible to improve build times.
However, I found that removing headers like 'types.h' didn't cause any build failure,
So I thought it would be better to remove headers that are unnecessary to improve build time.
But in the next patch, I'll explicitly include the headers you've pointed out.
---
Quoted 4 lines
Quoted 3 lines
+/*
+ * echo 0 >calibration_forced_value: zero point calibration
+ * (make sure the sensor has been worked under 400ppm for over 20 minutes.)
Quoted 8 lines
working
Quoted 2 lines
+ * echo [1000 1 5000] >
calibration_forced_value: span point calibration
+ * (make sure the sensor has been worked under a certain level co2 for over 20 minutes.)working
It seems you ignored this comment from the previous review.
Sorry, I only changed 'had -> has'.
I missed changing 'worked -> working' ..
---
Quoted 11 lines
drivers/iio/chemical/mhz19b.c line 183
Quoted 2 lines
drivers/iio/chemical/mhz19b.c new file +2
-0+if (ppm) { +if (!in_range (ppm,1000 ,4001 )) {Missing
minmax.h.The second parameter is length of the range.
drivers/iio/chemical/mhz19b.c line 185
Quoted 2 lines
drivers/iio/chemical/mhz19b.c new file +2
-0+dev_dbg (&indio_dev->dev, +"span point ppm should be 1000~5000" );The above range check doesn't agree with this message.
in_range() uses the range 'start <= val && val < (start + len)'. So, to allow 5000, the 'len' should be 4001, not 4000. I have tested this.
But would it be correct that I understand your point?
---
Quoted 8 lines
drivers/iio/chemical/mhz19b.c line 191
Quoted 6 lines
drivers/iio/chemical/mhz19b.c new file +6
-0+return -EINVAL ; + } + + cmd =MHZ19B_SPAN_POINT_CMD ; + }else + cmd =MHZ19B_ZERO_POINT_CMD ;Have you run checkpatch? This needs {} per Coding Style.
Yes, checkpatch.pl didn't raise any warnings.
And after making the changes as you point out, there were no warnings either. It seems that checkpatch.pl allows both.
But for consistency, I'll add the { }.
---
Quoted 3 lines
Quoted 1 line
+
dev_set_drvdata(dev, indio_dev);Is it really used?
Yes, this 'dev' is the same as '&serdev->dev'.
But I found 'serdev_device_set_drvdata()', so I'll change it to that.
--
Thanks,
Gyeyoung
Re: [PATCH v4 3/4] iio: chemical: add support for winsen MHZ19B CO2 sensor
Quoted 3 lines · Gyeyoung Baek
Quoted 1 line · Andy Shevchenko
On Sun, Apr 20, 2025 at 9:10 PM Gyeyoung Baek <[email protected]> wrote:
...
Quoted 17 lines
Quoted 9 lines
Quoted 2 lines
The datasheet is available at
Instead, just make it Datasheet: tag.
Quoted 1 line
Should not be this blank line here.
Quoted 1 line
Signed-off-by Gyeyoung Baek <[email protected]>Sorry, I now understand what you mean.
('Datasheet:' is a tag, not an explanation. So there should be no space between the tags.)
However, when I use the 'Datasheet:' tag, I get the following warning by checkpatch.pl.
Would it be OK? then I'll use 'Datasheet:' tag.
Quoted 5 lines
"WARNING: Unknown link reference 'Datasheet:', use 'Link:' or
'Closes:' instead#8: Datasheet:https://www.winsen-sensor.com/d/files/infrared-gas-sensor/mh-z19b-co2-ver1_0.pdf"
checkpatch is recommendation and sometimes has not fully suitable warnings. You may ignore this one.
...
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
drivers/iio/chemical/mhz19b.c new file +4
-0+#include <linux/completion.h> +#include <linux/device.h> +#include <linux/iio/iio.h> +#include <linux/iio/sysfs.h> Quoted 8 lines
drivers/iio/chemical/mhz19b.c line 19
Quoted 5 lines
drivers/iio/chemical/mhz19b.c new file +5
-0+#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/regulator/consumer.h> +#include <linux/serdev.h> +#include <linux/unaligned.h> Semi-baked list, see below what's missing (actually a lot). I believe I already pointed that out.
Quoted 6 lines
From the last review, I understood the two main points as:
(1) Avoid using large headers and explicitly include only the necessary ones.
(2) Reduce including headers as much as possible to improve build times.However, I found that removing headers like '
types.h' didn't cause any build failure,
Because we have other headers that may use it, but you shouldn't do that.
Quoted 3 lines
So I thought it would be better to remove headers that are unnecessary to improve build time.
But in the next patch, I'll explicitly include the headers you've pointed out.
You should follow IWYU principle, i.e. Include What You Use, e.g., types.h.
...
Quoted 10 lines
Quoted 10 lines
drivers/iio/chemical/mhz19b.c line 183
Quoted 2 lines
drivers/iio/chemical/mhz19b.c new file +2
-0+if (ppm) { +if (!in_range (ppm,1000 ,4001 )) {Missing
minmax.h.The second parameter is length of the range.
Quoted 2 lines
drivers/iio/chemical/mhz19b.c new file +2
-0+dev_dbg (&indio_dev->dev, +"span point ppm should be 1000~5000" );
Quoted 6 lines
Quoted 1 line
The above range check doesn't agree with this message.
in_range()uses the range 'start <= val && val < (start + len)'. So, to allow 5000, the 'len' should be 4001, not 4000. I have tested this.
But would it be correct that I understand your point?
I see now, I recommend then to define those two:
#define ..._PPM_MIN 1000
#define ..._PPM_MAX 5000
And use here as
if (!in_range(ppm, ..._MIN, ..._MAX - ..._MIN + 1)) {
dev_dbg(&indio_dev->dev,
"span point PPM should be in a range [%d-%d]\n",
_MIN, _MAX);Note, you missed \n as well.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
(quoted diff) +2
-0+ return -EINVAL; + }
Signature · 2 lines
With Best Regards, Andy Shevchenko
Gyeyoung Baek
maintainerPATCH v4 4/4 MAINTAINERS: Add WINSEN MHZ19B
In reply to Gyeyoung BaekAdd undersigned as a maintainer for the WINSEN MHZ19B.
--- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
@@ -26015,6 +26015,12 @@ M: David Härdeman <[email protected]> S: Maintained F: drivers/media/rc/winbond-cir.c +WINSEN MHZ19B +M: Gyeyoung Baek <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/iio/chemical/winsen,mhz19b.yaml +F: drivers/iio/chemical/mhz19b.c + WINSYSTEMS EBC-C384 WATCHDOG DRIVER L: [email protected] S: Orphan
Signature · 1 line
2.34.1