diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2011-04-26 13:14:57 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2011-05-11 15:37:15 -0400 |
commit | f5a592f7d74e38c5007876c731e6bf5580072e63 (patch) | |
tree | 893e896facaf984087c950e744eb5e449c40f704 /arch/powerpc/sysdev | |
parent | f98bf4aa39ecce96020631cba910be094c87ac3c (diff) |
PM / PowerPC: Use struct syscore_ops instead of sysdevs for PM
Make some PowerPC architecture's code use struct syscore_ops
objects for power management instead of sysdev classes and sysdevs.
This simplifies the code and reduces the kernel's memory footprint.
It also is necessary for removing sysdevs from the kernel entirely in
the future.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'arch/powerpc/sysdev')
-rw-r--r-- | arch/powerpc/sysdev/ipic.c | 36 | ||||
-rw-r--r-- | arch/powerpc/sysdev/mpic.c | 48 |
2 files changed, 35 insertions, 49 deletions
diff --git a/arch/powerpc/sysdev/ipic.c b/arch/powerpc/sysdev/ipic.c index fa438be962b7..596554a8725e 100644 --- a/arch/powerpc/sysdev/ipic.c +++ b/arch/powerpc/sysdev/ipic.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/stddef.h> | 18 | #include <linux/stddef.h> |
19 | #include <linux/sched.h> | 19 | #include <linux/sched.h> |
20 | #include <linux/signal.h> | 20 | #include <linux/signal.h> |
21 | #include <linux/sysdev.h> | 21 | #include <linux/syscore_ops.h> |
22 | #include <linux/device.h> | 22 | #include <linux/device.h> |
23 | #include <linux/bootmem.h> | 23 | #include <linux/bootmem.h> |
24 | #include <linux/spinlock.h> | 24 | #include <linux/spinlock.h> |
@@ -902,7 +902,7 @@ static struct { | |||
902 | u32 sercr; | 902 | u32 sercr; |
903 | } ipic_saved_state; | 903 | } ipic_saved_state; |
904 | 904 | ||
905 | static int ipic_suspend(struct sys_device *sdev, pm_message_t state) | 905 | static int ipic_suspend(void) |
906 | { | 906 | { |
907 | struct ipic *ipic = primary_ipic; | 907 | struct ipic *ipic = primary_ipic; |
908 | 908 | ||
@@ -933,7 +933,7 @@ static int ipic_suspend(struct sys_device *sdev, pm_message_t state) | |||
933 | return 0; | 933 | return 0; |
934 | } | 934 | } |
935 | 935 | ||
936 | static int ipic_resume(struct sys_device *sdev) | 936 | static void ipic_resume(void) |
937 | { | 937 | { |
938 | struct ipic *ipic = primary_ipic; | 938 | struct ipic *ipic = primary_ipic; |
939 | 939 | ||
@@ -949,44 +949,26 @@ static int ipic_resume(struct sys_device *sdev) | |||
949 | ipic_write(ipic->regs, IPIC_SECNR, ipic_saved_state.secnr); | 949 | ipic_write(ipic->regs, IPIC_SECNR, ipic_saved_state.secnr); |
950 | ipic_write(ipic->regs, IPIC_SERMR, ipic_saved_state.sermr); | 950 | ipic_write(ipic->regs, IPIC_SERMR, ipic_saved_state.sermr); |
951 | ipic_write(ipic->regs, IPIC_SERCR, ipic_saved_state.sercr); | 951 | ipic_write(ipic->regs, IPIC_SERCR, ipic_saved_state.sercr); |
952 | |||
953 | return 0; | ||
954 | } | 952 | } |
955 | #else | 953 | #else |
956 | #define ipic_suspend NULL | 954 | #define ipic_suspend NULL |
957 | #define ipic_resume NULL | 955 | #define ipic_resume NULL |
958 | #endif | 956 | #endif |
959 | 957 | ||
960 | static struct sysdev_class ipic_sysclass = { | 958 | static struct syscore_ops ipic_syscore_ops = { |
961 | .name = "ipic", | ||
962 | .suspend = ipic_suspend, | 959 | .suspend = ipic_suspend, |
963 | .resume = ipic_resume, | 960 | .resume = ipic_resume, |
964 | }; | 961 | }; |
965 | 962 | ||
966 | static struct sys_device device_ipic = { | 963 | static int __init init_ipic_syscore(void) |
967 | .id = 0, | ||
968 | .cls = &ipic_sysclass, | ||
969 | }; | ||
970 | |||
971 | static int __init init_ipic_sysfs(void) | ||
972 | { | 964 | { |
973 | int rc; | ||
974 | |||
975 | if (!primary_ipic || !primary_ipic->regs) | 965 | if (!primary_ipic || !primary_ipic->regs) |
976 | return -ENODEV; | 966 | return -ENODEV; |
977 | printk(KERN_DEBUG "Registering ipic with sysfs...\n"); | ||
978 | 967 | ||
979 | rc = sysdev_class_register(&ipic_sysclass); | 968 | printk(KERN_DEBUG "Registering ipic system core operations\n"); |
980 | if (rc) { | 969 | register_syscore_ops(&ipic_syscore_ops); |
981 | printk(KERN_ERR "Failed registering ipic sys class\n"); | 970 | |
982 | return -ENODEV; | ||
983 | } | ||
984 | rc = sysdev_register(&device_ipic); | ||
985 | if (rc) { | ||
986 | printk(KERN_ERR "Failed registering ipic sys device\n"); | ||
987 | return -ENODEV; | ||
988 | } | ||
989 | return 0; | 971 | return 0; |
990 | } | 972 | } |
991 | 973 | ||
992 | subsys_initcall(init_ipic_sysfs); | 974 | subsys_initcall(init_ipic_syscore); |
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c index f91c065bed5a..7e5dc8f4984a 100644 --- a/arch/powerpc/sysdev/mpic.c +++ b/arch/powerpc/sysdev/mpic.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/spinlock.h> | 27 | #include <linux/spinlock.h> |
28 | #include <linux/pci.h> | 28 | #include <linux/pci.h> |
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #include <linux/syscore_ops.h> | ||
30 | 31 | ||
31 | #include <asm/ptrace.h> | 32 | #include <asm/ptrace.h> |
32 | #include <asm/signal.h> | 33 | #include <asm/signal.h> |
@@ -1702,9 +1703,8 @@ void mpic_reset_core(int cpu) | |||
1702 | #endif /* CONFIG_SMP */ | 1703 | #endif /* CONFIG_SMP */ |
1703 | 1704 | ||
1704 | #ifdef CONFIG_PM | 1705 | #ifdef CONFIG_PM |
1705 | static int mpic_suspend(struct sys_device *dev, pm_message_t state) | 1706 | static void mpic_suspend_one(struct mpic *mpic) |
1706 | { | 1707 | { |
1707 | struct mpic *mpic = container_of(dev, struct mpic, sysdev); | ||
1708 | int i; | 1708 | int i; |
1709 | 1709 | ||
1710 | for (i = 0; i < mpic->num_sources; i++) { | 1710 | for (i = 0; i < mpic->num_sources; i++) { |
@@ -1713,13 +1713,22 @@ static int mpic_suspend(struct sys_device *dev, pm_message_t state) | |||
1713 | mpic->save_data[i].dest = | 1713 | mpic->save_data[i].dest = |
1714 | mpic_irq_read(i, MPIC_INFO(IRQ_DESTINATION)); | 1714 | mpic_irq_read(i, MPIC_INFO(IRQ_DESTINATION)); |
1715 | } | 1715 | } |
1716 | } | ||
1717 | |||
1718 | static int mpic_suspend(void) | ||
1719 | { | ||
1720 | struct mpic *mpic = mpics; | ||
1721 | |||
1722 | while (mpic) { | ||
1723 | mpic_suspend_one(mpic); | ||
1724 | mpic = mpic->next; | ||
1725 | } | ||
1716 | 1726 | ||
1717 | return 0; | 1727 | return 0; |
1718 | } | 1728 | } |
1719 | 1729 | ||
1720 | static int mpic_resume(struct sys_device *dev) | 1730 | static void mpic_resume_one(struct mpic *mpic) |
1721 | { | 1731 | { |
1722 | struct mpic *mpic = container_of(dev, struct mpic, sysdev); | ||
1723 | int i; | 1732 | int i; |
1724 | 1733 | ||
1725 | for (i = 0; i < mpic->num_sources; i++) { | 1734 | for (i = 0; i < mpic->num_sources; i++) { |
@@ -1746,33 +1755,28 @@ static int mpic_resume(struct sys_device *dev) | |||
1746 | } | 1755 | } |
1747 | #endif | 1756 | #endif |
1748 | } /* end for loop */ | 1757 | } /* end for loop */ |
1758 | } | ||
1749 | 1759 | ||
1750 | return 0; | 1760 | static void mpic_resume(void) |
1761 | { | ||
1762 | struct mpic *mpic = mpics; | ||
1763 | |||
1764 | while (mpic) { | ||
1765 | mpic_resume_one(mpic); | ||
1766 | mpic = mpic->next; | ||
1767 | } | ||
1751 | } | 1768 | } |
1752 | #endif | ||
1753 | 1769 | ||
1754 | static struct sysdev_class mpic_sysclass = { | 1770 | static struct syscore_ops mpic_syscore_ops = { |
1755 | #ifdef CONFIG_PM | ||
1756 | .resume = mpic_resume, | 1771 | .resume = mpic_resume, |
1757 | .suspend = mpic_suspend, | 1772 | .suspend = mpic_suspend, |
1758 | #endif | ||
1759 | .name = "mpic", | ||
1760 | }; | 1773 | }; |
1761 | 1774 | ||
1762 | static int mpic_init_sys(void) | 1775 | static int mpic_init_sys(void) |
1763 | { | 1776 | { |
1764 | struct mpic *mpic = mpics; | 1777 | register_syscore_ops(&mpic_syscore_ops); |
1765 | int error, id = 0; | 1778 | return 0; |
1766 | |||
1767 | error = sysdev_class_register(&mpic_sysclass); | ||
1768 | |||
1769 | while (mpic && !error) { | ||
1770 | mpic->sysdev.cls = &mpic_sysclass; | ||
1771 | mpic->sysdev.id = id++; | ||
1772 | error = sysdev_register(&mpic->sysdev); | ||
1773 | mpic = mpic->next; | ||
1774 | } | ||
1775 | return error; | ||
1776 | } | 1779 | } |
1777 | 1780 | ||
1778 | device_initcall(mpic_init_sys); | 1781 | device_initcall(mpic_init_sys); |
1782 | #endif | ||