From: Krzysztof Kozlowski <krzk@kernel.org>
To: Gyeyoung Baek <gye976@gmail.com>, jic23@kernel.org
Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
lars@metafoo.de, gustavograzs@gmail.com,
javier.carrasco.cruz@gmail.com, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v1 4/5] iio: chemical: add support for winsen MHZ19B CO2 sensor
Date: Thu, 3 Apr 2025 09:56:18 +0200 [thread overview]
Message-ID: <28f4a7e5-ff96-4c7f-9eab-6bf358f19007@kernel.org> (raw)
In-Reply-To: <20250403053225.298308-5-gye976@gmail.com>
On 03/04/2025 07:32, Gyeyoung Baek wrote:
> Add support for winsen MHZ19B CO2 sensor.
>
> Datasheet:
> https://www.winsen-sensor.com/d/files/infrared-gas-sensor/mh-z19b-co2-ver1_0.pdf
>
> Signed-off-by: Gyeyoung Baek <gye976@gmail.com>
> ---
> drivers/iio/chemical/Kconfig | 10 +
> drivers/iio/chemical/Makefile | 1 +
> drivers/iio/chemical/mhz19b.c | 386 ++++++++++++++++++++++++++++++++++
> 3 files changed, 397 insertions(+)
> create mode 100644 drivers/iio/chemical/mhz19b.c
>
> diff --git a/drivers/iio/chemical/Kconfig b/drivers/iio/chemical/Kconfig
> index 330fe0af946f..bb4dfe3986f6 100644
> --- a/drivers/iio/chemical/Kconfig
> +++ b/drivers/iio/chemical/Kconfig
> @@ -108,6 +108,16 @@ config IAQCORE
> iAQ-Core Continuous/Pulsed VOC (Volatile Organic Compounds)
> sensors
>
> +config MHZ19B
probably WINSEN_MHZ19B
> + tristate "MHZ19B CO2 sensor"
Similarly here
> + depends on SERIAL_DEV_BUS
> + help
> + Say Y here to build Serdev binterface support for the MHZ19B
Typo, interface
> + CO2 sensor.
> +
> + To compile this driver as a module, choose M here: the module will
> + be called mhz19b.
> +
> config PMS7003
> tristate "Plantower PMS7003 particulate matter sensor"
> depends on SERIAL_DEV_BUS
> diff --git a/drivers/iio/chemical/Makefile b/drivers/iio/chemical/Makefile
> index 4866db06bdc9..c63daebf39ac 100644
> --- a/drivers/iio/chemical/Makefile
> +++ b/drivers/iio/chemical/Makefile
> @@ -15,6 +15,7 @@ obj-$(CONFIG_ENS160) += ens160_core.o
> obj-$(CONFIG_ENS160_I2C) += ens160_i2c.o
> obj-$(CONFIG_ENS160_SPI) += ens160_spi.o
> obj-$(CONFIG_IAQCORE) += ams-iaq-core.o
> +obj-$(CONFIG_MHZ19B) += mhz19b.o
> obj-$(CONFIG_PMS7003) += pms7003.o
> obj-$(CONFIG_SCD30_CORE) += scd30_core.o
> obj-$(CONFIG_SCD30_I2C) += scd30_i2c.o
> diff --git a/drivers/iio/chemical/mhz19b.c b/drivers/iio/chemical/mhz19b.c
> new file mode 100644
> index 000000000000..f8f06c01623f
> --- /dev/null
> +++ b/drivers/iio/chemical/mhz19b.c
> @@ -0,0 +1,386 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * mh-z19b co2 sensor driver
> + *
> + * Copyright (c) 2025 Gyeyoung Baek <gye976@gmail.com>
> + *
> + * Datasheet:
> + * https://www.winsen-sensor.com/d/files/infrared-gas-sensor/mh-z19b-co2-ver1_0.pdf
> + *
> + * TODO:
> + * - vin supply regulator
> + */
> +
> +#include <linux/cleanup.h>
> +#include <linux/completion.h>
> +#include <linux/device.h>
> +#include <linux/iio/iio.h>
> +#include <linux/iio/sysfs.h>
> +#include <linux/init.h>
> +#include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/module.h>
> +#include <linux/mutex.h>
> +#include <linux/regulator/consumer.h>
> +#include <linux/serdev.h>
> +#include <linux/unaligned.h>
> +
> +struct mhz19b_state {
> + struct serdev_device *serdev;
> +
> + /* TO DO, nothing for now.*/
> + struct regulator *vin_supply;
Drop. Don't add dead code.
> +
> + /* serdev receive buffer.
> + * When data is received from the MH-Z19B,
> + * the 'mhz19b_receive_buf' callback function is called and fills this buffer.
> + */
> + char buf[9];
> + int buf_idx;
> +
> + /* must wait the 'buf' is filled with 9 bytes.*/
> + struct completion buf_ready;
> +
> + /* protect access to mhz19b_state */
> + struct mutex lock;
mhz19b_receive_buf() does not need any locking?
Best regards,
Krzysztof
next prev parent reply other threads:[~2025-04-03 7:56 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-03 5:32 [PATCH v1 0/5] add support for winsen MHZ19B CO2 sensor Gyeyoung Baek
2025-04-03 5:32 ` [PATCH v1 1/5] dt-bindings: add winsen to the vendor prefixes Gyeyoung Baek
2025-04-03 7:48 ` Krzysztof Kozlowski
2025-04-03 12:45 ` gyeyoung
2025-04-03 5:32 ` [PATCH v1 2/5] dt-bindings: add device tree support for winsen MHZ19B CO2 sensor Gyeyoung Baek
2025-04-03 7:48 ` Krzysztof Kozlowski
2025-04-03 5:32 ` [PATCH v1 3/5] ABI: iio: add new ABI doc for mhz19b Gyeyoung Baek
2025-04-03 7:51 ` Krzysztof Kozlowski
2025-04-03 14:09 ` gyeyoung
2025-04-04 11:33 ` Jonathan Cameron
2025-04-05 13:47 ` gyeyoung
2025-04-06 11:20 ` Jonathan Cameron
2025-04-06 11:26 ` Jonathan Cameron
2025-04-06 13:31 ` gyeyoung
2025-04-06 15:33 ` Jonathan Cameron
2025-04-07 2:10 ` gyeyoung
2025-04-07 18:52 ` Jonathan Cameron
2025-04-03 5:32 ` [PATCH v1 4/5] iio: chemical: add support for winsen MHZ19B CO2 sensor Gyeyoung Baek
2025-04-03 7:56 ` Krzysztof Kozlowski [this message]
2025-04-03 14:04 ` gyeyoung
2025-04-04 11:51 ` Jonathan Cameron
2025-04-05 14:45 ` gyeyoung
2025-04-06 11:21 ` Jonathan Cameron
2025-04-03 5:32 ` [PATCH v1 5/5] MAINTAINERS: Add WINSEN MHZ19B Gyeyoung Baek
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=28f4a7e5-ff96-4c7f-9eab-6bf358f19007@kernel.org \
--to=krzk@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gustavograzs@gmail.com \
--cc=gye976@gmail.com \
--cc=javier.carrasco.cruz@gmail.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=robh@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).