Skip to content

Commit 3849c95

Browse files
charleskeepaxbroonie
authored andcommitted
ASoC: SDCA: Move allocation of PDE delays array
Move the allocation of the PDE delays array until after the size has been adjusted, this saves an additional division and simplifies the code slightly. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev> Link: https://patch.msgid.link/20250516131011.221310-4-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 96bd04e commit 3849c95

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

sound/soc/sdca/sdca_functions.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,12 +1105,6 @@ static int find_sdca_entity_pde(struct device *dev,
11051105
return -EINVAL;
11061106
}
11071107

1108-
/* There are 3 values per delay */
1109-
delays = devm_kcalloc(dev, num_delays / mult_delay,
1110-
sizeof(*delays), GFP_KERNEL);
1111-
if (!delays)
1112-
return -ENOMEM;
1113-
11141108
delay_list = kcalloc(num_delays, sizeof(*delay_list), GFP_KERNEL);
11151109
if (!delay_list)
11161110
return -ENOMEM;
@@ -1121,6 +1115,10 @@ static int find_sdca_entity_pde(struct device *dev,
11211115

11221116
num_delays /= mult_delay;
11231117

1118+
delays = devm_kcalloc(dev, num_delays, sizeof(*delays), GFP_KERNEL);
1119+
if (!delays)
1120+
return -ENOMEM;
1121+
11241122
for (i = 0, j = 0; i < num_delays; i++) {
11251123
delays[i].from_ps = delay_list[j++];
11261124
delays[i].to_ps = delay_list[j++];

0 commit comments

Comments
 (0)