Commit 92c54a65 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by David S. Miller

atm: nicstar: Use kcalloc() to simplify code

Use kcalloc() instead of kmalloc_array() and a loop to set all the values
of the array to NULL.

While at it, remove a duplicated assignment to 'scq->num_entries'.
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 32d51cef
...@@ -861,7 +861,6 @@ static void ns_init_card_error(ns_dev *card, int error) ...@@ -861,7 +861,6 @@ static void ns_init_card_error(ns_dev *card, int error)
static scq_info *get_scq(ns_dev *card, int size, u32 scd) static scq_info *get_scq(ns_dev *card, int size, u32 scd)
{ {
scq_info *scq; scq_info *scq;
int i;
if (size != VBR_SCQSIZE && size != CBR_SCQSIZE) if (size != VBR_SCQSIZE && size != CBR_SCQSIZE)
return NULL; return NULL;
...@@ -875,9 +874,8 @@ static scq_info *get_scq(ns_dev *card, int size, u32 scd) ...@@ -875,9 +874,8 @@ static scq_info *get_scq(ns_dev *card, int size, u32 scd)
kfree(scq); kfree(scq);
return NULL; return NULL;
} }
scq->skb = kmalloc_array(size / NS_SCQE_SIZE, scq->skb = kcalloc(size / NS_SCQE_SIZE, sizeof(*scq->skb),
sizeof(*scq->skb), GFP_KERNEL);
GFP_KERNEL);
if (!scq->skb) { if (!scq->skb) {
dma_free_coherent(&card->pcidev->dev, dma_free_coherent(&card->pcidev->dev,
2 * size, scq->org, scq->dma); 2 * size, scq->org, scq->dma);
...@@ -890,15 +888,11 @@ static scq_info *get_scq(ns_dev *card, int size, u32 scd) ...@@ -890,15 +888,11 @@ static scq_info *get_scq(ns_dev *card, int size, u32 scd)
scq->last = scq->base + (scq->num_entries - 1); scq->last = scq->base + (scq->num_entries - 1);
scq->tail = scq->last; scq->tail = scq->last;
scq->scd = scd; scq->scd = scd;
scq->num_entries = size / NS_SCQE_SIZE;
scq->tbd_count = 0; scq->tbd_count = 0;
init_waitqueue_head(&scq->scqfull_waitq); init_waitqueue_head(&scq->scqfull_waitq);
scq->full = 0; scq->full = 0;
spin_lock_init(&scq->lock); spin_lock_init(&scq->lock);
for (i = 0; i < scq->num_entries; i++)
scq->skb[i] = NULL;
return scq; return scq;
} }
......
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