]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
iio: meter: ina3221: fix ina3221_set_channel return value
authorTimo Alho <talho@nvidia.com>
Tue, 18 Mar 2014 12:22:27 +0000 (14:22 +0200)
committerMrutyunjay Sawant <msawant@nvidia.com>
Mon, 24 Mar 2014 12:43:34 +0000 (05:43 -0700)
Writing to crit_current_X node caused an infinite loop due to
incorrect return value of ina3221_set_channel() function. This patch
addresses this issue.

Change-Id: I883c21418f0ec6c215107576d914c1d29e577a6d
Signed-off-by: Timo Alho <talho@nvidia.com>
Reviewed-on: http://git-master/r/383083
(cherry picked from commit 49f5e9c0b7ba5870c3a132d9aec8fe81e53e3366)
Reviewed-on: http://git-master/r/385212
GVS: Gerrit_Virtual_Submit
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
drivers/staging/iio/meter/ina3221.c

index cf6cd46bfe70503930d7e631b20dcd219f5d600e..6fa72cda10d79f7bccbc993dc9d2115517a0e080 100644 (file)
@@ -653,6 +653,7 @@ static ssize_t ina3221_set_channel(struct device *dev,
        int channel = UNPACK_CHAN(this_attr->address);
        long val;
        int current_ma;
+       int ret;
 
        if (channel >= 3) {
                dev_err(dev, "Invalid channel Id %d\n", channel);
@@ -665,7 +666,8 @@ static ssize_t ina3221_set_channel(struct device *dev,
                        return -EINVAL;
 
                current_ma = (int) val;
-               return ina3221_set_channel_critical(chip, channel, current_ma);
+               ret = ina3221_set_channel_critical(chip, channel, current_ma);
+               return ret < 0 ? ret : len;
 
        case RUNNING_MODE:
                return ina3221_set_mode(chip, buf, len);