Skip to content

Commit ca2c096

Browse files
tiwaiJaroslav Kysela
authored andcommitted
[ALSA] Replace with kzalloc() - core stuff
Control Midlevel,ALSA Core,HWDEP Midlevel,PCM Midlevel,RawMidi Midlevel Timer Midlevel,ALSA<-OSS emulation Replace kcalloc(1,..) with kzalloc(). Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 8648811 commit ca2c096

14 files changed

Lines changed: 46 additions & 46 deletions

File tree

‎sound/core/control.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static int snd_ctl_open(struct inode *inode, struct file *file)
6969
err = -EFAULT;
7070
goto __error2;
7171
}
72-
ctl = kcalloc(1, sizeof(*ctl), GFP_KERNEL);
72+
ctl = kzalloc(sizeof(*ctl), GFP_KERNEL);
7373
if (ctl == NULL) {
7474
err = -ENOMEM;
7575
goto __error;
@@ -162,7 +162,7 @@ void snd_ctl_notify(snd_card_t *card, unsigned int mask, snd_ctl_elem_id_t *id)
162162
goto _found;
163163
}
164164
}
165-
ev = kcalloc(1, sizeof(*ev), GFP_ATOMIC);
165+
ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
166166
if (ev) {
167167
ev->id = *id;
168168
ev->mask = mask;
@@ -195,7 +195,7 @@ snd_kcontrol_t *snd_ctl_new(snd_kcontrol_t * control, unsigned int access)
195195

196196
snd_runtime_check(control != NULL, return NULL);
197197
snd_runtime_check(control->count > 0, return NULL);
198-
kctl = kcalloc(1, sizeof(*kctl) + sizeof(snd_kcontrol_volatile_t) * control->count, GFP_KERNEL);
198+
kctl = kzalloc(sizeof(*kctl) + sizeof(snd_kcontrol_volatile_t) * control->count, GFP_KERNEL);
199199
if (kctl == NULL)
200200
return NULL;
201201
*kctl = *control;
@@ -521,7 +521,7 @@ static int snd_ctl_card_info(snd_card_t * card, snd_ctl_file_t * ctl,
521521
{
522522
snd_ctl_card_info_t *info;
523523

524-
info = kcalloc(1, sizeof(*info), GFP_KERNEL);
524+
info = kzalloc(sizeof(*info), GFP_KERNEL);
525525
if (! info)
526526
return -ENOMEM;
527527
down_read(&snd_ioctl_rwsem);
@@ -929,7 +929,7 @@ static int snd_ctl_elem_add(snd_ctl_file_t *file, snd_ctl_elem_info_t *info, int
929929
return -EINVAL;
930930
}
931931
private_size *= info->count;
932-
ue = kcalloc(1, sizeof(struct user_element) + private_size, GFP_KERNEL);
932+
ue = kzalloc(sizeof(struct user_element) + private_size, GFP_KERNEL);
933933
if (ue == NULL)
934934
return -ENOMEM;
935935
ue->info = *info;
@@ -1185,7 +1185,7 @@ static int _snd_ctl_register_ioctl(snd_kctl_ioctl_func_t fcn, struct list_head *
11851185
{
11861186
snd_kctl_ioctl_t *pn;
11871187

1188-
pn = kcalloc(1, sizeof(snd_kctl_ioctl_t), GFP_KERNEL);
1188+
pn = kzalloc(sizeof(snd_kctl_ioctl_t), GFP_KERNEL);
11891189
if (pn == NULL)
11901190
return -ENOMEM;
11911191
pn->fioctl = fcn;

‎sound/core/control_compat.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static int snd_ctl_elem_info_compat(snd_ctl_file_t *ctl, struct sndrv_ctl_elem_i
9292
struct sndrv_ctl_elem_info *data;
9393
int err;
9494

95-
data = kcalloc(1, sizeof(*data), GFP_KERNEL);
95+
data = kzalloc(sizeof(*data), GFP_KERNEL);
9696
if (! data)
9797
return -ENOMEM;
9898

@@ -271,7 +271,7 @@ static int snd_ctl_elem_read_user_compat(snd_card_t *card,
271271
struct sndrv_ctl_elem_value *data;
272272
int err, type, count;
273273

274-
data = kcalloc(1, sizeof(*data), GFP_KERNEL);
274+
data = kzalloc(sizeof(*data), GFP_KERNEL);
275275
if (data == NULL)
276276
return -ENOMEM;
277277

@@ -291,7 +291,7 @@ static int snd_ctl_elem_write_user_compat(snd_ctl_file_t *file,
291291
struct sndrv_ctl_elem_value *data;
292292
int err, type, count;
293293

294-
data = kcalloc(1, sizeof(*data), GFP_KERNEL);
294+
data = kzalloc(sizeof(*data), GFP_KERNEL);
295295
if (data == NULL)
296296
return -ENOMEM;
297297

@@ -313,7 +313,7 @@ static int snd_ctl_elem_add_compat(snd_ctl_file_t *file,
313313
struct sndrv_ctl_elem_info *data;
314314
int err;
315315

316-
data = kcalloc(1, sizeof(*data), GFP_KERNEL);
316+
data = kzalloc(sizeof(*data), GFP_KERNEL);
317317
if (! data)
318318
return -ENOMEM;
319319

‎sound/core/device.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ int snd_device_new(snd_card_t *card, snd_device_type_t type,
4949
snd_assert(card != NULL, return -ENXIO);
5050
snd_assert(device_data != NULL, return -ENXIO);
5151
snd_assert(ops != NULL, return -ENXIO);
52-
dev = kcalloc(1, sizeof(*dev), GFP_KERNEL);
52+
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
5353
if (dev == NULL)
5454
return -ENOMEM;
5555
dev->card = card;

‎sound/core/hwdep.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ int snd_hwdep_new(snd_card_t * card, char *id, int device, snd_hwdep_t ** rhwdep
359359
snd_assert(rhwdep != NULL, return -EINVAL);
360360
*rhwdep = NULL;
361361
snd_assert(card != NULL, return -ENXIO);
362-
hwdep = kcalloc(1, sizeof(*hwdep), GFP_KERNEL);
362+
hwdep = kzalloc(sizeof(*hwdep), GFP_KERNEL);
363363
if (hwdep == NULL)
364364
return -ENOMEM;
365365
hwdep->card = card;

‎sound/core/info.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file)
295295
goto __error;
296296
}
297297
}
298-
data = kcalloc(1, sizeof(*data), GFP_KERNEL);
298+
data = kzalloc(sizeof(*data), GFP_KERNEL);
299299
if (data == NULL) {
300300
err = -ENOMEM;
301301
goto __error;
@@ -304,7 +304,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file)
304304
switch (entry->content) {
305305
case SNDRV_INFO_CONTENT_TEXT:
306306
if (mode == O_RDONLY || mode == O_RDWR) {
307-
buffer = kcalloc(1, sizeof(*buffer), GFP_KERNEL);
307+
buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
308308
if (buffer == NULL) {
309309
kfree(data);
310310
err = -ENOMEM;
@@ -323,7 +323,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file)
323323
data->rbuffer = buffer;
324324
}
325325
if (mode == O_WRONLY || mode == O_RDWR) {
326-
buffer = kcalloc(1, sizeof(*buffer), GFP_KERNEL);
326+
buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
327327
if (buffer == NULL) {
328328
if (mode == O_RDWR) {
329329
vfree(data->rbuffer->buffer);
@@ -752,7 +752,7 @@ char *snd_info_get_str(char *dest, char *src, int len)
752752
static snd_info_entry_t *snd_info_create_entry(const char *name)
753753
{
754754
snd_info_entry_t *entry;
755-
entry = kcalloc(1, sizeof(*entry), GFP_KERNEL);
755+
entry = kzalloc(sizeof(*entry), GFP_KERNEL);
756756
if (entry == NULL)
757757
return NULL;
758758
entry->name = kstrdup(name, GFP_KERNEL);

‎sound/core/init.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ snd_card_t *snd_card_new(int idx, const char *xid,
7272

7373
if (extra_size < 0)
7474
extra_size = 0;
75-
card = kcalloc(1, sizeof(*card) + extra_size, GFP_KERNEL);
75+
card = kzalloc(sizeof(*card) + extra_size, GFP_KERNEL);
7676
if (card == NULL)
7777
return NULL;
7878
if (xid) {
@@ -702,7 +702,7 @@ static int snd_generic_device_register(snd_card_t *card)
702702
if (card->generic_dev)
703703
return 0; /* already registered */
704704

705-
dev = kcalloc(1, sizeof(*dev), GFP_KERNEL);
705+
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
706706
if (! dev) {
707707
snd_printk(KERN_ERR "can't allocate generic_device\n");
708708
return -ENOMEM;

‎sound/core/oss/mixer_oss.c‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static int snd_mixer_oss_open(struct inode *inode, struct file *file)
5353
err = snd_card_file_add(card, file);
5454
if (err < 0)
5555
return err;
56-
fmixer = kcalloc(1, sizeof(*fmixer), GFP_KERNEL);
56+
fmixer = kzalloc(sizeof(*fmixer), GFP_KERNEL);
5757
if (fmixer == NULL) {
5858
snd_card_file_remove(card, file);
5959
return -ENOMEM;
@@ -517,8 +517,8 @@ static void snd_mixer_oss_get_volume1_vol(snd_mixer_oss_file_t *fmixer,
517517
up_read(&card->controls_rwsem);
518518
return;
519519
}
520-
uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL);
521-
uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL);
520+
uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
521+
uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
522522
if (uinfo == NULL || uctl == NULL)
523523
goto __unalloc;
524524
snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc);
@@ -551,8 +551,8 @@ static void snd_mixer_oss_get_volume1_sw(snd_mixer_oss_file_t *fmixer,
551551
up_read(&card->controls_rwsem);
552552
return;
553553
}
554-
uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL);
555-
uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL);
554+
uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
555+
uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
556556
if (uinfo == NULL || uctl == NULL)
557557
goto __unalloc;
558558
snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc);
@@ -612,8 +612,8 @@ static void snd_mixer_oss_put_volume1_vol(snd_mixer_oss_file_t *fmixer,
612612
down_read(&card->controls_rwsem);
613613
if ((kctl = snd_ctl_find_numid(card, numid)) == NULL)
614614
return;
615-
uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL);
616-
uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL);
615+
uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
616+
uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
617617
if (uinfo == NULL || uctl == NULL)
618618
goto __unalloc;
619619
snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc);
@@ -649,8 +649,8 @@ static void snd_mixer_oss_put_volume1_sw(snd_mixer_oss_file_t *fmixer,
649649
up_read(&fmixer->card->controls_rwsem);
650650
return;
651651
}
652-
uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL);
653-
uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL);
652+
uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
653+
uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
654654
if (uinfo == NULL || uctl == NULL)
655655
goto __unalloc;
656656
snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc);
@@ -768,8 +768,8 @@ static int snd_mixer_oss_get_recsrc2(snd_mixer_oss_file_t *fmixer, unsigned int
768768
snd_ctl_elem_value_t *uctl;
769769
int err, idx;
770770

771-
uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL);
772-
uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL);
771+
uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
772+
uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
773773
if (uinfo == NULL || uctl == NULL) {
774774
err = -ENOMEM;
775775
goto __unlock;
@@ -813,8 +813,8 @@ static int snd_mixer_oss_put_recsrc2(snd_mixer_oss_file_t *fmixer, unsigned int
813813
int err;
814814
unsigned int idx;
815815

816-
uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL);
817-
uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL);
816+
uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
817+
uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
818818
if (uinfo == NULL || uctl == NULL) {
819819
err = -ENOMEM;
820820
goto __unlock;

‎sound/core/oss/pcm_oss.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1740,7 +1740,7 @@ static int snd_pcm_oss_open_file(struct file *file,
17401740
snd_assert(rpcm_oss_file != NULL, return -EINVAL);
17411741
*rpcm_oss_file = NULL;
17421742

1743-
pcm_oss_file = kcalloc(1, sizeof(*pcm_oss_file), GFP_KERNEL);
1743+
pcm_oss_file = kzalloc(sizeof(*pcm_oss_file), GFP_KERNEL);
17441744
if (pcm_oss_file == NULL)
17451745
return -ENOMEM;
17461746

‎sound/core/oss/pcm_plugin.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ int snd_pcm_plugin_build(snd_pcm_plug_t *plug,
171171

172172
snd_assert(plug != NULL, return -ENXIO);
173173
snd_assert(src_format != NULL && dst_format != NULL, return -ENXIO);
174-
plugin = kcalloc(1, sizeof(*plugin) + extra, GFP_KERNEL);
174+
plugin = kzalloc(sizeof(*plugin) + extra, GFP_KERNEL);
175175
if (plugin == NULL)
176176
return -ENOMEM;
177177
plugin->name = name;

‎sound/core/pcm.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ int snd_pcm_new_stream(snd_pcm_t *pcm, int stream, int substream_count)
597597
}
598598
prev = NULL;
599599
for (idx = 0, prev = NULL; idx < substream_count; idx++) {
600-
substream = kcalloc(1, sizeof(*substream), GFP_KERNEL);
600+
substream = kzalloc(sizeof(*substream), GFP_KERNEL);
601601
if (substream == NULL)
602602
return -ENOMEM;
603603
substream->pcm = pcm;
@@ -657,7 +657,7 @@ int snd_pcm_new(snd_card_t * card, char *id, int device,
657657
snd_assert(rpcm != NULL, return -EINVAL);
658658
*rpcm = NULL;
659659
snd_assert(card != NULL, return -ENXIO);
660-
pcm = kcalloc(1, sizeof(*pcm), GFP_KERNEL);
660+
pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
661661
if (pcm == NULL)
662662
return -ENOMEM;
663663
pcm->card = card;
@@ -795,7 +795,7 @@ int snd_pcm_open_substream(snd_pcm_t *pcm, int stream,
795795
if (substream == NULL)
796796
return -EAGAIN;
797797

798-
runtime = kcalloc(1, sizeof(*runtime), GFP_KERNEL);
798+
runtime = kzalloc(sizeof(*runtime), GFP_KERNEL);
799799
if (runtime == NULL)
800800
return -ENOMEM;
801801

0 commit comments

Comments
 (0)