From: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Ffor some reason we ended up with a boiler plate for dev_get_regmap in
wcd939x codec and started exporting a symbol for this. Remove this
redundant wrapper and direclty use dev_get_regmap from device pointer..
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
---
sound/soc/codecs/wcd939x-sdw.c | 9 ---------
sound/soc/codecs/wcd939x.c | 6 +++---
sound/soc/codecs/wcd939x.h | 6 ------
3 files changed, 3 insertions(+), 18 deletions(-)
diff --git a/sound/soc/codecs/wcd939x-sdw.c b/sound/soc/codecs/wcd939x-sdw.c
index df71d7777b71..2b0aa2108f33 100644
--- a/sound/soc/codecs/wcd939x-sdw.c
+++ b/sound/soc/codecs/wcd939x-sdw.c
@@ -186,15 +186,6 @@ int wcd939x_sdw_set_sdw_stream(struct wcd939x_sdw_priv *wcd,
}
EXPORT_SYMBOL_GPL(wcd939x_sdw_set_sdw_stream);
-struct regmap *wcd939x_swr_get_regmap(struct wcd939x_sdw_priv *wcd)
-{
- if (wcd->regmap)
- return wcd->regmap;
-
- return ERR_PTR(-EINVAL);
-}
-EXPORT_SYMBOL_GPL(wcd939x_swr_get_regmap);
-
static int wcd9390_update_status(struct sdw_slave *slave,
enum sdw_slave_status status)
{
diff --git a/sound/soc/codecs/wcd939x.c b/sound/soc/codecs/wcd939x.c
index 6bbdfa426365..18ccdba18291 100644
--- a/sound/soc/codecs/wcd939x.c
+++ b/sound/soc/codecs/wcd939x.c
@@ -3373,10 +3373,10 @@ static int wcd939x_bind(struct device *dev)
}
/* Get regmap from TX SoundWire device */
- wcd939x->regmap = wcd939x_swr_get_regmap(wcd939x->sdw_priv[AIF1_CAP]);
- if (IS_ERR(wcd939x->regmap)) {
+ wcd939x->regmap = dev_get_regmap(wcd939x->txdev, NULL);
+ if (!wcd939x->regmap) {
dev_err(dev, "could not get TX device regmap\n");
- ret = PTR_ERR(wcd939x->regmap);
+ ret = -ENODEV;
goto err_remove_rx_link;
}
diff --git a/sound/soc/codecs/wcd939x.h b/sound/soc/codecs/wcd939x.h
index 0ee0fbb49ff9..eba8205cdd0d 100644
--- a/sound/soc/codecs/wcd939x.h
+++ b/sound/soc/codecs/wcd939x.h
@@ -919,8 +919,6 @@ int wcd939x_sdw_hw_params(struct wcd939x_sdw_priv *wcd,
struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai);
-
-struct regmap *wcd939x_swr_get_regmap(struct wcd939x_sdw_priv *wcd);
#else
static inline int wcd939x_sdw_free(struct wcd939x_sdw_priv *wcd,
@@ -945,10 +943,6 @@ static inline int wcd939x_sdw_hw_params(struct wcd939x_sdw_priv *wcd,
return -EOPNOTSUPP;
}
-struct regmap *wcd939x_swr_get_regmap(struct wcd939x_sdw_priv *wcd)
-{
- return PTR_ERR(-EINVAL);
-}
#endif /* CONFIG_SND_SOC_WCD939X_SDW */
#endif /* __WCD939X_H__ */
--
2.50.0
On Wed, Jul 16, 2025 at 01:33:22PM +0100, srinivas.kandagatla@oss.qualcomm.com wrote:
> Ffor some reason we ended up with a boiler plate for dev_get_regmap in
> wcd939x codec and started exporting a symbol for this. Remove this
> redundant wrapper and direclty use dev_get_regmap from device pointer..
> -struct regmap *wcd939x_swr_get_regmap(struct wcd939x_sdw_priv *wcd)
> -{
> - if (wcd->regmap)
> - return wcd->regmap;
> -
> - return ERR_PTR(-EINVAL);
> -}
> -EXPORT_SYMBOL_GPL(wcd939x_swr_get_regmap);
> /* Get regmap from TX SoundWire device */
> - wcd939x->regmap = wcd939x_swr_get_regmap(wcd939x->sdw_priv[AIF1_CAP]);
> - if (IS_ERR(wcd939x->regmap)) {
> + wcd939x->regmap = dev_get_regmap(wcd939x->txdev, NULL);
> + if (!wcd939x->regmap) {
The existing code should be more efficient than dev_get_regmap(), the
latter does a devres_find() to look up the regmap while the above is
just a pointer dereference. It's probably a marginal difference in the
context of probe() but there is a reason to do something more direct if
you can, dev_get_regmap() is mainly intended for generic APIs that get
passed a struct device.
On 7/16/25 3:31 PM, Mark Brown wrote:
> On Wed, Jul 16, 2025 at 01:33:22PM +0100, srinivas.kandagatla@oss.qualcomm.com wrote:
>
>> Ffor some reason we ended up with a boiler plate for dev_get_regmap in
>> wcd939x codec and started exporting a symbol for this. Remove this
>> redundant wrapper and direclty use dev_get_regmap from device pointer..
>
>> -struct regmap *wcd939x_swr_get_regmap(struct wcd939x_sdw_priv *wcd)
>> -{
>> - if (wcd->regmap)
>> - return wcd->regmap;
>> -
>> - return ERR_PTR(-EINVAL);
>> -}
>> -EXPORT_SYMBOL_GPL(wcd939x_swr_get_regmap);
>
>
>> /* Get regmap from TX SoundWire device */
>> - wcd939x->regmap = wcd939x_swr_get_regmap(wcd939x->sdw_priv[AIF1_CAP]);
>> - if (IS_ERR(wcd939x->regmap)) {
>> + wcd939x->regmap = dev_get_regmap(wcd939x->txdev, NULL);
>> + if (!wcd939x->regmap) {
>
> The existing code should be more efficient than dev_get_regmap(), the
> latter does a devres_find() to look up the regmap while the above is
> just a pointer dereference. It's probably a marginal difference in the
> context of probe() but there is a reason to do something more direct if
> you can, dev_get_regmap() is mainly intended for generic APIs that get
Thanks Mark, I did not realize that dev_get_regmap was devres search at
the end, Will drop this patch and make something similar changes to
other codecs too.
--srini
> passed a struct device.
On 7/16/25 3:36 PM, Srinivas Kandagatla wrote:
> On 7/16/25 3:31 PM, Mark Brown wrote:
>> On Wed, Jul 16, 2025 at 01:33:22PM +0100, srinivas.kandagatla@oss.qualcomm.com wrote:
>>
>>> Ffor some reason we ended up with a boiler plate for dev_get_regmap in
>>> wcd939x codec and started exporting a symbol for this. Remove this
>>> redundant wrapper and direclty use dev_get_regmap from device pointer..
>>
>>> -struct regmap *wcd939x_swr_get_regmap(struct wcd939x_sdw_priv *wcd)
>>> -{
>>> - if (wcd->regmap)
>>> - return wcd->regmap;
>>> -
>>> - return ERR_PTR(-EINVAL);
>>> -}
>>> -EXPORT_SYMBOL_GPL(wcd939x_swr_get_regmap);
>>
>>
>>> /* Get regmap from TX SoundWire device */
>>> - wcd939x->regmap = wcd939x_swr_get_regmap(wcd939x->sdw_priv[AIF1_CAP]);
>>> - if (IS_ERR(wcd939x->regmap)) {
>>> + wcd939x->regmap = dev_get_regmap(wcd939x->txdev, NULL);
>>> + if (!wcd939x->regmap) {
Infact this turned out to me much simpler and not even use
dev_get_regmap() by just doing a deref of sdw_priv
wcd939x->regmap = wcd939x->sdw_priv[AIF1_CAP]->regmap;
Will fix such instances in next spin.
--srini
>>
>> The existing code should be more efficient than dev_get_regmap(), the
>> latter does a devres_find() to look up the regmap while the above is
>> just a pointer dereference. It's probably a marginal difference in the
>> context of probe() but there is a reason to do something more direct if
>> you can, dev_get_regmap() is mainly intended for generic APIs that get
> Thanks Mark, I did not realize that dev_get_regmap was devres search at
> the end, Will drop this patch and make something similar changes to
> other codecs too.
>
> --srini
>> passed a struct device.
>
© 2016 - 2026 Red Hat, Inc.