Skip to content

Commit

Permalink
winesync: Introduce WINESYNC_IOC_RESET_EVENT.
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Frade <kernel@xanmod.org>
  • Loading branch information
Zebediah Figura authored and xanmod committed Aug 2, 2022
1 parent 3ab668e commit 2770e07
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
31 changes: 31 additions & 0 deletions drivers/misc/winesync.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,35 @@ static int winesync_set_event(struct winesync_device *dev, void __user *argp)
return 0;
}

static int winesync_reset_event(struct winesync_device *dev, void __user *argp)
{
struct winesync_event_args __user *user_args = argp;
struct winesync_event_args args;
struct winesync_obj *event;
bool prev_state;

if (copy_from_user(&args, argp, sizeof(args)))
return -EFAULT;

event = get_obj_typed(dev, args.event, WINESYNC_TYPE_EVENT);
if (!event)
return -EINVAL;

spin_lock(&event->lock);

prev_state = event->u.event.signaled;
event->u.event.signaled = false;

spin_unlock(&event->lock);

put_obj(event);

if (put_user(prev_state, &user_args->signaled))
return -EFAULT;

return 0;
}

static int winesync_schedule(const struct winesync_q *q, ktime_t *timeout)
{
int ret = 0;
Expand Down Expand Up @@ -1049,6 +1078,8 @@ static long winesync_char_ioctl(struct file *file, unsigned int cmd,
return winesync_read_mutex(dev, argp);
case WINESYNC_IOC_READ_SEM:
return winesync_read_sem(dev, argp);
case WINESYNC_IOC_RESET_EVENT:
return winesync_reset_event(dev, argp);
case WINESYNC_IOC_SET_EVENT:
return winesync_set_event(dev, argp);
case WINESYNC_IOC_WAIT_ALL:
Expand Down
2 changes: 2 additions & 0 deletions include/uapi/linux/winesync.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,7 @@ struct winesync_wait_args {
struct winesync_event_args)
#define WINESYNC_IOC_SET_EVENT _IOWR(WINESYNC_IOC_BASE, 11, \
struct winesync_event_args)
#define WINESYNC_IOC_RESET_EVENT _IOWR(WINESYNC_IOC_BASE, 12, \
struct winesync_event_args)

#endif

0 comments on commit 2770e07

Please sign in to comment.