linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linuxppc-dev@lists.ozlabs.org,
	linux-arm-kernel@lists.infradead.org,
	Li Yang <leoyang.li@nxp.com>, Qiang Zhao <qiang.zhao@nxp.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 3/3] soc/fsl/qe: Use common error handling code in ucc_fast_init()
Date: Wed, 13 Dec 2017 18:36:08 +0100	[thread overview]
Message-ID: <9668351a-8189-037f-5912-5663ac8706b1@users.sourceforge.net> (raw)
In-Reply-To: <07738369-a787-98b4-41a5-71b7d630c356@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 13 Dec 2017 18:18:56 +0100

Add jump targets so that a bit of exception handling can be better reused
at the end of this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/soc/fsl/qe/ucc_fast.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/soc/fsl/qe/ucc_fast.c b/drivers/soc/fsl/qe/ucc_fast.c
index 2092bfdcf1bc..268dfc5dc89b 100644
--- a/drivers/soc/fsl/qe/ucc_fast.c
+++ b/drivers/soc/fsl/qe/ucc_fast.c
@@ -269,8 +269,7 @@ int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** ucc
 		printk(KERN_ERR "%s: cannot allocate MURAM for TX FIFO\n",
 			__func__);
 		uccf->ucc_fast_tx_virtual_fifo_base_offset = 0;
-		ucc_fast_free(uccf);
-		return -ENOMEM;
+		goto free_nomem;
 	}
 
 	/* Allocate memory for Rx Virtual Fifo */
@@ -282,8 +281,7 @@ int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** ucc
 		printk(KERN_ERR "%s: cannot allocate MURAM for RX FIFO\n",
 			__func__);
 		uccf->ucc_fast_rx_virtual_fifo_base_offset = 0;
-		ucc_fast_free(uccf);
-		return -ENOMEM;
+		goto free_nomem;
 	}
 
 	/* Set Virtual Fifo registers */
@@ -312,8 +310,7 @@ int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** ucc
 					COMM_DIR_RX)) {
 			printk(KERN_ERR "%s: illegal value for RX clock\n",
 			       __func__);
-			ucc_fast_free(uccf);
-			return -EINVAL;
+			goto free_inval;
 		}
 		/* Tx clock routing */
 		if ((uf_info->tx_clock != QE_CLK_NONE) &&
@@ -321,8 +318,7 @@ int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** ucc
 					COMM_DIR_TX)) {
 			printk(KERN_ERR "%s: illegal value for TX clock\n",
 			       __func__);
-			ucc_fast_free(uccf);
-			return -EINVAL;
+			goto free_inval;
 		}
 	} else {
 		/* tdm Rx clock routing */
@@ -330,8 +326,7 @@ int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** ucc
 		    ucc_set_tdm_rxtx_clk(uf_info->tdm_num, uf_info->rx_clock,
 					 COMM_DIR_RX)) {
 			pr_err("%s: illegal value for RX clock", __func__);
-			ucc_fast_free(uccf);
-			return -EINVAL;
+			goto free_inval;
 		}
 
 		/* tdm Tx clock routing */
@@ -339,8 +334,7 @@ int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** ucc
 		    ucc_set_tdm_rxtx_clk(uf_info->tdm_num, uf_info->tx_clock,
 					 COMM_DIR_TX)) {
 			pr_err("%s: illegal value for TX clock", __func__);
-			ucc_fast_free(uccf);
-			return -EINVAL;
+			goto free_inval;
 		}
 
 		/* tdm Rx sync clock routing */
@@ -348,8 +342,7 @@ int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** ucc
 		    ucc_set_tdm_rxtx_sync(uf_info->tdm_num, uf_info->rx_sync,
 					  COMM_DIR_RX)) {
 			pr_err("%s: illegal value for RX clock", __func__);
-			ucc_fast_free(uccf);
-			return -EINVAL;
+			goto free_inval;
 		}
 
 		/* tdm Tx sync clock routing */
@@ -357,8 +350,7 @@ int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** ucc
 		    ucc_set_tdm_rxtx_sync(uf_info->tdm_num, uf_info->tx_sync,
 					  COMM_DIR_TX)) {
 			pr_err("%s: illegal value for TX clock", __func__);
-			ucc_fast_free(uccf);
-			return -EINVAL;
+			goto free_inval;
 		}
 	}
 
@@ -374,6 +366,14 @@ int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** ucc
 
 	*uccf_ret = uccf;
 	return 0;
+
+free_nomem:
+	ucc_fast_free(uccf);
+	return -ENOMEM;
+
+free_inval:
+	ucc_fast_free(uccf);
+	return -EINVAL;
 }
 EXPORT_SYMBOL(ucc_fast_init);
 
-- 
2.15.1

      parent reply	other threads:[~2017-12-13 17:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-13 17:32 [PATCH 0/3] SoC/FSL/QE: Adjustments for three function implementations SF Markus Elfring
2017-12-13 17:33 ` [PATCH 1/3] soc/fsl/qe: Delete an error message for a failed memory allocation in three functions SF Markus Elfring
2017-12-13 17:34 ` [PATCH 2/3] soc/fsl/qe: Improve a size determination in two functions SF Markus Elfring
2017-12-13 17:36 ` SF Markus Elfring [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9668351a-8189-037f-5912-5663ac8706b1@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=leoyang.li@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=qiang.zhao@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).