Re: [PATCH 7/7] drivers: iio: imu: Add support for adis1657x family

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 8 May 2024 17:32:34 +0300
Ramona Gradinariu <ramona.bolboaca13@xxxxxxxxx> 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




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux