Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794598580; b=Qb/S3Ds/kXWH5+xMOuZHernFAnZRMY2fND0pSfBW9l0G0hBbsDbhEaLetcBZIbr15/kv 0Rv+/gjcP6lYM+7UuTd64/5URymuimbBuA+EtkjpceavUn5IUDq0yCEYotp2r25EmWFRM IKpGhpUJvA+oqbU05xkvKoz92YbPuzsqJXhLk+q3Cj6oPX60/HwD2HUPd9zM+72Kotzob /bgFudf3eUC4HvaMbFwjTDL8J+6rO0HfdWeQh61pHWH8ssHM4hHbc2U1agTCKPJGp4+Zg n6P7UyoEAnIDcIl7XVVwwLnsc1b58ieGX4IVG9Gnj0ymHa4cLbMnm3PmkGcAb4iA9qA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794598580; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=3btaDFzFg3AvVpdlTtk3uFKOC6fVO17Bzy75ueEGE/U=; b=02owja5l3LmdSLFkFVQfEDpJacL6jqECNoYhpjj07aymD4ndFjEcbAuBLbm8wvstA7xz X8RwLdQqutgwPOxvl40IehmRCoCl+kZlQj/RsEBVzgnYoigXRRd5QOSut4VIXvJSGjIPW DPpAj3R0gWIGLlTbQqPRXPVevHSlW2Rt6EJfQE+X+kRiqIEvnSIB04xeli2VxLsnWePPx MtdfzmllvOzzp8mbPgmBMaqvC5aGQCHAbQgduhwgbyzMhSyJC5IW3qBgQWkZ3ad5e1NIQ FpnEayuqjJ4EJ8/WFCMLHCOm/pWdFVQWHFLk5UIxw1K33PY8jh6HzGkaISYb1S1R/dw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ge8Iy3bd; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 841C1606A32D for ; Fri, 13 Nov 2026 19:36:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ge8Iy3bd Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93BA61F000C4; Fri, 13 Nov 2026 19:36:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794598580; bh=3btaDFzFg3AvVpdlTtk3uFKOC6fVO17Bzy75ueEGE/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ge8Iy3bdi7Fsp/dHEml82fzzK76FU4HD0rmNzs7DbyDd4zvIjHH1OnUH7Incqr/Jc ratYs0ZJcFHx/NC/WvkwXXOb4QNSV3O8g2aren1pUJ4lfzfRP3okTIy/uIsWUWvCUC yOakrHjcigvhMi9GwGNRX4E9IYhkNFWkL32+HuesP3+JMihugQUgfQ3WtjU2OAU7DI R6fh2sHauQ70o106WXKnoPfcfnM6GadmRvRrRn+/S64+RF3mEysbpqgQMrTecabKwb VIEjI0HrA+Lb9dCcBUXJ4mQxC3S26Vb/0PQtFNVyoN/dL9bEqstCGEG5eezBWSLD2Z ckU4PynCLG/fA== From: Sasha Levin To: stable@vger.kernel.org Cc: Srinivas Kandagatla , Charles Keepax , Mark Brown , Sasha Levin Subject: [PATCH 7.3.y 1/2] ASoC: SDCA: export PM helpers keyed on sdca_class_drv Date: Fri, 13 Nov 2026 14:36:17 -0500 Message-ID: <20261113193611.2457020-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261107050548-failed-7.3-d34a818a331f@kernel.org> References: <20261107050548-failed-7.3-d34a818a331f@kernel.org> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Srinivas Kandagatla [ Upstream commit 0985313a2a9d2e84d6a6b1041c88b5c57ee46dfa ] The class PM callbacks pull sdca_class_drv out of drvdata, so the built-in class_sdw_driver owns the drvdata slot. That works for the generic case but blocks codec drivers that want to embed sdca_class_drv in their own private struct -- they need drvdata for their codec priv. Split the four callbacks into exported helpers that take a struct sdca_class_drv * directly: sdca_class_system_suspend() sdca_class_system_resume() sdca_class_runtime_suspend() sdca_class_runtime_resume() Codec drivers can now compose these into their own dev_pm_ops without going through drvdata. For the built-in class_sdw_driver, add small dev_pm_ops wrappers that fetch drv from drvdata and wire them into sdca_class_pm_ops. The ops struct itself stays private to this file; codec drivers build their own dev_pm_ops from the four exported helpers above. No functional change: the built-in class_sdw_driver keeps the same PM semantics; only the internal plumbing shifts to operate on sdca_class_drv instead of struct device *dev. Signed-off-by: Srinivas Kandagatla Reviewed-by: Charles Keepax Link: https://patch.msgid.link/20260925161049.758913-3-srinivas.kandagatla@oss.qualcomm.com Signed-off-by: Mark Brown Stable-dep-of: d34a818a331f ("ASoC: SDCA: re-enable IRQ on pm_runtime_force_suspend failure") Signed-off-by: Sasha Levin --- .../soc/sdca => include/sound}/sdca_class.h | 14 ++++ sound/soc/sdca/sdca_class.c | 81 ++++++++++++++----- sound/soc/sdca/sdca_class_function.c | 2 +- 3 files changed, 78 insertions(+), 19 deletions(-) rename {sound/soc/sdca => include/sound}/sdca_class.h (58%) diff --git a/sound/soc/sdca/sdca_class.h b/include/sound/sdca_class.h similarity index 58% rename from sound/soc/sdca/sdca_class.h rename to include/sound/sdca_class.h index 57f7f8d08f497..8a6a34a8dd4c3 100644 --- a/sound/soc/sdca/sdca_class.h +++ b/include/sound/sdca_class.h @@ -32,4 +32,18 @@ struct sdca_class_drv { struct work_struct boot_work; }; +/* + * PM helpers. Codec drivers embed sdca_class_drv in their own priv, + * own dev_set_drvdata(), and compose these into their own dev_pm_ops: + * + * static int wcd_runtime_suspend(struct device *dev) { + * struct wcd_priv *priv = dev_get_drvdata(dev); + * return sdca_class_runtime_suspend(&priv->class); + * } + */ +int sdca_class_runtime_suspend(struct sdca_class_drv *drv); +int sdca_class_runtime_resume(struct sdca_class_drv *drv); +int sdca_class_system_suspend(struct sdca_class_drv *drv); +int sdca_class_system_resume(struct sdca_class_drv *drv); + #endif /* __SDCA_CLASS_H__ */ diff --git a/sound/soc/sdca/sdca_class.c b/sound/soc/sdca/sdca_class.c index e0e7aff70f93d..c5d6cf9896545 100644 --- a/sound/soc/sdca/sdca_class.c +++ b/sound/soc/sdca/sdca_class.c @@ -20,7 +20,7 @@ #include #include #include -#include "sdca_class.h" +#include #define CLASS_SDW_ATTACH_TIMEOUT_MS 5000 @@ -199,30 +199,41 @@ static void class_sdw_remove(struct sdw_slave *sdw) cancel_work_sync(&drv->boot_work); } -static int class_suspend(struct device *dev) +/** + * sdca_class_system_suspend - SDCA class system suspend helper + * @drv: caller-owned sdca_class_drv. + * + * Codec drivers compose this into their own dev_pm_ops. Disables the + * SoundWire interrupt and forces runtime suspend of the underlying + * class regmap. + */ +int sdca_class_system_suspend(struct sdca_class_drv *drv) { - struct sdca_class_drv *drv = dev_get_drvdata(dev); int ret; disable_irq(drv->sdw->irq); - ret = pm_runtime_force_suspend(dev); + ret = pm_runtime_force_suspend(drv->dev); if (ret) { - dev_err(dev, "failed to force suspend: %d\n", ret); + dev_err(drv->dev, "failed to force suspend: %d\n", ret); return ret; } return 0; } +EXPORT_SYMBOL_NS_GPL(sdca_class_system_suspend, "SND_SOC_SDCA_CLASS"); -static int class_resume(struct device *dev) +/** + * sdca_class_system_resume - SDCA class system resume helper + * @drv: caller-owned sdca_class_drv. + */ +int sdca_class_system_resume(struct sdca_class_drv *drv) { - struct sdca_class_drv *drv = dev_get_drvdata(dev); int ret; - ret = pm_runtime_force_resume(dev); + ret = pm_runtime_force_resume(drv->dev); if (ret) { - dev_err(dev, "failed to force resume: %d\n", ret); + dev_err(drv->dev, "failed to force resume: %d\n", ret); return ret; } @@ -230,11 +241,14 @@ static int class_resume(struct device *dev) return 0; } +EXPORT_SYMBOL_NS_GPL(sdca_class_system_resume, "SND_SOC_SDCA_CLASS"); -static int class_runtime_suspend(struct device *dev) +/** + * sdca_class_runtime_suspend - SDCA class runtime suspend helper + * @drv: caller-owned sdca_class_drv. + */ +int sdca_class_runtime_suspend(struct sdca_class_drv *drv) { - struct sdca_class_drv *drv = dev_get_drvdata(dev); - /* * Whilst the driver doesn't power the chip down here, going into runtime * suspend lets the SoundWire bus power down, which means the driver @@ -244,10 +258,14 @@ static int class_runtime_suspend(struct device *dev) return 0; } +EXPORT_SYMBOL_NS_GPL(sdca_class_runtime_suspend, "SND_SOC_SDCA_CLASS"); -static int class_runtime_resume(struct device *dev) +/** + * sdca_class_runtime_resume - SDCA class runtime resume helper + * @drv: caller-owned sdca_class_drv. + */ +int sdca_class_runtime_resume(struct sdca_class_drv *drv) { - struct sdca_class_drv *drv = dev_get_drvdata(dev); int ret; ret = sdw_slave_wait_for_init(drv->sdw, CLASS_SDW_ATTACH_TIMEOUT_MS); @@ -270,10 +288,37 @@ static int class_runtime_resume(struct device *dev) return ret; } +EXPORT_SYMBOL_NS_GPL(sdca_class_runtime_resume, "SND_SOC_SDCA_CLASS"); + +/* + * Convenience dev_pm_ops used by the built-in class_sdw_driver, which + * stashes its sdca_class_drv in drvdata directly. Codec drivers that + * embed sdca_class_drv in their own priv compose their own dev_pm_ops + * using the sdca_class_*_suspend/resume helpers above. + */ +static int class_pm_system_suspend(struct device *dev) +{ + return sdca_class_system_suspend(dev_get_drvdata(dev)); +} + +static int class_pm_system_resume(struct device *dev) +{ + return sdca_class_system_resume(dev_get_drvdata(dev)); +} + +static int class_pm_runtime_suspend(struct device *dev) +{ + return sdca_class_runtime_suspend(dev_get_drvdata(dev)); +} + +static int class_pm_runtime_resume(struct device *dev) +{ + return sdca_class_runtime_resume(dev_get_drvdata(dev)); +} -static const struct dev_pm_ops class_pm_ops = { - SYSTEM_SLEEP_PM_OPS(class_suspend, class_resume) - RUNTIME_PM_OPS(class_runtime_suspend, class_runtime_resume, NULL) +static const struct dev_pm_ops sdca_class_pm_ops = { + SYSTEM_SLEEP_PM_OPS(class_pm_system_suspend, class_pm_system_resume) + RUNTIME_PM_OPS(class_pm_runtime_suspend, class_pm_runtime_resume, NULL) }; static const struct sdw_device_id class_sdw_id[] = { @@ -287,7 +332,7 @@ MODULE_DEVICE_TABLE(sdw, class_sdw_id); static struct sdw_driver class_sdw_driver = { .driver = { .name = "sdca_class", - .pm = pm_ptr(&class_pm_ops), + .pm = pm_ptr(&sdca_class_pm_ops), }, .probe = class_sdw_probe, diff --git a/sound/soc/sdca/sdca_class_function.c b/sound/soc/sdca/sdca_class_function.c index 610931ae5531f..616d5f9736716 100644 --- a/sound/soc/sdca/sdca_class_function.c +++ b/sound/soc/sdca/sdca_class_function.c @@ -26,7 +26,7 @@ #include #include #include -#include "sdca_class.h" +#include #include "sdca_function_device.h" struct class_function_drv { -- 2.53.0