[ALSA] Conversions from kmalloc+memset to k(z|c)alloc

sound: Conversions from kmalloc+memset to k(c|z)alloc.

Signed-off-by: Panagiotis Issaris <takis@issaris.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>

authored by Panagiotis Issaris and committed by Jaroslav Kysela 59feddb2 fb6a0d63

+15 -29
+1 -2
sound/core/oss/mixer_oss.c
··· 988 if (ptr->index == 0 && (kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0)) != NULL) { 989 struct snd_ctl_elem_info *uinfo; 990 991 - uinfo = kmalloc(sizeof(*uinfo), GFP_KERNEL); 992 if (! uinfo) { 993 up_read(&mixer->card->controls_rwsem); 994 return -ENOMEM; 995 } 996 997 - memset(uinfo, 0, sizeof(*uinfo)); 998 if (kctl->info(kctl, uinfo)) { 999 up_read(&mixer->card->controls_rwsem); 1000 return 0;
··· 988 if (ptr->index == 0 && (kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0)) != NULL) { 989 struct snd_ctl_elem_info *uinfo; 990 991 + uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL); 992 if (! uinfo) { 993 up_read(&mixer->card->controls_rwsem); 994 return -ENOMEM; 995 } 996 997 if (kctl->info(kctl, uinfo)) { 998 up_read(&mixer->card->controls_rwsem); 999 return 0;
+1 -2
sound/core/seq/seq_device.c
··· 372 { 373 struct ops_list *ops; 374 375 - ops = kmalloc(sizeof(*ops), GFP_KERNEL); 376 if (ops == NULL) 377 return ops; 378 - memset(ops, 0, sizeof(*ops)); 379 380 /* set up driver entry */ 381 strlcpy(ops->id, id, sizeof(ops->id));
··· 372 { 373 struct ops_list *ops; 374 375 + ops = kzalloc(sizeof(*ops), GFP_KERNEL); 376 if (ops == NULL) 377 return ops; 378 379 /* set up driver entry */ 380 strlcpy(ops->id, id, sizeof(ops->id));
+3 -6
sound/core/sgbuf.c
··· 68 69 dmab->area = NULL; 70 dmab->addr = 0; 71 - dmab->private_data = sgbuf = kmalloc(sizeof(*sgbuf), GFP_KERNEL); 72 if (! sgbuf) 73 return NULL; 74 - memset(sgbuf, 0, sizeof(*sgbuf)); 75 sgbuf->dev = device; 76 pages = snd_sgbuf_aligned_pages(size); 77 sgbuf->tblsize = sgbuf_align_table(pages); 78 - sgbuf->table = kmalloc(sizeof(*sgbuf->table) * sgbuf->tblsize, GFP_KERNEL); 79 if (! sgbuf->table) 80 goto _failed; 81 - memset(sgbuf->table, 0, sizeof(*sgbuf->table) * sgbuf->tblsize); 82 - sgbuf->page_table = kmalloc(sizeof(*sgbuf->page_table) * sgbuf->tblsize, GFP_KERNEL); 83 if (! sgbuf->page_table) 84 goto _failed; 85 - memset(sgbuf->page_table, 0, sizeof(*sgbuf->page_table) * sgbuf->tblsize); 86 87 /* allocate each page */ 88 for (i = 0; i < pages; i++) {
··· 68 69 dmab->area = NULL; 70 dmab->addr = 0; 71 + dmab->private_data = sgbuf = kzalloc(sizeof(*sgbuf), GFP_KERNEL); 72 if (! sgbuf) 73 return NULL; 74 sgbuf->dev = device; 75 pages = snd_sgbuf_aligned_pages(size); 76 sgbuf->tblsize = sgbuf_align_table(pages); 77 + sgbuf->table = kcalloc(sgbuf->tblsize, sizeof(*sgbuf->table), GFP_KERNEL); 78 if (! sgbuf->table) 79 goto _failed; 80 + sgbuf->page_table = kcalloc(sgbuf->tblsize, sizeof(*sgbuf->page_table), GFP_KERNEL); 81 if (! sgbuf->page_table) 82 goto _failed; 83 84 /* allocate each page */ 85 for (i = 0; i < pages; i++) {
+2 -5
sound/drivers/vx/vx_pcm.c
··· 1252 chip->audio_info = rmh.Stat[1]; 1253 1254 /* allocate pipes */ 1255 - chip->playback_pipes = kmalloc(sizeof(struct vx_pipe *) * chip->audio_outs, GFP_KERNEL); 1256 if (!chip->playback_pipes) 1257 return -ENOMEM; 1258 - chip->capture_pipes = kmalloc(sizeof(struct vx_pipe *) * chip->audio_ins, GFP_KERNEL); 1259 if (!chip->capture_pipes) { 1260 kfree(chip->playback_pipes); 1261 return -ENOMEM; 1262 } 1263 - 1264 - memset(chip->playback_pipes, 0, sizeof(struct vx_pipe *) * chip->audio_outs); 1265 - memset(chip->capture_pipes, 0, sizeof(struct vx_pipe *) * chip->audio_ins); 1266 1267 preferred = chip->ibl.size; 1268 chip->ibl.size = 0;
··· 1252 chip->audio_info = rmh.Stat[1]; 1253 1254 /* allocate pipes */ 1255 + chip->playback_pipes = kcalloc(chip->audio_outs, sizeof(struct vx_pipe *), GFP_KERNEL); 1256 if (!chip->playback_pipes) 1257 return -ENOMEM; 1258 + chip->capture_pipes = kcalloc(chip->audio_ins, sizeof(struct vx_pipe *), GFP_KERNEL); 1259 if (!chip->capture_pipes) { 1260 kfree(chip->playback_pipes); 1261 return -ENOMEM; 1262 } 1263 1264 preferred = chip->ibl.size; 1265 chip->ibl.size = 0;
+2 -2
sound/pci/echoaudio/echoaudio.c
··· 236 chip = snd_pcm_substream_chip(substream); 237 runtime = substream->runtime; 238 239 - if (!(pipe = kmalloc(sizeof(struct audiopipe), GFP_KERNEL))) 240 return -ENOMEM; 241 - memset(pipe, 0, sizeof(struct audiopipe)); 242 pipe->index = -1; /* Not configured yet */ 243 244 /* Set up hw capabilities and contraints */
··· 236 chip = snd_pcm_substream_chip(substream); 237 runtime = substream->runtime; 238 239 + pipe = kzalloc(sizeof(struct audiopipe), GFP_KERNEL); 240 + if (!pipe) 241 return -ENOMEM; 242 pipe->index = -1; /* Not configured yet */ 243 244 /* Set up hw capabilities and contraints */
+1 -2
sound/ppc/awacs.c
··· 801 chip->revision = (in_le32(&chip->awacs->codec_stat) >> 12) & 0xf; 802 #ifdef PMAC_AMP_AVAIL 803 if (chip->revision == 3 && chip->has_iic && CHECK_CUDA_AMP()) { 804 - struct awacs_amp *amp = kmalloc(sizeof(*amp), GFP_KERNEL); 805 if (! amp) 806 return -ENOMEM; 807 chip->mixer_data = amp; 808 - memset(amp, 0, sizeof(*amp)); 809 chip->mixer_free = awacs_amp_free; 810 awacs_amp_set_vol(amp, 0, 63, 63, 0); /* mute and zero vol */ 811 awacs_amp_set_vol(amp, 1, 63, 63, 0);
··· 801 chip->revision = (in_le32(&chip->awacs->codec_stat) >> 12) & 0xf; 802 #ifdef PMAC_AMP_AVAIL 803 if (chip->revision == 3 && chip->has_iic && CHECK_CUDA_AMP()) { 804 + struct awacs_amp *amp = kzalloc(sizeof(*amp), GFP_KERNEL); 805 if (! amp) 806 return -ENOMEM; 807 chip->mixer_data = amp; 808 chip->mixer_free = awacs_amp_free; 809 awacs_amp_set_vol(amp, 0, 63, 63, 0); /* mute and zero vol */ 810 awacs_amp_set_vol(amp, 1, 63, 63, 0);
+1 -2
sound/ppc/daca.c
··· 258 request_module("i2c-powermac"); 259 #endif /* CONFIG_KMOD */ 260 261 - mix = kmalloc(sizeof(*mix), GFP_KERNEL); 262 if (! mix) 263 return -ENOMEM; 264 - memset(mix, 0, sizeof(*mix)); 265 chip->mixer_data = mix; 266 chip->mixer_free = daca_cleanup; 267 mix->amp_on = 1; /* default on */
··· 258 request_module("i2c-powermac"); 259 #endif /* CONFIG_KMOD */ 260 261 + mix = kzalloc(sizeof(*mix), GFP_KERNEL); 262 if (! mix) 263 return -ENOMEM; 264 chip->mixer_data = mix; 265 chip->mixer_free = daca_cleanup; 266 mix->amp_on = 1; /* default on */
+1 -2
sound/ppc/keywest.c
··· 64 if (strncmp(i2c_device_name(adapter), "mac-io", 6)) 65 return 0; /* ignored */ 66 67 - new_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 68 if (! new_client) 69 return -ENOMEM; 70 71 - memset(new_client, 0, sizeof(*new_client)); 72 new_client->addr = keywest_ctx->addr; 73 i2c_set_clientdata(new_client, keywest_ctx); 74 new_client->adapter = adapter;
··· 64 if (strncmp(i2c_device_name(adapter), "mac-io", 6)) 65 return 0; /* ignored */ 66 67 + new_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 68 if (! new_client) 69 return -ENOMEM; 70 71 new_client->addr = keywest_ctx->addr; 72 i2c_set_clientdata(new_client, keywest_ctx); 73 new_client->adapter = adapter;
+1 -2
sound/ppc/tumbler.c
··· 1316 request_module("i2c-powermac"); 1317 #endif /* CONFIG_KMOD */ 1318 1319 - mix = kmalloc(sizeof(*mix), GFP_KERNEL); 1320 if (! mix) 1321 return -ENOMEM; 1322 - memset(mix, 0, sizeof(*mix)); 1323 mix->headphone_irq = -1; 1324 1325 chip->mixer_data = mix;
··· 1316 request_module("i2c-powermac"); 1317 #endif /* CONFIG_KMOD */ 1318 1319 + mix = kzalloc(sizeof(*mix), GFP_KERNEL); 1320 if (! mix) 1321 return -ENOMEM; 1322 mix->headphone_irq = -1; 1323 1324 chip->mixer_data = mix;
+2 -4
sound/usb/usbaudio.c
··· 2260 } 2261 2262 /* create a new pcm */ 2263 - as = kmalloc(sizeof(*as), GFP_KERNEL); 2264 if (! as) 2265 return -ENOMEM; 2266 - memset(as, 0, sizeof(*as)); 2267 as->pcm_index = chip->pcm_devs; 2268 as->chip = chip; 2269 as->fmt_type = fp->fmt_type; ··· 2632 csep = NULL; 2633 } 2634 2635 - fp = kmalloc(sizeof(*fp), GFP_KERNEL); 2636 if (! fp) { 2637 snd_printk(KERN_ERR "cannot malloc\n"); 2638 return -ENOMEM; 2639 } 2640 2641 - memset(fp, 0, sizeof(*fp)); 2642 fp->iface = iface_no; 2643 fp->altsetting = altno; 2644 fp->altset_idx = i;
··· 2260 } 2261 2262 /* create a new pcm */ 2263 + as = kzalloc(sizeof(*as), GFP_KERNEL); 2264 if (! as) 2265 return -ENOMEM; 2266 as->pcm_index = chip->pcm_devs; 2267 as->chip = chip; 2268 as->fmt_type = fp->fmt_type; ··· 2633 csep = NULL; 2634 } 2635 2636 + fp = kzalloc(sizeof(*fp), GFP_KERNEL); 2637 if (! fp) { 2638 snd_printk(KERN_ERR "cannot malloc\n"); 2639 return -ENOMEM; 2640 } 2641 2642 fp->iface = iface_no; 2643 fp->altsetting = altno; 2644 fp->altset_idx = i;