Oops, sorry for the noise. Shortened reply below.
On 2/22/24 07:24, Guenter Roeck wrote:
On 2/22/24 06:58, Marek Behún wrote:
A few drivers are doing resource-managed mutex initialization by
implementing ad-hoc one-liner mutex dropping functions and using them
with devm_add_action_or_reset(). Help drivers avoid these repeated
one-liners by adding managed version of mutex initialization.
[ ... ]
+static inline int devm_mutex_init(struct device *dev, struct mutex *lock)
+{
+ mutex_init(lock);
+
+ /*
+ * mutex_destroy() is an empty function if CONFIG_DEBUG_MUTEXES is
+ * disabled. No need to allocate an action in that case.
+ */
+ if (IS_ENABLED(CONFIG_DEBUG_MUTEXES))
+ return devm_add_action_or_reset(dev, devm_mutex_drop, lock);
+ else
else after return is unnecessary.
+ return 0;
+}
+
#endif