Skip to contentSkip to conversation

staging: impedance-analyzer: ad5933: Remove unnecessary goto

PATCH In review simran singhal 2 participants 3 messages Mar 19, 2017

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

PATCH 1/1 staging: impedance-analyzer: ad5933: Remove unnecessary goto

Remove unnecessary goto.

---
 drivers/staging/iio/impedance-analyzer/ad5933.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/staging/iio/impedance-analyzer/ad5933.c +4 -6
index 297665d..c9ed2ac 100644
@@ -663,12 +663,12 @@ 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);
-		goto out;
+		mutex_unlock(&indio_dev->mlock);
 	}
 
 	ret = ad5933_i2c_read(st->client, AD5933_REG_STATUS, 1, &status);
 	if (ret)
-		goto out;
+		mutex_unlock(&indio_dev->mlock);
 
 	if (status & AD5933_STAT_DATA_VALID) {
 		int scan_count = bitmap_weight(indio_dev->active_scan_mask,
@@ -678,7 +678,7 @@ static void ad5933_work(struct work_struct *work)
 				AD5933_REG_REAL_DATA : AD5933_REG_IMAG_DATA,
 				scan_count * 2, (u8 *)buf);
 		if (ret)
-			goto out;
+			mutex_unlock(&indio_dev->mlock);
 
 		if (scan_count == 2) {
 			val[0] = be16_to_cpu(buf[0]);
@@ -690,7 +690,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);
-		goto out;
+		mutex_unlock(&indio_dev->mlock);
 	}
 
 	if (status & AD5933_STAT_SWEEP_DONE) {
@@ -703,8 +703,6 @@ 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);
 }
 
 static int ad5933_probe(struct i2c_client *client,
Signature · 1 line
2.7.4
#1 lore raw
Quoted 12 lines · simran singhal

Remove unnecessary goto.

---
 drivers/staging/iio/impedance-analyzer/ad5933.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/staging/iio/impedance-analyzer/ad5933.c +0 -0
index 297665d..c9ed2ac 100644

drivers/staging/iio/impedance-analyzer/ad5933.c static void ad5933_work(struct work_struct *work) · line 666

Quoted 5 lines
drivers/staging/iio/impedance-analyzer/ad5933.c +1 -1
@@ -663,12 +663,12 @@ 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);
-		goto out;
+		mutex_unlock(&indio_dev->mlock);

This is not correct. The code at the end of the function implicitly does a return, which has disappeared in the change. You could add a return to each place wher you have put a mutex_unlock, but I think that the code was better off as it was. It's microscopically less error prone to have this cleanup code in only one place.

julia

Quoted 46 lines
drivers/staging/iio/impedance-analyzer/ad5933.c +3 -6
 	}
 
 	ret = ad5933_i2c_read(st->client, AD5933_REG_STATUS, 1, &status);
 	if (ret)
-		goto out;
+		mutex_unlock(&indio_dev->mlock);
 
 	if (status & AD5933_STAT_DATA_VALID) {
 		int scan_count = bitmap_weight(indio_dev->active_scan_mask,
@@ -678,7 +678,7 @@ static void ad5933_work(struct work_struct *work)
 				AD5933_REG_REAL_DATA : AD5933_REG_IMAG_DATA,
 				scan_count * 2, (u8 *)buf);
 		if (ret)
-			goto out;
+			mutex_unlock(&indio_dev->mlock);
 
 		if (scan_count == 2) {
 			val[0] = be16_to_cpu(buf[0]);
@@ -690,7 +690,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);
-		goto out;
+		mutex_unlock(&indio_dev->mlock);
 	}
 
 	if (status & AD5933_STAT_SWEEP_DONE) {
@@ -703,8 +703,6 @@ 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);
 }
 
 static int ad5933_probe(struct i2c_client *client,
--

2.7.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170319175133.GA19710%40singhal-Inspiron-5558.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 11 lines · Julia Lawall
Quoted 7 lines · simran singhal

Remove unnecessary goto.

---
 drivers/staging/iio/impedance-analyzer/ad5933.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
Quoted 17 lines

drivers/staging/iio/impedance-analyzer/ad5933.c static void ad5933_work(struct work_struct *work) · line 666

Quoted 10 lines
drivers/staging/iio/impedance-analyzer/ad5933.c +1 -1
index 297665d..c9ed2ac 100644
@@ -663,12 +663,12 @@ 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);
-             goto out;
+             mutex_unlock(&indio_dev->mlock);

This is not correct. The code at the end of the function implicitly does a return, which has disappeared in the change. You could add a return to each place wher you have put a mutex_unlock, but I think that the code was better off as it was. It's microscopically less error prone to have this cleanup code in only one place.

OOPS!! This is totally wrong.
Sorry for this.

Quoted 48 lines

julia

Quoted 46 lines
drivers/staging/iio/impedance-analyzer/ad5933.c +3 -6
      }
 
      ret = ad5933_i2c_read(st->client, AD5933_REG_STATUS, 1, &status);
      if (ret)
-             goto out;
+             mutex_unlock(&indio_dev->mlock);
 
      if (status & AD5933_STAT_DATA_VALID) {
              int scan_count = bitmap_weight(indio_dev->active_scan_mask,
@@ -678,7 +678,7 @@ static void ad5933_work(struct work_struct *work)
                              AD5933_REG_REAL_DATA : AD5933_REG_IMAG_DATA,
                              scan_count * 2, (u8 *)buf);
              if (ret)
-                     goto out;
+                     mutex_unlock(&indio_dev->mlock);
 
              if (scan_count == 2) {
                      val[0] = be16_to_cpu(buf[0]);
@@ -690,7 +690,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);
-             goto out;
+             mutex_unlock(&indio_dev->mlock);
      }
 
      if (status & AD5933_STAT_SWEEP_DONE) {
@@ -703,8 +703,6 @@ 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);
 }
 
 static int ad5933_probe(struct i2c_client *client,
--

2.7.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170319175133.GA19710%40singhal-Inspiron-5558.
For more options, visit https://groups.google.com/d/optout.