Commit f9adcf4e authored by Pavel Machek's avatar Pavel Machek Committed by Linus Torvalds

[PATCH] swsusp: refrigerator cleanups

This patch is from Nigel's swsusp2, it kills ugly #include <suspend.h> from
all over the tree, and makes code slightly nicer.  I only left those parts
that do not change any code.

From: Nigel Cunningham <ncunningham@linuxmail.org>
Signed-off-by: default avatarPavel Machek <pavel@suse.cz>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 1bed67e3
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <linux/signal.h> #include <linux/signal.h>
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/personality.h> #include <linux/personality.h>
#include <linux/suspend.h>
#include <asm/cacheflush.h> #include <asm/cacheflush.h>
#include <asm/ucontext.h> #include <asm/ucontext.h>
...@@ -689,10 +688,8 @@ static int do_signal(sigset_t *oldset, struct pt_regs *regs, int syscall) ...@@ -689,10 +688,8 @@ static int do_signal(sigset_t *oldset, struct pt_regs *regs, int syscall)
if (!user_mode(regs)) if (!user_mode(regs))
return 0; return 0;
if (current->flags & PF_FREEZE) { if (try_to_freeze(0))
refrigerator(0);
goto no_signal; goto no_signal;
}
if (current->ptrace & PT_SINGLESTEP) if (current->ptrace & PT_SINGLESTEP)
ptrace_cancel_bpt(current); ptrace_cancel_bpt(current);
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/suspend.h>
#include <asm/ptrace.h> #include <asm/ptrace.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -179,10 +178,8 @@ asmlinkage int do_irix_signal(sigset_t *oldset, struct pt_regs *regs) ...@@ -179,10 +178,8 @@ asmlinkage int do_irix_signal(sigset_t *oldset, struct pt_regs *regs)
if (!user_mode(regs)) if (!user_mode(regs))
return 1; return 1;
if (current->flags & PF_FREEZE) { if (try_to_freeze(0))
refrigerator(0);
goto no_signal; goto no_signal;
}
if (!oldset) if (!oldset)
oldset = &current->blocked; oldset = &current->blocked;
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/suspend.h>
#include <linux/unistd.h> #include <linux/unistd.h>
#include <linux/compiler.h> #include <linux/compiler.h>
...@@ -577,10 +576,8 @@ asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs) ...@@ -577,10 +576,8 @@ asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs)
if (!user_mode(regs)) if (!user_mode(regs))
return 1; return 1;
if (current->flags & PF_FREEZE) { if (try_to_freeze(0))
refrigerator(0);
goto no_signal; goto no_signal;
}
if (!oldset) if (!oldset)
oldset = &current->blocked; oldset = &current->blocked;
......
...@@ -773,10 +773,8 @@ asmlinkage int do_signal32(sigset_t *oldset, struct pt_regs *regs) ...@@ -773,10 +773,8 @@ asmlinkage int do_signal32(sigset_t *oldset, struct pt_regs *regs)
if (!user_mode(regs)) if (!user_mode(regs))
return 1; return 1;
if (current->flags & PF_FREEZE) { if (try_to_freeze(0))
refrigerator(0);
goto no_signal; goto no_signal;
}
if (!oldset) if (!oldset)
oldset = &current->blocked; oldset = &current->blocked;
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include <linux/tty.h> #include <linux/tty.h>
#include <linux/personality.h> #include <linux/personality.h>
#include <linux/binfmts.h> #include <linux/binfmts.h>
#include <linux/suspend.h>
#include <asm/ucontext.h> #include <asm/ucontext.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -579,10 +578,8 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset) ...@@ -579,10 +578,8 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
if (!user_mode(regs)) if (!user_mode(regs))
return 1; return 1;
if (current->flags & PF_FREEZE) { if (try_to_freeze(0))
refrigerator(0);
goto no_signal; goto no_signal;
}
if (!oldset) if (!oldset)
oldset = &current->blocked; oldset = &current->blocked;
......
...@@ -701,10 +701,8 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset) ...@@ -701,10 +701,8 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
if (!user_mode(regs)) if (!user_mode(regs))
return 1; return 1;
if (current->flags & PF_FREEZE) { if (try_to_freeze(0))
refrigerator(0);
goto no_signal; goto no_signal;
}
if (!oldset) if (!oldset)
oldset = &current->blocked; oldset = &current->blocked;
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/personality.h> #include <linux/personality.h>
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/suspend.h>
#include <asm/ucontext.h> #include <asm/ucontext.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/i387.h> #include <asm/i387.h>
...@@ -423,10 +422,8 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset) ...@@ -423,10 +422,8 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
return 1; return 1;
} }
if (current->flags & PF_FREEZE) { if (try_to_freeze(0))
refrigerator(0);
goto no_signal; goto no_signal;
}
if (!oldset) if (!oldset)
oldset = &current->blocked; oldset = &current->blocked;
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/suspend.h>
#include <asm/atomic.h> #include <asm/atomic.h>
#include "ieee1394_types.h" #include "ieee1394_types.h"
...@@ -1480,10 +1479,8 @@ static int nodemgr_host_thread(void *__hi) ...@@ -1480,10 +1479,8 @@ static int nodemgr_host_thread(void *__hi)
if (down_interruptible(&hi->reset_sem) || if (down_interruptible(&hi->reset_sem) ||
down_interruptible(&nodemgr_serialize)) { down_interruptible(&nodemgr_serialize)) {
if (current->flags & PF_FREEZE) { if (try_to_freeze(PF_FREEZE))
refrigerator(0);
continue; continue;
}
printk("NodeMgr: received unexpected signal?!\n" ); printk("NodeMgr: received unexpected signal?!\n" );
break; break;
} }
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/suspend.h>
#include <linux/slab.h> #include <linux/slab.h>
MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
...@@ -225,8 +224,7 @@ static int serio_thread(void *nothing) ...@@ -225,8 +224,7 @@ static int serio_thread(void *nothing)
do { do {
serio_handle_events(); serio_handle_events();
wait_event_interruptible(serio_wait, !list_empty(&serio_event_list)); wait_event_interruptible(serio_wait, !list_empty(&serio_event_list));
if (current->flags & PF_FREEZE) try_to_freeze(PF_FREEZE);
refrigerator(PF_FREEZE);
} while (!signal_pending(current)); } while (!signal_pending(current));
printk(KERN_DEBUG "serio: kseriod exiting\n"); printk(KERN_DEBUG "serio: kseriod exiting\n");
......
...@@ -108,7 +108,6 @@ ...@@ -108,7 +108,6 @@
#include <linux/mii.h> #include <linux/mii.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/crc32.h> #include <linux/crc32.h>
#include <linux/suspend.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/irq.h> #include <asm/irq.h>
...@@ -1625,8 +1624,7 @@ static int rtl8139_thread (void *data) ...@@ -1625,8 +1624,7 @@ static int rtl8139_thread (void *data)
do { do {
timeout = interruptible_sleep_on_timeout (&tp->thr_wait, timeout); timeout = interruptible_sleep_on_timeout (&tp->thr_wait, timeout);
/* make swsusp happy with our thread */ /* make swsusp happy with our thread */
if (current->flags & PF_FREEZE) try_to_freeze(PF_FREEZE);
refrigerator(PF_FREEZE);
} while (!signal_pending (current) && (timeout > 0)); } while (!signal_pending (current) && (timeout > 0));
if (signal_pending (current)) { if (signal_pending (current)) {
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/suspend.h>
#include <net/irda/irda.h> #include <net/irda/irda.h>
......
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
#include <linux/time.h> #include <linux/time.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/suspend.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/usb.h> #include <linux/usb.h>
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/suspend.h>
#include <linux/in.h> #include <linux/in.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -2918,8 +2917,7 @@ static int airo_thread(void *data) { ...@@ -2918,8 +2917,7 @@ static int airo_thread(void *data) {
flush_signals(current); flush_signals(current);
/* make swsusp happy with our thread */ /* make swsusp happy with our thread */
if (current->flags & PF_FREEZE) try_to_freeze(PF_FREEZE);
refrigerator(PF_FREEZE);
if (test_bit(JOB_DIE, &ai->flags)) if (test_bit(JOB_DIE, &ai->flags))
break; break;
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/suspend.h>
#include <asm/system.h> #include <asm/system.h>
#include <asm/irq.h> #include <asm/irq.h>
...@@ -711,8 +710,7 @@ static int pccardd(void *__skt) ...@@ -711,8 +710,7 @@ static int pccardd(void *__skt)
} }
schedule(); schedule();
if (current->flags & PF_FREEZE) try_to_freeze(PF_FREEZE);
refrigerator(PF_FREEZE);
if (!skt->thread) if (!skt->thread)
break; break;
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/suspend.h>
#include <asm/system.h> #include <asm/system.h>
#include <asm/irq.h> #include <asm/irq.h>
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include <linux/ioctl.h> #include <linux/ioctl.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/usbdevice_fs.h> #include <linux/usbdevice_fs.h>
#include <linux/suspend.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -2748,8 +2747,7 @@ static int hub_thread(void *__unused) ...@@ -2748,8 +2747,7 @@ static int hub_thread(void *__unused)
do { do {
hub_events(); hub_events();
wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list)); wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list));
if (current->flags & PF_FREEZE) try_to_freeze(PF_FREEZE);
refrigerator(PF_FREEZE);
} while (!signal_pending(current)); } while (!signal_pending(current));
pr_debug ("%s: khubd exiting\n", usbcore_name); pr_debug ("%s: khubd exiting\n", usbcore_name);
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/suspend.h>
#include "w1.h" #include "w1.h"
#include "w1_io.h" #include "w1_io.h"
...@@ -628,8 +627,7 @@ int w1_control(void *data) ...@@ -628,8 +627,7 @@ int w1_control(void *data)
timeout = w1_timeout*HZ; timeout = w1_timeout*HZ;
do { do {
timeout = interruptible_sleep_on_timeout(&w1_control_wait, timeout); timeout = interruptible_sleep_on_timeout(&w1_control_wait, timeout);
if (current->flags & PF_FREEZE) try_to_freeze(PF_FREEZE);
refrigerator(PF_FREEZE);
} while (!signal_pending(current) && (timeout > 0)); } while (!signal_pending(current) && (timeout > 0));
if (signal_pending(current)) if (signal_pending(current))
...@@ -701,8 +699,7 @@ int w1_process(void *data) ...@@ -701,8 +699,7 @@ int w1_process(void *data)
timeout = w1_timeout*HZ; timeout = w1_timeout*HZ;
do { do {
timeout = interruptible_sleep_on_timeout(&dev->kwait, timeout); timeout = interruptible_sleep_on_timeout(&dev->kwait, timeout);
if (current->flags & PF_FREEZE) try_to_freeze(PF_FREEZE);
refrigerator(PF_FREEZE);
} while (!signal_pending(current) && (timeout > 0)); } while (!signal_pending(current) && (timeout > 0));
if (signal_pending(current)) if (signal_pending(current))
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include <linux/jffs2.h> #include <linux/jffs2.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/suspend.h>
#include "nodelist.h" #include "nodelist.h"
...@@ -93,12 +92,8 @@ static int jffs2_garbage_collect_thread(void *_c) ...@@ -93,12 +92,8 @@ static int jffs2_garbage_collect_thread(void *_c)
schedule(); schedule();
} }
if (current->flags & PF_FREEZE) { if (try_to_freeze(0))
refrigerator(0);
/* refrigerator() should recalc sigpending for us
but doesn't. No matter - allow_signal() will. */
continue; continue;
}
cond_resched(); cond_resched();
......
...@@ -50,7 +50,6 @@ ...@@ -50,7 +50,6 @@
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/suspend.h>
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/writeback.h> #include <linux/writeback.h>
......
...@@ -51,7 +51,6 @@ ...@@ -51,7 +51,6 @@
#include <linux/sysctl.h> #include <linux/sysctl.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/suspend.h>
#include <linux/percpu.h> #include <linux/percpu.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
...@@ -1685,9 +1684,7 @@ pagebuf_daemon( ...@@ -1685,9 +1684,7 @@ pagebuf_daemon(
INIT_LIST_HEAD(&tmp); INIT_LIST_HEAD(&tmp);
do { do {
/* swsusp */ try_to_freeze(PF_FREEZE);
if (current->flags & PF_FREEZE)
refrigerator(PF_FREEZE);
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout((xfs_buf_timer_centisecs * HZ) / 100); schedule_timeout((xfs_buf_timer_centisecs * HZ) / 100);
......
...@@ -71,7 +71,6 @@ ...@@ -71,7 +71,6 @@
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/suspend.h>
#include <linux/writeback.h> #include <linux/writeback.h>
STATIC struct quotactl_ops linvfs_qops; STATIC struct quotactl_ops linvfs_qops;
...@@ -489,8 +488,7 @@ xfssyncd( ...@@ -489,8 +488,7 @@ xfssyncd(
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
timeleft = schedule_timeout(timeleft); timeleft = schedule_timeout(timeleft);
/* swsusp */ /* swsusp */
if (current->flags & PF_FREEZE) try_to_freeze(PF_FREEZE);
refrigerator(PF_FREEZE);
if (vfsp->vfs_flag & VFS_UMOUNT) if (vfsp->vfs_flag & VFS_UMOUNT)
break; break;
......
...@@ -727,7 +727,7 @@ do { if (atomic_dec_and_test(&(tsk)->usage)) __put_task_struct(tsk); } while(0) ...@@ -727,7 +727,7 @@ do { if (atomic_dec_and_test(&(tsk)->usage)) __put_task_struct(tsk); } while(0)
#define PF_MEMDIE 0x00001000 /* Killed for out-of-memory */ #define PF_MEMDIE 0x00001000 /* Killed for out-of-memory */
#define PF_FLUSHER 0x00002000 /* responsible for disk writeback */ #define PF_FLUSHER 0x00002000 /* responsible for disk writeback */
#define PF_FREEZE 0x00004000 /* this task should be frozen for suspend */ #define PF_FREEZE 0x00004000 /* this task is being frozen for suspend now */
#define PF_NOFREEZE 0x00008000 /* this thread should not be frozen */ #define PF_NOFREEZE 0x00008000 /* this thread should not be frozen */
#define PF_FROZEN 0x00010000 /* frozen for system suspend */ #define PF_FROZEN 0x00010000 /* frozen for system suspend */
#define PF_FSTRANS 0x00020000 /* inside a filesystem transaction */ #define PF_FSTRANS 0x00020000 /* inside a filesystem transaction */
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <linux/gfp.h> #include <linux/gfp.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/suspend.h>
#include <linux/fs.h> // Needed by writeback.h #include <linux/fs.h> // Needed by writeback.h
#include <linux/writeback.h> // Prototypes pdflush_operation() #include <linux/writeback.h> // Prototypes pdflush_operation()
#include <linux/kthread.h> #include <linux/kthread.h>
...@@ -106,8 +105,7 @@ static int __pdflush(struct pdflush_work *my_work) ...@@ -106,8 +105,7 @@ static int __pdflush(struct pdflush_work *my_work)
spin_unlock_irq(&pdflush_lock); spin_unlock_irq(&pdflush_lock);
schedule(); schedule();
if (current->flags & PF_FREEZE) { if (try_to_freeze(PF_FREEZE)) {
refrigerator(PF_FREEZE);
spin_lock_irq(&pdflush_lock); spin_lock_irq(&pdflush_lock);
continue; continue;
} }
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include <linux/highmem.h> #include <linux/highmem.h>
#include <linux/file.h> #include <linux/file.h>
#include <linux/writeback.h> #include <linux/writeback.h>
#include <linux/suspend.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/buffer_head.h> /* for try_to_release_page(), #include <linux/buffer_head.h> /* for try_to_release_page(),
buffer_heads_over_limit */ buffer_heads_over_limit */
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/suspend.h>
#include <linux/sunrpc/clnt.h> #include <linux/sunrpc/clnt.h>
#include <linux/sunrpc/xprt.h> #include <linux/sunrpc/xprt.h>
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/suspend.h>
#include <net/sock.h> #include <net/sock.h>
#include <net/checksum.h> #include <net/checksum.h>
#include <net/ip.h> #include <net/ip.h>
...@@ -1227,8 +1226,7 @@ svc_recv(struct svc_serv *serv, struct svc_rqst *rqstp, long timeout) ...@@ -1227,8 +1226,7 @@ svc_recv(struct svc_serv *serv, struct svc_rqst *rqstp, long timeout)
schedule_timeout(timeout); schedule_timeout(timeout);
if (current->flags & PF_FREEZE) try_to_freeze(PF_FREEZE);
refrigerator(PF_FREEZE);
spin_lock_bh(&serv->sv_lock); spin_lock_bh(&serv->sv_lock);
remove_wait_queue(&rqstp->rq_wait, &wait); remove_wait_queue(&rqstp->rq_wait, &wait);
......
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