All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-iio@vger.kernel.org, Lars-Peter Clausen <lars@metafoo.de>
Subject: Re: [PATCH v1] iio: core: Use __sysfs_match_string() helper
Date: Sun, 11 Jun 2017 11:52:45 +0100	[thread overview]
Message-ID: <20170611115245.6215189e@kernel.org> (raw)
In-Reply-To: <20170609120816.22106-1-andriy.shevchenko@linux.intel.com>

On Fri,  9 Jun 2017 15:08:16 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> Use __sysfs_match_string() helper instead of open coded variant.
> 
> Cc: Jonathan Cameron <jic23@kernel.org>
> Cc: Lars-Peter Clausen <lars@metafoo.de>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

A nice little tidy up.  I'd missed that function being added.

Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with.

Jonathan
> ---
>  drivers/iio/industrialio-core.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index 4a1de59d153a..15c86a8cd704 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -478,21 +478,16 @@ ssize_t iio_enum_write(struct iio_dev *indio_dev,
>  	size_t len)
>  {
>  	const struct iio_enum *e = (const struct iio_enum *)priv;
> -	unsigned int i;
>  	int ret;
>  
>  	if (!e->set)
>  		return -EINVAL;
>  
> -	for (i = 0; i < e->num_items; i++) {
> -		if (sysfs_streq(buf, e->items[i]))
> -			break;
> -	}
> -
> -	if (i == e->num_items)
> -		return -EINVAL;
> +	ret = __sysfs_match_string(e->items, e->num_items, buf);
> +	if (ret < 0)
> +		return ret;
>  
> -	ret = e->set(indio_dev, chan, i);
> +	ret = e->set(indio_dev, chan, ret);
>  	return ret ? ret : len;
>  }
>  EXPORT_SYMBOL_GPL(iio_enum_write);


  reply	other threads:[~2017-06-13 18:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-09 12:08 [PATCH v1] iio: core: Use __sysfs_match_string() helper Andy Shevchenko
2017-06-11 10:52 ` Jonathan Cameron [this message]
2017-06-11 11:00 ` Jonathan Cameron

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=20170611115245.6215189e@kernel.org \
    --to=jic23@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --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.