} static int cmx270_resume(struct sys_device *dev) { cmx270_pci_resume(); /* restore MSC registers */ MSC0 = sleep_save_msc[0]; MSC1 = sleep_save_msc[1]; MSC2 = sleep_save_msc[2]; return 0; } static struct sysdev_class cmx270_pm_sysclass = { set_kset_name("pm"), .resume = cmx270_resume, .suspend = cmx270_suspend, }; static struct sys_device cmx270_pm_device = { .cls = &cmx270_pm_sysclass, }; static int __init cmx270_pm_init(void) { int error; error = sysdev_class_register(&cmx270_pm_sysclass); if (error == 0) error = sysdev_register(&cmx270_pm_device); return error;
* drivers/base/cpu.c - basic CPU class support */ #include <linux/sysdev.h> #include <linux/module.h> #include <linux/init.h> #include <linux/sched.h> #include <linux/cpu.h> #include <linux/topology.h> #include <linux/device.h> #include <linux/node.h> #include "base.h" struct sysdev_class cpu_sysdev_class = { set_kset_name("cpu"), }; EXPORT_SYMBOL(cpu_sysdev_class); static struct sys_device *cpu_sys_devices[NR_CPUS]; #ifdef CONFIG_HOTPLUG_CPU static ssize_t show_online(struct sys_device *dev, char *buf) { struct cpu *cpu = container_of(dev, struct cpu, sysdev); return sprintf(buf, "%u\n", !!cpu_online(cpu->sysdev.id)); } static ssize_t store_online(struct sys_device *dev, const char *buf, size_t count)
struct sa1100irq_state *st = &sa1100irq_state; if (st->saved) { ICCR = st->iccr; ICLR = st->iclr; GRER = GPIO_IRQ_rising_edge & GPIO_IRQ_mask; GFER = GPIO_IRQ_falling_edge & GPIO_IRQ_mask; ICMR = st->icmr; } return 0; } static struct sysdev_class sa1100irq_sysclass = { set_kset_name("sa11x0-irq"), .suspend = sa1100irq_suspend, .resume = sa1100irq_resume, }; static struct sys_device sa1100irq_device = { .id = 0, .cls = &sa1100irq_sysclass, }; static int __init sa1100irq_init_devicefs(void) { sysdev_class_register(&sa1100irq_sysclass); return sysdev_register(&sa1100irq_device); }
return 0; } static int s3c2410_dma_resume(struct sys_device *dev) { return 0; } #else #define s3c2410_dma_suspend NULL #define s3c2410_dma_resume NULL #endif /* CONFIG_PM */ static struct sysdev_class dma_sysclass = { set_kset_name("s3c24xx-dma"), .suspend = s3c2410_dma_suspend, .resume = s3c2410_dma_resume, }; /* kmem cache implementation */ static void s3c2410_dma_cache_ctor(void *p, kmem_cache_t *c, unsigned long f) { memset(p, 0, sizeof(s3c2410_dma_buf_t)); } /* initialisation code */ static int __init s3c2410_init_dma(void)
static const char *edac_caps[] = { [EDAC_UNKNOWN] = "Unknown", [EDAC_NONE] = "None", [EDAC_RESERVED] = "Reserved", [EDAC_PARITY] = "PARITY", [EDAC_EC] = "EC", [EDAC_SECDED] = "SECDED", [EDAC_S2ECD2ED] = "S2ECD2ED", [EDAC_S4ECD4ED] = "S4ECD4ED", [EDAC_S8ECD8ED] = "S8ECD8ED", [EDAC_S16ECD16ED] = "S16ECD16ED" }; /* sysfs object: /sys/devices/system/edac */ static struct sysdev_class edac_class = { set_kset_name("edac"), }; /* sysfs object: * /sys/devices/system/edac/mc */ static struct kobject edac_memctrl_kobj; /* We use these to wait for the reference counts on edac_memctrl_kobj and * edac_pci_kobj to reach 0. */ static struct completion edac_memctrl_kobj_complete; /* * /sys/devices/system/edac/mc; * data structures and methods
static int s3c244x_resume(struct sys_device *dev) { s3c2410_pm_do_restore(s3c244x_sleep, ARRAY_SIZE(s3c244x_sleep)); return 0; } #else #define s3c244x_suspend NULL #define s3c244x_resume NULL #endif /* Since the S3C2442 and S3C2440 share items, put both sysclasses here */ struct sysdev_class s3c2440_sysclass = { set_kset_name("s3c2440-core"), .suspend = s3c244x_suspend, .resume = s3c244x_resume }; struct sysdev_class s3c2442_sysclass = { set_kset_name("s3c2442-core"), .suspend = s3c244x_suspend, .resume = s3c244x_resume }; /* need to register class before we actually register the device, and * we also need to ensure that it has been initialised before any of the * drivers even try to use it (even if not on an s3c2440 based system) * as a driver which may support both 2410 and 2440 may try and use it. */
MST_INTSETCLR = 0; set_irq_chained_handler(IRQ_GPIO(0), mainstone_irq_handler); set_irq_type(IRQ_GPIO(0), IRQT_FALLING); } #ifdef CONFIG_PM static int mainstone_irq_resume(struct sys_device *dev) { MST_INTMSKENA = mainstone_irq_enabled; return 0; } static struct sysdev_class mainstone_irq_sysclass = { set_kset_name("cpld_irq"), .resume = mainstone_irq_resume, }; static struct sys_device mainstone_irq_device = { .cls = &mainstone_irq_sysclass, }; static int __init mainstone_irq_device_init(void) { int ret = sysdev_class_register(&mainstone_irq_sysclass); if (ret == 0) ret = sysdev_register(&mainstone_irq_device); return ret; }
static int osiris_pm_resume(struct sys_device *sd) { if (pm_osiris_ctrl0 & OSIRIS_CTRL0_FIX8) __raw_writeb(OSIRIS_CTRL1_FIX8, OSIRIS_VA_CTRL1); return 0; } #else #define osiris_pm_suspend NULL #define osiris_pm_resume NULL #endif static struct sysdev_class osiris_pm_sysclass = { set_kset_name("mach-osiris"), .suspend = osiris_pm_suspend, .resume = osiris_pm_resume, }; static struct sys_device osiris_pm_sysdev = { .cls = &osiris_pm_sysclass, }; /* Standard Osiris devices */ static struct platform_device *osiris_devices[] __initdata = { &s3c_device_i2c, &s3c_device_wdt, &s3c_device_nand, &osiris_pcmcia,
#include <asm/plat-s3c24xx/devs.h> #include <asm/plat-s3c24xx/common-smdk.h> #include <asm/plat-s3c24xx/cpu.h> static struct map_desc s3c2443_iodesc[] __initdata = { IODESC_ENT(WATCHDOG), IODESC_ENT(CLKPWR), IODESC_ENT(TIMER), IODESC_ENT(LCD), IODESC_ENT(EBI), IODESC_ENT(SROMC), IODESC_ENT(CS8900), }; struct sysdev_class s3c2443_sysclass = { set_kset_name("s3c2443-core"), }; static struct sys_device s3c2443_sysdev = { .cls = &s3c2443_sysclass, }; static void s3c2443_hard_reset(void) { __raw_writel(S3C2443_SWRST_RESET, S3C2443_SWRST); } int __init s3c2443_init(void) { printk("S3C2443: Initialising architecture\n");
return irq; } static void init_pci_source(void) { tsi108_write_reg( TSI108_PCI_OFFSET + TSI108_PCI_IRP_CFG_CTL, 0x0000ff00); tsi108_write_reg( TSI108_PCI_OFFSET + TSI108_PCI_IRP_ENABLE, 0x00400000); mb(); } static struct sysdev_class tsi108_pic_sysclass = { set_kset_name("tsi108_pic"), }; static struct sys_device device_tsi108_pic = { .id = 0, .cls = &tsi108_pic_sysclass, }; static struct sysdev_driver driver_tsi108_pic = { #ifdef CONFIG_PM /* FIXME: placeholder for future development */ .suspend = &tsi108_pic_suspend, .resume = &tsi108_pic_resume, #endif /* CONFIG_PM */ }; static int __init init_tsi108_pic_sysfs(void)
MST_INTSETCLR = 0; set_irq_chained_handler(IRQ_GPIO(0), mainstone_irq_handler); set_irq_type(IRQ_GPIO(0), IRQT_FALLING); } #ifdef CONFIG_PM static int mainstone_irq_resume(struct sys_device *dev) { MST_INTMSKENA = mainstone_irq_enabled; return 0; } static struct sysdev_class mainstone_irq_sysclass = { set_kset_name("mst_irq"), .resume = mainstone_irq_resume, }; static struct sys_device mainstone_irq_device = { .id = -1, .cls = &mainstone_irq_sysclass, }; static int __init mainstone_irq_device_init(void) { int ret = sysdev_class_register(&mainstone_irq_sysclass); if (ret == 0) ret = sysdev_register(&mainstone_irq_device); return ret; }
} struct class_interface test_interface = { .class = &test_class, .add = &test_intf_add, .remove = &test_intf_rem, }; /* my sys_device stuff */ int test_resume(struct sys_device *dev) { printk("tbase: Entered test resume for sys device\n"); return 0; } struct sysdev_class test_sysclass = { set_kset_name("TestSysclass"), .resume = test_resume, }; struct sys_device test_sys_device = { .id = 0, .cls = &test_sysclass, }; /* my attribute stuff */ static inline ssize_t store_new_id(struct device_driver * driver, const char * buf, size_t count) { printk("tbase: Entered store new id\n"); return count; }
s3c2450_pwm_chan_t *chan = &s3c_chans[channel]; pr_debug("%s: chan=%d, callback rtn=%p\n", __FUNCTION__, channel, rtn); chan->callback_fn = rtn; return 0; } #define s3c2450_pwm_suspend NULL #define s3c2450_pwm_resume NULL struct sysdev_class pwm_sysclass = { set_kset_name("s3c-pwm"), .suspend = s3c2450_pwm_suspend, .resume = s3c2450_pwm_resume, }; /* initialisation code */ static int __init s3c2450_init_pwm(void) { s3c2450_pwm_chan_t *cp; int channel; int ret; printk("S3C PWM Driver, (c) 2006-2007 Samsung Electronics\n");
#include <asm/plat-s3c24xx/common-smdk.h> #include <asm/plat-s3c24xx/cpu.h> static struct map_desc s3c2416_iodesc[] __initdata = { IODESC_ENT(WATCHDOG), IODESC_ENT(CLKPWR), IODESC_ENT(TIMER), IODESC_ENT(LCD), IODESC_ENT(EBI), IODESC_ENT(SROMC), IODESC_ENT(CS8900), IODESC_ENT(USBDEV), }; struct sysdev_class s3c2416_sysclass = { set_kset_name("s3c2416-core"), }; static struct sys_device s3c2416_sysdev = { .cls = &s3c2416_sysclass, }; static void s3c2416_hard_reset(void) { __raw_writel(S3C2443_SWRST_RESET, S3C2443_SWRST); } int __init s3c2416_init(void) { printk("S3C2416: Initialising architecture\n");
op_arm_model->stop(); up(&op_arm_sem); return 0; } static int op_arm_resume(struct sys_device *dev) { down(&op_arm_sem); if (op_arm_enabled && op_arm_model->start()) op_arm_enabled = 0; up(&op_arm_sem); return 0; } static struct sysdev_class oprofile_sysclass = { set_kset_name("oprofile"), .resume = op_arm_resume, .suspend = op_arm_suspend, }; static struct sys_device device_oprofile = { .id = 0, .cls = &oprofile_sysclass, }; static int __init init_driverfs(void) { int ret; if (!(ret = sysdev_class_register(&oprofile_sysclass))) ret = sysdev_register(&device_oprofile);
return 0; } static int s3c2412_resume(struct sys_device *dev) { s3c_pm_do_restore(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep)); return 0; } #else #define s3c2412_suspend NULL #define s3c2412_resume NULL #endif struct sysdev_class s3c2412_sysclass = { set_kset_name("s3c2412-core"), .suspend = s3c2412_suspend, .resume = s3c2412_resume }; static struct sys_device s3c2412_sysdev = { .cls = &s3c2412_sysclass, }; static void s3c2412_idle(void) { s3c2412_gen_stbywfi(S3C2412_PWRCFG_STBYWFI_IDLE); } void __init s3c2412_map_io(struct map_desc *mach_desc, int size) {
* called as close as possible to 500 ms before the new second starts. */ if (ntp_synced() && xtime.tv_sec > last_rtc_update + 660 && (xtime.tv_nsec / 1000) >= 500000 - ((unsigned) TICK_SIZE) / 2 && (xtime.tv_nsec / 1000) <= 500000 + ((unsigned) TICK_SIZE) / 2) { if (rtc_set_time(xtime.tv_sec) == 0) last_rtc_update = xtime.tv_sec; else /* do it again in 60s */ last_rtc_update = xtime.tv_sec - 600; } } static struct sysdev_class timer_sysclass = { set_kset_name("timer"), }; static int __init timer_init_sysfs(void) { int ret = sysdev_class_register(&timer_sysclass); if (ret != 0) return ret; sys_timer->dev.cls = &timer_sysclass; return sysdev_register(&sys_timer->dev); } device_initcall(timer_init_sysfs); void (*board_time_init)(void);
/* * drivers/base/node.c - basic Node class support */ #include <linux/sysdev.h> #include <linux/module.h> #include <linux/init.h> #include <linux/mm.h> #include <linux/node.h> #include <linux/hugetlb.h> #include <linux/cpumask.h> #include <linux/topology.h> #include <linux/nodemask.h> static struct sysdev_class node_class = { set_kset_name("node"), }; static ssize_t node_read_cpumap(struct sys_device * dev, char * buf) { struct node *node_dev = to_node(dev); cpumask_t mask = node_to_cpumask(node_dev->sysdev.id); int len; /* 2004/06/03: buf currently PAGE_SIZE, need > 1 char per 4 bits. */ BUILD_BUG_ON(MAX_NUMNODES/4 > PAGE_SIZE/2); len = cpumask_scnprintf(buf, PAGE_SIZE-1, mask); len += sprintf(buf + len, "\n"); return len;
{ return 0; } static int irq_resume(struct sys_device *dev) { /* disable all irq sources */ return 0; } #else #define irq_suspend NULL #define irq_resume NULL #endif static struct sysdev_class irq_class = { set_kset_name("irq"), .suspend = irq_suspend, .resume = irq_resume, }; static struct sys_device irq_device = { .id = 0, .cls = &irq_class, }; static int __init irq_init_sysfs(void) { int ret = sysdev_class_register(&irq_class); if (ret == 0) ret = sysdev_register(&irq_device); return ret;
static int acpi_shutdown(struct sys_device *x) { switch (system_state) { case SYSTEM_POWER_OFF: /* Prepare to power off the system */ return acpi_sleep_prepare(ACPI_STATE_S5); case SYSTEM_SUSPEND_DISK: /* Prepare to suspend the system to disk */ return acpi_sleep_prepare(ACPI_STATE_S4); default: return 0; } } static struct sysdev_class acpi_sysclass = { set_kset_name("acpi"), .shutdown = acpi_shutdown }; static struct sys_device device_acpi = { .id = 0, .cls = &acpi_sysclass, }; static int acpi_poweroff_init(void) { if (!acpi_disabled) { u8 type_a, type_b; acpi_status status; status =
static int lapic_nmi_suspend(struct sys_device *dev, u32 state) { nmi_pm_active = nmi_active; disable_lapic_nmi_watchdog(); return 0; } static int lapic_nmi_resume(struct sys_device *dev) { if (nmi_pm_active > 0) enable_lapic_nmi_watchdog(); return 0; } static struct sysdev_class nmi_sysclass = { set_kset_name("lapic_nmi"), .resume = lapic_nmi_resume, .suspend = lapic_nmi_suspend, }; static struct sys_device device_lapic_nmi = { .id = 0, .cls = &nmi_sysclass, }; static int __init init_lapic_nmi_sysfs(void) { int error; if (nmi_active == 0 || nmi_watchdog != NMI_LOCAL_APIC) return 0;
* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. */ #include <linux/kernel.h> #include <linux/init.h> #include <linux/sysdev.h> #include <linux/platform_device.h> #include <linux/module.h> #include <linux/err.h> #include <linux/string.h> #include <asm/dma.h> static struct sysdev_class dma_sysclass = { set_kset_name("dma"), }; EXPORT_SYMBOL(dma_sysclass); static ssize_t dma_show_devices(struct sys_device *dev, char *buf) { ssize_t len = 0; int i; for (i = 0; i < MAX_DMA_CHANNELS; i++) { struct dma_info *info = get_dma_info(i); struct dma_channel *channel = &info->channels[i]; len += sprintf(buf + len, "%2d: %14s %s\n", channel->chan, info->name,
apic_write(APIC_LVTPC, apic_pm_state.apic_lvtpc); apic_write(APIC_LVTT, apic_pm_state.apic_lvtt); apic_write(APIC_TDCR, apic_pm_state.apic_tdcr); apic_write(APIC_TMICT, apic_pm_state.apic_tmict); apic_write(APIC_ESR, 0); apic_read(APIC_ESR); apic_write(APIC_LVTERR, apic_pm_state.apic_lvterr); apic_write(APIC_ESR, 0); apic_read(APIC_ESR); local_irq_restore(flags); return 0; } static struct sysdev_class lapic_sysclass = { set_kset_name("lapic"), .resume = lapic_resume, .suspend = lapic_suspend, }; static struct sys_device device_lapic = { .id = 0, .cls = &lapic_sysclass, }; static void __init apic_pm_activate(void) { apic_pm_state.active = 1; } static int __init init_lapic_sysfs(void)
#include <linux/module.h> #include <linux/init.h> #include <linux/topology.h> #include <linux/capability.h> #include <linux/device.h> #include <linux/memory.h> #include <linux/kobject.h> #include <linux/memory_hotplug.h> #include <linux/mm.h> #include <asm/atomic.h> #include <asm/uaccess.h> #define MEMORY_CLASS_NAME "memory" static struct sysdev_class memory_sysdev_class = { set_kset_name(MEMORY_CLASS_NAME), }; static const char *memory_uevent_name(struct kset *kset, struct kobject *kobj) { return MEMORY_CLASS_NAME; } static int memory_uevent(struct kset *kset, struct kobject *kobj, char **envp, int num_envp, char *buffer, int buffer_size) { int retval = 0; return retval; }