From d301fe6fb22ed43d26ed3a10babb02186b56a864 Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Thu, 2 Jun 2011 20:02:08 +0000 Subject: wcte12xp: kmalloc/memset -> kzalloc. This is trivial cleanup. Fixing up a couple of places that followed a kmalloc with a memset to 0 and also sneaked in one ARRAY_SIZE usage change. Signed-off-by: Shaun Ruffell git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9947 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- drivers/dahdi/wcte12xp/base.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'drivers/dahdi/wcte12xp/base.c') diff --git a/drivers/dahdi/wcte12xp/base.c b/drivers/dahdi/wcte12xp/base.c index 20a1f82..fecf0e2 100644 --- a/drivers/dahdi/wcte12xp/base.c +++ b/drivers/dahdi/wcte12xp/base.c @@ -2272,7 +2272,7 @@ static int __devinit te12xp_init_one(struct pci_dev *pdev, const struct pci_devi int res; unsigned int index = -1; - for (x = 0; x < sizeof(ifaces) / sizeof(ifaces[0]); x++) { + for (x = 0; x < ARRAY_SIZE(ifaces); x++) { if (!ifaces[x]) { index = x; break; @@ -2285,12 +2285,12 @@ static int __devinit te12xp_init_one(struct pci_dev *pdev, const struct pci_devi return -EIO; } - if (!(wc = kmalloc(sizeof(*wc), GFP_KERNEL))) { + wc = kzalloc(sizeof(*wc), GFP_KERNEL); + if (!wc) return -ENOMEM; - } ifaces[index] = wc; - memset(wc, 0, sizeof(*wc)); + wc->ledstate = -1; spin_lock_init(&wc->reglock); INIT_LIST_HEAD(&wc->active_cmds); @@ -2374,18 +2374,19 @@ static int __devinit te12xp_init_one(struct pci_dev *pdev, const struct pci_devi } for (x = 0; x < (wc->spantype == TYPE_E1 ? 31 : 24); x++) { - if (!(wc->chans[x] = kmalloc(sizeof(*wc->chans[x]), GFP_KERNEL))) { + wc->chans[x] = kzalloc(sizeof(*wc->chans[x]), GFP_KERNEL); + if (!wc->chans[x]) { free_wc(wc); ifaces[index] = NULL; return -ENOMEM; } - memset(wc->chans[x], 0, sizeof(*wc->chans[x])); - if (!(wc->ec[x] = kmalloc(sizeof(*wc->ec[x]), GFP_KERNEL))) { + + wc->ec[x] = kzalloc(sizeof(*wc->ec[x]), GFP_KERNEL); + if (!wc->ec[x]) { free_wc(wc); ifaces[index] = NULL; return -ENOMEM; } - memset(wc->ec[x], 0, sizeof(*wc->ec[x])); } mod_timer(&wc->timer, jiffies + HZ/5); -- cgit v1.2.3