Skip to content

Commit 8120a8a

Browse files
Michal Nazarewiczgregkh
authored andcommitted
fs/timerfd.c: make use of wait_event_interruptible_locked_irq()
This patch modifies the fs/timerfd.c to use the newly created wait_event_interruptible_locked_irq() macro. This replaces an open code implementation with a single macro call. Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com> Cc: Kyungmin Park <kyungmin.park@samsung.com> Cc: Marek Szyprowski <m.szyprowski@samsung.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Roland Dreier <rolandd@cisco.com> Cc: Tejun Heo <tj@kernel.org> Cc: Christoph Lameter <cl@linux-foundation.org> Cc: Davide Libenzi <davidel@xmailserver.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 22c43c8 commit 8120a8a

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

fs/timerfd.c

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -110,31 +110,14 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count,
110110
struct timerfd_ctx *ctx = file->private_data;
111111
ssize_t res;
112112
u64 ticks = 0;
113-
DECLARE_WAITQUEUE(wait, current);
114113

115114
if (count < sizeof(ticks))
116115
return -EINVAL;
117116
spin_lock_irq(&ctx->wqh.lock);
118-
res = -EAGAIN;
119-
if (!ctx->ticks && !(file->f_flags & O_NONBLOCK)) {
120-
__add_wait_queue(&ctx->wqh, &wait);
121-
for (res = 0;;) {
122-
set_current_state(TASK_INTERRUPTIBLE);
123-
if (ctx->ticks) {
124-
res = 0;
125-
break;
126-
}
127-
if (signal_pending(current)) {
128-
res = -ERESTARTSYS;
129-
break;
130-
}
131-
spin_unlock_irq(&ctx->wqh.lock);
132-
schedule();
133-
spin_lock_irq(&ctx->wqh.lock);
134-
}
135-
__remove_wait_queue(&ctx->wqh, &wait);
136-
__set_current_state(TASK_RUNNING);
137-
}
117+
if (file->f_flags & O_NONBLOCK)
118+
res = -EAGAIN;
119+
else
120+
res = wait_event_interruptible_locked_irq(ctx->wqh, ctx->ticks);
138121
if (ctx->ticks) {
139122
ticks = ctx->ticks;
140123
if (ctx->expired && ctx->tintv.tv64) {

0 commit comments

Comments
 (0)