misc: ad525x_dpot: Fix the enabling of the "otpXen" attributes
authorDan Bogdan Nechita <dan.bogdan.nechita@gmail.com>
Tue, 23 Feb 2016 09:48:45 +0000 (11:48 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 2 Mar 2016 00:55:13 +0000 (16:55 -0800)
Currently writing the attributes with "echo" will result in comparing:
"enabled\n" with "enabled\0" and attribute is always set to false.

Use the sysfs_streq() instead because it treats both NUL and
new-line-then-NUL as equivalent string terminations.

Signed-off-by: Dan Bogdan Nechita <dan.bogdan.nechita@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/ad525x_dpot.c

index f1a0b99f5a9a3e0cbc44eb1a69ac774f134569f4..fe1672747bc1fd2c3ea1d26ae6e7154dadd8d11f 100644 (file)
@@ -452,7 +452,7 @@ static ssize_t sysfs_set_reg(struct device *dev,
        int err;
 
        if (reg & DPOT_ADDR_OTP_EN) {
-               if (!strncmp(buf, "enabled", sizeof("enabled")))
+               if (sysfs_streq(buf, "enabled"))
                        set_bit(DPOT_RDAC_MASK & reg, data->otp_en_mask);
                else
                        clear_bit(DPOT_RDAC_MASK & reg, data->otp_en_mask);