aboutsummaryrefslogtreecommitdiffstats
path: root/fs/timerfd.c
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /fs/timerfd.c
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'fs/timerfd.c')
-rw-r--r--fs/timerfd.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/fs/timerfd.c b/fs/timerfd.c
index d03822bbf19..dffeb3795af 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -234,17 +234,19 @@ static const struct file_operations timerfd_fops = {
234 .llseek = noop_llseek, 234 .llseek = noop_llseek,
235}; 235};
236 236
237static int timerfd_fget(int fd, struct fd *p) 237static struct file *timerfd_fget(int fd)
238{ 238{
239 struct fd f = fdget(fd); 239 struct file *file;
240 if (!f.file) 240
241 return -EBADF; 241 file = fget(fd);
242 if (f.file->f_op != &timerfd_fops) { 242 if (!file)
243 fdput(f); 243 return ERR_PTR(-EBADF);
244 return -EINVAL; 244 if (file->f_op != &timerfd_fops) {
245 fput(file);
246 return ERR_PTR(-EINVAL);
245 } 247 }
246 *p = f; 248
247 return 0; 249 return file;
248} 250}
249 251
250SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags) 252SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
@@ -282,7 +284,7 @@ SYSCALL_DEFINE4(timerfd_settime, int, ufd, int, flags,
282 const struct itimerspec __user *, utmr, 284 const struct itimerspec __user *, utmr,
283 struct itimerspec __user *, otmr) 285 struct itimerspec __user *, otmr)
284{ 286{
285 struct fd f; 287 struct file *file;
286 struct timerfd_ctx *ctx; 288 struct timerfd_ctx *ctx;
287 struct itimerspec ktmr, kotmr; 289 struct itimerspec ktmr, kotmr;
288 int ret; 290 int ret;
@@ -295,10 +297,10 @@ SYSCALL_DEFINE4(timerfd_settime, int, ufd, int, flags,
295 !timespec_valid(&ktmr.it_interval)) 297 !timespec_valid(&ktmr.it_interval))
296 return -EINVAL; 298 return -EINVAL;
297 299
298 ret = timerfd_fget(ufd, &f); 300 file = timerfd_fget(ufd);
299 if (ret) 301 if (IS_ERR(file))
300 return ret; 302 return PTR_ERR(file);
301 ctx = f.file->private_data; 303 ctx = file->private_data;
302 304
303 timerfd_setup_cancel(ctx, flags); 305 timerfd_setup_cancel(ctx, flags);
304 306
@@ -332,7 +334,7 @@ SYSCALL_DEFINE4(timerfd_settime, int, ufd, int, flags,
332 ret = timerfd_setup(ctx, flags, &ktmr); 334 ret = timerfd_setup(ctx, flags, &ktmr);
333 335
334 spin_unlock_irq(&ctx->wqh.lock); 336 spin_unlock_irq(&ctx->wqh.lock);
335 fdput(f); 337 fput(file);
336 if (otmr && copy_to_user(otmr, &kotmr, sizeof(kotmr))) 338 if (otmr && copy_to_user(otmr, &kotmr, sizeof(kotmr)))
337 return -EFAULT; 339 return -EFAULT;
338 340
@@ -341,13 +343,14 @@ SYSCALL_DEFINE4(timerfd_settime, int, ufd, int, flags,
341 343
342SYSCALL_DEFINE2(timerfd_gettime, int, ufd, struct itimerspec __user *, otmr) 344SYSCALL_DEFINE2(timerfd_gettime, int, ufd, struct itimerspec __user *, otmr)
343{ 345{
344 struct fd f; 346 struct file *file;
345 struct timerfd_ctx *ctx; 347 struct timerfd_ctx *ctx;
346 struct itimerspec kotmr; 348 struct itimerspec kotmr;
347 int ret = timerfd_fget(ufd, &f); 349
348 if (ret) 350 file = timerfd_fget(ufd);
349 return ret; 351 if (IS_ERR(file))
350 ctx = f.file->private_data; 352 return PTR_ERR(file);
353 ctx = file->private_data;
351 354
352 spin_lock_irq(&ctx->wqh.lock); 355 spin_lock_irq(&ctx->wqh.lock);
353 if (ctx->expired && ctx->tintv.tv64) { 356 if (ctx->expired && ctx->tintv.tv64) {
@@ -359,7 +362,7 @@ SYSCALL_DEFINE2(timerfd_gettime, int, ufd, struct itimerspec __user *, otmr)
359 kotmr.it_value = ktime_to_timespec(timerfd_get_remaining(ctx)); 362 kotmr.it_value = ktime_to_timespec(timerfd_get_remaining(ctx));
360 kotmr.it_interval = ktime_to_timespec(ctx->tintv); 363 kotmr.it_interval = ktime_to_timespec(ctx->tintv);
361 spin_unlock_irq(&ctx->wqh.lock); 364 spin_unlock_irq(&ctx->wqh.lock);
362 fdput(f); 365 fput(file);
363 366
364 return copy_to_user(otmr, &kotmr, sizeof(kotmr)) ? -EFAULT: 0; 367 return copy_to_user(otmr, &kotmr, sizeof(kotmr)) ? -EFAULT: 0;
365} 368}