diff options
| -rw-r--r-- | drivers/net/irda/sh_irda.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/drivers/net/irda/sh_irda.c b/drivers/net/irda/sh_irda.c index b86f408bbb7e..d275e276e742 100644 --- a/drivers/net/irda/sh_irda.c +++ b/drivers/net/irda/sh_irda.c | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include <linux/interrupt.h> | 26 | #include <linux/interrupt.h> |
| 27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
| 28 | #include <linux/platform_device.h> | 28 | #include <linux/platform_device.h> |
| 29 | #include <linux/pm_runtime.h> | ||
| 29 | #include <linux/clk.h> | 30 | #include <linux/clk.h> |
| 30 | #include <net/irda/wrapper.h> | 31 | #include <net/irda/wrapper.h> |
| 31 | #include <net/irda/irda_device.h> | 32 | #include <net/irda/irda_device.h> |
| @@ -145,7 +146,7 @@ struct sh_irda_xir_func { | |||
| 145 | struct sh_irda_self { | 146 | struct sh_irda_self { |
| 146 | void __iomem *membase; | 147 | void __iomem *membase; |
| 147 | unsigned int irq; | 148 | unsigned int irq; |
| 148 | struct clk *clk; | 149 | struct platform_device *pdev; |
| 149 | 150 | ||
| 150 | struct net_device *ndev; | 151 | struct net_device *ndev; |
| 151 | 152 | ||
| @@ -694,7 +695,7 @@ static int sh_irda_open(struct net_device *ndev) | |||
| 694 | struct sh_irda_self *self = netdev_priv(ndev); | 695 | struct sh_irda_self *self = netdev_priv(ndev); |
| 695 | int err; | 696 | int err; |
| 696 | 697 | ||
| 697 | clk_enable(self->clk); | 698 | pm_runtime_get_sync(&self->pdev->dev); |
| 698 | err = sh_irda_crc_init(self); | 699 | err = sh_irda_crc_init(self); |
| 699 | if (err) | 700 | if (err) |
| 700 | goto open_err; | 701 | goto open_err; |
| @@ -718,7 +719,7 @@ static int sh_irda_open(struct net_device *ndev) | |||
| 718 | return 0; | 719 | return 0; |
| 719 | 720 | ||
| 720 | open_err: | 721 | open_err: |
| 721 | clk_disable(self->clk); | 722 | pm_runtime_put_sync(&self->pdev->dev); |
| 722 | 723 | ||
| 723 | return err; | 724 | return err; |
| 724 | } | 725 | } |
| @@ -734,6 +735,7 @@ static int sh_irda_stop(struct net_device *ndev) | |||
| 734 | } | 735 | } |
| 735 | 736 | ||
| 736 | netif_stop_queue(ndev); | 737 | netif_stop_queue(ndev); |
| 738 | pm_runtime_put_sync(&self->pdev->dev); | ||
| 737 | 739 | ||
| 738 | dev_info(&ndev->dev, "stoped\n"); | 740 | dev_info(&ndev->dev, "stoped\n"); |
| 739 | 741 | ||
| @@ -786,11 +788,8 @@ static int __devinit sh_irda_probe(struct platform_device *pdev) | |||
| 786 | if (err) | 788 | if (err) |
| 787 | goto err_mem_2; | 789 | goto err_mem_2; |
| 788 | 790 | ||
| 789 | self->clk = clk_get(&pdev->dev, NULL); | 791 | self->pdev = pdev; |
| 790 | if (IS_ERR(self->clk)) { | 792 | pm_runtime_enable(&pdev->dev); |
| 791 | dev_err(&pdev->dev, "cannot get irda clock\n"); | ||
| 792 | goto err_mem_3; | ||
| 793 | } | ||
| 794 | 793 | ||
| 795 | irda_init_max_qos_capabilies(&self->qos); | 794 | irda_init_max_qos_capabilies(&self->qos); |
| 796 | 795 | ||
| @@ -820,8 +819,7 @@ static int __devinit sh_irda_probe(struct platform_device *pdev) | |||
| 820 | goto exit; | 819 | goto exit; |
| 821 | 820 | ||
| 822 | err_mem_4: | 821 | err_mem_4: |
| 823 | clk_put(self->clk); | 822 | pm_runtime_disable(&pdev->dev); |
| 824 | err_mem_3: | ||
| 825 | sh_irda_remove_iobuf(self); | 823 | sh_irda_remove_iobuf(self); |
| 826 | err_mem_2: | 824 | err_mem_2: |
| 827 | iounmap(self->membase); | 825 | iounmap(self->membase); |
| @@ -840,7 +838,7 @@ static int __devexit sh_irda_remove(struct platform_device *pdev) | |||
| 840 | return 0; | 838 | return 0; |
| 841 | 839 | ||
| 842 | unregister_netdev(ndev); | 840 | unregister_netdev(ndev); |
| 843 | clk_put(self->clk); | 841 | pm_runtime_disable(&pdev->dev); |
| 844 | sh_irda_remove_iobuf(self); | 842 | sh_irda_remove_iobuf(self); |
| 845 | iounmap(self->membase); | 843 | iounmap(self->membase); |
| 846 | free_netdev(ndev); | 844 | free_netdev(ndev); |
| @@ -849,11 +847,29 @@ static int __devexit sh_irda_remove(struct platform_device *pdev) | |||
| 849 | return 0; | 847 | return 0; |
| 850 | } | 848 | } |
| 851 | 849 | ||
| 850 | static int sh_irda_runtime_nop(struct device *dev) | ||
| 851 | { | ||
| 852 | /* Runtime PM callback shared between ->runtime_suspend() | ||
| 853 | * and ->runtime_resume(). Simply returns success. | ||
| 854 | * | ||
| 855 | * This driver re-initializes all registers after | ||
| 856 | * pm_runtime_get_sync() anyway so there is no need | ||
| 857 | * to save and restore registers here. | ||
| 858 | */ | ||
| 859 | return 0; | ||
| 860 | } | ||
| 861 | |||
| 862 | static const struct dev_pm_ops sh_irda_pm_ops = { | ||
| 863 | .runtime_suspend = sh_irda_runtime_nop, | ||
| 864 | .runtime_resume = sh_irda_runtime_nop, | ||
| 865 | }; | ||
| 866 | |||
| 852 | static struct platform_driver sh_irda_driver = { | 867 | static struct platform_driver sh_irda_driver = { |
| 853 | .probe = sh_irda_probe, | 868 | .probe = sh_irda_probe, |
| 854 | .remove = __devexit_p(sh_irda_remove), | 869 | .remove = __devexit_p(sh_irda_remove), |
| 855 | .driver = { | 870 | .driver = { |
| 856 | .name = DRIVER_NAME, | 871 | .name = DRIVER_NAME, |
| 872 | .pm = &sh_irda_pm_ops, | ||
| 857 | }, | 873 | }, |
| 858 | }; | 874 | }; |
| 859 | 875 | ||
