linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: michael.hennerich@analog.com
Cc: linux-iio@vger.kernel.org, device-drivers-devel@blackfin.uclinux.org
Subject: Re: [PATCH 1/3] iio: core: introduce dB scle: IIO_VAL_INT_PLUS_MICRO_DB
Date: Thu, 10 May 2012 09:09:07 +0100	[thread overview]
Message-ID: <4FAB77A3.2020507@kernel.org> (raw)
In-Reply-To: <1336559774-21136-1-git-send-email-michael.hennerich@analog.com>

On 5/9/2012 11:36 AM, michael.hennerich@analog.com wrote:
> From: Michael Hennerich<michael.hennerich@analog.com>
All looks fine and sensible cleaning up whilst you were at it.
> Signed-off-by: Michael Hennerich<michael.hennerich@analog.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
> ---
>   drivers/iio/industrialio-core.c |   19 +++++++++++++------
>   include/linux/iio/types.h       |    1 +
>   2 files changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index 72e33b8..e799d35 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -306,26 +306,33 @@ static ssize_t iio_read_channel_info(struct device *dev,
>   	struct iio_dev *indio_dev = dev_get_drvdata(dev);
>   	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
>   	int val, val2;
> +	bool scale_db = false;
>   	int ret = indio_dev->info->read_raw(indio_dev, this_attr->c,
>   					&val,&val2, this_attr->address);
>
>   	if (ret<  0)
>   		return ret;
>
> -	if (ret == IIO_VAL_INT)
> +	switch (ret) {
> +	case IIO_VAL_INT:
>   		return sprintf(buf, "%d\n", val);
> -	else if (ret == IIO_VAL_INT_PLUS_MICRO) {
> +	case IIO_VAL_INT_PLUS_MICRO_DB:
> +		scale_db = true;
> +	case IIO_VAL_INT_PLUS_MICRO:
>   		if (val2<  0)
> -			return sprintf(buf, "-%d.%06u\n", val, -val2);
> +			return sprintf(buf, "-%d.%06u%s\n", val, -val2,
> +				scale_db ? " dB" : "");
>   		else
> -			return sprintf(buf, "%d.%06u\n", val, val2);
> -	} else if (ret == IIO_VAL_INT_PLUS_NANO) {
> +			return sprintf(buf, "%d.%06u%s\n", val, val2,
> +				scale_db ? " dB" : "");
> +	case IIO_VAL_INT_PLUS_NANO:
>   		if (val2<  0)
>   			return sprintf(buf, "-%d.%09u\n", val, -val2);
>   		else
>   			return sprintf(buf, "%d.%09u\n", val, val2);
> -	} else
> +	default:
>   		return 0;
> +	}
>   }
>
>   static ssize_t iio_write_channel_info(struct device *dev,
> diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h
> index a471fd5..1b073b1 100644
> --- a/include/linux/iio/types.h
> +++ b/include/linux/iio/types.h
> @@ -50,5 +50,6 @@ enum iio_modifier {
>   #define IIO_VAL_INT 1
>   #define IIO_VAL_INT_PLUS_MICRO 2
>   #define IIO_VAL_INT_PLUS_NANO 3
> +#define IIO_VAL_INT_PLUS_MICRO_DB 4
>
>   #endif /* _IIO_TYPES_H_ */


  parent reply	other threads:[~2012-05-10  8:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-09 10:36 [PATCH 1/3] iio: core: introduce dB scle: IIO_VAL_INT_PLUS_MICRO_DB michael.hennerich
2012-05-09 10:36 ` [PATCH 2/3] iio: core: introduce IIO_CHAN_INFO_HARDWAREGAIN michael.hennerich
2012-05-10  8:09   ` Jonathan Cameron
2012-05-09 10:36 ` [PATCH 3/3] iio: amplifiers: New driver for AD8366 Dual-Digital Variable Gain Amplifier michael.hennerich
2012-05-10  9:08   ` Jonathan Cameron
2012-05-11  7:32     ` Michael Hennerich
2012-05-11  7:36       ` Jonathan Cameron
2012-05-10  8:09 ` Jonathan Cameron [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-05-11  9:36 [PATCH 1/3] iio: core: introduce dB scle: IIO_VAL_INT_PLUS_MICRO_DB michael.hennerich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FAB77A3.2020507@kernel.org \
    --to=jic23@kernel.org \
    --cc=device-drivers-devel@blackfin.uclinux.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=michael.hennerich@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).