]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
nvdimm: Convert nvdimm_bus guard to class
authorDmitry Ilvokhin <d@ilvokhin.com>
Tue, 2 Jun 2026 07:12:50 +0000 (07:12 +0000)
committerPeter Zijlstra <peterz@infradead.org>
Wed, 3 Jun 2026 09:38:47 +0000 (11:38 +0200)
The nvdimm_bus guard accepts NULL and skips locking when NULL is passed.
Convert from DEFINE_GUARD() to DEFINE_CLASS() + DEFINE_CLASS_IS_GUARD().

This is a preparatory change for making DEFINE_GUARD() constructors
__nonnull_args(). nvdimm_bus legitimately passes NULL, so it must be
adjusted to avoid a compile error.

No functional change.

Signed-off-by: Dmitry Ilvokhin <d@ilvokhin.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://patch.msgid.link/8c0417904d280896ecf2e9923ffa9f20076f59b8.1780064327.git.d@ilvokhin.com
drivers/nvdimm/nd.h

index b199eea3260ef6ea3e6b4aba2a2fdca230121030..18b64559664b286c918cbe1bad84445ba486874f 100644 (file)
@@ -632,8 +632,11 @@ u64 nd_region_interleave_set_cookie(struct nd_region *nd_region,
 u64 nd_region_interleave_set_altcookie(struct nd_region *nd_region);
 void nvdimm_bus_lock(struct device *dev);
 void nvdimm_bus_unlock(struct device *dev);
-DEFINE_GUARD(nvdimm_bus, struct device *,
-            if (_T) nvdimm_bus_lock(_T), if (_T) nvdimm_bus_unlock(_T));
+DEFINE_CLASS(nvdimm_bus, struct device *,
+            if (_T) nvdimm_bus_unlock(_T),
+            ({ if (_T) nvdimm_bus_lock(_T); _T; }),
+            struct device *_T);
+DEFINE_CLASS_IS_GUARD(nvdimm_bus);
 
 bool is_nvdimm_bus_locked(struct device *dev);
 void nvdimm_check_and_set_ro(struct gendisk *disk);