lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 13 Mar 2024 20:22:45 +0100
From: Vasileios Amoiridis <vassilisamir@...il.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Vasileios Amoiridis <vassilisamir@...il.com>, jic23@...nel.org,
	lars@...afoo.de, ang.iglesiasg@...il.com, mazziesaccount@...il.com,
	ak@...klinger.de, petre.rodan@...dimension.ro,
	linus.walleij@...aro.org, phil@...pberrypi.com, 579lpy@...il.com,
	linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/6] iio: pressure: Simplify read_* functions

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
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ