public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] misc: bh1770glc: Use common error handling code in bh1770_power_state_store()
@ 2017-10-27 16:20 SF Markus Elfring
  2017-10-27 17:11 ` Daniele Nicolodi
  0 siblings, 1 reply; 4+ messages in thread
From: SF Markus Elfring @ 2017-10-27 16:20 UTC (permalink / raw)
  To: kernel-janitors, Andrew Morton, Arnd Bergmann, Dan Carpenter,
	Greg Kroah-Hartman
  Cc: LKML, Jonathan Cameron, Samu Onkalo

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 27 Oct 2017 18:00:31 +0200

Adjust jump targets so that a bit of exception handling can be better
reused in an if branch of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/misc/bh1770glc.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/misc/bh1770glc.c b/drivers/misc/bh1770glc.c
index 9c62bf064f77..c4c108ed88b0 100644
--- a/drivers/misc/bh1770glc.c
+++ b/drivers/misc/bh1770glc.c
@@ -660,15 +660,14 @@ static ssize_t bh1770_power_state_store(struct device *dev,
 		pm_runtime_get_sync(dev);
 
 		ret = bh1770_lux_rate(chip, chip->lux_rate_index);
-		if (ret < 0) {
-			pm_runtime_put(dev);
-			goto leave;
-		}
+		if (ret < 0)
+			goto put_runtime;
 
 		ret = bh1770_lux_interrupt_control(chip, BH1770_ENABLE);
 		if (ret < 0) {
+put_runtime:
 			pm_runtime_put(dev);
-			goto leave;
+			goto unlock;
 		}
 
 		/* This causes interrupt after the next measurement cycle */
@@ -681,7 +680,7 @@ static ssize_t bh1770_power_state_store(struct device *dev,
 		pm_runtime_put(dev);
 	}
 	ret = count;
-leave:
+unlock:
 	mutex_unlock(&chip->mutex);
 	return ret;
 }
-- 
2.14.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-10-27 18:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-27 16:20 [PATCH] misc: bh1770glc: Use common error handling code in bh1770_power_state_store() SF Markus Elfring
2017-10-27 17:11 ` Daniele Nicolodi
2017-10-27 17:23   ` Greg Kroah-Hartman
2017-10-27 18:04   ` SF Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox