Linux IIO development
 help / color / mirror / Atom feed
* [PATCH v3] iio: core: added support for IIO_VAL_INT
@ 2015-11-09 12:55 Sean Nyekjaer
  2015-11-15 10:54 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Sean Nyekjaer @ 2015-11-09 12:55 UTC (permalink / raw)
  To: linux-iio; +Cc: Sean Nyekjaer

Added core support for IIO_VAL_INT in write_raw_get_fmt function.

Signed-off-by: Sean Nyekjaer <sean.nyekjaer@prevas.dk>
---
Sorry for v1, i've missed the "too many 'd's" comment

Changes since v2:
 - Fixed commit msg

Changes since v1:
 - fract_mult set to 0
 - iio_str_to_fixpoint uses kstrtoint for fract_mult = 0

 drivers/iio/industrialio-core.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 208358f..d0a84fe 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -512,6 +512,12 @@ int iio_str_to_fixpoint(const char *str, int fract_mult,
 	int i = 0, f = 0;
 	bool integer_part = true, negative = false;
 
+	if (fract_mult == 0) {
+		*fract = 0;
+
+		return kstrtoint(str, 0, integer);
+	}
+
 	if (str[0] == '-') {
 		negative = true;
 		str++;
@@ -571,6 +577,9 @@ static ssize_t iio_write_channel_info(struct device *dev,
 	if (indio_dev->info->write_raw_get_fmt)
 		switch (indio_dev->info->write_raw_get_fmt(indio_dev,
 			this_attr->c, this_attr->address)) {
+		case IIO_VAL_INT:
+			fract_mult = 0;
+			break;
 		case IIO_VAL_INT_PLUS_MICRO:
 			fract_mult = 100000;
 			break;
-- 
2.6.2


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

* Re: [PATCH v3] iio: core: added support for IIO_VAL_INT
  2015-11-09 12:55 [PATCH v3] iio: core: added support for IIO_VAL_INT Sean Nyekjaer
@ 2015-11-15 10:54 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2015-11-15 10:54 UTC (permalink / raw)
  To: Sean Nyekjaer, linux-iio

On 09/11/15 12:55, Sean Nyekjaer wrote:
> Added core support for IIO_VAL_INT in write_raw_get_fmt function.
> 
> Signed-off-by: Sean Nyekjaer <sean.nyekjaer@prevas.dk>
Applied to the togreg branch of iio.git - initially pushed out as
testing for the autobuilders to try and break it.

Thanks for sorting this out!

Jonathan
> ---
> Sorry for v1, i've missed the "too many 'd's" comment
> 
> Changes since v2:
>  - Fixed commit msg
> 
> Changes since v1:
>  - fract_mult set to 0
>  - iio_str_to_fixpoint uses kstrtoint for fract_mult = 0
> 
>  drivers/iio/industrialio-core.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index 208358f..d0a84fe 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -512,6 +512,12 @@ int iio_str_to_fixpoint(const char *str, int fract_mult,
>  	int i = 0, f = 0;
>  	bool integer_part = true, negative = false;
>  
> +	if (fract_mult == 0) {
> +		*fract = 0;
> +
> +		return kstrtoint(str, 0, integer);
> +	}
> +
>  	if (str[0] == '-') {
>  		negative = true;
>  		str++;
> @@ -571,6 +577,9 @@ static ssize_t iio_write_channel_info(struct device *dev,
>  	if (indio_dev->info->write_raw_get_fmt)
>  		switch (indio_dev->info->write_raw_get_fmt(indio_dev,
>  			this_attr->c, this_attr->address)) {
> +		case IIO_VAL_INT:
> +			fract_mult = 0;
> +			break;
>  		case IIO_VAL_INT_PLUS_MICRO:
>  			fract_mult = 100000;
>  			break;
> 


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

end of thread, other threads:[~2015-11-15 10:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-09 12:55 [PATCH v3] iio: core: added support for IIO_VAL_INT Sean Nyekjaer
2015-11-15 10:54 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox