Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Srinivas Kandagatla and committed by
Mark Brown
ebaf88c0 4652f02c

+34 -72
+27
sound/soc/codecs/wcd-common.c
··· 7 7 #include <linux/device.h> 8 8 #include <linux/of.h> 9 9 #include <linux/printk.h> 10 + #include <linux/component.h> 11 + #include <linux/pm_runtime.h> 10 12 11 13 #include "wcd-common.h" 12 14 ··· 68 66 return 0; 69 67 } 70 68 EXPORT_SYMBOL_GPL(wcd_dt_parse_micbias_info); 69 + 70 + static int wcd_sdw_component_bind(struct device *dev, struct device *master, void *data) 71 + { 72 + pm_runtime_set_autosuspend_delay(dev, 3000); 73 + pm_runtime_use_autosuspend(dev); 74 + pm_runtime_mark_last_busy(dev); 75 + pm_runtime_set_active(dev); 76 + pm_runtime_enable(dev); 77 + 78 + return 0; 79 + } 80 + 81 + static void wcd_sdw_component_unbind(struct device *dev, struct device *master, void *data) 82 + { 83 + pm_runtime_disable(dev); 84 + pm_runtime_set_suspended(dev); 85 + pm_runtime_dont_use_autosuspend(dev); 86 + } 87 + 88 + const struct component_ops wcd_sdw_component_ops = { 89 + .bind = wcd_sdw_component_bind, 90 + .unbind = wcd_sdw_component_unbind, 91 + }; 92 + EXPORT_SYMBOL_GPL(wcd_sdw_component_ops); 93 + 71 94 MODULE_DESCRIPTION("Common Qualcomm WCD Codec helpers driver"); 72 95 MODULE_LICENSE("GPL");
+1
sound/soc/codecs/wcd-common.h
··· 34 34 u32 micb_vout[WCD_MAX_MICBIAS]; 35 35 }; 36 36 37 + extern const struct component_ops wcd_sdw_component_ops; 37 38 int wcd_get_micb_vout_ctl_val(struct device *dev, u32 micb_mv); 38 39 int wcd_dt_parse_micbias_info(struct wcd_common *common); 39 40
+2 -27
sound/soc/codecs/wcd937x-sdw.c
··· 983 983 .interrupt_callback = wcd9370_interrupt_callback, 984 984 }; 985 985 986 - static int wcd937x_sdw_component_bind(struct device *dev, 987 - struct device *master, void *data) 988 - { 989 - pm_runtime_set_autosuspend_delay(dev, 3000); 990 - pm_runtime_use_autosuspend(dev); 991 - pm_runtime_mark_last_busy(dev); 992 - pm_runtime_set_active(dev); 993 - pm_runtime_enable(dev); 994 - 995 - return 0; 996 - } 997 - 998 - static void wcd937x_sdw_component_unbind(struct device *dev, 999 - struct device *master, void *data) 1000 - { 1001 - pm_runtime_disable(dev); 1002 - pm_runtime_set_suspended(dev); 1003 - pm_runtime_dont_use_autosuspend(dev); 1004 - } 1005 - 1006 - static const struct component_ops wcd937x_sdw_component_ops = { 1007 - .bind = wcd937x_sdw_component_bind, 1008 - .unbind = wcd937x_sdw_component_unbind, 1009 - }; 1010 - 1011 986 static int wcd9370_probe(struct sdw_slave *pdev, 1012 987 const struct sdw_device_id *id) 1013 988 { ··· 1068 1093 } 1069 1094 1070 1095 1071 - ret = component_add(dev, &wcd937x_sdw_component_ops); 1096 + ret = component_add(dev, &wcd_sdw_component_ops); 1072 1097 if (ret) 1073 1098 return ret; 1074 1099 ··· 1082 1107 { 1083 1108 struct device *dev = &pdev->dev; 1084 1109 1085 - component_del(dev, &wcd937x_sdw_component_ops); 1110 + component_del(dev, &wcd_sdw_component_ops); 1086 1111 1087 1112 return 0; 1088 1113 }
+2 -18
sound/soc/codecs/wcd938x-sdw.c
··· 1182 1182 .bus_config = wcd9380_bus_config, 1183 1183 }; 1184 1184 1185 - static int wcd938x_sdw_component_bind(struct device *dev, 1186 - struct device *master, void *data) 1187 - { 1188 - return 0; 1189 - } 1190 - 1191 - static void wcd938x_sdw_component_unbind(struct device *dev, 1192 - struct device *master, void *data) 1193 - { 1194 - } 1195 - 1196 - static const struct component_ops wcd938x_sdw_component_ops = { 1197 - .bind = wcd938x_sdw_component_bind, 1198 - .unbind = wcd938x_sdw_component_unbind, 1199 - }; 1200 - 1201 1185 static int wcd9380_probe(struct sdw_slave *pdev, 1202 1186 const struct sdw_device_id *id) 1203 1187 { ··· 1246 1262 pm_runtime_set_active(dev); 1247 1263 pm_runtime_enable(dev); 1248 1264 1249 - ret = component_add(dev, &wcd938x_sdw_component_ops); 1265 + ret = component_add(dev, &wcd_sdw_component_ops); 1250 1266 if (ret) 1251 1267 goto err_disable_rpm; 1252 1268 ··· 1264 1280 { 1265 1281 struct device *dev = &pdev->dev; 1266 1282 1267 - component_del(dev, &wcd938x_sdw_component_ops); 1283 + component_del(dev, &wcd_sdw_component_ops); 1268 1284 1269 1285 pm_runtime_disable(dev); 1270 1286 pm_runtime_set_suspended(dev);
+2 -27
sound/soc/codecs/wcd939x-sdw.c
··· 1378 1378 .bus_config = wcd9390_bus_config, 1379 1379 }; 1380 1380 1381 - static int wcd939x_sdw_component_bind(struct device *dev, struct device *master, 1382 - void *data) 1383 - { 1384 - pm_runtime_set_autosuspend_delay(dev, 3000); 1385 - pm_runtime_use_autosuspend(dev); 1386 - pm_runtime_mark_last_busy(dev); 1387 - pm_runtime_set_active(dev); 1388 - pm_runtime_enable(dev); 1389 - 1390 - return 0; 1391 - } 1392 - 1393 - static void wcd939x_sdw_component_unbind(struct device *dev, 1394 - struct device *master, void *data) 1395 - { 1396 - pm_runtime_disable(dev); 1397 - pm_runtime_set_suspended(dev); 1398 - pm_runtime_dont_use_autosuspend(dev); 1399 - } 1400 - 1401 - static const struct component_ops wcd939x_sdw_component_ops = { 1402 - .bind = wcd939x_sdw_component_bind, 1403 - .unbind = wcd939x_sdw_component_unbind, 1404 - }; 1405 - 1406 1381 static int wcd9390_probe(struct sdw_slave *pdev, const struct sdw_device_id *id) 1407 1382 { 1408 1383 struct device *dev = &pdev->dev; ··· 1441 1466 regcache_cache_only(wcd->regmap, true); 1442 1467 } 1443 1468 1444 - ret = component_add(dev, &wcd939x_sdw_component_ops); 1469 + ret = component_add(dev, &wcd_sdw_component_ops); 1445 1470 if (ret) 1446 1471 return ret; 1447 1472 ··· 1456 1481 struct device *dev = &pdev->dev; 1457 1482 struct wcd939x_sdw_priv *wcd = dev_get_drvdata(dev); 1458 1483 1459 - component_del(dev, &wcd939x_sdw_component_ops); 1484 + component_del(dev, &wcd_sdw_component_ops); 1460 1485 1461 1486 if (wcd->regmap) 1462 1487 regmap_exit(wcd->regmap);