staging: iio: ad5933: avoid uninitialized variable in error case
[pandora-kernel.git] / drivers / staging / iio / impedance-analyzer / ad5933.c
index 1086e0b..1ce569a 100644 (file)
@@ -112,10 +112,10 @@ static struct iio_chan_spec ad5933_channels[] = {
        IIO_CHAN(IIO_TEMP, 0, 1, 1, NULL, 0, 0, 0,
                 0, AD5933_REG_TEMP_DATA, IIO_ST('s', 14, 16, 0), 0),
        /* Ring Channels */
-       IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "real_raw", 0, 0,
+       IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "real", 0, 0,
                 (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
                 AD5933_REG_REAL_DATA, 0, IIO_ST('s', 16, 16, 0), 0),
-       IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "imag_raw", 0, 0,
+       IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "imag", 0, 0,
                 (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
                 AD5933_REG_IMAG_DATA, 1, IIO_ST('s', 16, 16, 0), 0),
 };
@@ -626,6 +626,7 @@ static void ad5933_work(struct work_struct *work)
        struct iio_buffer *ring = indio_dev->buffer;
        signed short buf[2];
        unsigned char status;
+       int ret;
 
        mutex_lock(&indio_dev->mlock);
        if (st->state == AD5933_CTRL_INIT_START_FREQ) {
@@ -633,17 +634,20 @@ static void ad5933_work(struct work_struct *work)
                ad5933_cmd(st, AD5933_CTRL_START_SWEEP);
                st->state = AD5933_CTRL_START_SWEEP;
                schedule_delayed_work(&st->work, st->poll_time_jiffies);
-               mutex_unlock(&indio_dev->mlock);
-               return;
+               goto out;
        }
 
-       ad5933_i2c_read(st->client, AD5933_REG_STATUS, 1, &status);
+       ret = ad5933_i2c_read(st->client, AD5933_REG_STATUS, 1, &status);
+       if (ret)
+               goto out;
 
        if (status & AD5933_STAT_DATA_VALID) {
-               ad5933_i2c_read(st->client,
+               ret = ad5933_i2c_read(st->client,
                                test_bit(1, ring->scan_mask) ?
                                AD5933_REG_REAL_DATA : AD5933_REG_IMAG_DATA,
                                ring->scan_count * 2, (u8 *)buf);
+               if (ret)
+                       goto out;
 
                if (ring->scan_count == 2) {
                        buf[0] = be16_to_cpu(buf[0]);
@@ -656,8 +660,7 @@ static void ad5933_work(struct work_struct *work)
        } else {
                /* no data available - try again later */
                schedule_delayed_work(&st->work, st->poll_time_jiffies);
-               mutex_unlock(&indio_dev->mlock);
-               return;
+               goto out;
        }
 
        if (status & AD5933_STAT_SWEEP_DONE) {
@@ -669,7 +672,7 @@ static void ad5933_work(struct work_struct *work)
                ad5933_cmd(st, AD5933_CTRL_INC_FREQ);
                schedule_delayed_work(&st->work, st->poll_time_jiffies);
        }
-
+out:
        mutex_unlock(&indio_dev->mlock);
 }