From patchwork Mon Nov 6 06:55:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 118005 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2444992qgn; Sun, 5 Nov 2017 22:56:13 -0800 (PST) X-Google-Smtp-Source: ABhQp+Sk036UncKwqBvLPLMpoTtL+70GC0DgF9NqHj+Sox3gVxJ6Abbbsk3OQO9ugvUaBLdswES1 X-Received: by 10.101.68.133 with SMTP id l5mr14480270pgq.332.1509951372994; Sun, 05 Nov 2017 22:56:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509951372; cv=none; d=google.com; s=arc-20160816; b=CFCx10kE+t+WEzHPWcMaAW2tLDJ2r5RbAlHMaW+vmCBxKNAPfEfQ6IQOpVDmrqmHHO OD158pWI6qGxAR7q2cyuzI/5l4bVhU0P62PEXPi0ww3BUd7t4NAd+gtRzR+pIOj5BAow DgL1jrQ3/R8VBfPrb+6QUXmzo5atL4fOZitLEaXkwa4mKNq3K1x0/MWXstmU2h0D/Qy2 5PgOcCvMUIaSQqUNe+NGFeY2YuQxkFX+r31Ln4puGLZMiNCgDedJkljKIxc+GUi4mrLt 2jGwvuMvpXD0dK2W0stbYHy4BOsXmYO3etlLFVXJzR02ThX58lYmD6UctPjjV6p8wVqV JbJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=2RTSGxqZblCOZ+1U/5dN4PnLRsABGOKHcud2RRad8cM=; b=C3rKTLKP6H0sFPCiMahCGK3dN3yk2fxfYYN2sCs5+eVRTx3QZengQYuIsGeoTAeNmD fGrxq0kZVP9dcEq5K6sZiNqv2+I03eu1I8ioCAm9vStJKC8qxWCmWeij5Nd5W6iFAbE8 ITVSS1+PtNeyIFo6o5PNQBANTJmEwx/AMs43CRD85orDwxKAVz5240YRB3zH31LDi6WQ yTDB89L9K8hQSrv8oVg9OZCIW3HJWhLDeJiN8KzMJUW6xpCfWSXVRaxcbcv+TEh2KEAf KmSKENKj/niSHs62LJDshVkH1ky4HHb6Kb5Q9LR5WEdplxQnFhuWfm9p1/WS2wneAYSu ygEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x8si9759663plv.620.2017.11.05.22.56.12; Sun, 05 Nov 2017 22:56:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751707AbdKFG4K (ORCPT + 1 other); Mon, 6 Nov 2017 01:56:10 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:60134 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751695AbdKFG4H (ORCPT ); Mon, 6 Nov 2017 01:56:07 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7EF5080D; Sun, 5 Nov 2017 22:56:07 -0800 (PST) Received: from sugar.kfn.arm.com (unknown [10.45.48.162]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CAA283F246; Sun, 5 Nov 2017 22:56:05 -0800 (PST) From: Gilad Ben-Yossef To: Greg Kroah-Hartman Cc: Ofir Drang , linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org Subject: [PATCH 1/3] staging: ccree: simplify error handling logic Date: Mon, 6 Nov 2017 06:55:50 +0000 Message-Id: <1509951354-16370-2-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509951354-16370-1-git-send-email-gilad@benyossef.com> References: <1509951354-16370-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Turn the code sites that don't require any special handling on error return to a simple return. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_driver.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) -- 2.7.4 diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 1d4c7bb..135a7e2 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -212,10 +212,9 @@ static int init_cc_resources(struct platform_device *plat_dev) int rc = 0; new_drvdata = devm_kzalloc(dev, sizeof(*new_drvdata), GFP_KERNEL); - if (!new_drvdata) { - rc = -ENOMEM; - goto post_drvdata_err; - } + if (!new_drvdata) + return -ENOMEM; + platform_set_drvdata(plat_dev, new_drvdata); new_drvdata->plat_dev = plat_dev; @@ -229,8 +228,7 @@ static int init_cc_resources(struct platform_device *plat_dev) new_drvdata->cc_base = devm_ioremap_resource(dev, req_mem_cc_regs); if (IS_ERR(new_drvdata->cc_base)) { dev_err(dev, "Failed to ioremap registers"); - rc = PTR_ERR(new_drvdata->cc_base); - goto post_drvdata_err; + return PTR_ERR(new_drvdata->cc_base); } dev_dbg(dev, "Got MEM resource (%s): %pR\n", req_mem_cc_regs->name, @@ -244,8 +242,7 @@ static int init_cc_resources(struct platform_device *plat_dev) new_drvdata->irq = platform_get_irq(plat_dev, 0); if (new_drvdata->irq < 0) { dev_err(dev, "Failed getting IRQ resource\n"); - rc = new_drvdata->irq; - goto post_drvdata_err; + return new_drvdata->irq; } rc = devm_request_irq(dev, new_drvdata->irq, cc_isr, @@ -253,7 +250,7 @@ static int init_cc_resources(struct platform_device *plat_dev) if (rc) { dev_err(dev, "Could not register to interrupt %d\n", new_drvdata->irq); - goto post_drvdata_err; + return rc; } dev_dbg(dev, "Registered to IRQ: %d\n", new_drvdata->irq); @@ -271,15 +268,16 @@ static int init_cc_resources(struct platform_device *plat_dev) } if (rc) { - dev_err(dev, "Error: failed in dma_set_mask, mask=%par\n", + dev_err(dev, "Failed in dma_set_mask, mask=%par\n", &dma_mask); - goto post_drvdata_err; + return rc; } rc = cc_clk_on(new_drvdata); - if (rc) - goto post_drvdata_err; - + if (rc) { + dev_err(dev, "Failed to enable clock"); + return rc; + } /* Verify correct mapping */ signature_val = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_SIGNATURE)); @@ -406,8 +404,6 @@ static int init_cc_resources(struct platform_device *plat_dev) fini_cc_regs(new_drvdata); post_clk_err: cc_clk_off(new_drvdata); -post_drvdata_err: - dev_err(dev, "ccree init error occurred!\n"); return rc; }