Commit f5a592f7 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

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: default avatarRafael J. Wysocki <rjw@sisk.pl>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent f98bf4aa
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/sysdev.h>
#include <asm/dcr.h> #include <asm/dcr.h>
#include <asm/msi_bitmap.h> #include <asm/msi_bitmap.h>
...@@ -320,8 +319,6 @@ struct mpic ...@@ -320,8 +319,6 @@ struct mpic
/* link */ /* link */
struct mpic *next; struct mpic *next;
struct sys_device sysdev;
#ifdef CONFIG_PM #ifdef CONFIG_PM
struct mpic_irq_save *save_data; struct mpic_irq_save *save_data;
#endif #endif
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/linux_logo.h> #include <linux/linux_logo.h>
#include <linux/syscore_ops.h>
#include <asm/spu.h> #include <asm/spu.h>
#include <asm/spu_priv1.h> #include <asm/spu_priv1.h>
#include <asm/spu_csa.h> #include <asm/spu_csa.h>
...@@ -521,18 +522,8 @@ void spu_init_channels(struct spu *spu) ...@@ -521,18 +522,8 @@ void spu_init_channels(struct spu *spu)
} }
EXPORT_SYMBOL_GPL(spu_init_channels); EXPORT_SYMBOL_GPL(spu_init_channels);
static int spu_shutdown(struct sys_device *sysdev)
{
struct spu *spu = container_of(sysdev, struct spu, sysdev);
spu_free_irqs(spu);
spu_destroy_spu(spu);
return 0;
}
static struct sysdev_class spu_sysdev_class = { static struct sysdev_class spu_sysdev_class = {
.name = "spu", .name = "spu",
.shutdown = spu_shutdown,
}; };
int spu_add_sysdev_attr(struct sysdev_attribute *attr) int spu_add_sysdev_attr(struct sysdev_attribute *attr)
...@@ -797,6 +788,22 @@ static inline void crash_register_spus(struct list_head *list) ...@@ -797,6 +788,22 @@ static inline void crash_register_spus(struct list_head *list)
} }
#endif #endif
static void spu_shutdown(void)
{
struct spu *spu;
mutex_lock(&spu_full_list_mutex);
list_for_each_entry(spu, &spu_full_list, full_list) {
spu_free_irqs(spu);
spu_destroy_spu(spu);
}
mutex_unlock(&spu_full_list_mutex);
}
static struct syscore_ops spu_syscore_ops = {
.shutdown = spu_shutdown,
};
static int __init init_spu_base(void) static int __init init_spu_base(void)
{ {
int i, ret = 0; int i, ret = 0;
...@@ -830,6 +837,7 @@ static int __init init_spu_base(void) ...@@ -830,6 +837,7 @@ static int __init init_spu_base(void)
crash_register_spus(&spu_full_list); crash_register_spus(&spu_full_list);
mutex_unlock(&spu_full_list_mutex); mutex_unlock(&spu_full_list_mutex);
spu_add_sysdev_attr(&attr_stat); spu_add_sysdev_attr(&attr_stat);
register_syscore_ops(&spu_syscore_ops);
spu_init_affinity(); spu_init_affinity();
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <linux/signal.h> #include <linux/signal.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/sysdev.h> #include <linux/syscore_ops.h>
#include <linux/adb.h> #include <linux/adb.h>
#include <linux/pmu.h> #include <linux/pmu.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -677,7 +677,7 @@ static int pmacpic_find_viaint(void) ...@@ -677,7 +677,7 @@ static int pmacpic_find_viaint(void)
return viaint; return viaint;
} }
static int pmacpic_suspend(struct sys_device *sysdev, pm_message_t state) static int pmacpic_suspend(void)
{ {
int viaint = pmacpic_find_viaint(); int viaint = pmacpic_find_viaint();
...@@ -698,7 +698,7 @@ static int pmacpic_suspend(struct sys_device *sysdev, pm_message_t state) ...@@ -698,7 +698,7 @@ static int pmacpic_suspend(struct sys_device *sysdev, pm_message_t state)
return 0; return 0;
} }
static int pmacpic_resume(struct sys_device *sysdev) static void pmacpic_resume(void)
{ {
int i; int i;
...@@ -709,39 +709,19 @@ static int pmacpic_resume(struct sys_device *sysdev) ...@@ -709,39 +709,19 @@ static int pmacpic_resume(struct sys_device *sysdev)
for (i = 0; i < max_real_irqs; ++i) for (i = 0; i < max_real_irqs; ++i)
if (test_bit(i, sleep_save_mask)) if (test_bit(i, sleep_save_mask))
pmac_unmask_irq(irq_get_irq_data(i)); pmac_unmask_irq(irq_get_irq_data(i));
return 0;
} }
#endif /* CONFIG_PM && CONFIG_PPC32 */ static struct syscore_ops pmacpic_syscore_ops = {
.suspend = pmacpic_suspend,
static struct sysdev_class pmacpic_sysclass = { .resume = pmacpic_resume,
.name = "pmac_pic",
}; };
static struct sys_device device_pmacpic = { static int __init init_pmacpic_syscore(void)
.id = 0,
.cls = &pmacpic_sysclass,
};
static struct sysdev_driver driver_pmacpic = {
#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
.suspend = &pmacpic_suspend,
.resume = &pmacpic_resume,
#endif /* CONFIG_PM && CONFIG_PPC32 */
};
static int __init init_pmacpic_sysfs(void)
{ {
#ifdef CONFIG_PPC32 register_syscore_ops(&pmacpic_syscore_ops);
if (max_irqs == 0)
return -ENODEV;
#endif
printk(KERN_DEBUG "Registering pmac pic with sysfs...\n");
sysdev_class_register(&pmacpic_sysclass);
sysdev_register(&device_pmacpic);
sysdev_driver_register(&pmacpic_sysclass, &driver_pmacpic);
return 0; return 0;
} }
machine_subsys_initcall(powermac, init_pmacpic_sysfs);
machine_subsys_initcall(powermac, init_pmacpic_syscore);
#endif /* CONFIG_PM && CONFIG_PPC32 */
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/signal.h> #include <linux/signal.h>
#include <linux/sysdev.h> #include <linux/syscore_ops.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/bootmem.h> #include <linux/bootmem.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
...@@ -902,7 +902,7 @@ static struct { ...@@ -902,7 +902,7 @@ static struct {
u32 sercr; u32 sercr;
} ipic_saved_state; } ipic_saved_state;
static int ipic_suspend(struct sys_device *sdev, pm_message_t state) static int ipic_suspend(void)
{ {
struct ipic *ipic = primary_ipic; struct ipic *ipic = primary_ipic;
...@@ -933,7 +933,7 @@ static int ipic_suspend(struct sys_device *sdev, pm_message_t state) ...@@ -933,7 +933,7 @@ static int ipic_suspend(struct sys_device *sdev, pm_message_t state)
return 0; return 0;
} }
static int ipic_resume(struct sys_device *sdev) static void ipic_resume(void)
{ {
struct ipic *ipic = primary_ipic; struct ipic *ipic = primary_ipic;
...@@ -949,44 +949,26 @@ static int ipic_resume(struct sys_device *sdev) ...@@ -949,44 +949,26 @@ static int ipic_resume(struct sys_device *sdev)
ipic_write(ipic->regs, IPIC_SECNR, ipic_saved_state.secnr); ipic_write(ipic->regs, IPIC_SECNR, ipic_saved_state.secnr);
ipic_write(ipic->regs, IPIC_SERMR, ipic_saved_state.sermr); ipic_write(ipic->regs, IPIC_SERMR, ipic_saved_state.sermr);
ipic_write(ipic->regs, IPIC_SERCR, ipic_saved_state.sercr); ipic_write(ipic->regs, IPIC_SERCR, ipic_saved_state.sercr);
return 0;
} }
#else #else
#define ipic_suspend NULL #define ipic_suspend NULL
#define ipic_resume NULL #define ipic_resume NULL
#endif #endif
static struct sysdev_class ipic_sysclass = { static struct syscore_ops ipic_syscore_ops = {
.name = "ipic",
.suspend = ipic_suspend, .suspend = ipic_suspend,
.resume = ipic_resume, .resume = ipic_resume,
}; };
static struct sys_device device_ipic = { static int __init init_ipic_syscore(void)
.id = 0,
.cls = &ipic_sysclass,
};
static int __init init_ipic_sysfs(void)
{ {
int rc;
if (!primary_ipic || !primary_ipic->regs) if (!primary_ipic || !primary_ipic->regs)
return -ENODEV; return -ENODEV;
printk(KERN_DEBUG "Registering ipic with sysfs...\n");
rc = sysdev_class_register(&ipic_sysclass); printk(KERN_DEBUG "Registering ipic system core operations\n");
if (rc) { register_syscore_ops(&ipic_syscore_ops);
printk(KERN_ERR "Failed registering ipic sys class\n");
return -ENODEV;
}
rc = sysdev_register(&device_ipic);
if (rc) {
printk(KERN_ERR "Failed registering ipic sys device\n");
return -ENODEV;
}
return 0; return 0;
} }
subsys_initcall(init_ipic_sysfs); subsys_initcall(init_ipic_syscore);
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/syscore_ops.h>
#include <asm/ptrace.h> #include <asm/ptrace.h>
#include <asm/signal.h> #include <asm/signal.h>
...@@ -1702,9 +1703,8 @@ void mpic_reset_core(int cpu) ...@@ -1702,9 +1703,8 @@ void mpic_reset_core(int cpu)
#endif /* CONFIG_SMP */ #endif /* CONFIG_SMP */
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int mpic_suspend(struct sys_device *dev, pm_message_t state) static void mpic_suspend_one(struct mpic *mpic)
{ {
struct mpic *mpic = container_of(dev, struct mpic, sysdev);
int i; int i;
for (i = 0; i < mpic->num_sources; i++) { 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,13 +1713,22 @@ static int mpic_suspend(struct sys_device *dev, pm_message_t state)
mpic->save_data[i].dest = mpic->save_data[i].dest =
mpic_irq_read(i, MPIC_INFO(IRQ_DESTINATION)); mpic_irq_read(i, MPIC_INFO(IRQ_DESTINATION));
} }
}
static int mpic_suspend(void)
{
struct mpic *mpic = mpics;
while (mpic) {
mpic_suspend_one(mpic);
mpic = mpic->next;
}
return 0; return 0;
} }
static int mpic_resume(struct sys_device *dev) static void mpic_resume_one(struct mpic *mpic)
{ {
struct mpic *mpic = container_of(dev, struct mpic, sysdev);
int i; int i;
for (i = 0; i < mpic->num_sources; i++) { for (i = 0; i < mpic->num_sources; i++) {
...@@ -1746,33 +1755,28 @@ static int mpic_resume(struct sys_device *dev) ...@@ -1746,33 +1755,28 @@ static int mpic_resume(struct sys_device *dev)
} }
#endif #endif
} /* end for loop */ } /* end for loop */
}
return 0; static void mpic_resume(void)
{
struct mpic *mpic = mpics;
while (mpic) {
mpic_resume_one(mpic);
mpic = mpic->next;
}
} }
#endif
static struct sysdev_class mpic_sysclass = { static struct syscore_ops mpic_syscore_ops = {
#ifdef CONFIG_PM
.resume = mpic_resume, .resume = mpic_resume,
.suspend = mpic_suspend, .suspend = mpic_suspend,
#endif
.name = "mpic",
}; };
static int mpic_init_sys(void) static int mpic_init_sys(void)
{ {
struct mpic *mpic = mpics; register_syscore_ops(&mpic_syscore_ops);
int error, id = 0; return 0;
error = sysdev_class_register(&mpic_sysclass);
while (mpic && !error) {
mpic->sysdev.cls = &mpic_sysclass;
mpic->sysdev.id = id++;
error = sysdev_register(&mpic->sysdev);
mpic = mpic->next;
}
return error;
} }
device_initcall(mpic_init_sys); device_initcall(mpic_init_sys);
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment