[PATCH RFC 5/6] iio: common: ssp_sensors: make use of iio_is_soft_ts_enabled()

Vasileios Amoiridis posted 6 patches 3 weeks, 5 days ago
[PATCH RFC 5/6] iio: common: ssp_sensors: make use of iio_is_soft_ts_enabled()
Posted by Vasileios Amoiridis 3 weeks, 5 days ago
Use the iio_is_soft_ts_enabled() accessor to access the value of the
scan_timestamp. This way, it can be marked as __private when there
are no direct accessors of it.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
---
 drivers/iio/common/ssp_sensors/ssp_iio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/common/ssp_sensors/ssp_iio.c b/drivers/iio/common/ssp_sensors/ssp_iio.c
index 88b8b56bfa51..c38bf1dfb7bd 100644
--- a/drivers/iio/common/ssp_sensors/ssp_iio.c
+++ b/drivers/iio/common/ssp_sensors/ssp_iio.c
@@ -82,7 +82,7 @@ int ssp_common_process_data(struct iio_dev *indio_dev, void *buf,
 	 */
 	memcpy(spd->buffer, buf, len);
 
-	if (indio_dev->scan_timestamp) {
+	if (iio_is_soft_ts_enabled(indio_dev)) {
 		memcpy(&time, &((char *)buf)[len], SSP_TIME_SIZE);
 		calculated_time =
 			timestamp + (int64_t)le32_to_cpu(time) * 1000000;
-- 
2.43.0
Re: [PATCH RFC 5/6] iio: common: ssp_sensors: make use of iio_is_soft_ts_enabled()
Posted by Jonathan Cameron 3 weeks, 4 days ago
On Sat, 30 Nov 2024 01:27:09 +0100
Vasileios Amoiridis <vassilisamir@gmail.com> wrote:

> Use the iio_is_soft_ts_enabled() accessor to access the value of the
> scan_timestamp. This way, it can be marked as __private when there
> are no direct accessors of it.
> 
> Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>

> ---
>  drivers/iio/common/ssp_sensors/ssp_iio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/common/ssp_sensors/ssp_iio.c b/drivers/iio/common/ssp_sensors/ssp_iio.c
> index 88b8b56bfa51..c38bf1dfb7bd 100644
> --- a/drivers/iio/common/ssp_sensors/ssp_iio.c
> +++ b/drivers/iio/common/ssp_sensors/ssp_iio.c
> @@ -82,7 +82,7 @@ int ssp_common_process_data(struct iio_dev *indio_dev, void *buf,
>  	 */
>  	memcpy(spd->buffer, buf, len);
>  
> -	if (indio_dev->scan_timestamp) {
> +	if (iio_is_soft_ts_enabled(indio_dev)) {

It might be simpler to just drop this conditional in favour of always computing the
value.



>  		memcpy(&time, &((char *)buf)[len], SSP_TIME_SIZE);
>  		calculated_time =
>  			timestamp + (int64_t)le32_to_cpu(time) * 1000000;

Good to replace this with something more modern like.

		calculated_time =
			timestamp + get_unaligned_le32(buf + len) * MEGA;

Jonathan
Re: [PATCH RFC 5/6] iio: common: ssp_sensors: make use of iio_is_soft_ts_enabled()
Posted by Vasileios Amoiridis 3 weeks, 1 day ago
On Sat, Nov 30, 2024 at 02:17:14PM +0000, Jonathan Cameron wrote:
> On Sat, 30 Nov 2024 01:27:09 +0100
> Vasileios Amoiridis <vassilisamir@gmail.com> wrote:
> 
> > Use the iio_is_soft_ts_enabled() accessor to access the value of the
> > scan_timestamp. This way, it can be marked as __private when there
> > are no direct accessors of it.
> > 
> > Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
> 
> > ---
> >  drivers/iio/common/ssp_sensors/ssp_iio.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iio/common/ssp_sensors/ssp_iio.c b/drivers/iio/common/ssp_sensors/ssp_iio.c
> > index 88b8b56bfa51..c38bf1dfb7bd 100644
> > --- a/drivers/iio/common/ssp_sensors/ssp_iio.c
> > +++ b/drivers/iio/common/ssp_sensors/ssp_iio.c
> > @@ -82,7 +82,7 @@ int ssp_common_process_data(struct iio_dev *indio_dev, void *buf,
> >  	 */
> >  	memcpy(spd->buffer, buf, len);
> >  
> > -	if (indio_dev->scan_timestamp) {
> > +	if (iio_is_soft_ts_enabled(indio_dev)) {
> 
> It might be simpler to just drop this conditional in favour of always computing the
> value.
> 
> 
> 
> >  		memcpy(&time, &((char *)buf)[len], SSP_TIME_SIZE);
> >  		calculated_time =
> >  			timestamp + (int64_t)le32_to_cpu(time) * 1000000;
> 
> Good to replace this with something more modern like.
> 
> 		calculated_time =
> 			timestamp + get_unaligned_le32(buf + len) * MEGA;
> 
> Jonathan
>

Hi Jonathan,

I could definitely do this, thanks!

Cheers,
Vasilis