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]
Message-ID: <20201213193436.GM1781038@piout.net>
Date:   Sun, 13 Dec 2020 20:34:36 +0100
From:   Alexandre Belloni <alexandre.belloni@...tlin.com>
To:     Jonathan Cameron <jic23@...nel.org>
Cc:     Lars-Peter Clausen <lars@...afoo.de>,
        Peter Meerwald-Stadler <pmeerw@...erw.net>,
        linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 5/6] iio:common:ms_sensors:ms_sensors_i2c: add support
 for alternative PROM layout

On 13/12/2020 17:20:42+0000, Jonathan Cameron wrote:
> > +/**
> > + * ms_sensors_tp_crc_valid_112() - CRC check function for
> > + *     Temperature and pressure devices for 112bit PROM.
> > + *     This function is only used when reading PROM coefficients
> > + *
> > + * @prom:	pointer to PROM coefficients array
> > + *
> > + * Return: CRC.
> 
> That's a bit confusing.  Perhaps return if CRC correct
> Sometimes CRC is used to refer to particular bits and sometimes
> to the check (i.e. whether it is right).
> 

Roght, this should have been "Return: True if CRC is ok."

> > + */
> > +static bool ms_sensors_tp_crc_valid_112(u16 *prom)
> > +{
> > +	u16 w0 = prom[0], crc_read = (w0 & 0xF000) >> 12;
> > +	u8 crc;
> > +
> > +	prom[0] &= 0x0FFF;      /* Clear the CRC computation part */
> > +	prom[MS_SENSORS_TP_PROM_WORDS_NB - 1] = 0;
> > +
> > +	crc = ms_sensors_tp_crc4(prom);
> > +
> > +	prom[0] = w0;
> > +
> > +	return crc == crc_read;
> > +}
> > +
> > +/**
> > + * ms_sensors_tp_crc_valid_128() - CRC check function for
> > + *     Temperature and pressure devices for 128bit PROM.
> > + *     This function is only used when reading PROM coefficients
> > + *
> > + * @prom:	pointer to PROM coefficients array
> > + *
> > + * Return: CRC.
> > + */
> > +static bool ms_sensors_tp_crc_valid_128(u16 *prom)
> > +{
> > +	u16 w7 = prom[7], crc_read = w7 & 0x000F;
> > +	u8 crc;
> > +
> > +	prom[7] &= 0xFF00;      /* Clear the CRC and LSB part */
> > +
> > +	crc = ms_sensors_tp_crc4(prom);
> > +
> > +	prom[7] = w7;
> > +
> > +	return crc == crc_read;
> >  }
> >  
> >  /**
> > @@ -535,6 +577,7 @@ static bool ms_sensors_tp_crc_valid(u16 *prom)
> >  int ms_sensors_tp_read_prom(struct ms_tp_dev *dev_data)
> >  {
> >  	int i, ret;
> > +	bool valid;
> >  
> >  	for (i = 0; i < dev_data->hw->prom_len; i++) {
> >  		ret = ms_sensors_read_prom_word(
> > @@ -546,7 +589,12 @@ int ms_sensors_tp_read_prom(struct ms_tp_dev *dev_data)
> >  			return ret;
> >  	}
> >  
> > -	if (!ms_sensors_tp_crc_valid(dev_data->prom)) {
> > +	if (dev_data->hw->prom_len == 8)
> > +		valid = ms_sensors_tp_crc_valid_128(dev_data->prom);
> > +	else
> > +		valid = ms_sensors_tp_crc_valid_112(dev_data->prom);
> > +
> > +	if (!valid) {
> >  		dev_err(&dev_data->client->dev,
> >  			"Calibration coefficients crc check error\n");
> >  		return -ENODEV;
> 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ