From nobody Mon May 25 04:34:00 2026 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB3561DA0E1 for ; Tue, 19 May 2026 01:04:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779152673; cv=none; b=HcliR39+VZaSrgYGDsihg+h/4bUicz5gxeEI6uXwiJsSIHaXeuvDMuiGaSFYE2OAmtTvkEgLGrWEHBsqSMj4yJNHoxuIi5C9DJAuPOkRl3eeUvxAjj809xNP3qPt1HeAhx5aR6hv+/wBlSiq9pnj76r4jBraLCkOfZ+3bLnh4h8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779152673; c=relaxed/simple; bh=I1lBZvuskjd9OZNrTxPW+xdzEXdgqIJibv5i+eVYhI0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PoB7llQR4tXBS9b5OODGNf42uhVC0QA060pY4SdA0PE02L7z+y7FQ4hKd2leX672rozZiSW7vvf/EJtM7m3M93CqgNbhRpAmerrLv4q03WhgRCYN4dLEZkhtkK/07Hmc/7e0j5BBkyPdi09vD2vWaXpCzrxEnLDNaAoE+yLLtz4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ESgWBXer; arc=none smtp.client-ip=209.85.216.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ESgWBXer" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-366375c4076so985679a91.3 for ; Mon, 18 May 2026 18:04:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779152671; x=1779757471; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=oXHtsnBY1AjSAv+HlUFo/FYDsuTcP65qwKVLI9BrKvM=; b=ESgWBXeroS1x9UHTZMW4VKwShu8I12v5ynXnHpg3WLAkb+zRNLmW7HgGBsX7ieNbPt /ceLkJtT07xXDuQ5XprSHO2QRI7wNfAkpqyYZS4y2rCoXSOlzcbGu5+1M7dryXOp6uoa xZvyIFzGUiqOkgxaPwjWOFjArCZ8etICtHO+7U+xYUiRMN9FkVFpQvwdJGFQoPgAQbn2 x1EF/Te3Pb5mz1TMcJfbNwUqyMRpZCeCQn3TDXk8+/POsEyLZeYW74gPeoF+90ccOF25 NPcSPvi1oMNopnx+++p8OQY5WH6ABZZ/gjTURHBYeH8UgnTGP/WyDNFM9TM5A512PnTM vNPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779152671; x=1779757471; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=oXHtsnBY1AjSAv+HlUFo/FYDsuTcP65qwKVLI9BrKvM=; b=Hdce9THo+l31/0ecut5eR0PbRQti0r411fVQMdjntF3QJ6MFvlOLsodaxg3gh/Dgh6 u9dCv5s1PcWn/hSneGVs+Uh/inXPWWuap2cyiZboHo4O+6PLHB7jzJuI8QwT9gSTmv5O GtiIiwwZasiNfdSl9hHSRzEG9/sSGU4JKc2M3JHPcINvJJWqvzkkc87LQzfw9hCME88e p5JE0zUbHDwWLmahWHzi/wkJaNqQiygQ6h4bk0ZeuEEso1+/Kswmh/npXiZs9i/wvHFy CAWETk8qpIgsPLKVyo6ubsyr+lhUksVpo5PT5szD37AolO1ujub5Io/SzDsCyuUqMKzD mxUA== X-Forwarded-Encrypted: i=1; AFNElJ902cCG1CNrVV2v7m86tevMaOMEpKWHLNUO/6DEF18g2+BwBexC9kSN4Y21N5c4jHHiJZqCfFtU79IL2eE=@vger.kernel.org X-Gm-Message-State: AOJu0YzJ/+o8Ligrkuls79R9LMyuQeUZB2/StRaHK+oHhGC11anFsuUy Riowrhjiz+cx2BJNOkHOpGa2oRFIxzcwQ7MaZ6V8WlXVm7He2LV6far/ X-Gm-Gg: Acq92OFWIfAJydPjCfzv/8R+ZUPvQM/WPaPIHllYkd3d3mChBSykcKK0p5k1beRiPjC 2CK7g/S5VT+AfnDyxln3rChgqWjyCAig6Ql2vDbadc8Adxk1sbizJfHMyvH3lCuz4HMI8E1oqWG 7MnLmFQ8Jb7Hl+/R8OlixYlBwnS7whFmhPD/SpwjFv6mjjI98yCcGMuF/OBkb+2utdsJ7AbjnxA xTOV5SD8112hR3FKyqvskkpguyquWtefMR/1cySdcyLaDhbT3r4nDKXAfVZEv52KnoDAKt2/7F8 zG8uB0AM4HsMmYQ/PlY9GxPf/DYXHDt6CpSMz7s+t2v+OjCxvgbd/2qW3CoxihZNGTmZ5hojogS 4uoetr96Ss/MebrRq64mqXHBvoxjXojApk7J/PaL1Df/9aTMkKUX45q993uXSAfYo9UTK0I0fMl QSFKYlFj5e6fIbjdtKurGy6AsEItJqHzfDR2WDvPe48Nif77Ksir6YYSLumWpm2HaSaBopW4cRj sSDmB/Ku+qkj07gXfZf3in4MmnQSt8iORDzhhGH3Hoijg== X-Received: by 2002:a17:90b:4a:b0:35d:a0b7:9608 with SMTP id 98e67ed59e1d1-369519feb17mr16805439a91.7.1779152671266; Mon, 18 May 2026 18:04:31 -0700 (PDT) Received: from ryzen ([2601:644:8000:5b5d:7285:c2ff:fe45:8a32]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36951278e7fsm12177196a91.8.2026.05.18.18.04.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2026 18:04:30 -0700 (PDT) From: Rosen Penev To: linux-sound@vger.kernel.org Cc: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Matthias Brugger , AngeloGioacchino Del Regno , linux-kernel@vger.kernel.org (open list:ARM/Mediatek SoC support), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Mediatek SoC support), linux-mediatek@lists.infradead.org (moderated list:ARM/Mediatek SoC support) Subject: [PATCH] ASoC: mediatek: mt2701: allocate i2s_path with priv Date: Mon, 18 May 2026 18:04:13 -0700 Message-ID: <20260519010413.629214-1-rosenp@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use a flexible array member to combine allocations. Clean up surrounding code and allocate based on afe_priv and not platform_priv which is a void pointer. struct_size needs a properly typed pointer to work. Signed-off-by: Rosen Penev --- sound/soc/mediatek/mt2701/mt2701-afe-common.h | 2 +- sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 21 ++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-common.h b/sound/soc/medi= atek/mt2701/mt2701-afe-common.h index 8b6f3a200048..c9477bc24ee9 100644 --- a/sound/soc/mediatek/mt2701/mt2701-afe-common.h +++ b/sound/soc/mediatek/mt2701/mt2701-afe-common.h @@ -89,7 +89,6 @@ struct mt2701_soc_variants { }; =20 struct mt2701_afe_private { - struct mt2701_i2s_path *i2s_path; struct clk *base_ck[MT2701_BASE_CLK_NUM]; struct clk *mrgif_ck; struct clk *hadds2pll_ck; @@ -99,6 +98,7 @@ struct mt2701_afe_private { bool mrg_enable[MTK_STREAM_NUM]; =20 const struct mt2701_soc_variants *soc; + struct mt2701_i2s_path i2s_path[]; }; =20 #endif diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediate= k/mt2701/mt2701-afe-pcm.c index bb459faa6e05..d56b498e8c0c 100644 --- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c +++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c @@ -1593,6 +1593,7 @@ static int mt2701_afe_runtime_resume(struct device *d= ev) =20 static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev) { + const struct mt2701_soc_variants *soc; struct mtk_base_afe *afe; struct mt2701_afe_private *afe_priv; struct device *dev; @@ -1602,23 +1603,19 @@ static int mt2701_afe_pcm_dev_probe(struct platform= _device *pdev) if (!afe) return -ENOMEM; =20 - afe->platform_priv =3D devm_kzalloc(&pdev->dev, sizeof(*afe_priv), - GFP_KERNEL); - if (!afe->platform_priv) + soc =3D of_device_get_match_data(&pdev->dev); + afe_priv =3D devm_kzalloc(&pdev->dev, + struct_size(afe_priv, i2s_path, soc->i2s_num), + GFP_KERNEL); + if (!afe_priv) return -ENOMEM; =20 - afe_priv =3D afe->platform_priv; - afe_priv->soc =3D of_device_get_match_data(&pdev->dev); + afe_priv->soc =3D soc; + + afe->platform_priv =3D afe_priv; afe->dev =3D &pdev->dev; dev =3D afe->dev; =20 - afe_priv->i2s_path =3D devm_kcalloc(dev, - afe_priv->soc->i2s_num, - sizeof(struct mt2701_i2s_path), - GFP_KERNEL); - if (!afe_priv->i2s_path) - return -ENOMEM; - irq_id =3D platform_get_irq_byname(pdev, "asys"); if (irq_id < 0) return irq_id; --=20 2.54.0