[PATCH v1 3/4] devres: Add devm_remove_action_optional() helper

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

 



Add a new helper to remove an action that was added via devm_add_action()
family of calls, but not warn in the cases where action wasn't found since
it is optional and wasn't even added.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
 include/linux/device/devres.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/linux/device/devres.h b/include/linux/device/devres.h
index ae696d10faff..4daebbf7f227 100644
--- a/include/linux/device/devres.h
+++ b/include/linux/device/devres.h
@@ -145,6 +145,19 @@ void devm_remove_action(struct device *dev, void (*action)(void *), void *data)
 	WARN_ON(devm_remove_action_nowarn(dev, action, data));
 }
 
+/* Same as devm_remove_action(), but doesn't WARN() if action wasn't added before */
+static inline
+void devm_remove_action_optional(struct device *dev, void (*action)(void *), void *data)
+{
+	int ret;
+
+	ret = devm_remove_action_nowarn(dev, action, data);
+	if (ret == -ENOENT)
+		return;
+
+	WARN_ON(ret);
+}
+
 void devm_release_action(struct device *dev, void (*action)(void *), void *data);
 
 int __devm_add_action(struct device *dev, void (*action)(void *), void *data, const char *name);
-- 
2.45.1.3035.g276e886db78b





[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