aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/ti
diff options
context:
space:
mode:
authorGeorge Cherian <george.cherian@ti.com>2014-05-12 00:51:21 -0400
committerDavid S. Miller <davem@davemloft.net>2014-05-15 13:42:14 -0400
commite194312854edc22a2faf1931b3c0608fe20cb969 (patch)
tree8ac9dba90ca6379ff00fc855725750c86457ffc0 /drivers/net/ethernet/ti
parenta92f40a9a30e57f0ebd5dc38b427ea0d3b6c5b7b (diff)
drivers: net: davinci_cpdma: Convert kzalloc() to devm_kzalloc().
Convert kzalloc() to devm_kzalloc(). Signed-off-by: George Cherian <george.cherian@ti.com> Reviewed-by: Felipe Balbi <balbi@ti.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/ti')
-rw-r--r--drivers/net/ethernet/ti/davinci_cpdma.c35
1 files changed, 12 insertions, 23 deletions
diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c
index 88ef27067bf2..539dbdecd310 100644
--- a/drivers/net/ethernet/ti/davinci_cpdma.c
+++ b/drivers/net/ethernet/ti/davinci_cpdma.c
@@ -158,9 +158,9 @@ cpdma_desc_pool_create(struct device *dev, u32 phys, u32 hw_addr,
158 int bitmap_size; 158 int bitmap_size;
159 struct cpdma_desc_pool *pool; 159 struct cpdma_desc_pool *pool;
160 160
161 pool = kzalloc(sizeof(*pool), GFP_KERNEL); 161 pool = devm_kzalloc(dev, sizeof(*pool), GFP_KERNEL);
162 if (!pool) 162 if (!pool)
163 return NULL; 163 goto fail;
164 164
165 spin_lock_init(&pool->lock); 165 spin_lock_init(&pool->lock);
166 166
@@ -170,7 +170,7 @@ cpdma_desc_pool_create(struct device *dev, u32 phys, u32 hw_addr,
170 pool->num_desc = size / pool->desc_size; 170 pool->num_desc = size / pool->desc_size;
171 171
172 bitmap_size = (pool->num_desc / BITS_PER_LONG) * sizeof(long); 172 bitmap_size = (pool->num_desc / BITS_PER_LONG) * sizeof(long);
173 pool->bitmap = kzalloc(bitmap_size, GFP_KERNEL); 173 pool->bitmap = devm_kzalloc(dev, bitmap_size, GFP_KERNEL);
174 if (!pool->bitmap) 174 if (!pool->bitmap)
175 goto fail; 175 goto fail;
176 176
@@ -187,10 +187,7 @@ cpdma_desc_pool_create(struct device *dev, u32 phys, u32 hw_addr,
187 187
188 if (pool->iomap) 188 if (pool->iomap)
189 return pool; 189 return pool;
190
191fail: 190fail:
192 kfree(pool->bitmap);
193 kfree(pool);
194 return NULL; 191 return NULL;
195} 192}
196 193
@@ -203,7 +200,6 @@ static void cpdma_desc_pool_destroy(struct cpdma_desc_pool *pool)
203 200
204 spin_lock_irqsave(&pool->lock, flags); 201 spin_lock_irqsave(&pool->lock, flags);
205 WARN_ON(pool->used_desc); 202 WARN_ON(pool->used_desc);
206 kfree(pool->bitmap);
207 if (pool->cpumap) { 203 if (pool->cpumap) {
208 dma_free_coherent(pool->dev, pool->mem_size, pool->cpumap, 204 dma_free_coherent(pool->dev, pool->mem_size, pool->cpumap,
209 pool->phys); 205 pool->phys);
@@ -211,7 +207,6 @@ static void cpdma_desc_pool_destroy(struct cpdma_desc_pool *pool)
211 iounmap(pool->iomap); 207 iounmap(pool->iomap);
212 } 208 }
213 spin_unlock_irqrestore(&pool->lock, flags); 209 spin_unlock_irqrestore(&pool->lock, flags);
214 kfree(pool);
215} 210}
216 211
217static inline dma_addr_t desc_phys(struct cpdma_desc_pool *pool, 212static inline dma_addr_t desc_phys(struct cpdma_desc_pool *pool,
@@ -276,7 +271,7 @@ struct cpdma_ctlr *cpdma_ctlr_create(struct cpdma_params *params)
276{ 271{
277 struct cpdma_ctlr *ctlr; 272 struct cpdma_ctlr *ctlr;
278 273
279 ctlr = kzalloc(sizeof(*ctlr), GFP_KERNEL); 274 ctlr = devm_kzalloc(params->dev, sizeof(*ctlr), GFP_KERNEL);
280 if (!ctlr) 275 if (!ctlr)
281 return NULL; 276 return NULL;
282 277
@@ -468,7 +463,6 @@ int cpdma_ctlr_destroy(struct cpdma_ctlr *ctlr)
468 463
469 cpdma_desc_pool_destroy(ctlr->pool); 464 cpdma_desc_pool_destroy(ctlr->pool);
470 spin_unlock_irqrestore(&ctlr->lock, flags); 465 spin_unlock_irqrestore(&ctlr->lock, flags);
471 kfree(ctlr);
472 return ret; 466 return ret;
473} 467}
474EXPORT_SYMBOL_GPL(cpdma_ctlr_destroy); 468EXPORT_SYMBOL_GPL(cpdma_ctlr_destroy);
@@ -507,21 +501,22 @@ struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num,
507 cpdma_handler_fn handler) 501 cpdma_handler_fn handler)
508{ 502{
509 struct cpdma_chan *chan; 503 struct cpdma_chan *chan;
510 int ret, offset = (chan_num % CPDMA_MAX_CHANNELS) * 4; 504 int offset = (chan_num % CPDMA_MAX_CHANNELS) * 4;
511 unsigned long flags; 505 unsigned long flags;
512 506
513 if (__chan_linear(chan_num) >= ctlr->num_chan) 507 if (__chan_linear(chan_num) >= ctlr->num_chan)
514 return NULL; 508 return NULL;
515 509
516 ret = -ENOMEM; 510 chan = devm_kzalloc(ctlr->dev, sizeof(*chan), GFP_KERNEL);
517 chan = kzalloc(sizeof(*chan), GFP_KERNEL);
518 if (!chan) 511 if (!chan)
519 goto err_chan_alloc; 512 return ERR_PTR(-ENOMEM);
520 513
521 spin_lock_irqsave(&ctlr->lock, flags); 514 spin_lock_irqsave(&ctlr->lock, flags);
522 ret = -EBUSY; 515 if (ctlr->channels[chan_num]) {
523 if (ctlr->channels[chan_num]) 516 spin_unlock_irqrestore(&ctlr->lock, flags);
524 goto err_chan_busy; 517 devm_kfree(ctlr->dev, chan);
518 return ERR_PTR(-EBUSY);
519 }
525 520
526 chan->ctlr = ctlr; 521 chan->ctlr = ctlr;
527 chan->state = CPDMA_STATE_IDLE; 522 chan->state = CPDMA_STATE_IDLE;
@@ -551,12 +546,6 @@ struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num,
551 ctlr->channels[chan_num] = chan; 546 ctlr->channels[chan_num] = chan;
552 spin_unlock_irqrestore(&ctlr->lock, flags); 547 spin_unlock_irqrestore(&ctlr->lock, flags);
553 return chan; 548 return chan;
554
555err_chan_busy:
556 spin_unlock_irqrestore(&ctlr->lock, flags);
557 kfree(chan);
558err_chan_alloc:
559 return ERR_PTR(ret);
560} 549}
561EXPORT_SYMBOL_GPL(cpdma_chan_create); 550EXPORT_SYMBOL_GPL(cpdma_chan_create);
562 551