Re: [PATCH 1/2] devm-helpers: Add resource managed version of mutex init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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







[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux