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] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 10 Feb 2022 17:47:26 +0100
From:   Peter Rosin <peda@...ntia.se>
To:     Liam Beguin <liambeguin@...il.com>, jic23@...nel.org,
        andy.shevchenko@...il.com, lars@...afoo.de
Cc:     linux-kernel@...r.kernel.org, linux-iio@...r.kernel.org,
        devicetree@...r.kernel.org, robh+dt@...nel.org
Subject: Re: [PATCH v14 03/11] iio: afe: rescale: add offset support

Hi!

On 2022-02-08 03:04, Liam Beguin wrote:
> This is a preparatory change required for the addition of temperature
> sensing front ends.
> 
> Signed-off-by: Liam Beguin <liambeguin@...il.com>
> Reviewed-by: Peter Rosin <peda@...ntia.se>
> ---
>  drivers/iio/afe/iio-rescale.c   | 81 +++++++++++++++++++++++++++++++++
>  include/linux/iio/afe/rescale.h |  4 ++
>  2 files changed, 85 insertions(+)
> 
> diff --git a/drivers/iio/afe/iio-rescale.c b/drivers/iio/afe/iio-rescale.c
> index f833eb38f8bb..63035b4bce5e 100644
> --- a/drivers/iio/afe/iio-rescale.c
> +++ b/drivers/iio/afe/iio-rescale.c
> @@ -3,6 +3,7 @@
>   * IIO rescale driver
>   *
>   * Copyright (C) 2018 Axentia Technologies AB
> + * Copyright (C) 2022 Liam Beguin <liambeguin@...il.com>
>   *
>   * Author: Peter Rosin <peda@...ntia.se>
>   */
> @@ -82,11 +83,46 @@ int rescale_process_scale(struct rescale *rescale, int scale_type,
>  	}
>  }
>  
> +int rescale_process_offset(struct rescale *rescale, int scale_type,
> +			   int scale, int scale2, int schan_off,
> +			   int *val, int *val2)
> +{
> +	s64 tmp, tmp2;
> +
> +	switch (scale_type) {
> +	case IIO_VAL_FRACTIONAL:
> +		tmp = (s64)rescale->offset * scale2;
> +		*val = div_s64(tmp, scale) + schan_off;
> +		return IIO_VAL_INT;
> +	case IIO_VAL_INT:
> +		*val = div_s64(rescale->offset, scale) + schan_off;
> +		return IIO_VAL_INT;
> +	case IIO_VAL_FRACTIONAL_LOG2:
> +		tmp = (s64)rescale->offset * (1 << scale2);
> +		*val = div_s64(tmp, scale) + schan_off;
> +		return IIO_VAL_INT;
> +	case IIO_VAL_INT_PLUS_NANO:
> +		tmp = (s64)rescale->offset * GIGA;
> +		tmp2 = ((s64)scale * GIGA) + scale2;

Same thing here as in patch 2/11, use NANO or the raw number. GIGA
has no connection to the usage.

> +		*val = div64_s64(tmp, tmp2) + schan_off;
> +		return IIO_VAL_INT;
> +	case IIO_VAL_INT_PLUS_MICRO:
> +		tmp = (s64)rescale->offset * MEGA;
> +		tmp2 = ((s64)scale * MEGA) + scale2;

And MICRO here of course.

Cheers,
Peter

*snip*

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ