2222#include <linux/init.h>
2323#include <linux/list.h>
2424#include <linux/io.h>
25- #include <linux/sysdev .h>
25+ #include <linux/syscore_ops .h>
2626#include <linux/device.h>
2727#include <linux/amba/bus.h>
2828
2929#include <asm/mach/irq.h>
3030#include <asm/hardware/vic.h>
3131
32- #if defined( CONFIG_PM )
32+ #ifdef CONFIG_PM
3333/**
3434 * struct vic_device - VIC PM device
35- * @sysdev: The system device which is registered.
3635 * @irq: The IRQ number for the base of the VIC.
3736 * @base: The register base for the VIC.
3837 * @resume_sources: A bitmask of interrupts for resume.
4342 * @protect: Save for VIC_PROTECT.
4443 */
4544struct vic_device {
46- struct sys_device sysdev ;
47-
4845 void __iomem * base ;
4946 int irq ;
5047 u32 resume_sources ;
@@ -59,11 +56,6 @@ struct vic_device {
5956static struct vic_device vic_devices [CONFIG_ARM_VIC_NR ];
6057
6158static int vic_id ;
62-
63- static inline struct vic_device * to_vic (struct sys_device * sys )
64- {
65- return container_of (sys , struct vic_device , sysdev );
66- }
6759#endif /* CONFIG_PM */
6860
6961/**
@@ -85,10 +77,9 @@ static void vic_init2(void __iomem *base)
8577 writel (32 , base + VIC_PL190_DEF_VECT_ADDR );
8678}
8779
88- #if defined( CONFIG_PM )
89- static int vic_class_resume (struct sys_device * dev )
80+ #ifdef CONFIG_PM
81+ static void resume_one_vic (struct vic_device * vic )
9082{
91- struct vic_device * vic = to_vic (dev );
9283 void __iomem * base = vic -> base ;
9384
9485 printk (KERN_DEBUG "%s: resuming vic at %p\n" , __func__ , base );
@@ -107,13 +98,18 @@ static int vic_class_resume(struct sys_device *dev)
10798
10899 writel (vic -> soft_int , base + VIC_INT_SOFT );
109100 writel (~vic -> soft_int , base + VIC_INT_SOFT_CLEAR );
101+ }
110102
111- return 0 ;
103+ static void vic_resume (void )
104+ {
105+ int id ;
106+
107+ for (id = vic_id - 1 ; id >= 0 ; id -- )
108+ resume_one_vic (vic_devices + id );
112109}
113110
114- static int vic_class_suspend (struct sys_device * dev , pm_message_t state )
111+ static void suspend_one_vic (struct vic_device * vic )
115112{
116- struct vic_device * vic = to_vic (dev );
117113 void __iomem * base = vic -> base ;
118114
119115 printk (KERN_DEBUG "%s: suspending vic at %p\n" , __func__ , base );
@@ -128,14 +124,21 @@ static int vic_class_suspend(struct sys_device *dev, pm_message_t state)
128124
129125 writel (vic -> resume_irqs , base + VIC_INT_ENABLE );
130126 writel (~vic -> resume_irqs , base + VIC_INT_ENABLE_CLEAR );
127+ }
128+
129+ static int vic_suspend (void )
130+ {
131+ int id ;
132+
133+ for (id = 0 ; id < vic_id ; id ++ )
134+ suspend_one_vic (vic_devices + id );
131135
132136 return 0 ;
133137}
134138
135- struct sysdev_class vic_class = {
136- .name = "vic" ,
137- .suspend = vic_class_suspend ,
138- .resume = vic_class_resume ,
139+ struct syscore_ops vic_syscore_ops = {
140+ .suspend = vic_suspend ,
141+ .resume = vic_resume ,
139142};
140143
141144/**
@@ -147,30 +150,8 @@ struct sysdev_class vic_class = {
147150*/
148151static int __init vic_pm_init (void )
149152{
150- struct vic_device * dev = vic_devices ;
151- int err ;
152- int id ;
153-
154- if (vic_id == 0 )
155- return 0 ;
156-
157- err = sysdev_class_register (& vic_class );
158- if (err ) {
159- printk (KERN_ERR "%s: cannot register class\n" , __func__ );
160- return err ;
161- }
162-
163- for (id = 0 ; id < vic_id ; id ++ , dev ++ ) {
164- dev -> sysdev .id = id ;
165- dev -> sysdev .cls = & vic_class ;
166-
167- err = sysdev_register (& dev -> sysdev );
168- if (err ) {
169- printk (KERN_ERR "%s: failed to register device\n" ,
170- __func__ );
171- return err ;
172- }
173- }
153+ if (vic_id > 0 )
154+ register_syscore_ops (& vic_syscore_ops );
174155
175156 return 0 ;
176157}
0 commit comments