]> git.hungrycats.org Git - linux/commitdiff
ASoC: SDCA: Use new SoundWire enumeration helper
authorCharles Keepax <ckeepax@opensource.cirrus.com>
Mon, 8 Jun 2026 10:27:13 +0000 (11:27 +0100)
committerMark Brown <broonie@kernel.org>
Thu, 11 Jun 2026 19:46:54 +0000 (20:46 +0100)
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 <ckeepax@opensource.cirrus.com>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Tested-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Link: https://patch.msgid.link/20260608102714.2503120-10-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sdca/sdca_class.c
sound/soc/sdca/sdca_class.h

index a6a3da8de4371a9f58e0ebaa4ef2cff3dd41a2d3..6937a91ddfb9bdf00db2bf7f48e1e37336515c49 100644 (file)
@@ -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);
index 8b63e62485e6476966cab147e4b5190b06d265a3..57f7f8d08f4970d54509546224207910648225d9 100644 (file)
@@ -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__ */