File ndctl-dimm-Fix-init-labels-success-reporting.patch of Package ndctl.14275

From 4f7cad25e06483ae20b9bebabefb05fb1e55a2a7 Mon Sep 17 00:00:00 2001
From: Dan Williams <dan.j.williams@intel.com>
Date: Sat, 27 Jul 2019 14:40:42 -0700
Subject: [PATCH] ndctl/dimm: Fix init-labels success reporting

Patch-mainline: v66
Git-commit: 4f7cad25e06483ae20b9bebabefb05fb1e55a2a7

When a DIMM is disabled due to a label parsing issue "ndctl init-labels"
mis-reports the status of the init-labels command:

    # ndctl init-labels all -f
    initialized 1 nmem
    [root@dwillia2-dev ndctl]# ndctl list -Di
    [
      {
        "dev":"nmem1",
        "id":"8680-57341200",
        "handle":2,
        "phys_id":0,
        "state":"disabled"
      },
      {
        "dev":"nmem0",
        "id":"8680-56341200",
        "handle":1,
        "phys_id":0
      }
    ]
    # ndctl init-labels nmem1 -f
    initialized 1020 nmems

Catch any positive return from action_init() as success:

    # ndctl init-labels all -f
    initialized 2 nmems
    # ndctl init-labels nmem1 -f
    initialized 1 nmem

Link: https://github.com/pmem/ndctl/issues/60
Reported-by: Jane Chu <jane.chu@oracle.com>
Reported-by: Steve Scargal <steve.scargall@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 ndctl/dimm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ndctl/dimm.c b/ndctl/dimm.c
index 5f05a75f00eb..db91f42421e4 100644
--- a/ndctl/dimm.c
+++ b/ndctl/dimm.c
@@ -1027,7 +1027,7 @@ static int __action_init(struct ndctl_dimm *dimm,
 
  out:
 	ndctl_cmd_unref(cmd_read);
-	return rc;
+	return rc >= 0 ? 0 : rc;
 }
 
 static int action_init(struct ndctl_dimm *dimm, struct action_context *actx)
-- 
2.23.0