diff options
author | Suman Anna <s-anna@ti.com> | 2014-06-24 20:43:37 -0400 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2014-07-29 04:55:09 -0400 |
commit | 28299a47f40af6af40c316989867cc1f56ec827b (patch) | |
tree | 95a197911e1796099fa883460cdae9ea694e4888 /drivers/mailbox | |
parent | cbf14f3ab9bd6295b345fc812f08ddd844fb183e (diff) |
mailbox/omap: use devm_* interfaces
Use the various devm_ interfaces to simplify the cleanup in
probe and remove functions in OMAP2+ mailbox driver.
Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'drivers/mailbox')
-rw-r--r-- | drivers/mailbox/mailbox-omap2.c | 64 |
1 files changed, 19 insertions, 45 deletions
diff --git a/drivers/mailbox/mailbox-omap2.c b/drivers/mailbox/mailbox-omap2.c index 42d2b893ea67..75fbc9072d01 100644 --- a/drivers/mailbox/mailbox-omap2.c +++ b/drivers/mailbox/mailbox-omap2.c | |||
@@ -236,23 +236,24 @@ static int omap2_mbox_probe(struct platform_device *pdev) | |||
236 | } | 236 | } |
237 | 237 | ||
238 | /* allocate one extra for marking end of list */ | 238 | /* allocate one extra for marking end of list */ |
239 | list = kzalloc((pdata->info_cnt + 1) * sizeof(*list), GFP_KERNEL); | 239 | list = devm_kzalloc(&pdev->dev, (pdata->info_cnt + 1) * sizeof(*list), |
240 | GFP_KERNEL); | ||
240 | if (!list) | 241 | if (!list) |
241 | return -ENOMEM; | 242 | return -ENOMEM; |
242 | 243 | ||
243 | mboxblk = mbox = kzalloc(pdata->info_cnt * sizeof(*mbox), GFP_KERNEL); | 244 | mboxblk = devm_kzalloc(&pdev->dev, pdata->info_cnt * sizeof(*mbox), |
244 | if (!mboxblk) { | 245 | GFP_KERNEL); |
245 | ret = -ENOMEM; | 246 | if (!mboxblk) |
246 | goto free_list; | 247 | return -ENOMEM; |
247 | } | ||
248 | 248 | ||
249 | privblk = priv = kzalloc(pdata->info_cnt * sizeof(*priv), GFP_KERNEL); | 249 | privblk = devm_kzalloc(&pdev->dev, pdata->info_cnt * sizeof(*priv), |
250 | if (!privblk) { | 250 | GFP_KERNEL); |
251 | ret = -ENOMEM; | 251 | if (!privblk) |
252 | goto free_mboxblk; | 252 | return -ENOMEM; |
253 | } | ||
254 | 253 | ||
255 | info = pdata->info; | 254 | info = pdata->info; |
255 | mbox = mboxblk; | ||
256 | priv = privblk; | ||
256 | for (i = 0; i < pdata->info_cnt; i++, info++, priv++) { | 257 | for (i = 0; i < pdata->info_cnt; i++, info++, priv++) { |
257 | priv->tx_fifo.msg = MAILBOX_MESSAGE(info->tx_id); | 258 | priv->tx_fifo.msg = MAILBOX_MESSAGE(info->tx_id); |
258 | priv->tx_fifo.fifo_stat = MAILBOX_FIFOSTATUS(info->tx_id); | 259 | priv->tx_fifo.fifo_stat = MAILBOX_FIFOSTATUS(info->tx_id); |
@@ -276,55 +277,28 @@ static int omap2_mbox_probe(struct platform_device *pdev) | |||
276 | mbox->name = info->name; | 277 | mbox->name = info->name; |
277 | mbox->ops = &omap2_mbox_ops; | 278 | mbox->ops = &omap2_mbox_ops; |
278 | mbox->irq = platform_get_irq(pdev, info->irq_id); | 279 | mbox->irq = platform_get_irq(pdev, info->irq_id); |
279 | if (mbox->irq < 0) { | 280 | if (mbox->irq < 0) |
280 | ret = mbox->irq; | 281 | return mbox->irq; |
281 | goto free_privblk; | ||
282 | } | ||
283 | list[i] = mbox++; | 282 | list[i] = mbox++; |
284 | } | 283 | } |
285 | 284 | ||
286 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 285 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
287 | if (!mem) { | 286 | mbox_base = devm_ioremap_resource(&pdev->dev, mem); |
288 | ret = -ENOENT; | 287 | if (IS_ERR(mbox_base)) |
289 | goto free_privblk; | 288 | return PTR_ERR(mbox_base); |
290 | } | ||
291 | |||
292 | mbox_base = ioremap(mem->start, resource_size(mem)); | ||
293 | if (!mbox_base) { | ||
294 | ret = -ENOMEM; | ||
295 | goto free_privblk; | ||
296 | } | ||
297 | 289 | ||
298 | ret = omap_mbox_register(&pdev->dev, list); | 290 | ret = omap_mbox_register(&pdev->dev, list); |
299 | if (ret) | 291 | if (ret) |
300 | goto unmap_mbox; | 292 | return ret; |
293 | |||
301 | platform_set_drvdata(pdev, list); | 294 | platform_set_drvdata(pdev, list); |
302 | 295 | ||
303 | return 0; | 296 | return 0; |
304 | |||
305 | unmap_mbox: | ||
306 | iounmap(mbox_base); | ||
307 | free_privblk: | ||
308 | kfree(privblk); | ||
309 | free_mboxblk: | ||
310 | kfree(mboxblk); | ||
311 | free_list: | ||
312 | kfree(list); | ||
313 | return ret; | ||
314 | } | 297 | } |
315 | 298 | ||
316 | static int omap2_mbox_remove(struct platform_device *pdev) | 299 | static int omap2_mbox_remove(struct platform_device *pdev) |
317 | { | 300 | { |
318 | struct omap_mbox2_priv *privblk; | ||
319 | struct omap_mbox **list = platform_get_drvdata(pdev); | ||
320 | struct omap_mbox *mboxblk = list[0]; | ||
321 | |||
322 | privblk = mboxblk->priv; | ||
323 | omap_mbox_unregister(); | 301 | omap_mbox_unregister(); |
324 | iounmap(mbox_base); | ||
325 | kfree(privblk); | ||
326 | kfree(mboxblk); | ||
327 | kfree(list); | ||
328 | 302 | ||
329 | return 0; | 303 | return 0; |
330 | } | 304 | } |