Skip to contentSkip to conversation

iio: adc: ad7791: Use sysfs_match_string() helper

PATCH In review Andy Shevchenko 2 participants 2 messages Jun 9, 2017 – Jun 11, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: adc: ad7791: Use sysfs_match_string() helper

Use sysfs_match_string() helper instead of open coded variant.

Cc Lars-Peter Clausen <[email protected]>
Cc Michael Hennerich <[email protected]>
Cc Jonathan Cameron <[email protected]>
---
 drivers/iio/adc/ad7791.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/iio/adc/ad7791.c +3 -5
index 1817ebf5ad84..34e353c43ac8 100644
@@ -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)
Signature · 1 line
2.11.0
maintainer
#1 lore raw
Quoted 6 lines · On Fri, 9 Jun 2017 15:08:10 +0300 Andy Shevchenko…

Use sysfs_match_string() helper instead of open coded variant.

Cc Lars-Peter Clausen <[email protected]>
Cc Michael Hennerich <[email protected]>
Cc Jonathan Cameron <[email protected]>

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

Quoted 23 lines
---
 drivers/iio/adc/ad7791.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/iio/adc/ad7791.c +3 -5
index 1817ebf5ad84..34e353c43ac8 100644
@@ -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)