From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Vasileios Amoiridis <vassilisamir@gmail.com>
Cc: jic23@kernel.org, lars@metafoo.de, ang.iglesiasg@gmail.com,
mazziesaccount@gmail.com, ak@it-klinger.de,
petre.rodan@subdimension.ro, phil@raspberrypi.com,
579lpy@gmail.com, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] iio: pressure: Add scale value for channels
Date: Mon, 4 Mar 2024 13:42:53 +0200 [thread overview]
Message-ID: <ZeWzvewAtqKKfnwI@smile.fi.intel.com> (raw)
In-Reply-To: <20240303165300.468011-3-vassilisamir@gmail.com>
On Sun, Mar 03, 2024 at 05:52:58PM +0100, Vasileios Amoiridis wrote:
> Add extra IIO_CHAN_INFO_SCALE in order to be able to have the scales
> for the values in userspace. Can be used for triggered buffers.
...
> + case IIO_CHAN_INFO_SCALE:
> + switch (chan->type) {
> + case IIO_HUMIDITYRELATIVE:
> + if (!strcmp(indio_dev->name, "bme280")) {
> + *val = 1000;
> + *val2 = 1024;
> + ret = IIO_VAL_FRACTIONAL;
> + } else {
> + ret = -EINVAL;
> + }
No, just make these int arrays part of chip_info, then
case IIO_HUMIDITYRELATIVE:
if (chip_info->hrel) {
*val = chip_info->hrel[0];
*val2 = chip_info->hrel[1];
ret = IIO_VAL_FRACTIONAL;
} else {
ret = -EINVAL;
}
> + break;
> + case IIO_PRESSURE:
> + if ((!strcmp(indio_dev->name, "bmp085")) ||
> + (!strcmp(indio_dev->name, "bmp180")) ||
> + (!strcmp(indio_dev->name, "bmp181"))) {
> + *val = 1;
> + *val2 = 1000;
> + ret = IIO_VAL_FRACTIONAL;
> + } else if ((!strcmp(indio_dev->name, "bmp280")) ||
> + (!strcmp(indio_dev->name, "bme280"))) {
> + *val = 1;
> + *val2 = 256000;
> + ret = IIO_VAL_FRACTIONAL;
> + } else if (!strcmp(indio_dev->name, "bmp380")) {
> + *val = 1;
> + *val2 = 100000;
> + ret = IIO_VAL_FRACTIONAL;
> + } else if (!strcmp(indio_dev->name, "bmp580")) {
> + *val = 1;
> + *val2 = 64000;
> + ret = IIO_VAL_FRACTIONAL;
> + } else {
> + ret = -EINVAL;
> + }
> + break;
Ditto.
> + case IIO_TEMP:
> + if ((!strcmp(indio_dev->name, "bmp085")) ||
> + (!strcmp(indio_dev->name, "bmp180")) ||
> + (!strcmp(indio_dev->name, "bmp181"))) {
> + *val = 100;
> + *val2 = 1;
> + ret = IIO_VAL_FRACTIONAL;
> + } else if ((!strcmp(indio_dev->name, "bmp280")) ||
> + (!strcmp(indio_dev->name, "bme280"))) {
> + *val = 10;
> + *val2 = 1;
> + ret = IIO_VAL_FRACTIONAL;
> + } else if (!strcmp(indio_dev->name, "bmp380")) {
> + *val = 10;
> + *val2 = 1;
> + ret = IIO_VAL_FRACTIONAL;
> + } else if (!strcmp(indio_dev->name, "bmp580")) {
> + *val = 1000;
> + *val2 = 16;
> + ret = IIO_VAL_FRACTIONAL_LOG2;
> + } else {
> + ret = -EINVAL;
> + }
> + break;
Ditto.
> + default:
> + ret = -EINVAL;
> + break;
> + }
> + break;
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2024-03-04 11:42 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-03 16:52 [PATCH 0/4] Series to add triggered buffer support to BMP280 driver Vasileios Amoiridis
2024-03-03 16:52 ` [PATCH 1/4] iio: pressure: BMP280 core driver headers sorting Vasileios Amoiridis
2024-03-04 11:36 ` Andy Shevchenko
2024-03-09 18:09 ` Jonathan Cameron
2024-03-03 16:52 ` [PATCH 2/4] iio: pressure: Add scale value for channels Vasileios Amoiridis
2024-03-04 11:42 ` Andy Shevchenko [this message]
2024-03-09 18:28 ` Jonathan Cameron
2024-03-03 16:52 ` [PATCH 3/4] iio: pressure: Add timestamp and scan_masks for BMP280 driver Vasileios Amoiridis
2024-03-04 11:47 ` Andy Shevchenko
2024-03-04 18:50 ` Vasileios Amoiridis
2024-03-04 19:07 ` Andy Shevchenko
2024-03-09 18:12 ` Jonathan Cameron
2024-03-03 16:53 ` [PATCH 4/4] iio: pressure: Add triggered buffer support " Vasileios Amoiridis
2024-03-04 11:52 ` Andy Shevchenko
2024-03-04 19:08 ` Vasileios Amoiridis
2024-03-04 19:18 ` Andy Shevchenko
2024-03-04 20:05 ` Vasileios Amoiridis
2024-03-09 18:19 ` Jonathan Cameron
2024-03-09 18:32 ` 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=ZeWzvewAtqKKfnwI@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=579lpy@gmail.com \
--cc=ak@it-klinger.de \
--cc=ang.iglesiasg@gmail.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mazziesaccount@gmail.com \
--cc=petre.rodan@subdimension.ro \
--cc=phil@raspberrypi.com \
--cc=vassilisamir@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.