iio: adc: ad7791: Use sysfs_match_string() helper
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 9 Jun 2017 12:08:10 +0000 (15:08 +0300)
committerJonathan Cameron <jic23@kernel.org>
Sun, 11 Jun 2017 14:07:35 +0000 (15:07 +0100)
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>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/adc/ad7791.c

index 1817ebf5ad8416b3c071c6ad97783d063c248680..34e353c43ac8bbfbb2d1b38299b4964f94e5b115 100644 (file)
@@ -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)