[PATCH 3/3] soc/fsl/qe: Use common error handling code in ucc_fast_init()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux