mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
ASoC: codecs: wcd-common: move component ops to common
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>
This commit is contained in:
committed by
Mark Brown
parent
4652f02cf6
commit
ebaf88c054
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user