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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Sat, 11 May 2024 12:27:08 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Ramona Gradinariu <ramona.bolboaca13@...il.com>
Cc: linux-kernel@...r.kernel.org, linux-iio@...r.kernel.org,
 devicetree@...r.kernel.org, conor+dt@...nel.org,
 krzysztof.kozlowski+dt@...aro.org, robh@...nel.org, nuno.sa@...log.com
Subject: Re: [PATCH 7/7] drivers: iio: imu: Add support for adis1657x family

On Wed, 8 May 2024 17:32:34 +0300
Ramona Gradinariu <ramona.bolboaca13@...il.com> wrote:

> Hello Jonathan,
> 
> Some explanations from my side.
> 
> >> @@ -437,6 +467,130 @@ static int adis16475_set_filter(struct adis16475 *st, const u32 filter)
> >>  	return 0;
> >>  }
> >>  
> >> +static ssize_t adis16475_get_fifo_enabled(struct device *dev,
> >> +					  struct device_attribute *attr,
> >> +					  char *buf)
> >> +{
> >> +	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> >> +	struct adis16475 *st = iio_priv(indio_dev);
> >> +	int ret;
> >> +	u16 val;
> >> +
> >> +	ret = adis_read_reg_16(&st->adis, ADIS16475_REG_FIFO_CTRL, &val);
> >> +	if (ret)
> >> +		return ret;
> >> +	val = FIELD_GET(ADIS16475_FIFO_EN_MASK, val);
> >> +
> >> +	return sysfs_emit(buf, "%d\n", val);  
> > As below, might as well put the FIELD_GET() in the sysfs_emit rather than
> > writing the local parameter.  
> 
> In all instances where I did, I did it to avoid casting. v2 inlines the values and
> the cast is needed to avoid compilation errors.

I'd guess that is because the type in the sysfs_emit isn't the same as FIELD_GET()
returns?  That will correspond to the type of the ADIS16475_FIFO_EN_MASK
which is defined as UL I think. So just use %lu here instead and need to cast goes
away. 

> 
> > 	  
> >> +	if (adis->data->burst_max_len)
> >> +		burst_max_length = adis->data->burst_max_len;
> >> +	else
> >> +		burst_max_length = burst_length;
> >> +
> >> +	tx = adis->buffer + burst_max_length;
> >> +	tx[0] = ADIS_READ_REG(burst_req);
> >> +
> >> +	if (burst_req)  
> > If !burst_req does the rest of this do anything at all?
> > If so flip the logic as
> > 	if (!burst_req)
> > 		return adis16475_push_single_sample(pf);
> >
> > 	the rest...
> > 	return spi_sync(adis->spi, &adis->msg);  
> 
> The update is needed even if burst_req is false. The adis message has to be updated
> based on the burst request value, which is then used either in 
> adis16475_push_single_sample or in spi_sync call.

Which update?  The content of tx[0]?  If so that is non obvious so definitely
need a comment. Perhaps even wrap up the update in a function with a name
that makes it clear it's changing the adis->msg.

adis_update_msg_burst() or something like that.
> 
> > 		
> >  
> >> +		return spi_sync(adis->spi, &adis->msg);
> >> +
> >> +	return adis16475_push_single_sample(pf);
> >> +}
> >> +

Jonathan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ