Merge branch 'drm-patches' of master.kernel.org:/pub/scm/linux/kernel/git/airlied...
[linux-drm-fsl-dcu.git] / arch / i386 / kernel / apm.c
index db99a8948dae1abad5b16357841b54efe969c9d7..367ff1d930cbac620ac30c2c11033f74a25a2787 100644 (file)
 #include <linux/slab.h>
 #include <linux/stat.h>
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <linux/miscdevice.h>
 #include <linux/apm_bios.h>
 #include <linux/init.h>
 #include <asm/desc.h>
 #include <asm/i8253.h>
 #include <asm/paravirt.h>
+#include <asm/reboot.h>
 
 #include "io_ports.h"
 
-extern unsigned long get_cmos_time(void);
-extern void machine_real_restart(unsigned char *, int);
-
 #if defined(CONFIG_APM_DISPLAY_BLANK) && defined(CONFIG_VT)
 extern int (*console_blank_hook)(int);
 #endif
@@ -384,13 +383,6 @@ static int                 ignore_sys_suspend;
 static int                     ignore_normal_resume;
 static int                     bounce_interval __read_mostly = DEFAULT_BOUNCE_INTERVAL;
 
-#ifdef CONFIG_APM_RTC_IS_GMT
-#      define  clock_cmos_diff 0
-#      define  got_clock_diff  1
-#else
-static long                    clock_cmos_diff;
-static int                     got_clock_diff;
-#endif
 static int                     debug __read_mostly;
 static int                     smp __read_mostly;
 static int                     apm_disabled = -1;
@@ -1175,28 +1167,6 @@ out:
        spin_unlock(&user_list_lock);
 }
 
-static void set_time(void)
-{
-       struct timespec ts;
-       if (got_clock_diff) {   /* Must know time zone in order to set clock */
-               ts.tv_sec = get_cmos_time() + clock_cmos_diff;
-               ts.tv_nsec = 0;
-               do_settimeofday(&ts);
-       } 
-}
-
-static void get_time_diff(void)
-{
-#ifndef CONFIG_APM_RTC_IS_GMT
-       /*
-        * Estimate time zone so that set_time can update the clock
-        */
-       clock_cmos_diff = -get_cmos_time();
-       clock_cmos_diff += get_seconds();
-       got_clock_diff = 1;
-#endif
-}
-
 static void reinit_timer(void)
 {
 #ifdef INIT_TIMER_AFTER_SUSPEND
@@ -1236,19 +1206,6 @@ static int suspend(int vetoable)
        local_irq_disable();
        device_power_down(PMSG_SUSPEND);
 
-       /* serialize with the timer interrupt */
-       write_seqlock(&xtime_lock);
-
-       /* protect against access to timer chip registers */
-       spin_lock(&i8253_lock);
-
-       get_time_diff();
-       /*
-        * Irq spinlock must be dropped around set_system_power_state.
-        * We'll undo any timer changes due to interrupts below.
-        */
-       spin_unlock(&i8253_lock);
-       write_sequnlock(&xtime_lock);
        local_irq_enable();
 
        save_processor_state();
@@ -1257,7 +1214,6 @@ static int suspend(int vetoable)
        restore_processor_state();
 
        local_irq_disable();
-       set_time();
        reinit_timer();
 
        if (err == APM_NO_ERROR)
@@ -1287,11 +1243,6 @@ static void standby(void)
 
        local_irq_disable();
        device_power_down(PMSG_SUSPEND);
-       /* serialize with the timer interrupt */
-       write_seqlock(&xtime_lock);
-       /* If needed, notify drivers here */
-       get_time_diff();
-       write_sequnlock(&xtime_lock);
        local_irq_enable();
 
        err = set_system_power_state(APM_STATE_STANDBY);
@@ -1385,7 +1336,6 @@ static void check_events(void)
                        ignore_bounce = 1;
                        if ((event != APM_NORMAL_RESUME)
                            || (ignore_normal_resume == 0)) {
-                               set_time();
                                device_resume();
                                pm_send_all(PM_RESUME, (void *)0);
                                queue_event(event, NULL);
@@ -1401,7 +1351,6 @@ static void check_events(void)
                        break;
 
                case APM_UPDATE_TIME:
-                       set_time();
                        break;
 
                case APM_CRITICAL_SUSPEND:
@@ -1636,9 +1585,8 @@ static int do_open(struct inode * inode, struct file * filp)
        return 0;
 }
 
-static int apm_get_info(char *buf, char **start, off_t fpos, int length)
+static int proc_apm_show(struct seq_file *m, void *v)
 {
-       char *          p;
        unsigned short  bx;
        unsigned short  cx;
        unsigned short  dx;
@@ -1650,8 +1598,6 @@ static int apm_get_info(char *buf, char **start, off_t fpos, int length)
        int             time_units     = -1;
        char            *units         = "?";
 
-       p = buf;
-
        if ((num_online_cpus() == 1) &&
            !(error = apm_get_power_status(&bx, &cx, &dx))) {
                ac_line_status = (bx >> 8) & 0xff;
@@ -1705,7 +1651,7 @@ static int apm_get_info(char *buf, char **start, off_t fpos, int length)
              -1: Unknown
           8) min = minutes; sec = seconds */
 
-       p += sprintf(p, "%s %d.%d 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n",
+       seq_printf(m, "%s %d.%d 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n",
                     driver_version,
                     (apm_info.bios.version >> 8) & 0xff,
                     apm_info.bios.version & 0xff,
@@ -1716,10 +1662,22 @@ static int apm_get_info(char *buf, char **start, off_t fpos, int length)
                     percentage,
                     time_units,
                     units);
+       return 0;
+}
 
-       return p - buf;
+static int proc_apm_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, proc_apm_show, NULL);
 }
 
+static const struct file_operations apm_file_ops = {
+       .owner          = THIS_MODULE,
+       .open           = proc_apm_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
 static int apm(void *unused)
 {
        unsigned short  bx;
@@ -2341,9 +2299,9 @@ static int __init apm_init(void)
        set_base(gdt[APM_DS >> 3],
                 __va((unsigned long)apm_info.bios.dseg << 4));
 
-       apm_proc = create_proc_info_entry("apm", 0, NULL, apm_get_info);
+       apm_proc = create_proc_entry("apm", 0, NULL);
        if (apm_proc)
-               apm_proc->owner = THIS_MODULE;
+               apm_proc->proc_fops = &apm_file_ops;
 
        kapmd_task = kthread_create(apm, NULL, "kapmd");
        if (IS_ERR(kapmd_task)) {