···2222#include <linux/cleanup.h>2323#include <linux/mutex_types.h>24242525+struct device;2626+2527#ifdef CONFIG_DEBUG_LOCK_ALLOC2628# define __DEP_MAP_MUTEX_INITIALIZER(lockname) \2729 , .dep_map = { \···118116 __mutex_init((mutex), #mutex, &__key); \119117} while (0)120118#endif /* CONFIG_PREEMPT_RT */119119+120120+#ifdef CONFIG_DEBUG_MUTEXES121121+122122+int __devm_mutex_init(struct device *dev, struct mutex *lock);123123+124124+#else125125+126126+static inline int __devm_mutex_init(struct device *dev, struct mutex *lock)127127+{128128+ /*129129+ * When CONFIG_DEBUG_MUTEXES is off mutex_destroy() is just a nop so130130+ * no really need to register it in the devm subsystem.131131+ */132132+ return 0;133133+}134134+135135+#endif136136+137137+#define devm_mutex_init(dev, mutex) \138138+({ \139139+ typeof(mutex) mutex_ = (mutex); \140140+ \141141+ mutex_init(mutex_); \142142+ __devm_mutex_init(dev, mutex_); \143143+})121144122145/*123146 * See kernel/locking/mutex.c for detailed documentation of these APIs.