mirror of
https://github.com/torvalds/linux.git
synced 2026-07-29 10:41:49 +02:00
ASoC: mediatek: mt2701: allocate i2s_path with priv
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 <rosenp@gmail.com> Link: https://patch.msgid.link/20260519010413.629214-1-rosenp@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
2fd19f0d58
commit
344a4c96b2
|
|
@ -89,7 +89,6 @@ struct mt2701_soc_variants {
|
|||
};
|
||||
|
||||
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];
|
||||
|
||||
const struct mt2701_soc_variants *soc;
|
||||
struct mt2701_i2s_path i2s_path[];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1593,6 +1593,7 @@ static int mt2701_afe_runtime_resume(struct device *dev)
|
|||
|
||||
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;
|
||||
|
||||
afe->platform_priv = devm_kzalloc(&pdev->dev, sizeof(*afe_priv),
|
||||
GFP_KERNEL);
|
||||
if (!afe->platform_priv)
|
||||
soc = of_device_get_match_data(&pdev->dev);
|
||||
afe_priv = devm_kzalloc(&pdev->dev,
|
||||
struct_size(afe_priv, i2s_path, soc->i2s_num),
|
||||
GFP_KERNEL);
|
||||
if (!afe_priv)
|
||||
return -ENOMEM;
|
||||
|
||||
afe_priv = afe->platform_priv;
|
||||
afe_priv->soc = of_device_get_match_data(&pdev->dev);
|
||||
afe_priv->soc = soc;
|
||||
|
||||
afe->platform_priv = afe_priv;
|
||||
afe->dev = &pdev->dev;
|
||||
dev = afe->dev;
|
||||
|
||||
afe_priv->i2s_path = devm_kcalloc(dev,
|
||||
afe_priv->soc->i2s_num,
|
||||
sizeof(struct mt2701_i2s_path),
|
||||
GFP_KERNEL);
|
||||
if (!afe_priv->i2s_path)
|
||||
return -ENOMEM;
|
||||
|
||||
irq_id = platform_get_irq_byname(pdev, "asys");
|
||||
if (irq_id < 0)
|
||||
return irq_id;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user