When there is no-interleave support, there is no range index.

Signed-off-by: Santosh Sivaraj <sant...@fossix.org>
---
 test/libndctl.c | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/test/libndctl.c b/test/libndctl.c
index d508948..1a5a267 100644
--- a/test/libndctl.c
+++ b/test/libndctl.c
@@ -495,6 +495,26 @@ static struct ndctl_region 
*get_pmem_region_by_range_index(struct ndctl_bus *bus
        return NULL;
 }
 
+static struct ndctl_region *get_pmem_region_by_dimm_handle(struct ndctl_bus 
*bus,
+               unsigned int handle)
+{
+       struct ndctl_region *region;
+
+       ndctl_region_foreach(bus, region) {
+               struct ndctl_mapping *map;
+
+               if (ndctl_region_get_type(region) != ND_DEVICE_REGION_PMEM)
+                       continue;
+               ndctl_mapping_foreach(region, map) {
+                       struct ndctl_dimm *dimm = ndctl_mapping_get_dimm(map);
+
+                       if (ndctl_dimm_get_handle(dimm) == handle)
+                               return region;
+               }
+       }
+       return NULL;
+}
+
 static struct ndctl_region *get_blk_region_by_dimm_handle(struct ndctl_bus 
*bus,
                unsigned int handle)
 {
@@ -532,8 +552,12 @@ static int check_regions(struct ndctl_bus *bus, struct 
region *regions, int n,
                struct ndctl_interleave_set *iset;
                char devname[50];
 
-               if (strcmp(regions[i].type, "pmem") == 0)
-                       region = get_pmem_region_by_range_index(bus, 
regions[i].range_index);
+               if (strcmp(regions[i].type, "pmem") == 0) {
+                       if (ndctl_bus_has_nfit(bus))
+                               region = get_pmem_region_by_range_index(bus, 
regions[i].range_index);
+                       else
+                               region = get_pmem_region_by_dimm_handle(bus, 
regions[i].handle);
+               }
                else
                        region = get_blk_region_by_dimm_handle(bus, 
regions[i].handle);
 
@@ -2668,6 +2692,10 @@ static int do_test1(struct ndctl_ctx *ctx, struct 
ndctl_test *test)
        if (ndctl_test_attempt(test, KERNEL_VERSION(4, 10, 0)))
                dimms1[0].handle = DIMM_HANDLE(1, 0, 0, 0, 0);
 
+       if (!ndctl_bus_has_nfit(bus))
+               regions1[0].handle = DIMM_HANDLE(1, 0, 0, 0, 0);
+
+
        rc = check_dimms(bus, dimms1, ARRAY_SIZE(dimms1), 0, 0, test);
        if (rc)
                return rc;
-- 
2.26.2
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org

Reply via email to