From patchwork Fri Jan 15 01:31:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 8037281 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 28A2A9F744 for ; Fri, 15 Jan 2016 01:32:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 38E32204FF for ; Fri, 15 Jan 2016 01:32:11 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 6035A204EA for ; Fri, 15 Jan 2016 01:32:10 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 548881A1E81; Thu, 14 Jan 2016 17:32:10 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by ml01.01.org (Postfix) with ESMTP id 4ECE11A1E81 for ; Thu, 14 Jan 2016 17:32:09 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP; 14 Jan 2016 17:32:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,297,1449561600"; d="scan'208";a="29651748" Received: from omniknight.lm.intel.com ([10.232.112.171]) by fmsmga004.fm.intel.com with ESMTP; 14 Jan 2016 17:32:08 -0800 From: Vishal Verma To: linux-nvdimm@lists.01.org Subject: [PATCH 3/3] libnvdimm: use enums for ARS statuses Date: Thu, 14 Jan 2016 18:31:56 -0700 Message-Id: <1452821516-26788-4-git-send-email-vishal.l.verma@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1452821516-26788-1-git-send-email-vishal.l.verma@intel.com> References: <1452821516-26788-1-git-send-email-vishal.l.verma@intel.com> Cc: linux-acpi@vger.kernel.org X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Replace the status checking in ARS_START, ARS_STATUS with enums for readability. Signed-off-by: Vishal Verma --- drivers/nvdimm/core.c | 17 +++++++---------- drivers/nvdimm/nd-core.h | 13 +++++++++++++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/nvdimm/core.c b/drivers/nvdimm/core.c index 69994036..489414f 100644 --- a/drivers/nvdimm/core.c +++ b/drivers/nvdimm/core.c @@ -542,15 +542,14 @@ static int ars_do_start(struct nvdimm_bus_descriptor *nd_desc, if (rc) return rc; switch (cmd->status) { - case 0: + case ND_ARS_START_SUCCESS: return 0; - case 1: + case ND_ARS_START_UNSUPP: /* ARS unsupported, but we should never get here */ return 0; - case 2: + case ND_ARS_START_INVALID_PARAM: return -EINVAL; - case 3: - /* ARS is in progress */ + case ND_ARS_START_IN_PROGRESS: msleep(1000); break; default: @@ -572,14 +571,12 @@ static int ars_get_status(struct nvdimm_bus_descriptor *nd_desc, /* Check extended status (Upper two bytes) */ switch (cmd->status >> 16) { - case 0: + case ND_ARS_STATUS_EXT_SUCCESS: return 0; - case 1: - /* ARS is in progress */ + case ND_ARS_STATUS_EXT_IN_PROGRESS: msleep(1000); break; - case 2: - /* No ARS performed for the current boot */ + case ND_ARS_STATUS_EXT_NOT_DONE: return 0; default: return -ENXIO; diff --git a/drivers/nvdimm/nd-core.h b/drivers/nvdimm/nd-core.h index 1d1500f..c4a2744 100644 --- a/drivers/nvdimm/nd-core.h +++ b/drivers/nvdimm/nd-core.h @@ -43,6 +43,19 @@ struct nvdimm { int id; }; +enum { + ND_ARS_START_SUCCESS = 0, + ND_ARS_START_UNSUPP = 1, + ND_ARS_START_INVALID_PARAM = 2, + ND_ARS_START_IN_PROGRESS = 3, +}; + +enum { + ND_ARS_STATUS_EXT_SUCCESS = 0, + ND_ARS_STATUS_EXT_IN_PROGRESS = 1, + ND_ARS_STATUS_EXT_NOT_DONE = 2, +}; + bool is_nvdimm(struct device *dev); bool is_nd_pmem(struct device *dev); bool is_nd_blk(struct device *dev);