mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-23 07:34:31 +00:00
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>
This commit is contained in:
parent
71ca97da9d
commit
ee62c6b2dc
2 changed files with 5 additions and 9 deletions
12
fs/eventfd.c
12
fs/eventfd.c
|
@ -46,20 +46,16 @@ struct eventfd_ctx {
|
||||||
* value, and we signal this as overflow condition by returining a POLLERR
|
* value, and we signal this as overflow condition by returining a POLLERR
|
||||||
* to poll(2).
|
* to poll(2).
|
||||||
*
|
*
|
||||||
* Returns @n in case of success, a non-negative number lower than @n in case
|
* Returns the amount by which the counter was incrememnted. This will be less
|
||||||
* of overflow, or the following error codes:
|
* than @n if the counter has overflowed.
|
||||||
*
|
|
||||||
* -EINVAL : The value of @n is negative.
|
|
||||||
*/
|
*/
|
||||||
int eventfd_signal(struct eventfd_ctx *ctx, int n)
|
__u64 eventfd_signal(struct eventfd_ctx *ctx, __u64 n)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
if (n < 0)
|
|
||||||
return -EINVAL;
|
|
||||||
spin_lock_irqsave(&ctx->wqh.lock, flags);
|
spin_lock_irqsave(&ctx->wqh.lock, flags);
|
||||||
if (ULLONG_MAX - ctx->count < n)
|
if (ULLONG_MAX - ctx->count < n)
|
||||||
n = (int) (ULLONG_MAX - ctx->count);
|
n = ULLONG_MAX - ctx->count;
|
||||||
ctx->count += n;
|
ctx->count += n;
|
||||||
if (waitqueue_active(&ctx->wqh))
|
if (waitqueue_active(&ctx->wqh))
|
||||||
wake_up_locked_poll(&ctx->wqh, POLLIN);
|
wake_up_locked_poll(&ctx->wqh, POLLIN);
|
||||||
|
|
|
@ -34,7 +34,7 @@ void eventfd_ctx_put(struct eventfd_ctx *ctx);
|
||||||
struct file *eventfd_fget(int fd);
|
struct file *eventfd_fget(int fd);
|
||||||
struct eventfd_ctx *eventfd_ctx_fdget(int fd);
|
struct eventfd_ctx *eventfd_ctx_fdget(int fd);
|
||||||
struct eventfd_ctx *eventfd_ctx_fileget(struct file *file);
|
struct eventfd_ctx *eventfd_ctx_fileget(struct file *file);
|
||||||
int eventfd_signal(struct eventfd_ctx *ctx, int n);
|
__u64 eventfd_signal(struct eventfd_ctx *ctx, __u64 n);
|
||||||
ssize_t eventfd_ctx_read(struct eventfd_ctx *ctx, int no_wait, __u64 *cnt);
|
ssize_t eventfd_ctx_read(struct eventfd_ctx *ctx, int no_wait, __u64 *cnt);
|
||||||
int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx, wait_queue_t *wait,
|
int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx, wait_queue_t *wait,
|
||||||
__u64 *cnt);
|
__u64 *cnt);
|
||||||
|
|
Loading…
Add table
Reference in a new issue