From 4f9df964ba4507958df39612103d0eb318b1e3e5 Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Wed, 1 Jul 2026 20:30:06 +0100 Subject: [PATCH] soundwire: qcom: Allocate sruntime array dynamically Instead of sizing sruntime[] with a hardcoded SWRM_MAX_DAIS constant, allocate it at probe time once the actual port count is known from hardware. This removes the need to keep the constant in sync with dt-binding limits and naturally supports any future port count increase. Reported-by: sashiko-bot Assisted-by: Claude Sonnet 4.6 Signed-off-by: Srinivas Kandagatla Link: https://patch.msgid.link/20260701193006.4113-3-srinivas.kandagatla@oss.qualcomm.com Signed-off-by: Vinod Koul --- drivers/soundwire/qcom.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index b288218f64b4..603f228f46b5 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -134,7 +134,6 @@ #define TIMEOUT_MS 100 #define QCOM_SWRM_MAX_RD_LEN 0x1 #define DEFAULT_CLK_FREQ 9600000 -#define SWRM_MAX_DAIS 0xF #define SWR_INVALID_PARAM 0xFF #define SWR_HSTOP_MAX_VAL 0xF #define SWR_HSTART_MIN_VAL 0x0 @@ -215,7 +214,7 @@ struct qcom_swrm_ctrl { u8 wcmd_id; /* Port numbers are 1 - 14 */ struct qcom_swrm_port_config *pconfig; - struct sdw_stream_runtime *sruntime[SWRM_MAX_DAIS]; + struct sdw_stream_runtime **sruntime; enum sdw_slave_status status[SDW_MAX_DEVICES + 1]; int (*reg_read)(struct qcom_swrm_ctrl *ctrl, int reg, u32 *val); int (*reg_write)(struct qcom_swrm_ctrl *ctrl, int reg, int val); @@ -1384,6 +1383,10 @@ static int qcom_swrm_register_dais(struct qcom_swrm_ctrl *ctrl) struct device *dev = ctrl->dev; int i; + ctrl->sruntime = devm_kcalloc(dev, num_dais, sizeof(*ctrl->sruntime), GFP_KERNEL); + if (!ctrl->sruntime) + return -ENOMEM; + /* PDM dais are only tested for now */ dais = devm_kcalloc(dev, num_dais, sizeof(*dais), GFP_KERNEL); if (!dais)