nvdimm: Convert nvdimm_bus guard to class

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
This commit is contained in:
Dmitry Ilvokhin 2026-06-02 07:12:50 +00:00 committed by Peter Zijlstra
parent 06961d60a0
commit 813e5598e5

View 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);