|
Jeff Moyer |
2c91dc |
From 3e4a66f0dfb02046f6d3375d637840b6da9c71d1 Mon Sep 17 00:00:00 2001
|
|
Jeff Moyer |
2c91dc |
From: michalbiesek <michal.biesek@intel.com>
|
|
Jeff Moyer |
2c91dc |
Date: Mon, 2 Dec 2019 11:21:03 +0100
|
|
Jeff Moyer |
2c91dc |
Subject: [PATCH 139/217] daxctl: provide safe versions of iteration API
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
Add support for safe iterate through regions and devices
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
Link: https://github.com/pmem/ndctl/pull/132
|
|
Jeff Moyer |
2c91dc |
Signed-off-by: Michal Biesek <michal.biesek@intel.com>
|
|
Jeff Moyer |
2c91dc |
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
Jeff Moyer |
2c91dc |
---
|
|
Jeff Moyer |
2c91dc |
daxctl/libdaxctl.h | 13 +++++++++++++
|
|
Jeff Moyer |
2c91dc |
1 file changed, 13 insertions(+)
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
diff --git a/daxctl/libdaxctl.h b/daxctl/libdaxctl.h
|
|
Jeff Moyer |
2c91dc |
index 6b6c71f..6876037 100644
|
|
Jeff Moyer |
2c91dc |
--- a/daxctl/libdaxctl.h
|
|
Jeff Moyer |
2c91dc |
+++ b/daxctl/libdaxctl.h
|
|
Jeff Moyer |
2c91dc |
@@ -93,12 +93,25 @@ int daxctl_memory_online_no_movable(struct daxctl_memory *mem);
|
|
Jeff Moyer |
2c91dc |
dev != NULL; \
|
|
Jeff Moyer |
2c91dc |
dev = daxctl_dev_get_next(dev))
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
+#define daxctl_dev_foreach_safe(region, dev, _dev) \
|
|
Jeff Moyer |
2c91dc |
+ for (dev = daxctl_dev_get_first(region), \
|
|
Jeff Moyer |
2c91dc |
+ _dev = dev ? daxctl_dev_get_next(dev) : NULL; \
|
|
Jeff Moyer |
2c91dc |
+ dev != NULL; \
|
|
Jeff Moyer |
2c91dc |
+ dev = _dev, \
|
|
Jeff Moyer |
2c91dc |
+ _dev = _dev ? daxctl_dev_get_next(_dev) : NULL)
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
#define daxctl_region_foreach(ctx, region) \
|
|
Jeff Moyer |
2c91dc |
for (region = daxctl_region_get_first(ctx); \
|
|
Jeff Moyer |
2c91dc |
region != NULL; \
|
|
Jeff Moyer |
2c91dc |
region = daxctl_region_get_next(region))
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
+#define daxctl_region_foreach_safe(ctx, region, _region) \
|
|
Jeff Moyer |
2c91dc |
+ for (region = daxctl_region_get_first(ctx), \
|
|
Jeff Moyer |
2c91dc |
+ _region = region ? daxctl_region_get_next(region) : NULL; \
|
|
Jeff Moyer |
2c91dc |
+ region != NULL; \
|
|
Jeff Moyer |
2c91dc |
+ region = _region, \
|
|
Jeff Moyer |
2c91dc |
+ _region = _region ? daxctl_region_get_next(_region) : NULL)
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
struct daxctl_mapping;
|
|
Jeff Moyer |
2c91dc |
struct daxctl_mapping *daxctl_mapping_get_first(struct daxctl_dev *dev);
|
|
Jeff Moyer |
2c91dc |
struct daxctl_mapping *daxctl_mapping_get_next(struct daxctl_mapping *mapping);
|
|
Jeff Moyer |
2c91dc |
--
|
|
Jeff Moyer |
2c91dc |
2.27.0
|
|
Jeff Moyer |
2c91dc |
|