diff mbox

[3/3] libnvdimm: use enums for ARS statuses

Message ID 1452821516-26788-4-git-send-email-vishal.l.verma@intel.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Verma, Vishal L Jan. 15, 2016, 1:31 a.m. UTC
Replace the status checking in ARS_START, ARS_STATUS with enums for
readability.

Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 drivers/nvdimm/core.c    | 17 +++++++----------
 drivers/nvdimm/nd-core.h | 13 +++++++++++++
 2 files changed, 20 insertions(+), 10 deletions(-)

Comments

Dan Williams Jan. 15, 2016, 4:29 a.m. UTC | #1
On Thu, Jan 14, 2016 at 5:31 PM, Vishal Verma <vishal.l.verma@intel.com> wrote:
> Replace the status checking in ARS_START, ARS_STATUS with enums for
> readability.
>
> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
> ---
>  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;

These status codes are dsm spec specific.  I think we should have the
conversion of dsm cmd status to Linux error code happen in the bus
provider.  Currently the status returned from ->ndctl() is the
execution status of the command.  I think we want to change the
definition of ->ndctl_fn to take a pointer to an additional  command
status integer.  That way the core only needs to deal in standard
errno codes and the dsm-status to errno conversion can remain in the
bus-provider-specific code where it belongs.
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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);