All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vasileios Amoiridis <vassilisamir@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Vasileios Amoiridis <vassilisamir@gmail.com>,
	jic23@kernel.org, lars@metafoo.de, ang.iglesiasg@gmail.com,
	mazziesaccount@gmail.com, ak@it-klinger.de,
	petre.rodan@subdimension.ro, linus.walleij@linaro.org,
	phil@raspberrypi.com, 579lpy@gmail.com,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/6] iio: pressure: Simplify read_* functions
Date: Wed, 13 Mar 2024 20:22:45 +0100	[thread overview]
Message-ID: <20240313192245.GA1938985@vamoiridPC> (raw)
In-Reply-To: <ZfH4IyeFTGFBKT4J@smile.fi.intel.com>

On Wed, Mar 13, 2024 at 09:01:55PM +0200, Andy Shevchenko wrote:
> On Wed, Mar 13, 2024 at 06:40:03PM +0100, Vasileios Amoiridis wrote:
> 
> In the Subject: ... read_*() functions
> 
> > Add the coefficients for the IIO standard units inside the chip_info
> > structure.
> > 
> > Remove the calculations with the coefficients for the IIO compatibility
> > from inside the read_(temp/press/humid) functions and move it to the
> 
> read_{temp,press,humid}()
> 
> > read_raw function.
> 
> read_raw()
> 
> > Execute the calculations with the coefficients inside the read_raw
> 
> read_raw()
> 
> > oneshot capture functions.
> > 
> > Also fix raw_* and comp_* values signs.
> 
Thank you very much for pointing these out, I should have thought it.

> ...
> 
> >  		case IIO_TEMP:
> > -			ret = data->chip_info->read_temp(data, val, val2);
> > +			ret = data->chip_info->read_temp(data);
> > +			*val = data->chip_info->temp_coeffs[0] * ret;
> > +			*val2 = data->chip_info->temp_coeffs[1];
> 
> > +			if (!strcmp(indio_dev->name, "bmp580"))
> > +				ret = IIO_VAL_FRACTIONAL_LOG2;
> > +			else
> > +				ret = IIO_VAL_FRACTIONAL;
> 
> I'm wondering if we may replace these strcmp():s by using enum and respective
> values in chip_info.
> 

The whole problem starts from the fact that all these BMPxxx_CHIP_ID defines are
not unique for the respective BMPxxx device. You mean to add a new variable
that could store some enum values that would be the actual chip_info IDs? Like:

enum chip_info_ids = {
	BMP085,
	BMP180,
	...
	BMP580,
};

and later for every chip_info struct to use it like this:

const struct bmp280_chip_info bmpxxx_chip_info = {
	...
	.chip_info_id = BIT(BMPxxx),
	...
}

And in the read_raw() function to just use the test_bit() function in the same
way that is done with the test_bit() and avail_scan_mask to test for the
enabled channels?

Best regards,
Vasilis Amoiridis 

> >  			break;
> 
> -- 
> With Best Regards,
> Andy Shevchenko
> 
> 

  reply	other threads:[~2024-03-13 19:22 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-13 17:40 [PATCH v2 0/6] Series to add triggered buffer support to BMP280 driver Vasileios Amoiridis
2024-03-13 17:40 ` [PATCH v2 1/6] iio: pressure: BMP280 core driver headers sorting Vasileios Amoiridis
2024-03-13 17:40 ` [PATCH v2 2/6] iio: pressure: Simplify read_* functions Vasileios Amoiridis
2024-03-13 19:01   ` Andy Shevchenko
2024-03-13 19:22     ` Vasileios Amoiridis [this message]
2024-03-13 19:28       ` Andy Shevchenko
2024-03-14 14:32         ` Jonathan Cameron
2024-03-14 19:52           ` Vasileios Amoiridis
2024-03-14 14:38   ` Jonathan Cameron
2024-03-13 17:40 ` [PATCH v3 3/6] iio: pressure: add SCALE and RAW values for channels Vasileios Amoiridis
2024-03-13 19:03   ` Andy Shevchenko
2024-03-13 19:51     ` Vasileios Amoiridis
2024-03-13 20:04       ` Andy Shevchenko
2024-03-13 21:28         ` Vasileios Amoiridis
2024-03-14 10:57           ` vamoirid
2024-03-14 14:46             ` Jonathan Cameron
2024-03-14 20:06               ` Vasileios Amoiridis
2024-03-15 13:11               ` Vasileios Amoiridis
2024-03-16 13:51                 ` Jonathan Cameron
2024-03-14 14:48   ` Jonathan Cameron
2024-03-13 17:40 ` [PATCH v2 4/6] iio: pressure: Simplify and make more clear temperature readings Vasileios Amoiridis
2024-03-13 19:04   ` Andy Shevchenko
2024-03-14 14:51     ` Jonathan Cameron
2024-03-14 15:09   ` Jonathan Cameron
2024-03-14 20:17     ` Vasileios Amoiridis
2024-03-14 23:22       ` Angel Iglesias
2024-03-15  9:05         ` Vasileios Amoiridis
2024-03-15 13:28           ` Angel Iglesias
2024-03-16 14:00             ` Jonathan Cameron
2024-03-13 17:40 ` [PATCH v2 5/6] iio: pressure: Add timestamp and scan_masks for BMP280 driver Vasileios Amoiridis
2024-03-13 18:54   ` Andy Shevchenko
2024-03-13 19:55     ` Vasileios Amoiridis
2024-03-13 17:40 ` [PATCH v2 6/6] iio: pressure: Add triggered buffer support " Vasileios Amoiridis
2024-03-13 18:58   ` Andy Shevchenko
2024-03-13 20:00     ` Vasileios Amoiridis
2024-03-14 15:25   ` Jonathan Cameron
2024-03-14 20:14     ` Vasileios Amoiridis
2024-03-16 14:03       ` 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=20240313192245.GA1938985@vamoiridPC \
    --to=vassilisamir@gmail.com \
    --cc=579lpy@gmail.com \
    --cc=ak@it-klinger.de \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=ang.iglesiasg@gmail.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --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 \
    /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.