From patchwork Thu Nov 2 18:33:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 10039195 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3ECEE60291 for ; Thu, 2 Nov 2017 18:34:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3225128B2D for ; Thu, 2 Nov 2017 18:34:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 27001292C1; Thu, 2 Nov 2017 18:34:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3ED5292CB for ; Thu, 2 Nov 2017 18:34:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752312AbdKBSeE (ORCPT ); Thu, 2 Nov 2017 14:34:04 -0400 Received: from mout.web.de ([212.227.15.3]:49222 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752105AbdKBSeD (ORCPT ); Thu, 2 Nov 2017 14:34:03 -0400 Received: from [192.168.1.3] ([78.49.200.43]) by smtp.web.de (mrweb004 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MfCyA-1dlXOX3heM-00Oq5T; Thu, 02 Nov 2017 19:34:00 +0100 To: linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, Andy Gross , Bjorn Andersson , David Brown Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Subject: [PATCH] soc/qcom/smp2p: Use common error handling code in qcom_smp2p_probe() Message-ID: Date: Thu, 2 Nov 2017 19:33:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Language: en-GB X-Provags-ID: V03:K0:7GnjoaOd/Z/BCjOBIKnRZsyvziIKcYWKVQGhJteaGr205hAeT+p Ye758UOW/pZ8cQiWDzAwZh+4AC5YL0in/z3b9Mw4y7y0uGW2jf9CfLv627+9LwZan1ALtal V9zwL3ieJlyMQCKFiNX9TKBiv/OuBld/xAyClKdWfZb8eoww5yzdN3gnh+ogX4GSVpf/zI9 QSeHwjnrYuUsteQ2GMk7A== X-UI-Out-Filterresults: notjunk:1; V01:K0:FfOJp6fC24s=:wZrEA7sQzvF0PDAVdvLS6r srCcGZtcPSghREDE+4Jd2s+0wYns2PN484zq/sq2MgqLEDPPEhCFQuXz7OZ+hFoDk6c7Qd4Fh avnNgby0XboSH2w3+TJR4tLTz29AaXui/SdNplQIEhbCCLStitQqMDla+55IRp3kZJmurmJao apbaICRLV8jW880rK6NyRO2GHWFYUSZi42OI4sjSp75UJBV5LwICkjTQfDZ6VhYQJH0SMLDI+ enAJRQx6auXpmSqkhoIWaOVXzFwvGINzIcGuDYMYDABk1PUqlR+hLlSt9tBuBTczg5IleBS6P Dc3FmJw+1wVbmwJGkoitEQyM+5a/P6xGmfrZUDEsa6LxVfcgTm9XxZ469DqM1F9ajVsHKt0e0 eGCJNXdVuC3Z3hVVI0ytE+sx4arKvedB5LQC2q0BP6DKfYC2v7P6qdcQ8D432vo8xmoZyrNWN icikYsG2ruU+qkf5/5nfhfwm1RsUCD0PSC1n87rMo5VCyKbmzHx/UqQGNbmbEGiH5GMBgAOMB wmUK/osrT+nSQj1Qq998Tm0zbOx7cW1AlFtxndqcM6prhQLprYyU4IBFk2I2klQtWNKXsPpHX Oh2j08NMW414RHjTb/HX2F3apgXJBmSNlsd093fQcjhdZox5D5FtAXQ/3zr+YPvC7Wd1o5XaO /nmqo0Ft8XCXkIhp3qzIXu+/fM0F4UySQFD6AbfSWDgCX8+SXndurzvzMYwY3hUhgTbrS6x1s 866ifRnBeaEfjywznyxfqxM5Jm+Y0fc4VVGMsqIjzhX2FbEE/S5+7lrPqOwEz/T4/iH+8UgvG lDJkDvSZ2SG214uLcnfVnHUqqLNJ5fbsP6TA1Xx8HPOncfmP4A= Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Thu, 2 Nov 2017 19:27:33 +0100 * Add a jump target so that a specific error message is stored only once at the end of this function implementation. * Replace two calls of the function "dev_err" by goto statements. * Adjust two condition checks. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/soc/qcom/smp2p.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c index f51fb2ea7200..b1040943da1a 100644 --- a/drivers/soc/qcom/smp2p.c +++ b/drivers/soc/qcom/smp2p.c @@ -465,17 +465,13 @@ static int qcom_smp2p_probe(struct platform_device *pdev) key = "qcom,local-pid"; ret = of_property_read_u32(pdev->dev.of_node, key, &smp2p->local_pid); - if (ret < 0) { - dev_err(&pdev->dev, "failed to read %s\n", key); - return -EINVAL; - } + if (ret) + goto report_read_failure; key = "qcom,remote-pid"; ret = of_property_read_u32(pdev->dev.of_node, key, &smp2p->remote_pid); - if (ret < 0) { - dev_err(&pdev->dev, "failed to read %s\n", key); - return -EINVAL; - } + if (ret) + goto report_read_failure; irq = platform_get_irq(pdev, 0); if (irq < 0) { @@ -541,6 +537,10 @@ static int qcom_smp2p_probe(struct platform_device *pdev) smp2p->out->valid_entries = 0; return ret; + +report_read_failure: + dev_err(&pdev->dev, "failed to read %s\n", key); + return -EINVAL; } static int qcom_smp2p_remove(struct platform_device *pdev)