From patchwork Thu Mar 16 22:59:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 9629417 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 42FF860132 for ; Thu, 16 Mar 2017 22:59:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34A4C2856B for ; Thu, 16 Mar 2017 22:59:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 29BCF2868F; Thu, 16 Mar 2017 22:59:13 +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=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E98102856B for ; Thu, 16 Mar 2017 22:59:12 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E140580415; Thu, 16 Mar 2017 15:59:12 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6565680417 for ; Thu, 16 Mar 2017 15:59:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489705151; x=1521241151; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iUjzF+emGogYefvRpidALl4WqA8G1GjQ61kyC2ZQFz8=; b=gVMD8FSmMwa56X/k1F6LhvM01DPxwc0Xa1Z99YnzLFYLmNbVnou5HpdG SMPli8SbrGl/OQ/vTRDEyZzjj19qMw==; Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Mar 2017 15:59:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.36,174,1486454400"; d="scan'208"; a="1143517087" Received: from djiang5-desk3.ch.intel.com ([143.182.137.38]) by fmsmga002.fm.intel.com with ESMTP; 16 Mar 2017 15:59:07 -0700 Subject: [PATCH v4 3/5] acpi: code cleanup for acpi_nfit_ctl calling xlat_status From: Dave Jiang To: dan.j.williams@intel.com Date: Thu, 16 Mar 2017 15:59:07 -0700 Message-ID: <148970514754.49411.8466981511141701031.stgit@djiang5-desk3.ch.intel.com> In-Reply-To: <148970513650.49411.10791297905780906216.stgit@djiang5-desk3.ch.intel.com> References: <148970513650.49411.10791297905780906216.stgit@djiang5-desk3.ch.intel.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-nvdimm@lists.01.org Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Moving the xlat_status() call to a single location to clean up the code since it is getting called in the main code paths already. We only need to bail on the error path at a single location. Signed-off-by: Dave Jiang Reviewed-by: Johannes Thumshirn --- drivers/acpi/nfit/core.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index 662036b..e7b05df 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -199,7 +199,7 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm, acpi_handle handle; unsigned int func; const u8 *uuid; - int rc, i; + int rc = 0, xlat_rc, i; func = cmd; if (cmd == ND_CMD_CALL) { @@ -343,21 +343,20 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm, * unfilled in the output buffer */ rc = buf_len - offset - in_buf.buffer.length; - if (cmd_rc) - *cmd_rc = xlat_status(nvdimm, buf, cmd, - fw_status); } else { dev_err(dev, "%s:%s underrun cmd: %s buf_len: %d out_len: %d\n", __func__, dimm_name, cmd_name, buf_len, offset); rc = -ENXIO; + goto out; } - } else { - rc = 0; - if (cmd_rc) - *cmd_rc = xlat_status(nvdimm, buf, cmd, fw_status); } + xlat_rc = xlat_status(nvdimm, buf, cmd, fw_status); + + if (cmd_rc) + *cmd_rc = xlat_rc; + out: ACPI_FREE(out_obj);