From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Muhammad Abu Bakar <m.abubakar365@yahoo.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/2] iio: pressure: add Sensirion SDP31 driver
Date: Tue, 29 Sep 2026 01:04:16 +0300 [thread overview]
Message-ID: <arrkYNNlD6_bCgiO@ashevche-desk.local> (raw)
In-Reply-To: <20260928215422.3720-3-m.abubakar365@yahoo.com>
On Tue, Sep 29, 2026 at 02:54:22AM +0500, Muhammad Abu Bakar wrote:
> Add an IIO driver for the Sensirion SDP3x family of differential pressure
> sensors (SDP31, SDP32 and SDP33). The devices are accessed over I2C and
> report differential pressure and temperature. Each measurement is
> validated using the sensor's CRC-8 checksum. The scale factor is read
> from the sensor at runtime, so all three parts are supported.
>
> Tested on an SDP31 connected to a Raspberry Pi 4 I2C bus.
...
> +#include <linux/cleanup.h>
> +#include <linux/crc8.h>
> +#include <linux/delay.h>
> +#include <linux/i2c.h>
> +#include <linux/module.h>
> +#include <linux/mutex.h>
> +#include <linux/once.h>
> +#include <linux/regulator/consumer.h>
> +#include <linux/unaligned.h>
Follow IWYU principle.
At least types.h, err.h or errno.h are absent.
...
> +static int sdp31_read_measurement(struct sdp31_data *data, s16 *pressure,
> + s16 *temp)
> +{
> + u8 rx[6];
> + int ret;
> +
> + ret = sdp31_trigger_read(data, rx, sizeof(rx));
> + if (ret)
> + return ret;
> +
> + if (sdp31_check_crc(&rx[0]) || sdp31_check_crc(&rx[3]))
> + return -EIO;
> + *pressure = (s16)get_unaligned_be16(&rx[0]);
> + *temp = (s16)get_unaligned_be16(&rx[3]);
And casting is for...?
> + return 0;
> +}
...
> + case IIO_CHAN_INFO_SCALE:
> + switch (chan->type) {
> + case IIO_PRESSURE:
> + *val = 1;
> + *val2 = data->dp_scale * 1000;
KILO?
> + return IIO_VAL_FRACTIONAL;
> + case IIO_TEMP:
> + /* raw / 200 = degC, so raw * 5 = milli-degC */
> + *val = 5;
> + return IIO_VAL_INT;
> + default:
> + return -EINVAL;
> + }
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-09-28 22:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260928215422.3720-1-m.abubakar365.ref@yahoo.com>
2026-09-28 21:54 ` [PATCH v4 0/2] " Muhammad Abu Bakar
2026-09-28 21:54 ` [PATCH v4 1/2] dt-bindings: iio: pressure: add Sensirion SDP31 Muhammad Abu Bakar
2026-09-28 21:54 ` [PATCH v4 2/2] iio: pressure: add Sensirion SDP31 driver Muhammad Abu Bakar
2026-09-28 22:04 ` Andy Shevchenko [this message]
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=arrkYNNlD6_bCgiO@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.abubakar365@yahoo.com \
--cc=nuno.sa@analog.com \
--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
all inboxes | Powered by JetHome®