Skip to content

Commit

Permalink
winesync: Introduce WINESYNC_IOC_READ_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 4f3ff01 commit 69dbb25
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
29 changes: 29 additions & 0 deletions drivers/misc/winesync.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,33 @@ static int winesync_read_mutex(struct winesync_device *dev, void __user *argp)
return ret;
}

static int winesync_read_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;
__u32 id;

if (get_user(id, &user_args->event))
return -EFAULT;

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

args.event = id;
spin_lock(&event->lock);
args.manual = event->u.event.manual;
args.signaled = event->u.event.signaled;
spin_unlock(&event->lock);

put_obj(event);

if (copy_to_user(user_args, &args, sizeof(args)))
return -EFAULT;
return 0;
}

/*
* Actually change the mutex state to mark its owner as dead.
*/
Expand Down Expand Up @@ -1081,6 +1108,8 @@ static long winesync_char_ioctl(struct file *file, unsigned int cmd,
return winesync_put_mutex(dev, argp);
case WINESYNC_IOC_PUT_SEM:
return winesync_put_sem(dev, argp);
case WINESYNC_IOC_READ_EVENT:
return winesync_read_event(dev, argp);
case WINESYNC_IOC_READ_MUTEX:
return winesync_read_mutex(dev, argp);
case WINESYNC_IOC_READ_SEM:
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 @@ -65,5 +65,7 @@ struct winesync_wait_args {
struct winesync_event_args)
#define WINESYNC_IOC_PULSE_EVENT _IOWR(WINESYNC_IOC_BASE, 13, \
struct winesync_event_args)
#define WINESYNC_IOC_READ_EVENT _IOWR(WINESYNC_IOC_BASE, 14, \
struct winesync_event_args)

#endif

0 comments on commit 69dbb25

Please sign in to comment.