]> www.infradead.org Git - users/hch/misc.git/commitdiff
ASoC: codecs: wcd-common: move component ops to common
authorSrinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Tue, 9 Sep 2025 12:19:50 +0000 (13:19 +0100)
committerMark Brown <broonie@kernel.org>
Thu, 18 Sep 2025 21:24:32 +0000 (22:24 +0100)
component_ops for wcd97x, wcd938x, wcd939x soundwire codecs are exactly
identlical, move them to common driver to remove this duplicate code.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Link: https://patch.msgid.link/20250909121954.225833-10-srinivas.kandagatla@oss.qualcomm.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/wcd-common.c
sound/soc/codecs/wcd-common.h
sound/soc/codecs/wcd937x-sdw.c
sound/soc/codecs/wcd938x-sdw.c
sound/soc/codecs/wcd939x-sdw.c

index 8f3c0806cdc92c09f0d0ad7208b3ed5a48e2f0f9..7a48cc5064ccf4b2aa0b56473ef8849df419db47 100644 (file)
@@ -7,6 +7,8 @@
 #include <linux/device.h>
 #include <linux/of.h>
 #include <linux/printk.h>
+#include <linux/component.h>
+#include <linux/pm_runtime.h>
 
 #include "wcd-common.h"
 
@@ -66,5 +68,30 @@ int wcd_dt_parse_micbias_info(struct wcd_common *common)
        return 0;
 }
 EXPORT_SYMBOL_GPL(wcd_dt_parse_micbias_info);
+
+static int wcd_sdw_component_bind(struct device *dev, struct device *master, void *data)
+{
+       pm_runtime_set_autosuspend_delay(dev, 3000);
+       pm_runtime_use_autosuspend(dev);
+       pm_runtime_mark_last_busy(dev);
+       pm_runtime_set_active(dev);
+       pm_runtime_enable(dev);
+
+       return 0;
+}
+
+static void wcd_sdw_component_unbind(struct device *dev, struct device *master, void *data)
+{
+       pm_runtime_disable(dev);
+       pm_runtime_set_suspended(dev);
+       pm_runtime_dont_use_autosuspend(dev);
+}
+
+const struct component_ops wcd_sdw_component_ops = {
+       .bind = wcd_sdw_component_bind,
+       .unbind = wcd_sdw_component_unbind,
+};
+EXPORT_SYMBOL_GPL(wcd_sdw_component_ops);
+
 MODULE_DESCRIPTION("Common Qualcomm WCD Codec helpers driver");
 MODULE_LICENSE("GPL");
index d94e8879a1d77f0c68901e0e19549f6414a2c839..0d4e9f8e39f215337d478d43c081956f2d7cdeea 100644 (file)
@@ -34,6 +34,7 @@ struct wcd_common {
        u32 micb_vout[WCD_MAX_MICBIAS];
 };
 
+extern const struct component_ops wcd_sdw_component_ops;
 int wcd_get_micb_vout_ctl_val(struct device *dev, u32 micb_mv);
 int wcd_dt_parse_micbias_info(struct wcd_common *common);
 
index 8f28191635277e79a9474d4c5513c7495f2328a9..59c353cafd31c608b228b0a7b10abf2ca7065630 100644 (file)
@@ -983,31 +983,6 @@ static const struct sdw_slave_ops wcd9370_slave_ops = {
        .interrupt_callback = wcd9370_interrupt_callback,
 };
 
-static int wcd937x_sdw_component_bind(struct device *dev,
-                                     struct device *master, void *data)
-{
-       pm_runtime_set_autosuspend_delay(dev, 3000);
-       pm_runtime_use_autosuspend(dev);
-       pm_runtime_mark_last_busy(dev);
-       pm_runtime_set_active(dev);
-       pm_runtime_enable(dev);
-
-       return 0;
-}
-
-static void wcd937x_sdw_component_unbind(struct device *dev,
-                                        struct device *master, void *data)
-{
-       pm_runtime_disable(dev);
-       pm_runtime_set_suspended(dev);
-       pm_runtime_dont_use_autosuspend(dev);
-}
-
-static const struct component_ops wcd937x_sdw_component_ops = {
-       .bind = wcd937x_sdw_component_bind,
-       .unbind = wcd937x_sdw_component_unbind,
-};
-
 static int wcd9370_probe(struct sdw_slave *pdev,
                         const struct sdw_device_id *id)
 {
@@ -1093,7 +1068,7 @@ static int wcd9370_probe(struct sdw_slave *pdev,
        }
 
 
-       ret = component_add(dev, &wcd937x_sdw_component_ops);
+       ret = component_add(dev, &wcd_sdw_component_ops);
        if (ret)
                return ret;
 
@@ -1107,7 +1082,7 @@ static int wcd9370_remove(struct sdw_slave *pdev)
 {
        struct device *dev = &pdev->dev;
 
-       component_del(dev, &wcd937x_sdw_component_ops);
+       component_del(dev, &wcd_sdw_component_ops);
 
        return 0;
 }
index 1dc13b6fabfa6e54e84cceed0982ff3f6a8b42eb..92714aef09d50e39d29fec2b0dd6aec5f9c11366 100644 (file)
@@ -1182,22 +1182,6 @@ static const struct sdw_slave_ops wcd9380_slave_ops = {
        .bus_config = wcd9380_bus_config,
 };
 
-static int wcd938x_sdw_component_bind(struct device *dev,
-                                     struct device *master, void *data)
-{
-       return 0;
-}
-
-static void wcd938x_sdw_component_unbind(struct device *dev,
-                                        struct device *master, void *data)
-{
-}
-
-static const struct component_ops wcd938x_sdw_component_ops = {
-       .bind   = wcd938x_sdw_component_bind,
-       .unbind = wcd938x_sdw_component_unbind,
-};
-
 static int wcd9380_probe(struct sdw_slave *pdev,
                         const struct sdw_device_id *id)
 {
@@ -1262,7 +1246,7 @@ static int wcd9380_probe(struct sdw_slave *pdev,
        pm_runtime_set_active(dev);
        pm_runtime_enable(dev);
 
-       ret = component_add(dev, &wcd938x_sdw_component_ops);
+       ret = component_add(dev, &wcd_sdw_component_ops);
        if (ret)
                goto err_disable_rpm;
 
@@ -1280,7 +1264,7 @@ static int wcd9380_remove(struct sdw_slave *pdev)
 {
        struct device *dev = &pdev->dev;
 
-       component_del(dev, &wcd938x_sdw_component_ops);
+       component_del(dev, &wcd_sdw_component_ops);
 
        pm_runtime_disable(dev);
        pm_runtime_set_suspended(dev);
index 97a829e3ce4f5179b5790c0d233906eb8afcf555..6aecad2a28aaaeb92f7832d8e146845ccdff1bb8 100644 (file)
@@ -1378,31 +1378,6 @@ static const struct sdw_slave_ops wcd9390_slave_ops = {
        .bus_config = wcd9390_bus_config,
 };
 
-static int wcd939x_sdw_component_bind(struct device *dev, struct device *master,
-                                     void *data)
-{
-       pm_runtime_set_autosuspend_delay(dev, 3000);
-       pm_runtime_use_autosuspend(dev);
-       pm_runtime_mark_last_busy(dev);
-       pm_runtime_set_active(dev);
-       pm_runtime_enable(dev);
-
-       return 0;
-}
-
-static void wcd939x_sdw_component_unbind(struct device *dev,
-                                        struct device *master, void *data)
-{
-       pm_runtime_disable(dev);
-       pm_runtime_set_suspended(dev);
-       pm_runtime_dont_use_autosuspend(dev);
-}
-
-static const struct component_ops wcd939x_sdw_component_ops = {
-       .bind = wcd939x_sdw_component_bind,
-       .unbind = wcd939x_sdw_component_unbind,
-};
-
 static int wcd9390_probe(struct sdw_slave *pdev, const struct sdw_device_id *id)
 {
        struct device *dev = &pdev->dev;
@@ -1466,7 +1441,7 @@ static int wcd9390_probe(struct sdw_slave *pdev, const struct sdw_device_id *id)
                regcache_cache_only(wcd->regmap, true);
        }
 
-       ret = component_add(dev, &wcd939x_sdw_component_ops);
+       ret = component_add(dev, &wcd_sdw_component_ops);
        if (ret)
                return ret;
 
@@ -1481,7 +1456,7 @@ static int wcd9390_remove(struct sdw_slave *pdev)
        struct device *dev = &pdev->dev;
        struct wcd939x_sdw_priv *wcd = dev_get_drvdata(dev);
 
-       component_del(dev, &wcd939x_sdw_component_ops);
+       component_del(dev, &wcd_sdw_component_ops);
 
        if (wcd->regmap)
                regmap_exit(wcd->regmap);