Commit 0c1cca1d authored by Om Narasimhan's avatar Om Narasimhan Committed by David S. Miller

[ATM]: kmalloc to kzalloc patches for drivers/atm

Signed-off-by: default avatarOm Narasimhan <om.turyx@gmail.com>
Signed-off-by: default avatarChas Williams <chas@cmf.nrl.navy.mil>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 617dbeaa
...@@ -113,15 +113,13 @@ static int __init adummy_init(void) ...@@ -113,15 +113,13 @@ static int __init adummy_init(void)
printk(KERN_ERR "adummy: version %s\n", DRV_VERSION); printk(KERN_ERR "adummy: version %s\n", DRV_VERSION);
adummy_dev = (struct adummy_dev *) kmalloc(sizeof(struct adummy_dev), adummy_dev = kzalloc(sizeof(struct adummy_dev),
GFP_KERNEL); GFP_KERNEL);
if (!adummy_dev) { if (!adummy_dev) {
printk(KERN_ERR DEV_LABEL ": kmalloc() failed\n"); printk(KERN_ERR DEV_LABEL ": kzalloc() failed\n");
err = -ENOMEM; err = -ENOMEM;
goto out; goto out;
} }
memset(adummy_dev, 0, sizeof(struct adummy_dev));
atm_dev = atm_dev_register(DEV_LABEL, &adummy_ops, -1, NULL); atm_dev = atm_dev_register(DEV_LABEL, &adummy_ops, -1, NULL);
if (!atm_dev) { if (!atm_dev) {
printk(KERN_ERR DEV_LABEL ": atm_dev_register() failed\n"); printk(KERN_ERR DEV_LABEL ": atm_dev_register() failed\n");
......
...@@ -1784,7 +1784,7 @@ static int __devinit fs_init (struct fs_dev *dev) ...@@ -1784,7 +1784,7 @@ static int __devinit fs_init (struct fs_dev *dev)
write_fs (dev, RAM, (1 << (28 - FS155_VPI_BITS - FS155_VCI_BITS)) - 1); write_fs (dev, RAM, (1 << (28 - FS155_VPI_BITS - FS155_VCI_BITS)) - 1);
dev->nchannels = FS155_NR_CHANNELS; dev->nchannels = FS155_NR_CHANNELS;
} }
dev->atm_vccs = kmalloc (dev->nchannels * sizeof (struct atm_vcc *), dev->atm_vccs = kcalloc (dev->nchannels, sizeof (struct atm_vcc *),
GFP_KERNEL); GFP_KERNEL);
fs_dprintk (FS_DEBUG_ALLOC, "Alloc atmvccs: %p(%Zd)\n", fs_dprintk (FS_DEBUG_ALLOC, "Alloc atmvccs: %p(%Zd)\n",
dev->atm_vccs, dev->nchannels * sizeof (struct atm_vcc *)); dev->atm_vccs, dev->nchannels * sizeof (struct atm_vcc *));
...@@ -1794,9 +1794,8 @@ static int __devinit fs_init (struct fs_dev *dev) ...@@ -1794,9 +1794,8 @@ static int __devinit fs_init (struct fs_dev *dev)
/* XXX Clean up..... */ /* XXX Clean up..... */
return 1; return 1;
} }
memset (dev->atm_vccs, 0, dev->nchannels * sizeof (struct atm_vcc *));
dev->tx_inuse = kmalloc (dev->nchannels / 8 /* bits/byte */ , GFP_KERNEL); dev->tx_inuse = kzalloc (dev->nchannels / 8 /* bits/byte */ , GFP_KERNEL);
fs_dprintk (FS_DEBUG_ALLOC, "Alloc tx_inuse: %p(%d)\n", fs_dprintk (FS_DEBUG_ALLOC, "Alloc tx_inuse: %p(%d)\n",
dev->atm_vccs, dev->nchannels / 8); dev->atm_vccs, dev->nchannels / 8);
...@@ -1805,8 +1804,6 @@ static int __devinit fs_init (struct fs_dev *dev) ...@@ -1805,8 +1804,6 @@ static int __devinit fs_init (struct fs_dev *dev)
/* XXX Clean up..... */ /* XXX Clean up..... */
return 1; return 1;
} }
memset (dev->tx_inuse, 0, dev->nchannels / 8);
/* -- RAS1 : FS155 and 50 differ. Default (0) should be OK for both */ /* -- RAS1 : FS155 and 50 differ. Default (0) should be OK for both */
/* -- RAS2 : FS50 only: Default is OK. */ /* -- RAS2 : FS50 only: Default is OK. */
...@@ -1893,14 +1890,11 @@ static int __devinit firestream_init_one (struct pci_dev *pci_dev, ...@@ -1893,14 +1890,11 @@ static int __devinit firestream_init_one (struct pci_dev *pci_dev,
if (pci_enable_device(pci_dev)) if (pci_enable_device(pci_dev))
goto err_out; goto err_out;
fs_dev = kmalloc (sizeof (struct fs_dev), GFP_KERNEL); fs_dev = kzalloc (sizeof (struct fs_dev), GFP_KERNEL);
fs_dprintk (FS_DEBUG_ALLOC, "Alloc fs-dev: %p(%Zd)\n", fs_dprintk (FS_DEBUG_ALLOC, "Alloc fs-dev: %p(%Zd)\n",
fs_dev, sizeof (struct fs_dev)); fs_dev, sizeof (struct fs_dev));
if (!fs_dev) if (!fs_dev)
goto err_out; goto err_out;
memset (fs_dev, 0, sizeof (struct fs_dev));
atm_dev = atm_dev_register("fs", &ops, -1, NULL); atm_dev = atm_dev_register("fs", &ops, -1, NULL);
if (!atm_dev) if (!atm_dev)
goto err_out_free_fs_dev; goto err_out_free_fs_dev;
......
...@@ -383,14 +383,12 @@ he_init_one(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent) ...@@ -383,14 +383,12 @@ he_init_one(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent)
} }
pci_set_drvdata(pci_dev, atm_dev); pci_set_drvdata(pci_dev, atm_dev);
he_dev = (struct he_dev *) kmalloc(sizeof(struct he_dev), he_dev = kzalloc(sizeof(struct he_dev),
GFP_KERNEL); GFP_KERNEL);
if (!he_dev) { if (!he_dev) {
err = -ENOMEM; err = -ENOMEM;
goto init_one_failure; goto init_one_failure;
} }
memset(he_dev, 0, sizeof(struct he_dev));
he_dev->pci_dev = pci_dev; he_dev->pci_dev = pci_dev;
he_dev->atm_dev = atm_dev; he_dev->atm_dev = atm_dev;
he_dev->atm_dev->dev_data = he_dev; he_dev->atm_dev->dev_data = he_dev;
......
...@@ -2719,7 +2719,7 @@ static int __devinit hrz_probe(struct pci_dev *pci_dev, const struct pci_device_ ...@@ -2719,7 +2719,7 @@ static int __devinit hrz_probe(struct pci_dev *pci_dev, const struct pci_device_
goto out_disable; goto out_disable;
} }
dev = kmalloc(sizeof(hrz_dev), GFP_KERNEL); dev = kzalloc(sizeof(hrz_dev), GFP_KERNEL);
if (!dev) { if (!dev) {
// perhaps we should be nice: deregister all adapters and abort? // perhaps we should be nice: deregister all adapters and abort?
PRINTD(DBG_ERR, "out of memory"); PRINTD(DBG_ERR, "out of memory");
...@@ -2727,8 +2727,6 @@ static int __devinit hrz_probe(struct pci_dev *pci_dev, const struct pci_device_ ...@@ -2727,8 +2727,6 @@ static int __devinit hrz_probe(struct pci_dev *pci_dev, const struct pci_device_
goto out_release; goto out_release;
} }
memset(dev, 0, sizeof(hrz_dev));
pci_set_drvdata(pci_dev, dev); pci_set_drvdata(pci_dev, dev);
// grab IRQ and install handler - move this someplace more sensible // grab IRQ and install handler - move this someplace more sensible
......
...@@ -642,11 +642,9 @@ alloc_scq(struct idt77252_dev *card, int class) ...@@ -642,11 +642,9 @@ alloc_scq(struct idt77252_dev *card, int class)
{ {
struct scq_info *scq; struct scq_info *scq;
scq = (struct scq_info *) kmalloc(sizeof(struct scq_info), GFP_KERNEL); scq = kzalloc(sizeof(struct scq_info), GFP_KERNEL);
if (!scq) if (!scq)
return NULL; return NULL;
memset(scq, 0, sizeof(struct scq_info));
scq->base = pci_alloc_consistent(card->pcidev, SCQ_SIZE, scq->base = pci_alloc_consistent(card->pcidev, SCQ_SIZE,
&scq->paddr); &scq->paddr);
if (scq->base == NULL) { if (scq->base == NULL) {
...@@ -2142,11 +2140,9 @@ idt77252_init_est(struct vc_map *vc, int pcr) ...@@ -2142,11 +2140,9 @@ idt77252_init_est(struct vc_map *vc, int pcr)
{ {
struct rate_estimator *est; struct rate_estimator *est;
est = kmalloc(sizeof(struct rate_estimator), GFP_KERNEL); est = kzalloc(sizeof(struct rate_estimator), GFP_KERNEL);
if (!est) if (!est)
return NULL; return NULL;
memset(est, 0, sizeof(*est));
est->maxcps = pcr < 0 ? -pcr : pcr; est->maxcps = pcr < 0 ? -pcr : pcr;
est->cps = est->maxcps; est->cps = est->maxcps;
est->avcps = est->cps << 5; est->avcps = est->cps << 5;
...@@ -2451,14 +2447,12 @@ idt77252_open(struct atm_vcc *vcc) ...@@ -2451,14 +2447,12 @@ idt77252_open(struct atm_vcc *vcc)
index = VPCI2VC(card, vpi, vci); index = VPCI2VC(card, vpi, vci);
if (!card->vcs[index]) { if (!card->vcs[index]) {
card->vcs[index] = kmalloc(sizeof(struct vc_map), GFP_KERNEL); card->vcs[index] = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
if (!card->vcs[index]) { if (!card->vcs[index]) {
printk("%s: can't alloc vc in open()\n", card->name); printk("%s: can't alloc vc in open()\n", card->name);
up(&card->mutex); up(&card->mutex);
return -ENOMEM; return -ENOMEM;
} }
memset(card->vcs[index], 0, sizeof(struct vc_map));
card->vcs[index]->card = card; card->vcs[index]->card = card;
card->vcs[index]->index = index; card->vcs[index]->index = index;
...@@ -2926,13 +2920,11 @@ open_card_oam(struct idt77252_dev *card) ...@@ -2926,13 +2920,11 @@ open_card_oam(struct idt77252_dev *card)
for (vci = 3; vci < 5; vci++) { for (vci = 3; vci < 5; vci++) {
index = VPCI2VC(card, vpi, vci); index = VPCI2VC(card, vpi, vci);
vc = kmalloc(sizeof(struct vc_map), GFP_KERNEL); vc = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
if (!vc) { if (!vc) {
printk("%s: can't alloc vc\n", card->name); printk("%s: can't alloc vc\n", card->name);
return -ENOMEM; return -ENOMEM;
} }
memset(vc, 0, sizeof(struct vc_map));
vc->index = index; vc->index = index;
card->vcs[index] = vc; card->vcs[index] = vc;
...@@ -2995,12 +2987,11 @@ open_card_ubr0(struct idt77252_dev *card) ...@@ -2995,12 +2987,11 @@ open_card_ubr0(struct idt77252_dev *card)
{ {
struct vc_map *vc; struct vc_map *vc;
vc = kmalloc(sizeof(struct vc_map), GFP_KERNEL); vc = kzalloc(sizeof(struct vc_map), GFP_KERNEL);
if (!vc) { if (!vc) {
printk("%s: can't alloc vc\n", card->name); printk("%s: can't alloc vc\n", card->name);
return -ENOMEM; return -ENOMEM;
} }
memset(vc, 0, sizeof(struct vc_map));
card->vcs[0] = vc; card->vcs[0] = vc;
vc->class = SCHED_UBR0; vc->class = SCHED_UBR0;
...@@ -3695,14 +3686,12 @@ idt77252_init_one(struct pci_dev *pcidev, const struct pci_device_id *id) ...@@ -3695,14 +3686,12 @@ idt77252_init_one(struct pci_dev *pcidev, const struct pci_device_id *id)
goto err_out_disable_pdev; goto err_out_disable_pdev;
} }
card = kmalloc(sizeof(struct idt77252_dev), GFP_KERNEL); card = kzalloc(sizeof(struct idt77252_dev), GFP_KERNEL);
if (!card) { if (!card) {
printk("idt77252-%d: can't allocate private data\n", index); printk("idt77252-%d: can't allocate private data\n", index);
err = -ENOMEM; err = -ENOMEM;
goto err_out_disable_pdev; goto err_out_disable_pdev;
} }
memset(card, 0, sizeof(struct idt77252_dev));
card->revision = revision; card->revision = revision;
card->index = index; card->index = index;
card->pcidev = pcidev; card->pcidev = pcidev;
......
...@@ -1482,16 +1482,10 @@ static inline void vcc_table_deallocate(const struct lanai_dev *lanai) ...@@ -1482,16 +1482,10 @@ static inline void vcc_table_deallocate(const struct lanai_dev *lanai)
static inline struct lanai_vcc *new_lanai_vcc(void) static inline struct lanai_vcc *new_lanai_vcc(void)
{ {
struct lanai_vcc *lvcc; struct lanai_vcc *lvcc;
lvcc = (struct lanai_vcc *) kmalloc(sizeof(*lvcc), GFP_KERNEL); lvcc = kzalloc(sizeof(*lvcc), GFP_KERNEL);
if (likely(lvcc != NULL)) { if (likely(lvcc != NULL)) {
lvcc->vbase = NULL;
lvcc->rx.atmvcc = lvcc->tx.atmvcc = NULL;
lvcc->nref = 0;
memset(&lvcc->stats, 0, sizeof lvcc->stats);
lvcc->rx.buf.start = lvcc->tx.buf.start = NULL;
skb_queue_head_init(&lvcc->tx.backlog); skb_queue_head_init(&lvcc->tx.backlog);
#ifdef DEBUG #ifdef DEBUG
lvcc->tx.unqueue = NULL;
lvcc->vci = -1; lvcc->vci = -1;
#endif #endif
} }
......
...@@ -603,9 +603,8 @@ static int start_rx(struct atm_dev *dev) ...@@ -603,9 +603,8 @@ static int start_rx(struct atm_dev *dev)
DPRINTK("start_rx\n"); DPRINTK("start_rx\n");
zatm_dev = ZATM_DEV(dev); zatm_dev = ZATM_DEV(dev);
size = sizeof(struct atm_vcc *)*zatm_dev->chans; size = sizeof(struct atm_vcc *)*zatm_dev->chans;
zatm_dev->rx_map = (struct atm_vcc **) kmalloc(size,GFP_KERNEL); zatm_dev->rx_map = kzalloc(size,GFP_KERNEL);
if (!zatm_dev->rx_map) return -ENOMEM; if (!zatm_dev->rx_map) return -ENOMEM;
memset(zatm_dev->rx_map,0,size);
/* set VPI/VCI split (use all VCIs and give what's left to VPIs) */ /* set VPI/VCI split (use all VCIs and give what's left to VPIs) */
zpokel(zatm_dev,(1 << dev->ci_range.vci_bits)-1,uPD98401_VRR); zpokel(zatm_dev,(1 << dev->ci_range.vci_bits)-1,uPD98401_VRR);
/* prepare free buffer pools */ /* prepare free buffer pools */
...@@ -951,9 +950,8 @@ static int open_tx_first(struct atm_vcc *vcc) ...@@ -951,9 +950,8 @@ static int open_tx_first(struct atm_vcc *vcc)
skb_queue_head_init(&zatm_vcc->tx_queue); skb_queue_head_init(&zatm_vcc->tx_queue);
init_waitqueue_head(&zatm_vcc->tx_wait); init_waitqueue_head(&zatm_vcc->tx_wait);
/* initialize ring */ /* initialize ring */
zatm_vcc->ring = kmalloc(RING_SIZE,GFP_KERNEL); zatm_vcc->ring = kzalloc(RING_SIZE,GFP_KERNEL);
if (!zatm_vcc->ring) return -ENOMEM; if (!zatm_vcc->ring) return -ENOMEM;
memset(zatm_vcc->ring,0,RING_SIZE);
loop = zatm_vcc->ring+RING_ENTRIES*RING_WORDS; loop = zatm_vcc->ring+RING_ENTRIES*RING_WORDS;
loop[0] = uPD98401_TXPD_V; loop[0] = uPD98401_TXPD_V;
loop[1] = loop[2] = 0; loop[1] = loop[2] = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment