* [PATCH v2 0/4] ASoC: codecs: wcd937x/8x/9x: cleanup
@ 2025-07-04 12:12 srinivas.kandagatla
2025-07-04 12:12 ` [PATCH v2 1/4] soundwire: bus: add of_sdw_find_device_by_node helper srinivas.kandagatla
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: srinivas.kandagatla @ 2025-07-04 12:12 UTC (permalink / raw)
To: vkoul, broonie
Cc: yung-chuan.liao, pierre-louis.bossart, lgirdwood, perex, tiwai,
krzysztof.kozlowski, linux-kernel, linux-sound, linux-arm-msm,
Srinivas Kandagatla
From: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
All these 3 codecs have been duplicating two of the soundwire
functions. Noticed another new driver starting to do the same, its time
to make some helpers so that we do not duplicate these functions.
I have added two helpers of_sdw_find_device_by_node() and
sdw_slave_get_current_bank() in soundwire layer for the codecs to use them.
Changes since v1:
- updated sdw_slave_get_current_bank do error checks on read
Srinivas Kandagatla (4):
soundwire: bus: add of_sdw_find_device_by_node helper
soundwire: bus: add sdw_slave_get_current_bank helper
ASoC: codecs: wcdxxxx: use of_sdw_find_device_by_node helper
ASoC: codecs: wcdxxxx: use sdw_slave_get_current_bank helper
drivers/soundwire/bus.c | 12 ++++++++++++
drivers/soundwire/slave.c | 6 ++++++
include/linux/soundwire/sdw.h | 17 +++++++++++++++++
sound/soc/codecs/wcd937x-sdw.c | 6 ------
sound/soc/codecs/wcd937x.c | 4 ++--
sound/soc/codecs/wcd937x.h | 2 --
sound/soc/codecs/wcd938x-sdw.c | 17 -----------------
sound/soc/codecs/wcd938x.c | 7 +++----
sound/soc/codecs/wcd938x.h | 13 -------------
sound/soc/codecs/wcd939x-sdw.c | 13 -------------
sound/soc/codecs/wcd939x.c | 6 +++---
sound/soc/codecs/wcd939x.h | 13 -------------
12 files changed, 43 insertions(+), 73 deletions(-)
--
2.49.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/4] soundwire: bus: add of_sdw_find_device_by_node helper
2025-07-04 12:12 [PATCH v2 0/4] ASoC: codecs: wcd937x/8x/9x: cleanup srinivas.kandagatla
@ 2025-07-04 12:12 ` srinivas.kandagatla
2025-10-13 5:44 ` Vinod Koul
2025-07-04 12:12 ` [PATCH v2 2/4] soundwire: bus: add sdw_slave_get_current_bank helper srinivas.kandagatla
` (3 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: srinivas.kandagatla @ 2025-07-04 12:12 UTC (permalink / raw)
To: vkoul, broonie
Cc: yung-chuan.liao, pierre-louis.bossart, lgirdwood, perex, tiwai,
krzysztof.kozlowski, linux-kernel, linux-sound, linux-arm-msm,
Srinivas Kandagatla, Dmitry Baryshkov
From: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
There has been more than 3 instances of this helper in multiple codec
drivers, it does not make sense to keep duplicating this part of code.
Lets add a helper of_sdw_find_device_by_node for codec drivers to use it.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
drivers/soundwire/slave.c | 6 ++++++
include/linux/soundwire/sdw.h | 9 +++++++++
2 files changed, 15 insertions(+)
diff --git a/drivers/soundwire/slave.c b/drivers/soundwire/slave.c
index d2d99555ec5a..3d4d00188c26 100644
--- a/drivers/soundwire/slave.c
+++ b/drivers/soundwire/slave.c
@@ -273,4 +273,10 @@ int sdw_of_find_slaves(struct sdw_bus *bus)
return 0;
}
+struct device *of_sdw_find_device_by_node(struct device_node *np)
+{
+ return bus_find_device_by_of_node(&sdw_bus_type, np);
+}
+EXPORT_SYMBOL_GPL(of_sdw_find_device_by_node);
+
MODULE_IMPORT_NS("SND_SOC_SDCA");
diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h
index 0832776262ac..096213956d31 100644
--- a/include/linux/soundwire/sdw.h
+++ b/include/linux/soundwire/sdw.h
@@ -19,6 +19,7 @@
struct dentry;
struct fwnode_handle;
+struct device_node;
struct sdw_bus;
struct sdw_slave;
@@ -1086,6 +1087,8 @@ int sdw_stream_add_slave(struct sdw_slave *slave,
int sdw_stream_remove_slave(struct sdw_slave *slave,
struct sdw_stream_runtime *stream);
+struct device *of_sdw_find_device_by_node(struct device_node *np);
+
int sdw_slave_get_scale_index(struct sdw_slave *slave, u8 *base);
/* messaging and data APIs */
@@ -1119,6 +1122,12 @@ static inline int sdw_stream_remove_slave(struct sdw_slave *slave,
return -EINVAL;
}
+static inline struct device *of_sdw_find_device_by_node(struct device_node *np)
+{
+ WARN_ONCE(1, "SoundWire API is disabled");
+ return NULL;
+}
+
/* messaging and data APIs */
static inline int sdw_read(struct sdw_slave *slave, u32 addr)
{
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 2/4] soundwire: bus: add sdw_slave_get_current_bank helper
2025-07-04 12:12 [PATCH v2 0/4] ASoC: codecs: wcd937x/8x/9x: cleanup srinivas.kandagatla
2025-07-04 12:12 ` [PATCH v2 1/4] soundwire: bus: add of_sdw_find_device_by_node helper srinivas.kandagatla
@ 2025-07-04 12:12 ` srinivas.kandagatla
2025-07-04 14:18 ` Dmitry Baryshkov
2025-07-04 12:12 ` [PATCH v2 3/4] ASoC: codecs: wcdxxxx: use of_sdw_find_device_by_node helper srinivas.kandagatla
` (2 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: srinivas.kandagatla @ 2025-07-04 12:12 UTC (permalink / raw)
To: vkoul, broonie
Cc: yung-chuan.liao, pierre-louis.bossart, lgirdwood, perex, tiwai,
krzysztof.kozlowski, linux-kernel, linux-sound, linux-arm-msm,
Srinivas Kandagatla
From: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
There has been 2 instances of this helper in codec drivers,
it does not make sense to keep duplicating this part of code.
Lets add a helper sdw_get_current_bank() for codec drivers to use it.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
---
drivers/soundwire/bus.c | 12 ++++++++++++
include/linux/soundwire/sdw.h | 8 ++++++++
2 files changed, 20 insertions(+)
diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
index 4fd5cac799c5..55c1db816534 100644
--- a/drivers/soundwire/bus.c
+++ b/drivers/soundwire/bus.c
@@ -1360,6 +1360,18 @@ int sdw_slave_get_scale_index(struct sdw_slave *slave, u8 *base)
}
EXPORT_SYMBOL(sdw_slave_get_scale_index);
+int sdw_slave_get_current_bank(struct sdw_slave *slave)
+{
+ int tmp;
+
+ tmp = sdw_read(slave, SDW_SCP_CTRL);
+ if (tmp < 0)
+ return tmp;
+
+ return FIELD_GET(SDW_SCP_STAT_CURR_BANK, tmp);
+}
+EXPORT_SYMBOL_GPL(sdw_slave_get_current_bank);
+
static int sdw_slave_set_frequency(struct sdw_slave *slave)
{
int scale_index;
diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h
index 096213956d31..e6a3476bcef1 100644
--- a/include/linux/soundwire/sdw.h
+++ b/include/linux/soundwire/sdw.h
@@ -1089,6 +1089,8 @@ int sdw_stream_remove_slave(struct sdw_slave *slave,
struct device *of_sdw_find_device_by_node(struct device_node *np);
+int sdw_slave_get_current_bank(struct sdw_slave *sdev);
+
int sdw_slave_get_scale_index(struct sdw_slave *slave, u8 *base);
/* messaging and data APIs */
@@ -1128,6 +1130,12 @@ static inline struct device *of_sdw_find_device_by_node(struct device_node *np)
return NULL;
}
+static inline int sdw_slave_get_current_bank(struct sdw_slave *sdev)
+{
+ WARN_ONCE(1, "SoundWire API is disabled");
+ return -EINVAL;
+}
+
/* messaging and data APIs */
static inline int sdw_read(struct sdw_slave *slave, u32 addr)
{
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 3/4] ASoC: codecs: wcdxxxx: use of_sdw_find_device_by_node helper
2025-07-04 12:12 [PATCH v2 0/4] ASoC: codecs: wcd937x/8x/9x: cleanup srinivas.kandagatla
2025-07-04 12:12 ` [PATCH v2 1/4] soundwire: bus: add of_sdw_find_device_by_node helper srinivas.kandagatla
2025-07-04 12:12 ` [PATCH v2 2/4] soundwire: bus: add sdw_slave_get_current_bank helper srinivas.kandagatla
@ 2025-07-04 12:12 ` srinivas.kandagatla
2025-07-04 12:12 ` [PATCH v2 4/4] ASoC: codecs: wcdxxxx: use sdw_slave_get_current_bank helper srinivas.kandagatla
2025-08-15 5:32 ` [PATCH v2 0/4] ASoC: codecs: wcd937x/8x/9x: cleanup Srinivas Kandagatla
4 siblings, 0 replies; 10+ messages in thread
From: srinivas.kandagatla @ 2025-07-04 12:12 UTC (permalink / raw)
To: vkoul, broonie
Cc: yung-chuan.liao, pierre-louis.bossart, lgirdwood, perex, tiwai,
krzysztof.kozlowski, linux-kernel, linux-sound, linux-arm-msm,
Srinivas Kandagatla, Dmitry Baryshkov
From: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
use of_sdw_find_device_by_node helper function, rather than duplicating
this function in every codec driver.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
sound/soc/codecs/wcd937x-sdw.c | 6 ------
sound/soc/codecs/wcd937x.c | 4 ++--
sound/soc/codecs/wcd937x.h | 2 --
sound/soc/codecs/wcd938x-sdw.c | 7 -------
sound/soc/codecs/wcd938x.c | 4 ++--
sound/soc/codecs/wcd938x.h | 6 ------
sound/soc/codecs/wcd939x-sdw.c | 6 ------
sound/soc/codecs/wcd939x.c | 4 ++--
sound/soc/codecs/wcd939x.h | 6 ------
9 files changed, 6 insertions(+), 39 deletions(-)
diff --git a/sound/soc/codecs/wcd937x-sdw.c b/sound/soc/codecs/wcd937x-sdw.c
index 1bfe7383b311..e7cc699bd8bc 100644
--- a/sound/soc/codecs/wcd937x-sdw.c
+++ b/sound/soc/codecs/wcd937x-sdw.c
@@ -78,12 +78,6 @@ static struct sdw_dpn_prop wcd937x_dpn_prop[WCD937X_MAX_SWR_PORTS] = {
}
};
-struct device *wcd937x_sdw_device_get(struct device_node *np)
-{
- return bus_find_device_by_of_node(&sdw_bus_type, np);
-}
-EXPORT_SYMBOL_GPL(wcd937x_sdw_device_get);
-
int wcd937x_sdw_hw_params(struct wcd937x_sdw_priv *wcd,
struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
diff --git a/sound/soc/codecs/wcd937x.c b/sound/soc/codecs/wcd937x.c
index 3b0a8cc314e0..ccd542033967 100644
--- a/sound/soc/codecs/wcd937x.c
+++ b/sound/soc/codecs/wcd937x.c
@@ -2788,7 +2788,7 @@ static int wcd937x_bind(struct device *dev)
return ret;
}
- wcd937x->rxdev = wcd937x_sdw_device_get(wcd937x->rxnode);
+ wcd937x->rxdev = of_sdw_find_device_by_node(wcd937x->rxnode);
if (!wcd937x->rxdev) {
dev_err(dev, "could not find slave with matching of node\n");
return -EINVAL;
@@ -2797,7 +2797,7 @@ static int wcd937x_bind(struct device *dev)
wcd937x->sdw_priv[AIF1_PB] = dev_get_drvdata(wcd937x->rxdev);
wcd937x->sdw_priv[AIF1_PB]->wcd937x = wcd937x;
- wcd937x->txdev = wcd937x_sdw_device_get(wcd937x->txnode);
+ wcd937x->txdev = of_sdw_find_device_by_node(wcd937x->txnode);
if (!wcd937x->txdev) {
dev_err(dev, "could not find txslave with matching of node\n");
return -EINVAL;
diff --git a/sound/soc/codecs/wcd937x.h b/sound/soc/codecs/wcd937x.h
index 3ab21bb5846e..49e5dce6f8c9 100644
--- a/sound/soc/codecs/wcd937x.h
+++ b/sound/soc/codecs/wcd937x.h
@@ -549,8 +549,6 @@ int wcd937x_sdw_hw_params(struct wcd937x_sdw_priv *wcd,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai);
-struct device *wcd937x_sdw_device_get(struct device_node *np);
-
#else
int wcd937x_sdw_free(struct wcd937x_sdw_priv *wcd,
struct snd_pcm_substream *substream,
diff --git a/sound/soc/codecs/wcd938x-sdw.c b/sound/soc/codecs/wcd938x-sdw.c
index e822cc145250..a7514d716086 100644
--- a/sound/soc/codecs/wcd938x-sdw.c
+++ b/sound/soc/codecs/wcd938x-sdw.c
@@ -82,13 +82,6 @@ static struct sdw_dpn_prop wcd938x_dpn_prop[WCD938X_MAX_SWR_PORTS] = {
}
};
-struct device *wcd938x_sdw_device_get(struct device_node *np)
-{
- return bus_find_device_by_of_node(&sdw_bus_type, np);
-
-}
-EXPORT_SYMBOL_GPL(wcd938x_sdw_device_get);
-
int wcd938x_swr_get_current_bank(struct sdw_slave *sdev)
{
int bank;
diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c
index 711f373ece24..e2cb0758bca7 100644
--- a/sound/soc/codecs/wcd938x.c
+++ b/sound/soc/codecs/wcd938x.c
@@ -3400,7 +3400,7 @@ static int wcd938x_bind(struct device *dev)
return ret;
}
- wcd938x->rxdev = wcd938x_sdw_device_get(wcd938x->rxnode);
+ wcd938x->rxdev = of_sdw_find_device_by_node(wcd938x->rxnode);
if (!wcd938x->rxdev) {
dev_err(dev, "could not find slave with matching of node\n");
ret = -EINVAL;
@@ -3409,7 +3409,7 @@ static int wcd938x_bind(struct device *dev)
wcd938x->sdw_priv[AIF1_PB] = dev_get_drvdata(wcd938x->rxdev);
wcd938x->sdw_priv[AIF1_PB]->wcd938x = wcd938x;
- wcd938x->txdev = wcd938x_sdw_device_get(wcd938x->txnode);
+ wcd938x->txdev = of_sdw_find_device_by_node(wcd938x->txnode);
if (!wcd938x->txdev) {
dev_err(dev, "could not find txslave with matching of node\n");
ret = -EINVAL;
diff --git a/sound/soc/codecs/wcd938x.h b/sound/soc/codecs/wcd938x.h
index fb6a0e4ef337..dbafcae247f4 100644
--- a/sound/soc/codecs/wcd938x.h
+++ b/sound/soc/codecs/wcd938x.h
@@ -670,7 +670,6 @@ int wcd938x_sdw_hw_params(struct wcd938x_sdw_priv *wcd,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai);
-struct device *wcd938x_sdw_device_get(struct device_node *np);
int wcd938x_swr_get_current_bank(struct sdw_slave *sdev);
#else
@@ -697,11 +696,6 @@ static inline int wcd938x_sdw_hw_params(struct wcd938x_sdw_priv *wcd,
return -EOPNOTSUPP;
}
-static inline struct device *wcd938x_sdw_device_get(struct device_node *np)
-{
- return NULL;
-}
-
static inline int wcd938x_swr_get_current_bank(struct sdw_slave *sdev)
{
return 0;
diff --git a/sound/soc/codecs/wcd939x-sdw.c b/sound/soc/codecs/wcd939x-sdw.c
index f7a9323a9fea..e487a1bb0194 100644
--- a/sound/soc/codecs/wcd939x-sdw.c
+++ b/sound/soc/codecs/wcd939x-sdw.c
@@ -128,12 +128,6 @@ static struct sdw_dpn_prop wcd939x_tx_dpn_prop[WCD939X_MAX_TX_SWR_PORTS] = {
}
};
-struct device *wcd939x_sdw_device_get(struct device_node *np)
-{
- return bus_find_device_by_of_node(&sdw_bus_type, np);
-}
-EXPORT_SYMBOL_GPL(wcd939x_sdw_device_get);
-
unsigned int wcd939x_swr_get_current_bank(struct sdw_slave *sdev)
{
return FIELD_GET(SDW_SCP_STAT_CURR_BANK,
diff --git a/sound/soc/codecs/wcd939x.c b/sound/soc/codecs/wcd939x.c
index 64f082e474c1..5a56c79a8922 100644
--- a/sound/soc/codecs/wcd939x.c
+++ b/sound/soc/codecs/wcd939x.c
@@ -3383,7 +3383,7 @@ static int wcd939x_bind(struct device *dev)
goto err_put_typec_switch;
}
- wcd939x->rxdev = wcd939x_sdw_device_get(wcd939x->rxnode);
+ wcd939x->rxdev = of_sdw_find_device_by_node(wcd939x->rxnode);
if (!wcd939x->rxdev) {
dev_err(dev, "could not find slave with matching of node\n");
ret = -EINVAL;
@@ -3392,7 +3392,7 @@ static int wcd939x_bind(struct device *dev)
wcd939x->sdw_priv[AIF1_PB] = dev_get_drvdata(wcd939x->rxdev);
wcd939x->sdw_priv[AIF1_PB]->wcd939x = wcd939x;
- wcd939x->txdev = wcd939x_sdw_device_get(wcd939x->txnode);
+ wcd939x->txdev = of_sdw_find_device_by_node(wcd939x->txnode);
if (!wcd939x->txdev) {
dev_err(dev, "could not find txslave with matching of node\n");
ret = -EINVAL;
diff --git a/sound/soc/codecs/wcd939x.h b/sound/soc/codecs/wcd939x.h
index 3204fb10b58d..3f189e5cafd5 100644
--- a/sound/soc/codecs/wcd939x.h
+++ b/sound/soc/codecs/wcd939x.h
@@ -930,7 +930,6 @@ int wcd939x_sdw_hw_params(struct wcd939x_sdw_priv *wcd,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai);
-struct device *wcd939x_sdw_device_get(struct device_node *np);
unsigned int wcd939x_swr_get_current_bank(struct sdw_slave *sdev);
struct regmap *wcd939x_swr_get_regmap(struct wcd939x_sdw_priv *wcd);
@@ -958,11 +957,6 @@ static inline int wcd939x_sdw_hw_params(struct wcd939x_sdw_priv *wcd,
return -EOPNOTSUPP;
}
-static inline struct device *wcd939x_sdw_device_get(struct device_node *np)
-{
- return NULL;
-}
-
static inline unsigned int wcd939x_swr_get_current_bank(struct sdw_slave *sdev)
{
return 0;
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 4/4] ASoC: codecs: wcdxxxx: use sdw_slave_get_current_bank helper
2025-07-04 12:12 [PATCH v2 0/4] ASoC: codecs: wcd937x/8x/9x: cleanup srinivas.kandagatla
` (2 preceding siblings ...)
2025-07-04 12:12 ` [PATCH v2 3/4] ASoC: codecs: wcdxxxx: use of_sdw_find_device_by_node helper srinivas.kandagatla
@ 2025-07-04 12:12 ` srinivas.kandagatla
2025-07-04 14:18 ` Dmitry Baryshkov
2025-08-15 5:32 ` [PATCH v2 0/4] ASoC: codecs: wcd937x/8x/9x: cleanup Srinivas Kandagatla
4 siblings, 1 reply; 10+ messages in thread
From: srinivas.kandagatla @ 2025-07-04 12:12 UTC (permalink / raw)
To: vkoul, broonie
Cc: yung-chuan.liao, pierre-louis.bossart, lgirdwood, perex, tiwai,
krzysztof.kozlowski, linux-kernel, linux-sound, linux-arm-msm,
Srinivas Kandagatla
From: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
use sdw_slave_get_current_bank() helper function, rather than duplicating
this function in every codec driver.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
---
sound/soc/codecs/wcd938x-sdw.c | 10 ----------
sound/soc/codecs/wcd938x.c | 3 +--
sound/soc/codecs/wcd938x.h | 7 -------
sound/soc/codecs/wcd939x-sdw.c | 7 -------
sound/soc/codecs/wcd939x.c | 2 +-
sound/soc/codecs/wcd939x.h | 7 -------
6 files changed, 2 insertions(+), 34 deletions(-)
diff --git a/sound/soc/codecs/wcd938x-sdw.c b/sound/soc/codecs/wcd938x-sdw.c
index a7514d716086..8bcd8396f375 100644
--- a/sound/soc/codecs/wcd938x-sdw.c
+++ b/sound/soc/codecs/wcd938x-sdw.c
@@ -82,16 +82,6 @@ static struct sdw_dpn_prop wcd938x_dpn_prop[WCD938X_MAX_SWR_PORTS] = {
}
};
-int wcd938x_swr_get_current_bank(struct sdw_slave *sdev)
-{
- int bank;
-
- bank = sdw_read(sdev, SDW_SCP_CTRL);
-
- return ((bank & 0x40) ? 1 : 0);
-}
-EXPORT_SYMBOL_GPL(wcd938x_swr_get_current_bank);
-
int wcd938x_sdw_hw_params(struct wcd938x_sdw_priv *wcd,
struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c
index e2cb0758bca7..f8d7bf27a6ed 100644
--- a/sound/soc/codecs/wcd938x.c
+++ b/sound/soc/codecs/wcd938x.c
@@ -1094,8 +1094,7 @@ static int wcd938x_tx_swr_ctrl(struct snd_soc_dapm_widget *w,
int bank;
int rate;
- bank = (wcd938x_swr_get_current_bank(wcd938x->sdw_priv[AIF1_CAP]->sdev)) ? 0 : 1;
- bank = bank ? 0 : 1;
+ bank = sdw_slave_get_current_bank(wcd938x->sdw_priv[AIF1_CAP]->sdev);
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
diff --git a/sound/soc/codecs/wcd938x.h b/sound/soc/codecs/wcd938x.h
index dbafcae247f4..54ee56b7fbd6 100644
--- a/sound/soc/codecs/wcd938x.h
+++ b/sound/soc/codecs/wcd938x.h
@@ -669,9 +669,6 @@ int wcd938x_sdw_hw_params(struct wcd938x_sdw_priv *wcd,
struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai);
-
-int wcd938x_swr_get_current_bank(struct sdw_slave *sdev);
-
#else
static inline int wcd938x_sdw_free(struct wcd938x_sdw_priv *wcd,
@@ -696,9 +693,5 @@ static inline int wcd938x_sdw_hw_params(struct wcd938x_sdw_priv *wcd,
return -EOPNOTSUPP;
}
-static inline int wcd938x_swr_get_current_bank(struct sdw_slave *sdev)
-{
- return 0;
-}
#endif /* CONFIG_SND_SOC_WCD938X_SDW */
#endif /* __WCD938X_H__ */
diff --git a/sound/soc/codecs/wcd939x-sdw.c b/sound/soc/codecs/wcd939x-sdw.c
index e487a1bb0194..477d6cf27d32 100644
--- a/sound/soc/codecs/wcd939x-sdw.c
+++ b/sound/soc/codecs/wcd939x-sdw.c
@@ -128,13 +128,6 @@ static struct sdw_dpn_prop wcd939x_tx_dpn_prop[WCD939X_MAX_TX_SWR_PORTS] = {
}
};
-unsigned int wcd939x_swr_get_current_bank(struct sdw_slave *sdev)
-{
- return FIELD_GET(SDW_SCP_STAT_CURR_BANK,
- sdw_read(sdev, SDW_SCP_CTRL));
-}
-EXPORT_SYMBOL_GPL(wcd939x_swr_get_current_bank);
-
int wcd939x_sdw_hw_params(struct wcd939x_sdw_priv *wcd,
struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
diff --git a/sound/soc/codecs/wcd939x.c b/sound/soc/codecs/wcd939x.c
index 5a56c79a8922..85730ae40c2c 100644
--- a/sound/soc/codecs/wcd939x.c
+++ b/sound/soc/codecs/wcd939x.c
@@ -1017,7 +1017,7 @@ static int wcd939x_tx_swr_ctrl(struct snd_soc_dapm_widget *w,
int bank;
int rate;
- bank = wcd939x_swr_get_current_bank(wcd939x->sdw_priv[AIF1_CAP]->sdev);
+ bank = sdw_slave_get_current_bank(wcd939x->sdw_priv[AIF1_CAP]->sdev);
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
diff --git a/sound/soc/codecs/wcd939x.h b/sound/soc/codecs/wcd939x.h
index 3f189e5cafd5..e70445b1a4bc 100644
--- a/sound/soc/codecs/wcd939x.h
+++ b/sound/soc/codecs/wcd939x.h
@@ -930,8 +930,6 @@ int wcd939x_sdw_hw_params(struct wcd939x_sdw_priv *wcd,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai);
-unsigned int wcd939x_swr_get_current_bank(struct sdw_slave *sdev);
-
struct regmap *wcd939x_swr_get_regmap(struct wcd939x_sdw_priv *wcd);
#else
@@ -957,11 +955,6 @@ static inline int wcd939x_sdw_hw_params(struct wcd939x_sdw_priv *wcd,
return -EOPNOTSUPP;
}
-static inline unsigned int wcd939x_swr_get_current_bank(struct sdw_slave *sdev)
-{
- return 0;
-}
-
struct regmap *wcd939x_swr_get_regmap(struct wcd939x_sdw_priv *wcd)
{
return PTR_ERR(-EINVAL);
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/4] soundwire: bus: add sdw_slave_get_current_bank helper
2025-07-04 12:12 ` [PATCH v2 2/4] soundwire: bus: add sdw_slave_get_current_bank helper srinivas.kandagatla
@ 2025-07-04 14:18 ` Dmitry Baryshkov
0 siblings, 0 replies; 10+ messages in thread
From: Dmitry Baryshkov @ 2025-07-04 14:18 UTC (permalink / raw)
To: srinivas.kandagatla
Cc: vkoul, broonie, yung-chuan.liao, pierre-louis.bossart, lgirdwood,
perex, tiwai, krzysztof.kozlowski, linux-kernel, linux-sound,
linux-arm-msm
On Fri, Jul 04, 2025 at 01:12:16PM +0100, srinivas.kandagatla@oss.qualcomm.com wrote:
> From: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
>
> There has been 2 instances of this helper in codec drivers,
> it does not make sense to keep duplicating this part of code.
>
> Lets add a helper sdw_get_current_bank() for codec drivers to use it.
>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
> ---
> drivers/soundwire/bus.c | 12 ++++++++++++
> include/linux/soundwire/sdw.h | 8 ++++++++
> 2 files changed, 20 insertions(+)
>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 4/4] ASoC: codecs: wcdxxxx: use sdw_slave_get_current_bank helper
2025-07-04 12:12 ` [PATCH v2 4/4] ASoC: codecs: wcdxxxx: use sdw_slave_get_current_bank helper srinivas.kandagatla
@ 2025-07-04 14:18 ` Dmitry Baryshkov
0 siblings, 0 replies; 10+ messages in thread
From: Dmitry Baryshkov @ 2025-07-04 14:18 UTC (permalink / raw)
To: srinivas.kandagatla
Cc: vkoul, broonie, yung-chuan.liao, pierre-louis.bossart, lgirdwood,
perex, tiwai, krzysztof.kozlowski, linux-kernel, linux-sound,
linux-arm-msm
On Fri, Jul 04, 2025 at 01:12:18PM +0100, srinivas.kandagatla@oss.qualcomm.com wrote:
> From: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
>
> use sdw_slave_get_current_bank() helper function, rather than duplicating
> this function in every codec driver.
>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
> ---
> sound/soc/codecs/wcd938x-sdw.c | 10 ----------
> sound/soc/codecs/wcd938x.c | 3 +--
> sound/soc/codecs/wcd938x.h | 7 -------
> sound/soc/codecs/wcd939x-sdw.c | 7 -------
> sound/soc/codecs/wcd939x.c | 2 +-
> sound/soc/codecs/wcd939x.h | 7 -------
> 6 files changed, 2 insertions(+), 34 deletions(-)
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/4] ASoC: codecs: wcd937x/8x/9x: cleanup
2025-07-04 12:12 [PATCH v2 0/4] ASoC: codecs: wcd937x/8x/9x: cleanup srinivas.kandagatla
` (3 preceding siblings ...)
2025-07-04 12:12 ` [PATCH v2 4/4] ASoC: codecs: wcdxxxx: use sdw_slave_get_current_bank helper srinivas.kandagatla
@ 2025-08-15 5:32 ` Srinivas Kandagatla
2025-08-20 17:19 ` Vinod Koul
4 siblings, 1 reply; 10+ messages in thread
From: Srinivas Kandagatla @ 2025-08-15 5:32 UTC (permalink / raw)
To: vkoul, broonie
Cc: yung-chuan.liao, pierre-louis.bossart, lgirdwood, perex, tiwai,
krzysztof.kozlowski, linux-kernel, linux-sound, linux-arm-msm
Hi Vinod,
On 7/4/25 1:12 PM, srinivas.kandagatla@oss.qualcomm.com wrote:
> From: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
>
> All these 3 codecs have been duplicating two of the soundwire
> functions. Noticed another new driver starting to do the same, its time
> to make some helpers so that we do not duplicate these functions.
>
> I have added two helpers of_sdw_find_device_by_node() and
> sdw_slave_get_current_bank() in soundwire layer for the codecs to use them.
>
> Changes since v1:
> - updated sdw_slave_get_current_bank do error checks on read
>
> Srinivas Kandagatla (4):
> soundwire: bus: add of_sdw_find_device_by_node helper
> soundwire: bus: add sdw_slave_get_current_bank helper
Do you have any comments these two soundwire patches in this series?
--srini
> ASoC: codecs: wcdxxxx: use of_sdw_find_device_by_node helper
> ASoC: codecs: wcdxxxx: use sdw_slave_get_current_bank helper
>
> drivers/soundwire/bus.c | 12 ++++++++++++
> drivers/soundwire/slave.c | 6 ++++++
> include/linux/soundwire/sdw.h | 17 +++++++++++++++++
> sound/soc/codecs/wcd937x-sdw.c | 6 ------
> sound/soc/codecs/wcd937x.c | 4 ++--
> sound/soc/codecs/wcd937x.h | 2 --
> sound/soc/codecs/wcd938x-sdw.c | 17 -----------------
> sound/soc/codecs/wcd938x.c | 7 +++----
> sound/soc/codecs/wcd938x.h | 13 -------------
> sound/soc/codecs/wcd939x-sdw.c | 13 -------------
> sound/soc/codecs/wcd939x.c | 6 +++---
> sound/soc/codecs/wcd939x.h | 13 -------------
> 12 files changed, 43 insertions(+), 73 deletions(-)
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/4] ASoC: codecs: wcd937x/8x/9x: cleanup
2025-08-15 5:32 ` [PATCH v2 0/4] ASoC: codecs: wcd937x/8x/9x: cleanup Srinivas Kandagatla
@ 2025-08-20 17:19 ` Vinod Koul
0 siblings, 0 replies; 10+ messages in thread
From: Vinod Koul @ 2025-08-20 17:19 UTC (permalink / raw)
To: Srinivas Kandagatla
Cc: broonie, yung-chuan.liao, pierre-louis.bossart, lgirdwood, perex,
tiwai, krzysztof.kozlowski, linux-kernel, linux-sound,
linux-arm-msm
On 15-08-25, 06:32, Srinivas Kandagatla wrote:
> Hi Vinod,
> On 7/4/25 1:12 PM, srinivas.kandagatla@oss.qualcomm.com wrote:
> > From: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
> >
> > All these 3 codecs have been duplicating two of the soundwire
> > functions. Noticed another new driver starting to do the same, its time
> > to make some helpers so that we do not duplicate these functions.
> >
> > I have added two helpers of_sdw_find_device_by_node() and
> > sdw_slave_get_current_bank() in soundwire layer for the codecs to use them.
> >
> > Changes since v1:
> > - updated sdw_slave_get_current_bank do error checks on read
> >
> > Srinivas Kandagatla (4):
> > soundwire: bus: add of_sdw_find_device_by_node helper
> > soundwire: bus: add sdw_slave_get_current_bank helper
>
>
> Do you have any comments these two soundwire patches in this series?
Yes I am nota helpers like this, but I dont think it is big deal so:
Acked-by: Vinod Koul <vkoul@kernel.org>
--
~Vinod
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/4] soundwire: bus: add of_sdw_find_device_by_node helper
2025-07-04 12:12 ` [PATCH v2 1/4] soundwire: bus: add of_sdw_find_device_by_node helper srinivas.kandagatla
@ 2025-10-13 5:44 ` Vinod Koul
0 siblings, 0 replies; 10+ messages in thread
From: Vinod Koul @ 2025-10-13 5:44 UTC (permalink / raw)
To: srinivas.kandagatla
Cc: broonie, yung-chuan.liao, pierre-louis.bossart, lgirdwood, perex,
tiwai, krzysztof.kozlowski, linux-kernel, linux-sound,
linux-arm-msm, Dmitry Baryshkov
On 04-07-25, 13:12, srinivas.kandagatla@oss.qualcomm.com wrote:
> From: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
>
> There has been more than 3 instances of this helper in multiple codec
> drivers, it does not make sense to keep duplicating this part of code.
>
> Lets add a helper of_sdw_find_device_by_node for codec drivers to use it.
Acked-by: Vinod Koul <vkoul@kernel.org>
--
~Vinod
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-10-13 5:44 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-04 12:12 [PATCH v2 0/4] ASoC: codecs: wcd937x/8x/9x: cleanup srinivas.kandagatla
2025-07-04 12:12 ` [PATCH v2 1/4] soundwire: bus: add of_sdw_find_device_by_node helper srinivas.kandagatla
2025-10-13 5:44 ` Vinod Koul
2025-07-04 12:12 ` [PATCH v2 2/4] soundwire: bus: add sdw_slave_get_current_bank helper srinivas.kandagatla
2025-07-04 14:18 ` Dmitry Baryshkov
2025-07-04 12:12 ` [PATCH v2 3/4] ASoC: codecs: wcdxxxx: use of_sdw_find_device_by_node helper srinivas.kandagatla
2025-07-04 12:12 ` [PATCH v2 4/4] ASoC: codecs: wcdxxxx: use sdw_slave_get_current_bank helper srinivas.kandagatla
2025-07-04 14:18 ` Dmitry Baryshkov
2025-08-15 5:32 ` [PATCH v2 0/4] ASoC: codecs: wcd937x/8x/9x: cleanup Srinivas Kandagatla
2025-08-20 17:19 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox