Replace kmalloc() + memset() pairs with the appropriate kzalloc() calls.
Signed-off-by: Robert P. J. Day <rpjday@mindspring.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
struct ac97_codec *ac97_alloc_codec(void)
{
- struct ac97_codec *codec = kmalloc(sizeof(struct ac97_codec), GFP_KERNEL);
+ struct ac97_codec *codec = kzalloc(sizeof(struct ac97_codec), GFP_KERNEL);
if(!codec)
return NULL;
- memset(codec, 0, sizeof(*codec));
spin_lock_init(&codec->lock);
INIT_LIST_HEAD(&codec->list);
return codec;
struct dmabuf *dmabuf;
int i;
- if ((dev = kmalloc(sizeof(ad1889_dev_t), GFP_KERNEL)) == NULL)
+ if ((dev = kzalloc(sizeof(ad1889_dev_t), GFP_KERNEL)) == NULL)
return NULL;
- memset(dev, 0, sizeof(ad1889_dev_t));
spin_lock_init(&dev->lock);
dev->pci = pci;
return -EBUSY;
}
- bta = kmalloc(sizeof(*bta),GFP_ATOMIC);
+ bta = kzalloc(sizeof(*bta),GFP_ATOMIC);
if (!bta) {
rc = -ENOMEM;
goto fail0;
}
- memset(bta,0,sizeof(*bta));
bta->pci = pci_dev;
bta->irq = pci_dev->irq;
CS_DBGOUT(CS_WAVE_READ, 2, printk("cs46xx: cs_open() FMODE_READ\n") );
if (card->states[0] == NULL) {
state = card->states[0] =
- kmalloc(sizeof(struct cs_state), GFP_KERNEL);
+ kzalloc(sizeof(struct cs_state), GFP_KERNEL);
if (state == NULL)
return -ENOMEM;
- memset(state, 0, sizeof(struct cs_state));
mutex_init(&state->sem);
dmabuf = &state->dmabuf;
dmabuf->pbuf = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
CS_DBGOUT(CS_OPEN, 2, printk("cs46xx: cs_open() FMODE_WRITE\n") );
if (card->states[1] == NULL) {
state = card->states[1] =
- kmalloc(sizeof(struct cs_state), GFP_KERNEL);
+ kzalloc(sizeof(struct cs_state), GFP_KERNEL);
if (state == NULL)
return -ENOMEM;
- memset(state, 0, sizeof(struct cs_state));
mutex_init(&state->sem);
dmabuf = &state->dmabuf;
dmabuf->pbuf = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
pci_read_config_word(pci_dev, PCI_SUBSYSTEM_VENDOR_ID, &ss_vendor);
pci_read_config_word(pci_dev, PCI_SUBSYSTEM_ID, &ss_card);
- if ((card = kmalloc(sizeof(struct cs_card), GFP_KERNEL)) == NULL) {
+ if ((card = kzalloc(sizeof(struct cs_card), GFP_KERNEL)) == NULL) {
printk(KERN_ERR "cs46xx: out of memory\n");
return -ENOMEM;
}
- memset(card, 0, sizeof(*card));
card->ba0_addr = RSRCADDRESS(pci_dev, 0);
card->ba1_addr = RSRCADDRESS(pci_dev, 1);
card->pci_dev = pci_dev;
struct i2c_client *new_client;
int rc = -ENODEV;
- new_client = kmalloc(sizeof(*new_client), GFP_KERNEL);
+ new_client = kzalloc(sizeof(*new_client), GFP_KERNEL);
if (!new_client)
return -ENOMEM;
- memset(new_client, 0, sizeof(*new_client));
new_client->addr = address;
new_client->adapter = adapter;
size_t sz = sizeof(*self) + (TAS3001C_REG_MAX*sizeof(tas_shadow_t));
int i, j;
- self = kmalloc(sz, GFP_KERNEL);
+ self = kzalloc(sz, GFP_KERNEL);
if (!self)
return -ENOMEM;
- memset(self, 0, sz);
self->super.client = client;
self->super.shadow = (tas_shadow_t *)(self+1);
char mcr2 = 0;
int i, j;
- self = kmalloc(sz, GFP_KERNEL);
+ self = kzalloc(sz, GFP_KERNEL);
if (!self)
return -ENOMEM;
- memset(self, 0, sz);
self->super.client = client;
self->super.shadow = (tas_shadow_t *)(self+1);
return -ENODEV;
}
- new_client = kmalloc(sizeof(*new_client), GFP_KERNEL);
+ new_client = kzalloc(sizeof(*new_client), GFP_KERNEL);
if (!new_client)
return -ENOMEM;
- memset(new_client, 0, sizeof(*new_client));
new_client->addr = address;
new_client->adapter = adapter;
{
int ret;
- card->mpuout = kmalloc(sizeof(struct emu10k1_mpuout), GFP_KERNEL);
+ card->mpuout = kzalloc(sizeof(struct emu10k1_mpuout), GFP_KERNEL);
if (card->mpuout == NULL) {
printk(KERN_WARNING "emu10k1: Unable to allocate emu10k1_mpuout: out of memory\n");
ret = -ENOMEM;
goto err_out1;
}
- memset(card->mpuout, 0, sizeof(struct emu10k1_mpuout));
-
card->mpuout->intr = 1;
card->mpuout->status = FLAGS_AVAILABLE;
card->mpuout->state = CARDMIDIOUT_STATE_DEFAULT;
spin_lock_init(&card->mpuout->lock);
- card->mpuin = kmalloc(sizeof(struct emu10k1_mpuin), GFP_KERNEL);
+ card->mpuin = kzalloc(sizeof(struct emu10k1_mpuin), GFP_KERNEL);
if (card->mpuin == NULL) {
printk(KERN_WARNING "emu10k1: Unable to allocate emu10k1_mpuin: out of memory\n");
ret = -ENOMEM;
goto err_out2;
}
- memset(card->mpuin, 0, sizeof(struct emu10k1_mpuin));
-
card->mpuin->status = FLAGS_AVAILABLE;
tasklet_init(&card->mpuin->tasklet, emu10k1_mpuin_bh, (unsigned long) card->mpuin);
pci_set_master(pci_dev);
- if ((card = kmalloc(sizeof(struct emu10k1_card), GFP_KERNEL)) == NULL) {
+ if ((card = kzalloc(sizeof(struct emu10k1_card), GFP_KERNEL)) == NULL) {
printk(KERN_ERR "emu10k1: out of memory\n");
return -ENOMEM;
}
- memset(card, 0, sizeof(struct emu10k1_card));
card->iobase = pci_resource_start(pci_dev, 0);
card->length = pci_resource_len(pci_dev, 0);
printk(KERN_WARNING "es1371: architecture does not support 32bit PCI busmaster DMA\n");
return i;
}
- if (!(s = kmalloc(sizeof(struct es1371_state), GFP_KERNEL))) {
+ if (!(s = kzalloc(sizeof(struct es1371_state), GFP_KERNEL))) {
printk(KERN_WARNING PFX "out of memory\n");
return -ENOMEM;
}
- memset(s, 0, sizeof(struct es1371_state));
s->codec = ac97_alloc_codec();
if(s->codec == NULL)
int ret = 0;
struct hal2_card *hal2;
- hal2 = kmalloc(sizeof(struct hal2_card), GFP_KERNEL);
+ hal2 = kzalloc(sizeof(struct hal2_card), GFP_KERNEL);
if (!hal2)
return -ENOMEM;
- memset(hal2, 0, sizeof(struct hal2_card));
hal2->ctl_regs = (struct hal2_ctl_regs *)hpc3->pbus_extregs[0];
hal2->aes_regs = (struct hal2_aes_regs *)hpc3->pbus_extregs[1];
for (i = 0; i < NR_HW_CH && card && !card->initializing; i++) {
if (card->states[i] == NULL) {
state = card->states[i] = (struct i810_state *)
- kmalloc(sizeof(struct i810_state), GFP_KERNEL);
+ kzalloc(sizeof(struct i810_state), GFP_KERNEL);
if (state == NULL)
return -ENOMEM;
- memset(state, 0, sizeof(struct i810_state));
dmabuf = &state->dmabuf;
goto found_virt;
}
*/
if(card != NULL) {
state = card->states[0] = (struct i810_state *)
- kmalloc(sizeof(struct i810_state), GFP_KERNEL);
+ kzalloc(sizeof(struct i810_state), GFP_KERNEL);
if (state == NULL)
return;
- memset(state, 0, sizeof(struct i810_state));
dmabuf = &state->dmabuf;
dmabuf->write_channel = card->alloc_pcm_channel(card);
return -ENODEV;
}
- if ((card = kmalloc(sizeof(struct i810_card), GFP_KERNEL)) == NULL) {
+ if ((card = kzalloc(sizeof(struct i810_card), GFP_KERNEL)) == NULL) {
printk(KERN_ERR "i810_audio: out of memory\n");
return -ENOMEM;
}
- memset(card, 0, sizeof(*card));
card->initializing = 1;
card->pci_dev = pci_dev;
printk(KERN_INFO "kahlua: XpressAudio on IRQ %d, DMA %d, %d\n",
irq, dma8, dma16);
- hw_config = kmalloc(sizeof(struct address_info), GFP_KERNEL);
+ hw_config = kzalloc(sizeof(struct address_info), GFP_KERNEL);
if(hw_config == NULL)
{
printk(KERN_ERR "kahlua: out of memory.\n");
return 1;
}
- memset(hw_config, 0, sizeof(*hw_config));
pci_set_drvdata(pdev, hw_config);
if (pcidev->irq == 0)
return -1;
- if (!(s = kmalloc(sizeof(struct vrc5477_ac97_state), GFP_KERNEL))) {
+ if (!(s = kzalloc(sizeof(struct vrc5477_ac97_state), GFP_KERNEL))) {
printk(KERN_ERR PFX "alloc of device struct failed\n");
return -1;
}
- memset(s, 0, sizeof(struct vrc5477_ac97_state));
init_waitqueue_head(&s->dma_adc.wait);
init_waitqueue_head(&s->dma_dac.wait);
return 0;
}
- devc = kmalloc(sizeof(*devc), GFP_KERNEL);
+ devc = kzalloc(sizeof(*devc), GFP_KERNEL);
if (devc == NULL)
{
return 0;
}
- memset(devc, 0, sizeof(*devc));
strcpy(devc->fm_info.name, "OPL2");
if (!request_region(ioaddr, 4, devc->fm_info.name)) {
{
struct sb_module_options sbmo = {0};
- if((legacy = kmalloc(sizeof(struct sb_card_config), GFP_KERNEL)) == NULL) {
+ if((legacy = kzalloc(sizeof(struct sb_card_config), GFP_KERNEL)) == NULL) {
printk(KERN_ERR "sb: Error: Could not allocate memory\n");
return -ENOMEM;
}
- memset(legacy, 0, sizeof(struct sb_card_config));
legacy->conf.io_base = io;
legacy->conf.irq = irq;
return -EBUSY;
}
- if((scc = kmalloc(sizeof(struct sb_card_config), GFP_KERNEL)) == NULL) {
+ if((scc = kzalloc(sizeof(struct sb_card_config), GFP_KERNEL)) == NULL) {
printk(KERN_ERR "sb: Error: Could not allocate memory\n");
return -ENOMEM;
}
- memset(scc, 0, sizeof(struct sb_card_config));
printk(KERN_INFO "sb: PnP: Found Card Named = \"%s\", Card PnP id = " \
"%s, Device PnP id = %s\n", card->card->name, card_id->id,
/* Descriptors */
dma->ringsz = DMA_DESCR;
- dma->descrtab = kmalloc(dma->ringsz * sizeof(serdma_descr_t), GFP_KERNEL);
+ dma->descrtab = kzalloc(dma->ringsz * sizeof(serdma_descr_t), GFP_KERNEL);
if (!dma->descrtab) {
- printk(KERN_ERR "cs4297a: kmalloc descrtab failed\n");
+ printk(KERN_ERR "cs4297a: kzalloc descrtab failed\n");
return -1;
}
- memset(dma->descrtab, 0, dma->ringsz * sizeof(serdma_descr_t));
dma->descrtab_end = dma->descrtab + dma->ringsz;
/* XXX bloddy mess, use proper DMA API here ... */
dma->descrtab_phys = CPHYSADDR((long)dma->descrtab);
dma->descr_add = dma->descr_rem = dma->descrtab;
/* Frame buffer area */
- dma->dma_buf = kmalloc(DMA_BUF_SIZE, GFP_KERNEL);
+ dma->dma_buf = kzalloc(DMA_BUF_SIZE, GFP_KERNEL);
if (!dma->dma_buf) {
- printk(KERN_ERR "cs4297a: kmalloc dma_buf failed\n");
+ printk(KERN_ERR "cs4297a: kzalloc dma_buf failed\n");
kfree(dma->descrtab);
return -1;
}
- memset(dma->dma_buf, 0, DMA_BUF_SIZE);
dma->dma_buf_phys = CPHYSADDR((long)dma->dma_buf);
/* Samples buffer area */
udelay(100);
#endif
- if (!(s = kmalloc(sizeof(struct cs4297a_state), GFP_KERNEL))) {
+ if (!(s = kzalloc(sizeof(struct cs4297a_state), GFP_KERNEL))) {
CS_DBGOUT(CS_ERROR, 1, printk(KERN_ERR
"cs4297a: probe() no memory for state struct.\n"));
return -1;
}
- memset(s, 0, sizeof(struct cs4297a_state));
s->magic = CS4297a_MAGIC;
init_waitqueue_head(&s->dma_adc.wait);
init_waitqueue_head(&s->dma_dac.wait);
}
for (i = 0; i < NR_HW_CH; i++) {
if (card->states[i] == NULL) {
- state = card->states[i] = kmalloc(sizeof(*state), GFP_KERNEL);
+ state = card->states[i] = kzalloc(sizeof(*state), GFP_KERNEL);
if (state == NULL) {
mutex_unlock(&card->open_mutex);
return -ENOMEM;
}
- memset(state, 0, sizeof(*state));
mutex_init(&state->sem);
dmabuf = &state->dmabuf;
goto found_virt;
}
return -EBUSY;
}
- s = card->states[i] = kmalloc(sizeof(*state), GFP_KERNEL);
+ s = card->states[i] = kzalloc(sizeof(*state), GFP_KERNEL);
if (!s) {
num = ali_multi_channels_5_1[state_count];
ali_free_pcm_channel(card, num);
}
return -ENOMEM;
}
- memset(s, 0, sizeof(*state));
s->dmabuf.channel = channel;
s->dmabuf.ossfragshift = s->dmabuf.ossmaxfrags =
}
rc = -ENOMEM;
- if ((card = kmalloc(sizeof(*card), GFP_KERNEL)) == NULL) {
+ if ((card = kzalloc(sizeof(*card), GFP_KERNEL)) == NULL) {
printk(KERN_ERR "trident: out of memory\n");
goto out_release_region;
}
- memset(card, 0, sizeof (*card));
init_timer(&card->timer);
card->iobase = iobase;
conf_printf2(dev_name, devc->hw.io_base, devc->hw.irq,
devc->hw.dma, devc->hw.dma2);
- portc = kmalloc(sizeof(wavnc_port_info), GFP_KERNEL);
+ portc = kzalloc(sizeof(wavnc_port_info), GFP_KERNEL);
if (portc == NULL)
goto nomem;
- memset(portc, 0, sizeof(wavnc_port_info));
-
my_dev = sound_install_audiodrv(AUDIO_DRIVER_VERSION, dev_name,
&waveartist_audio_driver, sizeof(struct audio_driver),
devc->audio_flags, AFMT_U8 | AFMT_S16_LE | AFMT_S8,