提交 ca2c0966 编写于 作者: T Takashi Iwai 提交者: Jaroslav Kysela

[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: NTakashi Iwai <tiwai@suse.de>
上级 8648811f
......@@ -69,7 +69,7 @@ static int snd_ctl_open(struct inode *inode, struct file *file)
err = -EFAULT;
goto __error2;
}
ctl = kcalloc(1, sizeof(*ctl), GFP_KERNEL);
ctl = kzalloc(sizeof(*ctl), GFP_KERNEL);
if (ctl == NULL) {
err = -ENOMEM;
goto __error;
......@@ -162,7 +162,7 @@ void snd_ctl_notify(snd_card_t *card, unsigned int mask, snd_ctl_elem_id_t *id)
goto _found;
}
}
ev = kcalloc(1, sizeof(*ev), GFP_ATOMIC);
ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
if (ev) {
ev->id = *id;
ev->mask = mask;
......@@ -195,7 +195,7 @@ snd_kcontrol_t *snd_ctl_new(snd_kcontrol_t * control, unsigned int access)
snd_runtime_check(control != NULL, return NULL);
snd_runtime_check(control->count > 0, return NULL);
kctl = kcalloc(1, sizeof(*kctl) + sizeof(snd_kcontrol_volatile_t) * control->count, GFP_KERNEL);
kctl = kzalloc(sizeof(*kctl) + sizeof(snd_kcontrol_volatile_t) * control->count, GFP_KERNEL);
if (kctl == NULL)
return NULL;
*kctl = *control;
......@@ -521,7 +521,7 @@ static int snd_ctl_card_info(snd_card_t * card, snd_ctl_file_t * ctl,
{
snd_ctl_card_info_t *info;
info = kcalloc(1, sizeof(*info), GFP_KERNEL);
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (! info)
return -ENOMEM;
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
return -EINVAL;
}
private_size *= info->count;
ue = kcalloc(1, sizeof(struct user_element) + private_size, GFP_KERNEL);
ue = kzalloc(sizeof(struct user_element) + private_size, GFP_KERNEL);
if (ue == NULL)
return -ENOMEM;
ue->info = *info;
......@@ -1185,7 +1185,7 @@ static int _snd_ctl_register_ioctl(snd_kctl_ioctl_func_t fcn, struct list_head *
{
snd_kctl_ioctl_t *pn;
pn = kcalloc(1, sizeof(snd_kctl_ioctl_t), GFP_KERNEL);
pn = kzalloc(sizeof(snd_kctl_ioctl_t), GFP_KERNEL);
if (pn == NULL)
return -ENOMEM;
pn->fioctl = fcn;
......
......@@ -92,7 +92,7 @@ static int snd_ctl_elem_info_compat(snd_ctl_file_t *ctl, struct sndrv_ctl_elem_i
struct sndrv_ctl_elem_info *data;
int err;
data = kcalloc(1, sizeof(*data), GFP_KERNEL);
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (! data)
return -ENOMEM;
......@@ -271,7 +271,7 @@ static int snd_ctl_elem_read_user_compat(snd_card_t *card,
struct sndrv_ctl_elem_value *data;
int err, type, count;
data = kcalloc(1, sizeof(*data), GFP_KERNEL);
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (data == NULL)
return -ENOMEM;
......@@ -291,7 +291,7 @@ static int snd_ctl_elem_write_user_compat(snd_ctl_file_t *file,
struct sndrv_ctl_elem_value *data;
int err, type, count;
data = kcalloc(1, sizeof(*data), GFP_KERNEL);
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (data == NULL)
return -ENOMEM;
......@@ -313,7 +313,7 @@ static int snd_ctl_elem_add_compat(snd_ctl_file_t *file,
struct sndrv_ctl_elem_info *data;
int err;
data = kcalloc(1, sizeof(*data), GFP_KERNEL);
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (! data)
return -ENOMEM;
......
......@@ -49,7 +49,7 @@ int snd_device_new(snd_card_t *card, snd_device_type_t type,
snd_assert(card != NULL, return -ENXIO);
snd_assert(device_data != NULL, return -ENXIO);
snd_assert(ops != NULL, return -ENXIO);
dev = kcalloc(1, sizeof(*dev), GFP_KERNEL);
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (dev == NULL)
return -ENOMEM;
dev->card = card;
......
......@@ -359,7 +359,7 @@ int snd_hwdep_new(snd_card_t * card, char *id, int device, snd_hwdep_t ** rhwdep
snd_assert(rhwdep != NULL, return -EINVAL);
*rhwdep = NULL;
snd_assert(card != NULL, return -ENXIO);
hwdep = kcalloc(1, sizeof(*hwdep), GFP_KERNEL);
hwdep = kzalloc(sizeof(*hwdep), GFP_KERNEL);
if (hwdep == NULL)
return -ENOMEM;
hwdep->card = card;
......
......@@ -295,7 +295,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file)
goto __error;
}
}
data = kcalloc(1, sizeof(*data), GFP_KERNEL);
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (data == NULL) {
err = -ENOMEM;
goto __error;
......@@ -304,7 +304,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file)
switch (entry->content) {
case SNDRV_INFO_CONTENT_TEXT:
if (mode == O_RDONLY || mode == O_RDWR) {
buffer = kcalloc(1, sizeof(*buffer), GFP_KERNEL);
buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
if (buffer == NULL) {
kfree(data);
err = -ENOMEM;
......@@ -323,7 +323,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file)
data->rbuffer = buffer;
}
if (mode == O_WRONLY || mode == O_RDWR) {
buffer = kcalloc(1, sizeof(*buffer), GFP_KERNEL);
buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
if (buffer == NULL) {
if (mode == O_RDWR) {
vfree(data->rbuffer->buffer);
......@@ -752,7 +752,7 @@ char *snd_info_get_str(char *dest, char *src, int len)
static snd_info_entry_t *snd_info_create_entry(const char *name)
{
snd_info_entry_t *entry;
entry = kcalloc(1, sizeof(*entry), GFP_KERNEL);
entry = kzalloc(sizeof(*entry), GFP_KERNEL);
if (entry == NULL)
return NULL;
entry->name = kstrdup(name, GFP_KERNEL);
......
......@@ -72,7 +72,7 @@ snd_card_t *snd_card_new(int idx, const char *xid,
if (extra_size < 0)
extra_size = 0;
card = kcalloc(1, sizeof(*card) + extra_size, GFP_KERNEL);
card = kzalloc(sizeof(*card) + extra_size, GFP_KERNEL);
if (card == NULL)
return NULL;
if (xid) {
......@@ -702,7 +702,7 @@ static int snd_generic_device_register(snd_card_t *card)
if (card->generic_dev)
return 0; /* already registered */
dev = kcalloc(1, sizeof(*dev), GFP_KERNEL);
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (! dev) {
snd_printk(KERN_ERR "can't allocate generic_device\n");
return -ENOMEM;
......
......@@ -53,7 +53,7 @@ static int snd_mixer_oss_open(struct inode *inode, struct file *file)
err = snd_card_file_add(card, file);
if (err < 0)
return err;
fmixer = kcalloc(1, sizeof(*fmixer), GFP_KERNEL);
fmixer = kzalloc(sizeof(*fmixer), GFP_KERNEL);
if (fmixer == NULL) {
snd_card_file_remove(card, file);
return -ENOMEM;
......@@ -517,8 +517,8 @@ static void snd_mixer_oss_get_volume1_vol(snd_mixer_oss_file_t *fmixer,
up_read(&card->controls_rwsem);
return;
}
uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL);
uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL);
uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
if (uinfo == NULL || uctl == NULL)
goto __unalloc;
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,
up_read(&card->controls_rwsem);
return;
}
uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL);
uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL);
uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
if (uinfo == NULL || uctl == NULL)
goto __unalloc;
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,
down_read(&card->controls_rwsem);
if ((kctl = snd_ctl_find_numid(card, numid)) == NULL)
return;
uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL);
uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL);
uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
if (uinfo == NULL || uctl == NULL)
goto __unalloc;
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,
up_read(&fmixer->card->controls_rwsem);
return;
}
uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL);
uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL);
uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
if (uinfo == NULL || uctl == NULL)
goto __unalloc;
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
snd_ctl_elem_value_t *uctl;
int err, idx;
uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL);
uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL);
uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
if (uinfo == NULL || uctl == NULL) {
err = -ENOMEM;
goto __unlock;
......@@ -813,8 +813,8 @@ static int snd_mixer_oss_put_recsrc2(snd_mixer_oss_file_t *fmixer, unsigned int
int err;
unsigned int idx;
uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL);
uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL);
uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
if (uinfo == NULL || uctl == NULL) {
err = -ENOMEM;
goto __unlock;
......
......@@ -1740,7 +1740,7 @@ static int snd_pcm_oss_open_file(struct file *file,
snd_assert(rpcm_oss_file != NULL, return -EINVAL);
*rpcm_oss_file = NULL;
pcm_oss_file = kcalloc(1, sizeof(*pcm_oss_file), GFP_KERNEL);
pcm_oss_file = kzalloc(sizeof(*pcm_oss_file), GFP_KERNEL);
if (pcm_oss_file == NULL)
return -ENOMEM;
......
......@@ -171,7 +171,7 @@ int snd_pcm_plugin_build(snd_pcm_plug_t *plug,
snd_assert(plug != NULL, return -ENXIO);
snd_assert(src_format != NULL && dst_format != NULL, return -ENXIO);
plugin = kcalloc(1, sizeof(*plugin) + extra, GFP_KERNEL);
plugin = kzalloc(sizeof(*plugin) + extra, GFP_KERNEL);
if (plugin == NULL)
return -ENOMEM;
plugin->name = name;
......
......@@ -597,7 +597,7 @@ int snd_pcm_new_stream(snd_pcm_t *pcm, int stream, int substream_count)
}
prev = NULL;
for (idx = 0, prev = NULL; idx < substream_count; idx++) {
substream = kcalloc(1, sizeof(*substream), GFP_KERNEL);
substream = kzalloc(sizeof(*substream), GFP_KERNEL);
if (substream == NULL)
return -ENOMEM;
substream->pcm = pcm;
......@@ -657,7 +657,7 @@ int snd_pcm_new(snd_card_t * card, char *id, int device,
snd_assert(rpcm != NULL, return -EINVAL);
*rpcm = NULL;
snd_assert(card != NULL, return -ENXIO);
pcm = kcalloc(1, sizeof(*pcm), GFP_KERNEL);
pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
if (pcm == NULL)
return -ENOMEM;
pcm->card = card;
......@@ -795,7 +795,7 @@ int snd_pcm_open_substream(snd_pcm_t *pcm, int stream,
if (substream == NULL)
return -EAGAIN;
runtime = kcalloc(1, sizeof(*runtime), GFP_KERNEL);
runtime = kzalloc(sizeof(*runtime), GFP_KERNEL);
if (runtime == NULL)
return -ENOMEM;
......
......@@ -321,7 +321,7 @@ int snd_pcm_lib_malloc_pages(snd_pcm_substream_t *substream, size_t size)
if (substream->dma_buffer.area != NULL && substream->dma_buffer.bytes >= size) {
dmab = &substream->dma_buffer; /* use the pre-allocated buffer */
} else {
dmab = kcalloc(1, sizeof(*dmab), GFP_KERNEL);
dmab = kzalloc(sizeof(*dmab), GFP_KERNEL);
if (! dmab)
return -ENOMEM;
dmab->dev = substream->dma_buffer.dev;
......
......@@ -2001,7 +2001,7 @@ static int snd_pcm_open_file(struct file *file,
snd_assert(rpcm_file != NULL, return -EINVAL);
*rpcm_file = NULL;
pcm_file = kcalloc(1, sizeof(*pcm_file), GFP_KERNEL);
pcm_file = kzalloc(sizeof(*pcm_file), GFP_KERNEL);
if (pcm_file == NULL) {
return -ENOMEM;
}
......
......@@ -101,7 +101,7 @@ static int snd_rawmidi_runtime_create(snd_rawmidi_substream_t * substream)
{
snd_rawmidi_runtime_t *runtime;
if ((runtime = kcalloc(1, sizeof(*runtime), GFP_KERNEL)) == NULL)
if ((runtime = kzalloc(sizeof(*runtime), GFP_KERNEL)) == NULL)
return -ENOMEM;
spin_lock_init(&runtime->lock);
init_waitqueue_head(&runtime->sleep);
......@@ -1374,7 +1374,7 @@ static int snd_rawmidi_alloc_substreams(snd_rawmidi_t *rmidi,
INIT_LIST_HEAD(&stream->substreams);
for (idx = 0; idx < count; idx++) {
substream = kcalloc(1, sizeof(*substream), GFP_KERNEL);
substream = kzalloc(sizeof(*substream), GFP_KERNEL);
if (substream == NULL)
return -ENOMEM;
substream->stream = direction;
......@@ -1417,7 +1417,7 @@ int snd_rawmidi_new(snd_card_t * card, char *id, int device,
snd_assert(rrawmidi != NULL, return -EINVAL);
*rrawmidi = NULL;
snd_assert(card != NULL, return -ENXIO);
rmidi = kcalloc(1, sizeof(*rmidi), GFP_KERNEL);
rmidi = kzalloc(sizeof(*rmidi), GFP_KERNEL);
if (rmidi == NULL)
return -ENOMEM;
rmidi->card = card;
......
......@@ -98,7 +98,7 @@ static void snd_timer_reschedule(snd_timer_t * timer, unsigned long ticks_left);
static snd_timer_instance_t *snd_timer_instance_new(char *owner, snd_timer_t *timer)
{
snd_timer_instance_t *timeri;
timeri = kcalloc(1, sizeof(*timeri), GFP_KERNEL);
timeri = kzalloc(sizeof(*timeri), GFP_KERNEL);
if (timeri == NULL)
return NULL;
timeri->owner = kstrdup(owner, GFP_KERNEL);
......@@ -764,7 +764,7 @@ int snd_timer_new(snd_card_t *card, char *id, snd_timer_id_t *tid, snd_timer_t *
snd_assert(tid != NULL, return -EINVAL);
snd_assert(rtimer != NULL, return -EINVAL);
*rtimer = NULL;
timer = kcalloc(1, sizeof(*timer), GFP_KERNEL);
timer = kzalloc(sizeof(*timer), GFP_KERNEL);
if (timer == NULL)
return -ENOMEM;
timer->tmr_class = tid->dev_class;
......@@ -1017,7 +1017,7 @@ static int snd_timer_register_system(void)
return err;
strcpy(timer->name, "system timer");
timer->hw = snd_timer_system;
priv = kcalloc(1, sizeof(*priv), GFP_KERNEL);
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (priv == NULL) {
snd_timer_free(timer);
return -ENOMEM;
......@@ -1202,7 +1202,7 @@ static int snd_timer_user_open(struct inode *inode, struct file *file)
{
snd_timer_user_t *tu;
tu = kcalloc(1, sizeof(*tu), GFP_KERNEL);
tu = kzalloc(sizeof(*tu), GFP_KERNEL);
if (tu == NULL)
return -ENOMEM;
spin_lock_init(&tu->qlock);
......@@ -1513,7 +1513,7 @@ static int snd_timer_user_info(struct file *file, snd_timer_info_t __user *_info
t = tu->timeri->timer;
snd_assert(t != NULL, return -ENXIO);
info = kcalloc(1, sizeof(*info), GFP_KERNEL);
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (! info)
return -ENOMEM;
info->card = t->card ? t->card->number : -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册