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]
Date:   Wed, 18 Mar 2020 16:10:08 +0100
From:   Lars-Peter Clausen <lars@...afoo.de>
To:     Alexandru Ardelean <ardeleanalex@...il.com>,
        linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     Michael.Hennerich@...log.com, renatogeh@...il.com,
        jic23@...nel.org, mircea.caprioru@...log.com,
        Alexandru Ardelean <alexandru.ardelean@...log.com>
Subject: Re: [PATCH 5/5] iio: adc: ad7793: use read_avail iio hook for scale
 available

On 3/18/20 2:40 PM, Alexandru Ardelean wrote:
> This change uses the read_avail and '.info_mask_shared_by_type_available'
> modifier to set the available scale.
> Essentially, nothing changes to the driver's ABI.
> 
> The main idea for this patch is to remove the AD7793 driver from
> checkpatch's radar. There have been about ~3 attempts to fix/break the
> 'in_voltage-voltage_scale_available' attribute, because checkpatch assumed
> it to be an arithmetic operation and people were trying to change that.


Yeah, probably a good idea!

> 
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@...log.com>
> ---
>   drivers/iio/adc/ad7793.c | 53 +++++++++++++++++++++++++++-------------
>   1 file changed, 36 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c
> index 5592ae573e6b..fad98f1801db 100644
> --- a/drivers/iio/adc/ad7793.c
> +++ b/drivers/iio/adc/ad7793.c
> @@ -354,29 +354,28 @@ static IIO_CONST_ATTR_SAMP_FREQ_AVAIL(
>   static IIO_CONST_ATTR_NAMED(sampling_frequency_available_ad7797,
>   	sampling_frequency_available, "123 62 50 33 17 16 12 10 8 6 4");
>   
> -static ssize_t ad7793_show_scale_available(struct device *dev,
> -			struct device_attribute *attr, char *buf)
> +static int ad7793_read_avail(struct iio_dev *indio_dev,
> +			     struct iio_chan_spec const *chan,
> +			     const int **vals, int *type, int *length,
> +			     long mask)
>   {
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>   	struct ad7793_state *st = iio_priv(indio_dev);
> -	int i, len = 0;
>   
> -	for (i = 0; i < ARRAY_SIZE(st->scale_avail); i++)
> -		len += sprintf(buf + len, "%d.%09u ", st->scale_avail[i][0],
> -			       st->scale_avail[i][1]);
> +	switch (mask) {
> +	case IIO_CHAN_INFO_SCALE:
> +		*vals = (int *)st->scale_avail;

Can you change the type of scale_avail to int so we don't need the cast?

> +		*type = IIO_VAL_INT_PLUS_NANO;
> +		/* Values are stored in a 2D matrix  */
> +		*length = ARRAY_SIZE(st->scale_avail) * 2;
>   
> -	len += sprintf(buf + len, "\n");
> +		return IIO_AVAIL_LIST;
> +	}
>   
> -	return len;
> +	return -EINVAL;
>   }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ