linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] iio: adc: ad7791: Use sysfs_match_string() helper
@ 2017-06-09 12:08 Andy Shevchenko
  2017-06-11 11:02 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2017-06-09 12:08 UTC (permalink / raw)
  To: linux-iio
  Cc: Andy Shevchenko, Lars-Peter Clausen, Michael Hennerich,
	Jonathan Cameron

Use sysfs_match_string() helper instead of open coded variant.

Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/adc/ad7791.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/adc/ad7791.c b/drivers/iio/adc/ad7791.c
index 1817ebf5ad84..34e353c43ac8 100644
--- a/drivers/iio/adc/ad7791.c
+++ b/drivers/iio/adc/ad7791.c
@@ -272,11 +272,9 @@ static ssize_t ad7791_write_frequency(struct device *dev,
 	struct ad7791_state *st = iio_priv(indio_dev);
 	int i, ret;
 
-	for (i = 0; i < ARRAY_SIZE(ad7791_sample_freq_avail); i++)
-		if (sysfs_streq(ad7791_sample_freq_avail[i], buf))
-			break;
-	if (i == ARRAY_SIZE(ad7791_sample_freq_avail))
-		return -EINVAL;
+	i = sysfs_match_string(ad7791_sample_freq_avail, buf);
+	if (i < 0)
+		return i;
 
 	ret = iio_device_claim_direct_mode(indio_dev);
 	if (ret)
-- 
2.11.0

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

* Re: [PATCH v1] iio: adc: ad7791: Use sysfs_match_string() helper
  2017-06-09 12:08 [PATCH v1] iio: adc: ad7791: Use sysfs_match_string() helper Andy Shevchenko
@ 2017-06-11 11:02 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2017-06-11 11:02 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-iio, Lars-Peter Clausen, Michael Hennerich

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

> Use sysfs_match_string() helper instead of open coded variant.
> 
> Cc: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Michael Hennerich <Michael.Hennerich@analog.com>
> Cc: Jonathan Cameron <jic23@kernel.org>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Looks obvious enough that I'm happy to apply without waiting
for Lars or Michael to have a moment.  It'll be in my testing
branch for at least a little while though if either of you
want to comment or add an Ack.

Thanks,

Jonathan
> ---
>  drivers/iio/adc/ad7791.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7791.c b/drivers/iio/adc/ad7791.c
> index 1817ebf5ad84..34e353c43ac8 100644
> --- a/drivers/iio/adc/ad7791.c
> +++ b/drivers/iio/adc/ad7791.c
> @@ -272,11 +272,9 @@ static ssize_t ad7791_write_frequency(struct device *dev,
>  	struct ad7791_state *st = iio_priv(indio_dev);
>  	int i, ret;
>  
> -	for (i = 0; i < ARRAY_SIZE(ad7791_sample_freq_avail); i++)
> -		if (sysfs_streq(ad7791_sample_freq_avail[i], buf))
> -			break;
> -	if (i == ARRAY_SIZE(ad7791_sample_freq_avail))
> -		return -EINVAL;
> +	i = sysfs_match_string(ad7791_sample_freq_avail, buf);
> +	if (i < 0)
> +		return i;
>  
>  	ret = iio_device_claim_direct_mode(indio_dev);
>  	if (ret)


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

end of thread, other threads:[~2017-06-11 11:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-09 12:08 [PATCH v1] iio: adc: ad7791: Use sysfs_match_string() helper Andy Shevchenko
2017-06-11 11:02 ` Jonathan Cameron

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).