]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] OSS: replace kmalloc()+memset() combos with kzalloc()
authorRobert P. J. Day <rpjday@mindspring.com>
Wed, 14 Feb 2007 08:33:16 +0000 (00:33 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Wed, 14 Feb 2007 16:09:54 +0000 (08:09 -0800)
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>
19 files changed:
sound/oss/ac97_codec.c
sound/oss/ad1889.c
sound/oss/btaudio.c
sound/oss/cs46xx.c
sound/oss/dmasound/dac3550a.c
sound/oss/dmasound/tas3001c.c
sound/oss/dmasound/tas3004.c
sound/oss/dmasound/tas_common.c
sound/oss/emu10k1/main.c
sound/oss/es1371.c
sound/oss/hal2.c
sound/oss/i810_audio.c
sound/oss/kahlua.c
sound/oss/nec_vrc5477.c
sound/oss/opl3.c
sound/oss/sb_card.c
sound/oss/swarm_cs4297a.c
sound/oss/trident.c
sound/oss/waveartist.c

index 602db497929abd70d048d1d5215b0d869651ab5f..fef56cac06c832650db596299af04185dc9919dc 100644 (file)
@@ -744,11 +744,10 @@ static int ac97_check_modem(struct ac97_codec *codec)
  
 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;
index f0724327493c0c47e66a822e009ee0602c064a9b..c0730a3563a2962ab86a4c24ec39c063c4df0de4 100644 (file)
@@ -230,9 +230,8 @@ static ad1889_dev_t *ad1889_alloc_dev(struct pci_dev *pci)
        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;
 
index f845528e1facc8713e025a4b600f37343c4f6fc1..f813ae9c2134e2e7b17f41c486bf23c7d167a543 100644 (file)
@@ -915,12 +915,11 @@ static int __devinit btaudio_probe(struct pci_dev *pci_dev,
                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;
index 147c8a951137a4452fb059a66dab5cbfbc381c7d..2a1f0d9ac968083f5ec0ec3a6164bf15ff6bc5b4 100644 (file)
@@ -3048,10 +3048,9 @@ static int cs_open(struct inode *inode, struct file *file)
                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, struct file *file)
                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(struct pci_dev *pci_dev,
        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;
index 7360d8954d6009009f57e7b18b8f437fb15f9c52..0f0d03a55dab71139fbac2fd1da9fb3832f605ba 100644 (file)
@@ -163,10 +163,9 @@ static int daca_detect_client(struct i2c_adapter *adapter, int address)
        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;
index 2f21a3c00374ad2b40e40482ab1aff41594f9a09..4b7dbdd2a43833c2553c2b994a28f599e3d6bc46 100644 (file)
@@ -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);
index af34fb39bc29ed2323572097dd8c8d99cd778502..678bf0ff6da27329ad0951b9b2bf2ae7bb7714c9 100644 (file)
@@ -1092,10 +1092,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);
index 882ae98a41b127c7b23d76d4465bc1cc3e5f2acf..665e85b5562bd56785494bbfbd428b9459afaa5a 100644 (file)
@@ -135,10 +135,9 @@ tas_detect_client(struct i2c_adapter *adapter, int address)
                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;
index 6c59df7b00011965f04cad5f5f3a3bd17319ae5d..16ac02540a3f77ac0ee591abe4e529abe8430e02 100644 (file)
@@ -455,15 +455,13 @@ static int __devinit emu10k1_midi_init(struct emu10k1_card *card)
 {
        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(struct emu10k1_card *card)
 
        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);
@@ -1280,11 +1276,10 @@ static int __devinit emu10k1_probe(struct pci_dev *pci_dev, const struct pci_dev
 
        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); 
index e1fbcca8e72236beb0d05240281f08f0e0c8153c..974dd732b1499606c37d6b324e6b932a4dddab14 100644 (file)
@@ -2871,11 +2871,10 @@ static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_devic
                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)
index 80a42773c6485c98cbc80706a97741861ef713ef..a94b9df489dcbcae8c8253b28a552288495cdd53 100644 (file)
@@ -1435,10 +1435,9 @@ static int hal2_init_card(struct hal2_card **phal2, struct hpc3_regs *hpc3)
        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];
index c3c8a720d555a73749c1b9f62587f16097f7fae2..f5e31f11973d39a1ae995dd0d311c253c028551c 100644 (file)
@@ -2580,10 +2580,9 @@ static int i810_open(struct inode *inode, struct file *file)
                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;
                        }
@@ -3205,10 +3204,9 @@ static void __devinit i810_configure_clocking (void)
         */
        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 pci_dev *pci_dev, const struct pci_device
                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;
index 12e7b3038be2bb8a05dcb2c27045d4023c340464..dfe670f12e67d71117904db746c2a2b8e87af10d 100644 (file)
@@ -139,13 +139,12 @@ static int __devinit probe_one(struct pci_dev *pdev, const struct pci_device_id
        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);
        
index d459bdb14154e9c11907ae8e8cd7e1a386c31a53..27b4ba3aaa7cc78746c3469ce95f5894afb62bcc 100644 (file)
@@ -1860,11 +1860,10 @@ static int __devinit vrc5477_ac97_probe(struct pci_dev *pcidev,
        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);
index 2e8cfa5481f28c4e1e7d7f2d40b5326538bd02d7..fc273e55094480db93f3ad351c4e6aea49137c28 100644 (file)
@@ -166,7 +166,7 @@ int opl3_detect(int ioaddr, int *osp)
                return 0;
        }
 
-       devc = kmalloc(sizeof(*devc), GFP_KERNEL);
+       devc = 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)) {
index 8666291c00523fccca590df1d6a5fbedbf6c28c7..27acd6f29b98ffe06e4ffddd737e2d49218ce7c3 100644 (file)
@@ -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_link *card, const struct pnp_card_device
                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,
index 9f7e5f59ac82b3560d1717b8840aa0e2d840b789..016b918329ada95227ddb95666fdd6ccc7615531 100644 (file)
@@ -616,25 +616,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 */
@@ -2619,12 +2617,11 @@ static int __init cs4297a_init(void)
         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);
index 6b1f8c9cdcf870419924dad10156dcf395df4e9f..72a8a0ed36a2855cca84d0d64a1c3844a96ab344 100644 (file)
@@ -2729,12 +2729,11 @@ trident_open(struct inode *inode, struct file *file)
                }
                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(struct trident_state *state, int chan_nums)
                        }
                        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(struct trident_state *state, int chan_nums)
                        }
                        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, const struct pci_device_id *pci_id)
        }
 
        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;
index 26a7c6af95bcc5c18992cbe2a2ebea1763f741c7..b48c72923a13dfb30c35669213112a31baa4ffc2 100644 (file)
@@ -1267,12 +1267,10 @@ static int __init waveartist_init(wavnc_info *devc)
        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,