From: Jonathan Cameron <jic23@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH v2 01/20] iio: Factor IIO value formating into its own function
Date: Sat, 12 Oct 2013 12:24:11 +0100 [thread overview]
Message-ID: <5259315B.3020305@kernel.org> (raw)
In-Reply-To: <1381155094-20166-1-git-send-email-lars@metafoo.de>
On 10/07/13 15:11, Lars-Peter Clausen wrote:
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git
There was a bit of fuzz so might be worth a sanity check that I haven't
messed it up.
Thanks,
> ---
> drivers/iio/iio_core.h | 2 ++
> drivers/iio/industrialio-core.c | 38 ++++++++++++++++++++++++++------------
> 2 files changed, 28 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/iio/iio_core.h b/drivers/iio/iio_core.h
> index 9209f47..0157686 100644
> --- a/drivers/iio/iio_core.h
> +++ b/drivers/iio/iio_core.h
> @@ -34,6 +34,8 @@ int __iio_add_chan_devattr(const char *postfix,
> struct device *dev,
> struct list_head *attr_list);
>
> +ssize_t iio_format_value(char *buf, unsigned int type, int val, int val2);
> +
> /* Event interface flags */
> #define IIO_BUSY_BIT_POS 1
>
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index 863aa01..af69723 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -362,22 +362,20 @@ ssize_t iio_enum_write(struct iio_dev *indio_dev,
> }
> EXPORT_SYMBOL_GPL(iio_enum_write);
>
> -static ssize_t iio_read_channel_info(struct device *dev,
> - struct device_attribute *attr,
> - char *buf)
> +/**
> + * iio_format_value() - Formats a IIO value into its string representation
> + * @buf: The buffer to which the formated value gets written
> + * @type: One of the IIO_VAL_... constants. This decides how the val and val2
> + * parameters are formatted.
> + * @val: First part of the value, exact meaning depends on the type parameter.
> + * @val2: Second part of the value, exact meaning depends on the type parameter.
> + */
> +ssize_t iio_format_value(char *buf, unsigned int type, int val, int val2)
> {
> - struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> - struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> unsigned long long tmp;
> - 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;
> -
> - switch (ret) {
> + switch (type) {
> case IIO_VAL_INT:
> return sprintf(buf, "%d\n", val);
> case IIO_VAL_INT_PLUS_MICRO_DB:
> @@ -409,6 +407,22 @@ static ssize_t iio_read_channel_info(struct device *dev,
> }
> }
>
> +static ssize_t iio_read_channel_info(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> + int val, val2;
> + int ret = indio_dev->info->read_raw(indio_dev, this_attr->c,
> + &val, &val2, this_attr->address);
> +
> + if (ret < 0)
> + return ret;
> +
> + return iio_format_value(buf, ret, val, val2);
> +}
> +
> /**
> * iio_str_to_fixpoint() - Parse a fixed-point number from a string
> * @str: The string to parse
>
prev parent reply other threads:[~2013-10-12 10:23 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-07 14:11 [PATCH v2 01/20] iio: Factor IIO value formating into its own function Lars-Peter Clausen
2013-10-07 14:11 ` [PATCH v2 02/20] iio: Extend the event config interface Lars-Peter Clausen
2013-10-12 11:33 ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 03/20] iio:max1363: Switch to new " Lars-Peter Clausen
2013-10-12 11:34 ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 04/20] iio:ad5421: " Lars-Peter Clausen
2013-10-12 11:35 ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 05/20] iio:gp2ap020a00f: " Lars-Peter Clausen
2013-10-12 11:36 ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 06/20] iio:tsl2563: " Lars-Peter Clausen
2013-10-12 11:39 ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 07/20] iio:apds9300: Use " Lars-Peter Clausen
2013-10-12 11:41 ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 08/20] staging:iio:lis3l02dq: Switch to " Lars-Peter Clausen
2013-10-12 11:42 ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 09/20] staging:iio:lis2l02dq: Share threshold value between axis Lars-Peter Clausen
2013-10-12 11:43 ` Jonathan Cameron
2013-10-12 11:45 ` Jonathan Cameron
2013-10-12 10:51 ` Lars-Peter Clausen
2013-10-07 14:11 ` [PATCH v2 10/20] staging:iio:sca3000: Switch to new config interface Lars-Peter Clausen
2013-10-12 11:46 ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 11/20] staging:iio:ad7291: Switch to new event " Lars-Peter Clausen
2013-10-12 11:46 ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 12/20] staging:iio:ad799x: " Lars-Peter Clausen
2013-10-12 11:47 ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 13/20] staging:iio:ad7150: " Lars-Peter Clausen
2013-10-12 11:48 ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 14/20] staging:iio:simple_dummy: " Lars-Peter Clausen
2013-10-12 11:50 ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 15/20] staging:iio:tsl2x7x: " Lars-Peter Clausen
2013-10-12 11:50 ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 16/20] iio: Add a hysteresis event info attribute Lars-Peter Clausen
2013-10-12 11:51 ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 17/20] staging:iio:ad799x: Simplify threshold register look-up Lars-Peter Clausen
2013-10-12 11:52 ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 18/20] staging:iio:ad799x: Use event spec for threshold hysteresis Lars-Peter Clausen
2013-10-12 12:02 ` Jonathan Cameron
2013-10-12 11:40 ` Lars-Peter Clausen
2013-10-12 13:05 ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 19/20] staging:iio:ad7291: " Lars-Peter Clausen
2013-10-12 12:04 ` Jonathan Cameron
2013-10-07 14:11 ` [PATCH v2 20/20] iio: Remove support for the legacy event config interface Lars-Peter Clausen
2013-10-12 11:24 ` Jonathan Cameron [this message]
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=5259315B.3020305@kernel.org \
--to=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.