[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZeWzvewAtqKKfnwI@smile.fi.intel.com>
Date: Mon, 4 Mar 2024 13:42:53 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Vasileios Amoiridis <vassilisamir@...il.com>
Cc: jic23@...nel.org, lars@...afoo.de, ang.iglesiasg@...il.com,
mazziesaccount@...il.com, ak@...klinger.de,
petre.rodan@...dimension.ro, phil@...pberrypi.com, 579lpy@...il.com,
linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/4] iio: pressure: Add scale value for channels
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
Powered by blists - more mailing lists