diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2011-03-22 16:19:28 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2011-03-23 05:57:37 -0400 |
commit | a696b89c582e3201ef10bfb0d0b3594e29b75e0f (patch) | |
tree | f9dbbc6e14d4576c65298e365ad63f24626fdbcd /drivers/sh/clk | |
parent | f47adbb988aa4436135799fd26710bff2c1b1eb6 (diff) |
sh: Use struct syscore_ops instead of sysdevs
Convert the SuperH clocks framework and shared interrupt handling
code to using struct syscore_ops instead of a sysdev classes and
sysdevs for power managment.
This reduces the code size significantly and simplifies it. The
optimizations causing things not to be restored after creating a
hibernation image are removed, but they might lead to undesirable
effects during resume from hibernation (e.g. the clocks would be left
as the boot kernel set them, which might be not the same way as the
hibernated kernel had seen them before the hibernation).
This also is necessary for removing sysdevs from the kernel entirely
in the future.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'drivers/sh/clk')
-rw-r--r-- | drivers/sh/clk/core.c | 68 |
1 files changed, 18 insertions, 50 deletions
diff --git a/drivers/sh/clk/core.c b/drivers/sh/clk/core.c index 5f63c3b83828..4f64183b27fa 100644 --- a/drivers/sh/clk/core.c +++ b/drivers/sh/clk/core.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | #include <linux/mutex.h> | 22 | #include <linux/mutex.h> |
23 | #include <linux/list.h> | 23 | #include <linux/list.h> |
24 | #include <linux/sysdev.h> | 24 | #include <linux/syscore_ops.h> |
25 | #include <linux/seq_file.h> | 25 | #include <linux/seq_file.h> |
26 | #include <linux/err.h> | 26 | #include <linux/err.h> |
27 | #include <linux/io.h> | 27 | #include <linux/io.h> |
@@ -630,68 +630,36 @@ long clk_round_parent(struct clk *clk, unsigned long target, | |||
630 | EXPORT_SYMBOL_GPL(clk_round_parent); | 630 | EXPORT_SYMBOL_GPL(clk_round_parent); |
631 | 631 | ||
632 | #ifdef CONFIG_PM | 632 | #ifdef CONFIG_PM |
633 | static int clks_sysdev_suspend(struct sys_device *dev, pm_message_t state) | 633 | static void clks_core_resume(void) |
634 | { | 634 | { |
635 | static pm_message_t prev_state; | ||
636 | struct clk *clkp; | 635 | struct clk *clkp; |
637 | 636 | ||
638 | switch (state.event) { | 637 | list_for_each_entry(clkp, &clock_list, node) { |
639 | case PM_EVENT_ON: | 638 | if (likely(clkp->ops)) { |
640 | /* Resumeing from hibernation */ | 639 | unsigned long rate = clkp->rate; |
641 | if (prev_state.event != PM_EVENT_FREEZE) | 640 | |
642 | break; | 641 | if (likely(clkp->ops->set_parent)) |
643 | 642 | clkp->ops->set_parent(clkp, | |
644 | list_for_each_entry(clkp, &clock_list, node) { | 643 | clkp->parent); |
645 | if (likely(clkp->ops)) { | 644 | if (likely(clkp->ops->set_rate)) |
646 | unsigned long rate = clkp->rate; | 645 | clkp->ops->set_rate(clkp, rate); |
647 | 646 | else if (likely(clkp->ops->recalc)) | |
648 | if (likely(clkp->ops->set_parent)) | 647 | clkp->rate = clkp->ops->recalc(clkp); |
649 | clkp->ops->set_parent(clkp, | ||
650 | clkp->parent); | ||
651 | if (likely(clkp->ops->set_rate)) | ||
652 | clkp->ops->set_rate(clkp, rate); | ||
653 | else if (likely(clkp->ops->recalc)) | ||
654 | clkp->rate = clkp->ops->recalc(clkp); | ||
655 | } | ||
656 | } | 648 | } |
657 | break; | ||
658 | case PM_EVENT_FREEZE: | ||
659 | break; | ||
660 | case PM_EVENT_SUSPEND: | ||
661 | break; | ||
662 | } | 649 | } |
663 | |||
664 | prev_state = state; | ||
665 | return 0; | ||
666 | } | ||
667 | |||
668 | static int clks_sysdev_resume(struct sys_device *dev) | ||
669 | { | ||
670 | return clks_sysdev_suspend(dev, PMSG_ON); | ||
671 | } | 650 | } |
672 | 651 | ||
673 | static struct sysdev_class clks_sysdev_class = { | 652 | static struct syscore_ops clks_syscore_ops = { |
674 | .name = "clks", | 653 | .resume = clks_core_resume, |
675 | }; | ||
676 | |||
677 | static struct sysdev_driver clks_sysdev_driver = { | ||
678 | .suspend = clks_sysdev_suspend, | ||
679 | .resume = clks_sysdev_resume, | ||
680 | }; | ||
681 | |||
682 | static struct sys_device clks_sysdev_dev = { | ||
683 | .cls = &clks_sysdev_class, | ||
684 | }; | 654 | }; |
685 | 655 | ||
686 | static int __init clk_sysdev_init(void) | 656 | static int __init clk_syscore_init(void) |
687 | { | 657 | { |
688 | sysdev_class_register(&clks_sysdev_class); | 658 | register_syscore_ops(&clks_syscore_ops); |
689 | sysdev_driver_register(&clks_sysdev_class, &clks_sysdev_driver); | ||
690 | sysdev_register(&clks_sysdev_dev); | ||
691 | 659 | ||
692 | return 0; | 660 | return 0; |
693 | } | 661 | } |
694 | subsys_initcall(clk_sysdev_init); | 662 | subsys_initcall(clk_syscore_init); |
695 | #endif | 663 | #endif |
696 | 664 | ||
697 | /* | 665 | /* |