linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: inkern: add iio_write_channel_raw
@ 2014-11-26 22:42 Dmitry Eremin-Solenikov
  2014-11-27  8:07 ` Lars-Peter Clausen
  2014-12-10 23:01 ` Hartmut Knaack
  0 siblings, 2 replies; 5+ messages in thread
From: Dmitry Eremin-Solenikov @ 2014-11-26 22:42 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald
  Cc: linux-iio

Introduce API for easy in-kernel setting of DAC values.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/iio/inkern.c         | 29 +++++++++++++++++++++++++++++
 include/linux/iio/consumer.h | 11 +++++++++++
 2 files changed, 40 insertions(+)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index f084610..5b03e69 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -608,3 +608,32 @@ err_unlock:
 	return ret;
 }
 EXPORT_SYMBOL_GPL(iio_get_channel_type);
+
+static int iio_channel_write(struct iio_channel *chan, int val, int val2,
+	enum iio_chan_info_enum info)
+{
+	int ret;
+
+	ret = chan->indio_dev->info->write_raw(chan->indio_dev,
+			chan->channel, val, val2, info);
+
+	return ret;
+}
+
+int iio_write_channel_raw(struct iio_channel *chan, int val)
+{
+	int ret;
+
+	mutex_lock(&chan->indio_dev->info_exist_lock);
+	if (chan->indio_dev->info == NULL) {
+		ret = -ENODEV;
+		goto err_unlock;
+	}
+
+	ret = iio_channel_write(chan, val, 0, IIO_CHAN_INFO_RAW);
+err_unlock:
+	mutex_unlock(&chan->indio_dev->info_exist_lock);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(iio_write_channel_raw);
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
index 651f9a0..06f4688 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -151,6 +151,17 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val);
 int iio_read_channel_processed(struct iio_channel *chan, int *val);
 
 /**
+ * iio_write_channel_raw() - write to a given channel
+ * @chan:		The channel being queried.
+ * @val:		Value being written.
+ *
+ * Note raw writes to iio channels are in dac counts and hence
+ * scale will need to be applied if standard units required.
+ */
+int iio_write_channel_raw(struct iio_channel *chan,
+			 int val);
+
+/**
  * iio_get_channel_type() - get the type of a channel
  * @channel:		The channel being queried.
  * @type:		The type of the channel.
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] iio: inkern: add iio_write_channel_raw
  2014-11-26 22:42 [PATCH] iio: inkern: add iio_write_channel_raw Dmitry Eremin-Solenikov
@ 2014-11-27  8:07 ` Lars-Peter Clausen
  2014-12-10 23:01 ` Hartmut Knaack
  1 sibling, 0 replies; 5+ messages in thread
From: Lars-Peter Clausen @ 2014-11-27  8:07 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov, Jonathan Cameron, Hartmut Knaack,
	Peter Meerwald
  Cc: linux-iio

On 11/26/2014 11:42 PM, Dmitry Eremin-Solenikov wrote:
> Introduce API for easy in-kernel setting of DAC values.
>
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>

Looks good...

> ---
>   drivers/iio/inkern.c         | 29 +++++++++++++++++++++++++++++
>   include/linux/iio/consumer.h | 11 +++++++++++
>   2 files changed, 40 insertions(+)
>
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index f084610..5b03e69 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -608,3 +608,32 @@ err_unlock:
>   	return ret;
>   }
>   EXPORT_SYMBOL_GPL(iio_get_channel_type);
> +
> +static int iio_channel_write(struct iio_channel *chan, int val, int val2,
> +	enum iio_chan_info_enum info)
> +{
> +	int ret;
> +
> +	ret = chan->indio_dev->info->write_raw(chan->indio_dev,
> +			chan->channel, val, val2, info);
> +
> +	return ret;


... but this is something the kbuild bot tester will complain about. There 
is no need for the ret variable.

> +}



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] iio: inkern: add iio_write_channel_raw
  2014-11-26 22:42 [PATCH] iio: inkern: add iio_write_channel_raw Dmitry Eremin-Solenikov
  2014-11-27  8:07 ` Lars-Peter Clausen
@ 2014-12-10 23:01 ` Hartmut Knaack
  2014-12-12 10:17   ` Jonathan Cameron
  1 sibling, 1 reply; 5+ messages in thread
From: Hartmut Knaack @ 2014-12-10 23:01 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov, Jonathan Cameron, Lars-Peter Clausen,
	Peter Meerwald
  Cc: linux-iio

Dmitry Eremin-Solenikov schrieb am 26.11.2014 um 23:42:
> Introduce API for easy in-kernel setting of DAC values.
> 
Looking good in general, but indentation of parameters could be
improved to align with opening parenthesis. See inline.
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> ---
>  drivers/iio/inkern.c         | 29 +++++++++++++++++++++++++++++
>  include/linux/iio/consumer.h | 11 +++++++++++
>  2 files changed, 40 insertions(+)
> 
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index f084610..5b03e69 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -608,3 +608,32 @@ err_unlock:
>  	return ret;
>  }
>  EXPORT_SYMBOL_GPL(iio_get_channel_type);
> +
> +static int iio_channel_write(struct iio_channel *chan, int val, int val2,
> +	enum iio_chan_info_enum info)
Here.
> +{
> +	int ret;
> +
> +	ret = chan->indio_dev->info->write_raw(chan->indio_dev,
> +			chan->channel, val, val2, info);
Here.
> +
> +	return ret;
> +}
> +
> +int iio_write_channel_raw(struct iio_channel *chan, int val)
> +{
> +	int ret;
> +
> +	mutex_lock(&chan->indio_dev->info_exist_lock);
> +	if (chan->indio_dev->info == NULL) {
> +		ret = -ENODEV;
> +		goto err_unlock;
> +	}
> +
> +	ret = iio_channel_write(chan, val, 0, IIO_CHAN_INFO_RAW);
> +err_unlock:
> +	mutex_unlock(&chan->indio_dev->info_exist_lock);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(iio_write_channel_raw);
> diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
> index 651f9a0..06f4688 100644
> --- a/include/linux/iio/consumer.h
> +++ b/include/linux/iio/consumer.h
> @@ -151,6 +151,17 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val);
>  int iio_read_channel_processed(struct iio_channel *chan, int *val);
>  
>  /**
> + * iio_write_channel_raw() - write to a given channel
> + * @chan:		The channel being queried.
> + * @val:		Value being written.
> + *
> + * Note raw writes to iio channels are in dac counts and hence
> + * scale will need to be applied if standard units required.
> + */
> +int iio_write_channel_raw(struct iio_channel *chan,
> +			 int val);
And here, everything would easily fit in just one line.
> +
> +/**
>   * iio_get_channel_type() - get the type of a channel
>   * @channel:		The channel being queried.
>   * @type:		The type of the channel.
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] iio: inkern: add iio_write_channel_raw
  2014-12-10 23:01 ` Hartmut Knaack
@ 2014-12-12 10:17   ` Jonathan Cameron
  2014-12-12 13:33     ` Dmitry Eremin-Solenikov
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2014-12-12 10:17 UTC (permalink / raw)
  To: Hartmut Knaack, Dmitry Eremin-Solenikov, Lars-Peter Clausen,
	Peter Meerwald
  Cc: linux-iio

On 10/12/14 23:01, Hartmut Knaack wrote:
> Dmitry Eremin-Solenikov schrieb am 26.11.2014 um 23:42:
>> Introduce API for easy in-kernel setting of DAC values.
>>
> Looking good in general, but indentation of parameters could be
> improved to align with opening parenthesis. See inline.
>> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
I've fixed up both Lars and Hartmut's comments and applied to the
togreg branch of iio.git - initially pushed out as testing sometime
later today.  Lots to catch up with first ;)
>> ---
>>  drivers/iio/inkern.c         | 29 +++++++++++++++++++++++++++++
>>  include/linux/iio/consumer.h | 11 +++++++++++
>>  2 files changed, 40 insertions(+)
>>
>> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
>> index f084610..5b03e69 100644
>> --- a/drivers/iio/inkern.c
>> +++ b/drivers/iio/inkern.c
>> @@ -608,3 +608,32 @@ err_unlock:
>>  	return ret;
>>  }
>>  EXPORT_SYMBOL_GPL(iio_get_channel_type);
>> +
>> +static int iio_channel_write(struct iio_channel *chan, int val, int val2,
>> +	enum iio_chan_info_enum info)
> Here.
>> +{
>> +	int ret;
>> +
>> +	ret = chan->indio_dev->info->write_raw(chan->indio_dev,
>> +			chan->channel, val, val2, info);
> Here.
>> +
>> +	return ret;
>> +}
>> +
>> +int iio_write_channel_raw(struct iio_channel *chan, int val)
>> +{
>> +	int ret;
>> +
>> +	mutex_lock(&chan->indio_dev->info_exist_lock);
>> +	if (chan->indio_dev->info == NULL) {
>> +		ret = -ENODEV;
>> +		goto err_unlock;
>> +	}
>> +
>> +	ret = iio_channel_write(chan, val, 0, IIO_CHAN_INFO_RAW);
>> +err_unlock:
>> +	mutex_unlock(&chan->indio_dev->info_exist_lock);
>> +
>> +	return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(iio_write_channel_raw);
>> diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
>> index 651f9a0..06f4688 100644
>> --- a/include/linux/iio/consumer.h
>> +++ b/include/linux/iio/consumer.h
>> @@ -151,6 +151,17 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val);
>>  int iio_read_channel_processed(struct iio_channel *chan, int *val);
>>  
>>  /**
>> + * iio_write_channel_raw() - write to a given channel
>> + * @chan:		The channel being queried.
>> + * @val:		Value being written.
>> + *
>> + * Note raw writes to iio channels are in dac counts and hence
>> + * scale will need to be applied if standard units required.
>> + */
>> +int iio_write_channel_raw(struct iio_channel *chan,
>> +			 int val);
> And here, everything would easily fit in just one line.
>> +
>> +/**
>>   * iio_get_channel_type() - get the type of a channel
>>   * @channel:		The channel being queried.
>>   * @type:		The type of the channel.
>>
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] iio: inkern: add iio_write_channel_raw
  2014-12-12 10:17   ` Jonathan Cameron
@ 2014-12-12 13:33     ` Dmitry Eremin-Solenikov
  0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Eremin-Solenikov @ 2014-12-12 13:33 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald, linux-iio

2014-12-12 13:17 GMT+03:00 Jonathan Cameron <jic23@kernel.org>:
> On 10/12/14 23:01, Hartmut Knaack wrote:
>> Dmitry Eremin-Solenikov schrieb am 26.11.2014 um 23:42:
>>> Introduce API for easy in-kernel setting of DAC values.
>>>
>> Looking good in general, but indentation of parameters could be
>> improved to align with opening parenthesis. See inline.
>>> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> I've fixed up both Lars and Hartmut's comments and applied to the
> togreg branch of iio.git - initially pushed out as testing sometime
> later today.  Lots to catch up with first ;)

Thank you. I was under the pile of other patches, so didn't have time
to react to those comments.

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-12-12 13:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-26 22:42 [PATCH] iio: inkern: add iio_write_channel_raw Dmitry Eremin-Solenikov
2014-11-27  8:07 ` Lars-Peter Clausen
2014-12-10 23:01 ` Hartmut Knaack
2014-12-12 10:17   ` Jonathan Cameron
2014-12-12 13:33     ` Dmitry Eremin-Solenikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).