diff --git a/include/linux/component.h b/include/linux/component.h
index 16de18f473d7..5a7468ea827c 100644
--- a/include/linux/component.h
+++ b/include/linux/component.h
@@ -2,6 +2,8 @@
#ifndef COMPONENT_H
#define COMPONENT_H
+#include <linux/device.h>
+#include <linux/of.h>
#include <linux/stddef.h>
@@ -82,6 +84,22 @@ struct component_master_ops {
void (*unbind)(struct device *master);
};
+/* A set common helpers for compare/release functions */
+static inline int compare_of(struct device *dev, void *data)
+{
+ return dev->of_node == data;
+}
+static inline void release_of(struct device *dev, void *data)
+{
+ of_node_put(data);
+}
+
+static inline int compare_dev(struct device *dev, void *data)
+{
+ return dev == data;
+}
+
void component_master_del(struct device *,
const struct component_master_ops *);
diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c
index eff200a07d9f..992132cbfb9f 100644
--- a/sound/soc/codecs/wcd938x.c
+++ b/sound/soc/codecs/wcd938x.c
@@ -4417,16 +4417,6 @@ static const struct component_master_ops wcd938x_comp_ops = {
.unbind = wcd938x_unbind,
};
-static int wcd938x_compare_of(struct device *dev, void *data)
-{
- return dev->of_node == data;
-}
-
-static void wcd938x_release_of(struct device *dev, void *data)
-{
- of_node_put(data);
-}
-
static int wcd938x_add_slave_components(struct wcd938x_priv *wcd938x,
struct device *dev,
struct component_match **matchptr)
@@ -4442,8 +4432,7 @@ static int wcd938x_add_slave_components(struct wcd938x_priv *wcd938x,
}
of_node_get(wcd938x->rxnode);
- component_match_add_release(dev, matchptr, wcd938x_release_of,
- wcd938x_compare_of, wcd938x->rxnode);
+ component_match_add_release(dev, matchptr, release_of, compare_of, wcd938x->rxnode);
wcd938x->txnode = of_parse_phandle(np, "qcom,tx-device", 0);
if (!wcd938x->txnode) {
@@ -4451,8 +4440,7 @@ static int wcd938x_add_slave_components(struct wcd938x_priv *wcd938x,
return -ENODEV;
}
of_node_get(wcd938x->txnode);
- component_match_add_release(dev, matchptr, wcd938x_release_of,
- wcd938x_compare_of, wcd938x->txnode);
+ component_match_add_release(dev, matchptr, release_of, compare_of, wcd938x->txnode);
return 0;
}