[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250716123323.5831-4-srinivas.kandagatla@oss.qualcomm.com>
Date: Wed, 16 Jul 2025 13:33:21 +0100
From: srinivas.kandagatla@....qualcomm.com
To: broonie@...nel.org
Cc: lgirdwood@...il.com, perex@...ex.cz, tiwai@...e.com, srini@...nel.org,
linux-kernel@...r.kernel.org, linux-sound@...r.kernel.org,
linux-arm-msm@...r.kernel.org, neil.armstrong@...aro.org,
krzysztof.kozlowski@...aro.org,
Srinivas Kandagatla <srinivas.kandagatla@....qualcomm.com>
Subject: [PATCH 3/5] ASoC: codecs: wcd-common: move component ops to common
From: Srinivas Kandagatla <srinivas.kandagatla@....qualcomm.com>
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@....qualcomm.com>
---
sound/soc/codecs/wcd-common.c | 27 +++++++++++++++++++++++++++
sound/soc/codecs/wcd-common.h | 1 +
sound/soc/codecs/wcd937x-sdw.c | 29 ++---------------------------
sound/soc/codecs/wcd938x-sdw.c | 20 ++------------------
sound/soc/codecs/wcd939x-sdw.c | 29 ++---------------------------
5 files changed, 34 insertions(+), 72 deletions(-)
diff --git a/sound/soc/codecs/wcd-common.c b/sound/soc/codecs/wcd-common.c
index dffb0431a48c..0c1ffa015403 100644
--- a/sound/soc/codecs/wcd-common.c
+++ b/sound/soc/codecs/wcd-common.c
@@ -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"
@@ -62,5 +64,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");
diff --git a/sound/soc/codecs/wcd-common.h b/sound/soc/codecs/wcd-common.h
index ee101f8547d5..deb78241236b 100644
--- a/sound/soc/codecs/wcd-common.h
+++ b/sound/soc/codecs/wcd-common.h
@@ -29,6 +29,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);
diff --git a/sound/soc/codecs/wcd937x-sdw.c b/sound/soc/codecs/wcd937x-sdw.c
index 8f2819163527..59c353cafd31 100644
--- a/sound/soc/codecs/wcd937x-sdw.c
+++ b/sound/soc/codecs/wcd937x-sdw.c
@@ -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;
}
diff --git a/sound/soc/codecs/wcd938x-sdw.c b/sound/soc/codecs/wcd938x-sdw.c
index 40c6896eb781..e43d6ac1c913 100644
--- a/sound/soc/codecs/wcd938x-sdw.c
+++ b/sound/soc/codecs/wcd938x-sdw.c
@@ -1181,22 +1181,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)
{
@@ -1261,7 +1245,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;
@@ -1279,7 +1263,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);
diff --git a/sound/soc/codecs/wcd939x-sdw.c b/sound/soc/codecs/wcd939x-sdw.c
index b5a35c3b22e1..df71d7777b71 100644
--- a/sound/soc/codecs/wcd939x-sdw.c
+++ b/sound/soc/codecs/wcd939x-sdw.c
@@ -1377,31 +1377,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;
@@ -1465,7 +1440,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;
@@ -1480,7 +1455,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);
--
2.50.0
Powered by blists - more mailing lists