From e8b69435af3cb76513b95e7ba7d817b2325089ba Mon Sep 17 00:00:00 2001 From: Cristian Stoica Date: Tue, 23 Sep 2014 13:59:21 +0300 Subject: crypto: caamctrl refactoring: remove code duplication Both error and normal paths call clrbits32 before returning. Put this call in a single place to avoid code duplication Signed-off-by: Cristian Stoica (cherry picked from commit c75e03a2d47583e39f46c2925abd0ca79a693086) Signed-off-by: Matthew Weigel Conflicts: drivers/crypto/caam/ctrl.c Change-Id: I3c2ec1c34215b5d2a1ee036809beaeabf724ac48 Reviewed-on: http://git.am.freescale.net:8181/24179 Tested-by: Review Code-CDREVIEW Reviewed-by: Matthew Weigel diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index dcf360c..17c4cb9 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -85,7 +85,7 @@ static inline int run_descriptor_deco0(struct device *ctrldev, u32 *desc, struct caam_deco __iomem *deco = ctrlpriv->deco; unsigned int timeout = 100000; u32 deco_dbg_reg, flags; - int i; + int i, ret; if (ctrlpriv->virt_en == 1) { @@ -106,8 +106,8 @@ static inline int run_descriptor_deco0(struct device *ctrldev, u32 *desc, if (!timeout) { dev_err(ctrldev, "failed to acquire DECO 0\n"); - clrbits32(&ctrl->deco_rq, DECORR_RQD0ENABLE); - return -ENODEV; + ret = -ENODEV; + goto out_err; } for (i = 0; i < desc_len(desc); i++) @@ -143,13 +143,12 @@ static inline int run_descriptor_deco0(struct device *ctrldev, u32 *desc, if (ctrlpriv->virt_en == 1) clrbits32(&ctrl->deco_rsr, DECORSR_JR0); + ret = timeout ? 0 : -EAGAIN; + +out_err: /* Mark the DECO as free */ clrbits32(&ctrl->deco_rq, DECORR_RQD0ENABLE); - - if (!timeout) - return -EAGAIN; - - return 0; + return ret; } /* -- cgit v0.10.2