diff options
| author | Julia Lawall <Julia.Lawall@lip6.fr> | 2012-12-06 18:15:23 -0500 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-01-16 02:38:43 -0500 |
| commit | eea2172e6915a92cab1d3a79a4961e14a3c388ff (patch) | |
| tree | d37dfa0ae8ab771df7ec8227d52a7a6dfc4c102e /drivers/w1/masters | |
| parent | feee830394cab4e697d2204da6d10a606619de3d (diff) | |
drivers/w1/masters/ds1wm.c: use devm_ functions
The various devm_ functions allocate memory that is released when a driver
detaches. This patch uses these functions for data that is allocated in
the probe function of a platform device and is only freed in the remove
function.
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/w1/masters')
| -rw-r--r-- | drivers/w1/masters/ds1wm.c | 52 |
1 files changed, 18 insertions, 34 deletions
diff --git a/drivers/w1/masters/ds1wm.c b/drivers/w1/masters/ds1wm.c index 7c294f4dc0ed..96cab6ac2b4e 100644 --- a/drivers/w1/masters/ds1wm.c +++ b/drivers/w1/masters/ds1wm.c | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | 13 | ||
| 14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
| 15 | #include <linux/interrupt.h> | 15 | #include <linux/interrupt.h> |
| 16 | #include <linux/io.h> | ||
| 16 | #include <linux/irq.h> | 17 | #include <linux/irq.h> |
| 17 | #include <linux/pm.h> | 18 | #include <linux/pm.h> |
| 18 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
| @@ -459,43 +460,34 @@ static int ds1wm_probe(struct platform_device *pdev) | |||
| 459 | if (!pdev) | 460 | if (!pdev) |
| 460 | return -ENODEV; | 461 | return -ENODEV; |
| 461 | 462 | ||
| 462 | ds1wm_data = kzalloc(sizeof(*ds1wm_data), GFP_KERNEL); | 463 | ds1wm_data = devm_kzalloc(&pdev->dev, sizeof(*ds1wm_data), GFP_KERNEL); |
| 463 | if (!ds1wm_data) | 464 | if (!ds1wm_data) |
| 464 | return -ENOMEM; | 465 | return -ENOMEM; |
| 465 | 466 | ||
| 466 | platform_set_drvdata(pdev, ds1wm_data); | 467 | platform_set_drvdata(pdev, ds1wm_data); |
| 467 | 468 | ||
| 468 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 469 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 469 | if (!res) { | 470 | if (!res) |
| 470 | ret = -ENXIO; | 471 | return -ENXIO; |
| 471 | goto err0; | 472 | ds1wm_data->map = devm_ioremap(&pdev->dev, res->start, |
| 472 | } | 473 | resource_size(res)); |
| 473 | ds1wm_data->map = ioremap(res->start, resource_size(res)); | 474 | if (!ds1wm_data->map) |
| 474 | if (!ds1wm_data->map) { | 475 | return -ENOMEM; |
| 475 | ret = -ENOMEM; | ||
| 476 | goto err0; | ||
| 477 | } | ||
| 478 | 476 | ||
| 479 | /* calculate bus shift from mem resource */ | 477 | /* calculate bus shift from mem resource */ |
| 480 | ds1wm_data->bus_shift = resource_size(res) >> 3; | 478 | ds1wm_data->bus_shift = resource_size(res) >> 3; |
| 481 | 479 | ||
| 482 | ds1wm_data->pdev = pdev; | 480 | ds1wm_data->pdev = pdev; |
| 483 | ds1wm_data->cell = mfd_get_cell(pdev); | 481 | ds1wm_data->cell = mfd_get_cell(pdev); |
| 484 | if (!ds1wm_data->cell) { | 482 | if (!ds1wm_data->cell) |
| 485 | ret = -ENODEV; | 483 | return -ENODEV; |
| 486 | goto err1; | ||
| 487 | } | ||
| 488 | plat = pdev->dev.platform_data; | 484 | plat = pdev->dev.platform_data; |
| 489 | if (!plat) { | 485 | if (!plat) |
| 490 | ret = -ENODEV; | 486 | return -ENODEV; |
| 491 | goto err1; | ||
| 492 | } | ||
| 493 | 487 | ||
| 494 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 488 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
| 495 | if (!res) { | 489 | if (!res) |
| 496 | ret = -ENXIO; | 490 | return -ENXIO; |
| 497 | goto err1; | ||
| 498 | } | ||
| 499 | ds1wm_data->irq = res->start; | 491 | ds1wm_data->irq = res->start; |
| 500 | ds1wm_data->int_en_reg_none = (plat->active_high ? DS1WM_INTEN_IAS : 0); | 492 | ds1wm_data->int_en_reg_none = (plat->active_high ? DS1WM_INTEN_IAS : 0); |
| 501 | ds1wm_data->reset_recover_delay = plat->reset_recover_delay; | 493 | ds1wm_data->reset_recover_delay = plat->reset_recover_delay; |
| @@ -505,10 +497,10 @@ static int ds1wm_probe(struct platform_device *pdev) | |||
| 505 | if (res->flags & IORESOURCE_IRQ_LOWEDGE) | 497 | if (res->flags & IORESOURCE_IRQ_LOWEDGE) |
| 506 | irq_set_irq_type(ds1wm_data->irq, IRQ_TYPE_EDGE_FALLING); | 498 | irq_set_irq_type(ds1wm_data->irq, IRQ_TYPE_EDGE_FALLING); |
| 507 | 499 | ||
| 508 | ret = request_irq(ds1wm_data->irq, ds1wm_isr, | 500 | ret = devm_request_irq(&pdev->dev, ds1wm_data->irq, ds1wm_isr, |
| 509 | IRQF_DISABLED | IRQF_SHARED, "ds1wm", ds1wm_data); | 501 | IRQF_DISABLED | IRQF_SHARED, "ds1wm", ds1wm_data); |
| 510 | if (ret) | 502 | if (ret) |
| 511 | goto err1; | 503 | return ret; |
| 512 | 504 | ||
| 513 | ds1wm_up(ds1wm_data); | 505 | ds1wm_up(ds1wm_data); |
| 514 | 506 | ||
| @@ -516,17 +508,12 @@ static int ds1wm_probe(struct platform_device *pdev) | |||
| 516 | 508 | ||
| 517 | ret = w1_add_master_device(&ds1wm_master); | 509 | ret = w1_add_master_device(&ds1wm_master); |
| 518 | if (ret) | 510 | if (ret) |
| 519 | goto err2; | 511 | goto err; |
| 520 | 512 | ||
| 521 | return 0; | 513 | return 0; |
| 522 | 514 | ||
| 523 | err2: | 515 | err: |
| 524 | ds1wm_down(ds1wm_data); | 516 | ds1wm_down(ds1wm_data); |
| 525 | free_irq(ds1wm_data->irq, ds1wm_data); | ||
| 526 | err1: | ||
| 527 | iounmap(ds1wm_data->map); | ||
| 528 | err0: | ||
| 529 | kfree(ds1wm_data); | ||
| 530 | 517 | ||
| 531 | return ret; | 518 | return ret; |
| 532 | } | 519 | } |
| @@ -560,9 +547,6 @@ static int ds1wm_remove(struct platform_device *pdev) | |||
| 560 | 547 | ||
| 561 | w1_remove_master_device(&ds1wm_master); | 548 | w1_remove_master_device(&ds1wm_master); |
| 562 | ds1wm_down(ds1wm_data); | 549 | ds1wm_down(ds1wm_data); |
| 563 | free_irq(ds1wm_data->irq, ds1wm_data); | ||
| 564 | iounmap(ds1wm_data->map); | ||
| 565 | kfree(ds1wm_data); | ||
| 566 | 550 | ||
| 567 | return 0; | 551 | return 0; |
| 568 | } | 552 | } |
