[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <164982973080.684294.10727665061649724835.stgit@dwillia2-desk3.amr.corp.intel.com>
Date: Tue, 12 Apr 2022 23:02:10 -0700
From: Dan Williams <dan.j.williams@...el.com>
To: linux-cxl@...r.kernel.org
Cc: Vishal Verma <vishal.l.verma@...el.com>,
Dave Jiang <dave.jiang@...el.com>,
Ira Weiny <ira.weiny@...el.com>,
Dave Jiang <dave.jiang@...el.com>,
Kevin Tian <kevin.tian@...el.com>, peterz@...radead.org,
alison.schofield@...el.com, gregkh@...uxfoundation.org,
linux-kernel@...r.kernel.org, nvdimm@...ts.linux.dev
Subject: [PATCH v2 08/12] libnvdimm: Refactor an nvdimm_lock_class() helper
In preparation for moving to the device-core device_lock lockdep
validation, refactor an nvdimm_lock_class() helper to be used with
device_set_lock_class().
Cc: Vishal Verma <vishal.l.verma@...el.com>
Cc: Dave Jiang <dave.jiang@...el.com>
Cc: Ira Weiny <ira.weiny@...el.com>
Reviewed-by: Dave Jiang <dave.jiang@...el.com>
Reviewed-by: Kevin Tian <kevin.tian@...el.com>
Signed-off-by: Dan Williams <dan.j.williams@...el.com>
---
drivers/nvdimm/nd-core.h | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/nvdimm/nd-core.h b/drivers/nvdimm/nd-core.h
index 448f9dcb4bb7..deb3d047571e 100644
--- a/drivers/nvdimm/nd-core.h
+++ b/drivers/nvdimm/nd-core.h
@@ -174,22 +174,27 @@ enum {
LOCK_CLAIM,
};
-static inline void debug_nvdimm_lock(struct device *dev)
+static inline int nvdimm_lock_class(struct device *dev)
{
if (is_nd_region(dev))
- mutex_lock_nested(&dev->lockdep_mutex, LOCK_REGION);
+ return LOCK_REGION;
else if (is_nvdimm(dev))
- mutex_lock_nested(&dev->lockdep_mutex, LOCK_DIMM);
+ return LOCK_DIMM;
else if (is_nd_btt(dev) || is_nd_pfn(dev) || is_nd_dax(dev))
- mutex_lock_nested(&dev->lockdep_mutex, LOCK_CLAIM);
+ return LOCK_CLAIM;
else if (dev->parent && (is_nd_region(dev->parent)))
- mutex_lock_nested(&dev->lockdep_mutex, LOCK_NAMESPACE);
+ return LOCK_NAMESPACE;
else if (is_nvdimm_bus(dev))
- mutex_lock_nested(&dev->lockdep_mutex, LOCK_BUS);
+ return LOCK_BUS;
else if (dev->class && dev->class == nd_class)
- mutex_lock_nested(&dev->lockdep_mutex, LOCK_NDCTL);
+ return LOCK_NDCTL;
else
- dev_WARN(dev, "unknown lock level\n");
+ return -1;
+}
+
+static inline void debug_nvdimm_lock(struct device *dev)
+{
+ mutex_lock_nested(&dev->lockdep_mutex, nvdimm_lock_class(dev));
}
static inline void debug_nvdimm_unlock(struct device *dev)
Powered by blists - more mailing lists