Skip to content

Commit b7a253d

Browse files
committed
ASoC: Intel: avs: Replace devm_kzalloc() with
Merge series from Ethan Carter Edwards <ethan@ethancedwards.com>: Open coded arithmetic in allocator arguments is discouraged. Helper functions like kcalloc or, in this case, devm_kcalloc are preferred. Not only for readability purposes but safety purposes. The changes move `devm_kzalloc(dev, sizeof(var) * n, GFP_KERNEL)` to the helper function `devm_kcalloc(dev, n, sizeof(var), GFP_KERNEL)`. Here is a series of four patches within the Intel/avs drivers that make these changes. They are all compile tested only but should have no effect on runtime behaviour. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments Link: KSPP#162
2 parents 1822c44 + 3602571 commit b7a253d

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

sound/soc/intel/avs/boards/max98373.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
111111
dl->name = devm_kasprintf(dev, GFP_KERNEL,
112112
AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot));
113113
dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL);
114-
dl->codecs = devm_kzalloc(dev, sizeof(*dl->codecs) * 2, GFP_KERNEL);
114+
dl->codecs = devm_kcalloc(dev, 2, sizeof(*dl->codecs), GFP_KERNEL);
115115
if (!dl->name || !dl->cpus || !dl->codecs)
116116
return -ENOMEM;
117117

sound/soc/intel/avs/boards/max98927.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
108108
dl->name = devm_kasprintf(dev, GFP_KERNEL,
109109
AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot));
110110
dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL);
111-
dl->codecs = devm_kzalloc(dev, sizeof(*dl->codecs) * 2, GFP_KERNEL);
111+
dl->codecs = devm_kcalloc(dev, 2, sizeof(*dl->codecs), GFP_KERNEL);
112112
if (!dl->name || !dl->cpus || !dl->codecs)
113113
return -ENOMEM;
114114

sound/soc/intel/avs/boards/ssm4567.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
9797
dl->name = devm_kasprintf(dev, GFP_KERNEL,
9898
AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot));
9999
dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL);
100-
dl->codecs = devm_kzalloc(dev, sizeof(*dl->codecs) * 2, GFP_KERNEL);
100+
dl->codecs = devm_kcalloc(dev, 2, sizeof(*dl->codecs), GFP_KERNEL);
101101
if (!dl->name || !dl->cpus || !dl->codecs)
102102
return -ENOMEM;
103103

sound/soc/intel/avs/pcm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,7 @@ int avs_i2s_platform_register(struct avs_dev *adev, const char *name, unsigned l
13801380
for_each_set_bit(i, &port_mask, ssp_count)
13811381
cpu_count += hweight_long(tdms[i]);
13821382

1383-
cpus = devm_kzalloc(adev->dev, sizeof(*cpus) * cpu_count, GFP_KERNEL);
1383+
cpus = devm_kcalloc(adev->dev, cpu_count, sizeof(*cpus), GFP_KERNEL);
13841384
if (!cpus)
13851385
return -ENOMEM;
13861386

0 commit comments

Comments
 (0)