sound : Replace kmalloc()+memset(0) with kzalloc().
PATCH 1/1 sound : Replace kmalloc()+memset(0) with kzalloc().
Replace all appropriate kmalloc() + memset() combinations withkzalloc() throughout the sound/ directory.
---
sound/oss/ac97_codec.c | 3 +-- sound/oss/ad1889.c | 3 +-- sound/oss/btaudio.c | 3 +-- sound/oss/cs46xx.c | 9 +++------ sound/oss/dmasound/dac3550a.c | 3 +-- sound/oss/dmasound/tas3001c.c | 3 +-- sound/oss/dmasound/tas3004.c | 3 +-- sound/oss/dmasound/tas_common.c | 3 +-- sound/oss/emu10k1/main.c | 11 +++-------- sound/oss/es1371.c | 3 +-- sound/oss/hal2.c | 3 +-- sound/oss/i810_audio.c | 9 +++------ sound/oss/kahlua.c | 3 +-- sound/oss/nec_vrc5477.c | 3 +-- sound/oss/opl3.c | 3 +-- sound/oss/sb_card.c | 6 ++---- sound/oss/swarm_cs4297a.c | 13 +++++-------- sound/oss/trident.c | 9 +++------ sound/oss/waveartist.c | 4 +--- 19 files changed, 32 insertions(+), 65 deletions(-)
sound/oss/ac97_codec.c +1 -2
@@ -744,11 +744,10 @@ static int ac97_check_modem(struct ac97_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;
sound/oss/ad1889.c +1 -2
@@ -230,9 +230,8 @@ static ad1889_dev_t *ad1889_alloc_dev(ststruct 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;
sound/oss/btaudio.c +1 -2
@@ -915,12 +915,11 @@ static int __devinit btaudio_probe(strucreturn -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;
sound/oss/cs46xx.c +3 -6
@@ -3048,10 +3048,9 @@ static int cs_open(struct inode *inode,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 );
@@ -3114,10 +3113,9 @@ static int cs_open(struct inode *inode,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 );
@@ -5075,11 +5073,10 @@ static int __devinit cs46xx_probe(structpci_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;
sound/oss/dmasound/dac3550a.c +1 -2
@@ -163,10 +163,9 @@ static int daca_detect_client(struct i2cstruct 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;
sound/oss/dmasound/tas3001c.c +1 -2
@@ -807,10 +807,9 @@ tas3001c_init(struct i2c_client *client)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 );
sound/oss/dmasound/tas3004.c +1 -2
@@ -1093,10 +1093,9 @@ tas3004_init(struct i2c_client *client)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 );
sound/oss/dmasound/tas_common.c +1 -2
@@ -135,10 +135,9 @@ tas_detect_client(struct i2c_adapter *adreturn -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;
sound/oss/emu10k1/main.c +3 -8
@@ -455,15 +455,13 @@ static int __devinit emu10k1_midi_init(s {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 ;
@@ -472,15 +470,13 @@ static int __devinit emu10k1_midi_init(sspin_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);
@@ -1280,11 +1276,10 @@ static int __devinit emu10k1_probe(strucpci_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 );
sound/oss/es1371.c +1 -2
@@ -2870,11 +2870,10 @@ static int __devinit es1371_probe(structprintk (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 )
sound/oss/hal2.c +1 -2
@@ -1435,10 +1435,9 @@ static int hal2_init_card(struct hal2_caint ret =0 ;struct hal2_card *hal2; - hal2 = (struct hal2_card *)kmalloc (sizeof (struct hal2_card ),GFP_KERNEL ); + hal2 = (struct hal2_card *)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 ];
sound/oss/i810_audio.c +3 -6
@@ -2580,10 +2580,9 @@ static int i810_open(struct inode *inodefor (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; }
@@ -3205,10 +3204,9 @@ static void __devinit i810_configure_clo*/ 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);
@@ -3273,11 +3271,10 @@ static int __devinit i810_probe(struct preturn -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;
sound/oss/kahlua.c +1 -2
@@ -139,13 +139,12 @@ static int __devinit probe_one(struct pcprintk (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);
sound/oss/nec_vrc5477.c +1 -2
@@ -1860,11 +1860,10 @@ #endifif (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);
sound/oss/opl3.c +1 -2
@@ -166,7 +166,7 @@ int opl3_detect(int ioaddr, int *osp)return 0 ; } - devc = (struct opl_devinfo *)kmalloc (sizeof (*devc),GFP_KERNEL ); + devc = (struct opl_devinfo *)kzalloc (sizeof (*devc),GFP_KERNEL );if (devc ==NULL ) {
@@ -175,7 +175,6 @@ int opl3_detect(int ioaddr, int *osp)return 0 ; } -memset (devc,0 ,sizeof (*devc));strcpy (devc->fm_info.name,"OPL2" );if (!request_region (ioaddr,4 , devc->fm_info.name)) {
sound/oss/sb_card.c +2 -4
@@ -137,11 +137,10 @@ static int __init sb_init_legacy(void) {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;
@@ -247,11 +246,10 @@ static int sb_pnp_probe(struct pnp_card_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,
sound/oss/swarm_cs4297a.c +5 -8
@@ -615,25 +615,23 @@ static int init_serdma(serdma_t *dma)/* 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 */
@@ -2618,12 +2616,11 @@ #ifndef CONFIG_BCM_CS4297A_CSWARMudelay (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);
sound/oss/trident.c +3 -6
@@ -2729,12 +2729,11 @@ trident_open(struct inode *inode, struct }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;
@@ -3618,7 +3617,7 @@ ali_allocate_other_states_resources(stru }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);
@@ -3630,7 +3629,6 @@ ali_allocate_other_states_resources(stru }return -ENOMEM ; } -memset (s,0 ,sizeof (*state)); s->dmabuf.channel = channel; s->dmabuf.ossfragshift = s->dmabuf.ossmaxfrags =
@@ -4399,11 +4397,10 @@ trident_probe(struct pci_dev *pci_dev, c } 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;
sound/oss/waveartist.c +1 -3
@@ -1267,12 +1267,10 @@ static int __init waveartist_init(wavnc_conf_printf2 (dev_name, devc->hw.io_base, devc->hw.irq, devc->hw.dma, devc->hw.dma2); - portc = (wavnc_port_info *)kmalloc (sizeof (wavnc_port_info),GFP_KERNEL ); + portc = (wavnc_port_info *)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,
Hello,
Quoted 2 lines
Replace all appropriate
kmalloc()+memset()combinations withkzalloc()throughout thesound/directory.
[... cut ...]
sound/oss/i810_audio.c static int i810_open(struct inode *inode · line 2583
Quoted 10 lines
sound/oss/i810_audio.c +1
-1@@ -2580,10 +2580,9 @@ static int i810_open(struct inode *inodefor (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 );
You can remove those casts while you're at it.
Signature · 3 lines
Regards, Mariusz Kozlowski
Quoted 8 lines · Mariusz Kozlowski
Hello,
Quoted 2 lines
Replace all appropriate
kmalloc()+memset()combinations withkzalloc()throughout thesound/directory.[... cut ...]
Quoted 12 lines
sound/oss/i810_audio.c static int i810_open(struct inode *inode · line 2583
Quoted 10 lines
sound/oss/i810_audio.c +1
-1@@ -2580,10 +2580,9 @@ static int i810_open(struct inode *inodefor (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 );You can remove those casts while you're at it.
i actually thought about that, but decided to restrict that submission to just the kmalloc/memset replacement. a subsequent patch could do a global change of all k*alloc calls to get rid of superfluous casts.
rday