diff options
author | Felipe Balbi <balbi@ti.com> | 2012-07-25 08:05:30 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-16 12:58:43 -0400 |
commit | 19afea50f12b2dc5e2aaca488d1733188d06a619 (patch) | |
tree | a464e1d0294fbbfc3f172ab0a54b69d5f1650ad1 /drivers/w1/masters | |
parent | 8650bbb58062f183ce5d983b6ba4ddd1e9b67f4a (diff) |
w1: omap-hdq: convert to devm_* functions
this lets us remove a bit of boilerplate code.
Signed-off-by: Felipe Balbi <balbi@ti.com>
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/w1/masters')
-rw-r--r-- | drivers/w1/masters/omap_hdq.c | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c index 0427c2c60eab..5c13e7df9c69 100644 --- a/drivers/w1/masters/omap_hdq.c +++ b/drivers/w1/masters/omap_hdq.c | |||
@@ -544,33 +544,31 @@ static void omap_w1_write_byte(void *_hdq, u8 byte) | |||
544 | 544 | ||
545 | static int __devinit omap_hdq_probe(struct platform_device *pdev) | 545 | static int __devinit omap_hdq_probe(struct platform_device *pdev) |
546 | { | 546 | { |
547 | struct device *dev = &pdev->dev; | ||
547 | struct hdq_data *hdq_data; | 548 | struct hdq_data *hdq_data; |
548 | struct resource *res; | 549 | struct resource *res; |
549 | int ret, irq; | 550 | int ret, irq; |
550 | u8 rev; | 551 | u8 rev; |
551 | 552 | ||
552 | hdq_data = kmalloc(sizeof(*hdq_data), GFP_KERNEL); | 553 | hdq_data = devm_kzalloc(dev, sizeof(*hdq_data), GFP_KERNEL); |
553 | if (!hdq_data) { | 554 | if (!hdq_data) { |
554 | dev_dbg(&pdev->dev, "unable to allocate memory\n"); | 555 | dev_dbg(&pdev->dev, "unable to allocate memory\n"); |
555 | ret = -ENOMEM; | 556 | return -ENOMEM; |
556 | goto err_kmalloc; | ||
557 | } | 557 | } |
558 | 558 | ||
559 | hdq_data->dev = &pdev->dev; | 559 | hdq_data->dev = dev; |
560 | platform_set_drvdata(pdev, hdq_data); | 560 | platform_set_drvdata(pdev, hdq_data); |
561 | 561 | ||
562 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 562 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
563 | if (!res) { | 563 | if (!res) { |
564 | dev_dbg(&pdev->dev, "unable to get resource\n"); | 564 | dev_dbg(&pdev->dev, "unable to get resource\n"); |
565 | ret = -ENXIO; | 565 | return -ENXIO; |
566 | goto err_resource; | ||
567 | } | 566 | } |
568 | 567 | ||
569 | hdq_data->hdq_base = ioremap(res->start, resource_size(res)); | 568 | hdq_data->hdq_base = devm_request_and_ioremap(dev, res); |
570 | if (!hdq_data->hdq_base) { | 569 | if (!hdq_data->hdq_base) { |
571 | dev_dbg(&pdev->dev, "ioremap failed\n"); | 570 | dev_dbg(&pdev->dev, "ioremap failed\n"); |
572 | ret = -EINVAL; | 571 | return -ENOMEM; |
573 | goto err_ioremap; | ||
574 | } | 572 | } |
575 | 573 | ||
576 | hdq_data->hdq_usecount = 0; | 574 | hdq_data->hdq_usecount = 0; |
@@ -591,7 +589,8 @@ static int __devinit omap_hdq_probe(struct platform_device *pdev) | |||
591 | goto err_irq; | 589 | goto err_irq; |
592 | } | 590 | } |
593 | 591 | ||
594 | ret = request_irq(irq, hdq_isr, IRQF_DISABLED, "omap_hdq", hdq_data); | 592 | ret = devm_request_irq(dev, irq, hdq_isr, IRQF_DISABLED, |
593 | "omap_hdq", hdq_data); | ||
595 | if (ret < 0) { | 594 | if (ret < 0) { |
596 | dev_dbg(&pdev->dev, "could not request irq\n"); | 595 | dev_dbg(&pdev->dev, "could not request irq\n"); |
597 | goto err_irq; | 596 | goto err_irq; |
@@ -616,16 +615,7 @@ err_irq: | |||
616 | err_w1: | 615 | err_w1: |
617 | pm_runtime_disable(&pdev->dev); | 616 | pm_runtime_disable(&pdev->dev); |
618 | 617 | ||
619 | iounmap(hdq_data->hdq_base); | ||
620 | |||
621 | err_ioremap: | ||
622 | err_resource: | ||
623 | platform_set_drvdata(pdev, NULL); | ||
624 | kfree(hdq_data); | ||
625 | |||
626 | err_kmalloc: | ||
627 | return ret; | 618 | return ret; |
628 | |||
629 | } | 619 | } |
630 | 620 | ||
631 | static int __devexit omap_hdq_remove(struct platform_device *pdev) | 621 | static int __devexit omap_hdq_remove(struct platform_device *pdev) |
@@ -644,10 +634,6 @@ static int __devexit omap_hdq_remove(struct platform_device *pdev) | |||
644 | 634 | ||
645 | /* remove module dependency */ | 635 | /* remove module dependency */ |
646 | pm_runtime_disable(&pdev->dev); | 636 | pm_runtime_disable(&pdev->dev); |
647 | free_irq(INT_24XX_HDQ_IRQ, hdq_data); | ||
648 | platform_set_drvdata(pdev, NULL); | ||
649 | iounmap(hdq_data->hdq_base); | ||
650 | kfree(hdq_data); | ||
651 | 637 | ||
652 | return 0; | 638 | return 0; |
653 | } | 639 | } |