From: Charles Keepax Date: Mon, 8 Jun 2026 10:27:13 +0000 (+0100) Subject: ASoC: SDCA: Use new SoundWire enumeration helper X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90a49e0f16529719fd695c8856324702ed281f82;p=linux ASoC: SDCA: Use new SoundWire enumeration helper Now the new wait for SoundWire enumeration helper no longer depends on unattach_request it is safe to use from probe time. Update the driver to use the new core helper. Signed-off-by: Charles Keepax Reviewed-by: Srinivas Kandagatla Tested-by: Srinivas Kandagatla Link: https://patch.msgid.link/20260608102714.2503120-10-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown --- diff --git a/sound/soc/sdca/sdca_class.c b/sound/soc/sdca/sdca_class.c index a6a3da8de4371..6937a91ddfb9b 100644 --- a/sound/soc/sdca/sdca_class.c +++ b/sound/soc/sdca/sdca_class.c @@ -38,35 +38,8 @@ static int class_read_prop(struct sdw_slave *sdw) return 0; } -static int class_sdw_update_status(struct sdw_slave *sdw, enum sdw_slave_status status) -{ - struct sdca_class_drv *drv = dev_get_drvdata(&sdw->dev); - - switch (status) { - case SDW_SLAVE_ATTACHED: - dev_dbg(drv->dev, "device attach\n"); - - drv->attached = true; - - complete(&drv->device_attach); - break; - case SDW_SLAVE_UNATTACHED: - dev_dbg(drv->dev, "device detach\n"); - - drv->attached = false; - - reinit_completion(&drv->device_attach); - break; - default: - break; - } - - return 0; -} - static const struct sdw_slave_ops class_sdw_ops = { .read_prop = class_read_prop, - .update_status = class_sdw_update_status, }; static void class_regmap_lock(void *data) @@ -83,24 +56,6 @@ static void class_regmap_unlock(void *data) mutex_unlock(lock); } -static int class_wait_for_attach(struct sdca_class_drv *drv) -{ - if (!drv->attached) { - unsigned long timeout = msecs_to_jiffies(CLASS_SDW_ATTACH_TIMEOUT_MS); - unsigned long time; - - time = wait_for_completion_timeout(&drv->device_attach, timeout); - if (!time) { - dev_err(drv->dev, "timed out waiting for device re-attach\n"); - return -ETIMEDOUT; - } - } - - regcache_cache_only(drv->dev_regmap, false); - - return 0; -} - static bool class_dev_regmap_volatile(struct device *dev, unsigned int reg) { switch (reg) { @@ -151,10 +106,12 @@ static void class_boot_work(struct work_struct *work) boot_work); int ret; - ret = class_wait_for_attach(drv); + ret = sdw_slave_wait_for_init(drv->sdw, CLASS_SDW_ATTACH_TIMEOUT_MS); if (ret) goto err; + regcache_cache_only(drv->dev_regmap, false); + drv->irq_info = sdca_irq_allocate(drv->dev, drv->dev_regmap, drv->sdw->irq); if (IS_ERR(drv->irq_info)) @@ -206,7 +163,6 @@ static int class_sdw_probe(struct sdw_slave *sdw, const struct sdw_device_id *id dev_set_drvdata(drv->dev, drv); INIT_WORK(&drv->boot_work, class_boot_work); - init_completion(&drv->device_attach); dev_config->lock_arg = &drv->regmap_lock; @@ -290,10 +246,11 @@ static int class_runtime_resume(struct device *dev) struct sdca_class_drv *drv = dev_get_drvdata(dev); int ret; - ret = class_wait_for_attach(drv); + ret = sdw_slave_wait_for_init(drv->sdw, CLASS_SDW_ATTACH_TIMEOUT_MS); if (ret) goto err; + regcache_cache_only(drv->dev_regmap, false); regcache_mark_dirty(drv->dev_regmap); ret = regcache_sync(drv->dev_regmap); diff --git a/sound/soc/sdca/sdca_class.h b/sound/soc/sdca/sdca_class.h index 8b63e62485e64..57f7f8d08f497 100644 --- a/sound/soc/sdca/sdca_class.h +++ b/sound/soc/sdca/sdca_class.h @@ -30,9 +30,6 @@ struct sdca_class_drv { /* Serialise function initialisations */ struct mutex init_lock; struct work_struct boot_work; - struct completion device_attach; - - bool attached; }; #endif /* __SDCA_CLASS_H__ */