diff options
author | Sha Zhengju <handai.szj@taobao.com> | 2012-05-31 19:26:41 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-31 20:49:32 -0400 |
commit | ee62c6b2dc93c09585b51fad18449dc5edb9977f (patch) | |
tree | 538f5338f6a00d1a4cee9e69ba74082747a452aa | |
parent | 71ca97da9d027009d318d319cbacf54a72f666c1 (diff) |
eventfd: change int to __u64 in eventfd_signal()
eventfd_ctx->count is an __u64 counter which is allowed to reach
ULLONG_MAX. eventfd_write() adds a __u64 value to "count", but the kernel
side eventfd_signal() only adds an int value to it. Make them consistent.
[akpm@linux-foundation.org: update interface documentation]
Signed-off-by: Sha Zhengju <handai.szj@taobao.com>
Cc: Davide Libenzi <davidel@xmailserver.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/eventfd.c | 12 | ||||
-rw-r--r-- | include/linux/eventfd.h | 2 |
2 files changed, 5 insertions, 9 deletions
diff --git a/fs/eventfd.c b/fs/eventfd.c index dba15fecf23e..d81b9f654086 100644 --- a/fs/eventfd.c +++ b/fs/eventfd.c | |||
@@ -46,20 +46,16 @@ struct eventfd_ctx { | |||
46 | * value, and we signal this as overflow condition by returining a POLLERR | 46 | * value, and we signal this as overflow condition by returining a POLLERR |
47 | * to poll(2). | 47 | * to poll(2). |
48 | * | 48 | * |
49 | * Returns @n in case of success, a non-negative number lower than @n in case | 49 | * Returns the amount by which the counter was incrememnted. This will be less |
50 | * of overflow, or the following error codes: | 50 | * than @n if the counter has overflowed. |
51 | * | ||
52 | * -EINVAL : The value of @n is negative. | ||
53 | */ | 51 | */ |
54 | int eventfd_signal(struct eventfd_ctx *ctx, int n) | 52 | __u64 eventfd_signal(struct eventfd_ctx *ctx, __u64 n) |
55 | { | 53 | { |
56 | unsigned long flags; | 54 | unsigned long flags; |
57 | 55 | ||
58 | if (n < 0) | ||
59 | return -EINVAL; | ||
60 | spin_lock_irqsave(&ctx->wqh.lock, flags); | 56 | spin_lock_irqsave(&ctx->wqh.lock, flags); |
61 | if (ULLONG_MAX - ctx->count < n) | 57 | if (ULLONG_MAX - ctx->count < n) |
62 | n = (int) (ULLONG_MAX - ctx->count); | 58 | n = ULLONG_MAX - ctx->count; |
63 | ctx->count += n; | 59 | ctx->count += n; |
64 | if (waitqueue_active(&ctx->wqh)) | 60 | if (waitqueue_active(&ctx->wqh)) |
65 | wake_up_locked_poll(&ctx->wqh, POLLIN); | 61 | wake_up_locked_poll(&ctx->wqh, POLLIN); |
diff --git a/include/linux/eventfd.h b/include/linux/eventfd.h index 91bb4f27238c..3c3ef19a625a 100644 --- a/include/linux/eventfd.h +++ b/include/linux/eventfd.h | |||
@@ -34,7 +34,7 @@ void eventfd_ctx_put(struct eventfd_ctx *ctx); | |||
34 | struct file *eventfd_fget(int fd); | 34 | struct file *eventfd_fget(int fd); |
35 | struct eventfd_ctx *eventfd_ctx_fdget(int fd); | 35 | struct eventfd_ctx *eventfd_ctx_fdget(int fd); |
36 | struct eventfd_ctx *eventfd_ctx_fileget(struct file *file); | 36 | struct eventfd_ctx *eventfd_ctx_fileget(struct file *file); |
37 | int eventfd_signal(struct eventfd_ctx *ctx, int n); | 37 | __u64 eventfd_signal(struct eventfd_ctx *ctx, __u64 n); |
38 | ssize_t eventfd_ctx_read(struct eventfd_ctx *ctx, int no_wait, __u64 *cnt); | 38 | ssize_t eventfd_ctx_read(struct eventfd_ctx *ctx, int no_wait, __u64 *cnt); |
39 | int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx, wait_queue_t *wait, | 39 | int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx, wait_queue_t *wait, |
40 | __u64 *cnt); | 40 | __u64 *cnt); |