From patchwork Wed Mar 15 18:33:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 9626403 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 200D86048C for ; Wed, 15 Mar 2017 18:33:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1768728601 for ; Wed, 15 Mar 2017 18:33:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BFEE2861F; Wed, 15 Mar 2017 18:33:32 +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 C144328601 for ; Wed, 15 Mar 2017 18:33:31 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B3D928037D; Wed, 15 Mar 2017 11:33:31 -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 051F88036C for ; Wed, 15 Mar 2017 11:33:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489602809; x=1521138809; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iUjzF+emGogYefvRpidALl4WqA8G1GjQ61kyC2ZQFz8=; b=J5UQjqU3S+qh/9o0GsUeJEyl/d0B4lzE8gde2ARi6DU4ORKtyMzDv5LN VsuYhedMve758u4qqvjtAxP7c0P0Zw==; Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Mar 2017 11:33:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,170,1486454400"; d="scan'208";a="835034040" Received: from djiang5-desk3.ch.intel.com ([143.182.137.38]) by FMSMGA003.fm.intel.com with ESMTP; 15 Mar 2017 11:33:29 -0700 Subject: [PATCH v3 3/5] acpi: code cleanup for acpi_nfit_ctl calling xlat_status From: Dave Jiang To: dan.j.williams@intel.com Date: Wed, 15 Mar 2017 11:33:29 -0700 Message-ID: <148960280935.4721.4767844494740081080.stgit@djiang5-desk3.ch.intel.com> In-Reply-To: <148960279823.4721.5449530412401763266.stgit@djiang5-desk3.ch.intel.com> References: <148960279823.4721.5449530412401763266.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);