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]
Message-ID: <alpine.DEB.2.01.1208160940380.3550@pmeerw.net>
Date:	Thu, 16 Aug 2012 09:42:13 +0200 (CEST)
From:	Peter Meerwald <pmeerw@...erw.net>
To:	"Kim, Milo" <Milo.Kim@...com>
cc:	Jonathan Cameron <jic23@...nel.org>,
	Lars-Peter Clausen <lars@...afoo.de>,
	"jic23@....ac.uk" <jic23@....ac.uk>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"linux-iio@...r.kernel.org" <linux-iio@...r.kernel.org>
Subject: Re: [PATCH 1/3] iio: add iio_read_channel_offset() consumer api


comment below

p.

> This allows the iio consumer to get the offset of the channel.
> The value of offset can be used when calculating the result such
> as 'result = raw * scale + offset'.
> 
> Signed-off-by: Milo(Woogyom) Kim <milo.kim@...com>
> ---
>  drivers/iio/inkern.c         |   21 +++++++++++++++++++++
>  include/linux/iio/consumer.h |    9 +++++++++
>  2 files changed, 30 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index b5afc2f..bd09245 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -269,6 +269,27 @@ err_unlock:
>  }
>  EXPORT_SYMBOL_GPL(iio_read_channel_scale);
>  
> +int iio_read_channel_offset(struct iio_channel *chan, int *val)
> +{
> +	int val2, ret;
> +
> +	mutex_lock(&chan->indio_dev->info_exist_lock);
> +	if (chan->indio_dev->info == NULL) {
> +		ret = -ENODEV;
> +		goto err_unlock;
> +	}
> +
> +	ret = chan->indio_dev->info->read_raw(chan->indio_dev,
> +					      chan->channel,
> +					      val, &val2,
> +					      IIO_CHAN_INFO_OFFSET);
> +err_unlock:
> +	mutex_unlock(&chan->indio_dev->info_exist_lock);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(iio_read_channel_offset);
> +
>  int iio_get_channel_type(struct iio_channel *chan, enum iio_chan_type *type)
>  {
>  	int ret = 0;
> diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
> index e2657e6..d9d69fa 100644
> --- a/include/linux/iio/consumer.h
> +++ b/include/linux/iio/consumer.h
> @@ -93,4 +93,13 @@ int iio_get_channel_type(struct iio_channel *channel,
>  int iio_read_channel_scale(struct iio_channel *chan, int *val,
>  			   int *val2);
>  
> +/**
> + * iio_read_channel_offset() - read offset from a given channel
> + * @channel:		The channel being queried.

the parameter is 'chan', not 'channel'

> + * @val:		Offset Value read back.
> + *
> + * Note offset can be used in the consumer when calculating the result
> + * such as 'result = raw * scale + offset'.
> + */
> +int iio_read_channel_offset(struct iio_channel *chan, int *val);
>  #endif
> 

-- 

Peter Meerwald
+43-664-2444418 (mobile)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ