mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mfd: ab8500-debugfs: Use common error handling code in ab8500_print_modem_registers()
@ 2017-10-27 15:37 SF Markus Elfring
  2017-10-31 10:06 ` Linus Walleij
  2017-11-29 10:59 ` Lee Jones
  0 siblings, 2 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-10-27 15:37 UTC (permalink / raw)
  To: linux-arm-kernel, Lee Jones, Linus Walleij; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 27 Oct 2017 17:20:45 +0200

Add jump targets so that two error messages are stored only once
at the end of this function implementation.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mfd/ab8500-debugfs.c | 35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index c1c815241e02..37f39b2a1aa1 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -1620,18 +1620,15 @@ static int ab8500_print_modem_registers(struct seq_file *s, void *p)
 
 	err = abx500_get_register_interruptible(dev,
 		AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG, &orig_value);
-	if (err < 0) {
-		dev_err(dev, "ab->read fail %d\n", err);
-		return err;
-	}
+	if (err < 0)
+		goto report_read_failure;
+
 	/* Config 1 will allow APE side to read SIM registers */
 	err = abx500_set_register_interruptible(dev,
 		AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG,
 		AB8500_SUPPLY_CONTROL_CONFIG_1);
-	if (err < 0) {
-		dev_err(dev, "ab->write fail %d\n", err);
-		return err;
-	}
+	if (err < 0)
+		goto report_write_failure;
 
 	seq_printf(s, " bank 0x%02X:\n", bank);
 
@@ -1641,19 +1638,25 @@ static int ab8500_print_modem_registers(struct seq_file *s, void *p)
 	for (reg = AB8500_FIRST_SIM_REG; reg <= last_sim_reg; reg++) {
 		err = abx500_get_register_interruptible(dev,
 			bank, reg, &value);
-		if (err < 0) {
-			dev_err(dev, "ab->read fail %d\n", err);
-			return err;
-		}
+		if (err < 0)
+			goto report_read_failure;
+
 		seq_printf(s, "  [0x%02X/0x%02X]: 0x%02X\n", bank, reg, value);
 	}
 	err = abx500_set_register_interruptible(dev,
 		AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG, orig_value);
-	if (err < 0) {
-		dev_err(dev, "ab->write fail %d\n", err);
-		return err;
-	}
+	if (err < 0)
+		goto report_write_failure;
+
 	return 0;
+
+report_read_failure:
+	dev_err(dev, "ab->read fail %d\n", err);
+	return err;
+
+report_write_failure:
+	dev_err(dev, "ab->write fail %d\n", err);
+	return err;
 }
 
 static int ab8500_modem_open(struct inode *inode, struct file *file)
-- 
2.14.3

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

* Re: [PATCH] mfd: ab8500-debugfs: Use common error handling code in ab8500_print_modem_registers()
  2017-10-27 15:37 [PATCH] mfd: ab8500-debugfs: Use common error handling code in ab8500_print_modem_registers() SF Markus Elfring
@ 2017-10-31 10:06 ` Linus Walleij
  2017-11-29 10:59 ` Lee Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2017-10-31 10:06 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-arm-kernel, Lee Jones, kernel-janitors, LKML

On Fri, Oct 27, 2017 at 5:37 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 27 Oct 2017 17:20:45 +0200
>
> Add jump targets so that two error messages are stored only once
> at the end of this function implementation.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH] mfd: ab8500-debugfs: Use common error handling code in ab8500_print_modem_registers()
  2017-10-27 15:37 [PATCH] mfd: ab8500-debugfs: Use common error handling code in ab8500_print_modem_registers() SF Markus Elfring
  2017-10-31 10:06 ` Linus Walleij
@ 2017-11-29 10:59 ` Lee Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Lee Jones @ 2017-11-29 10:59 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-arm-kernel, Linus Walleij, LKML, kernel-janitors

On Fri, 27 Oct 2017, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 27 Oct 2017 17:20:45 +0200
> 
> Add jump targets so that two error messages are stored only once
> at the end of this function implementation.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/mfd/ab8500-debugfs.c | 35 +++++++++++++++++++----------------
>  1 file changed, 19 insertions(+), 16 deletions(-)

Applied, thanks.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

end of thread, other threads:[~2017-11-29 10:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-27 15:37 [PATCH] mfd: ab8500-debugfs: Use common error handling code in ab8500_print_modem_registers() SF Markus Elfring
2017-10-31 10:06 ` Linus Walleij
2017-11-29 10:59 ` Lee Jones

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

Powered by JetHome