]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ntsync: Introduce NTSYNC_IOC_EVENT_RESET.
authorElizabeth Figura <zfigura@codeweavers.com>
Fri, 13 Dec 2024 19:34:51 +0000 (13:34 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Jan 2025 12:18:11 +0000 (13:18 +0100)
This corresponds to the NT syscall NtResetEvent().

This sets the event to the unsignaled state, and returns its previous state.

Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20241213193511.457338-11-zfigura@codeweavers.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/ntsync.c
include/uapi/linux/ntsync.h

index 0a87f8ad59932672522cef5de94c1c92925822fe..b31443aa9692b3ec076d867a0ebfda3815dfd239 100644 (file)
@@ -559,6 +559,28 @@ static int ntsync_event_set(struct ntsync_obj *event, void __user *argp)
        return 0;
 }
 
+static int ntsync_event_reset(struct ntsync_obj *event, void __user *argp)
+{
+       struct ntsync_device *dev = event->dev;
+       __u32 prev_state;
+       bool all;
+
+       if (event->type != NTSYNC_TYPE_EVENT)
+               return -EINVAL;
+
+       all = ntsync_lock_obj(dev, event);
+
+       prev_state = event->u.event.signaled;
+       event->u.event.signaled = false;
+
+       ntsync_unlock_obj(dev, event, all);
+
+       if (put_user(prev_state, (__u32 __user *)argp))
+               return -EFAULT;
+
+       return 0;
+}
+
 static int ntsync_obj_release(struct inode *inode, struct file *file)
 {
        struct ntsync_obj *obj = file->private_data;
@@ -584,6 +606,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd,
                return ntsync_mutex_kill(obj, argp);
        case NTSYNC_IOC_EVENT_SET:
                return ntsync_event_set(obj, argp);
+       case NTSYNC_IOC_EVENT_RESET:
+               return ntsync_event_reset(obj, argp);
        default:
                return -ENOIOCTLCMD;
        }
index db2512f6e3f42cae62abaf848fa457c2448a77e3..d74c4e4f93d8116a3a067726e39eb32021a943fb 100644 (file)
@@ -49,5 +49,6 @@ struct ntsync_wait_args {
 #define NTSYNC_IOC_MUTEX_UNLOCK                _IOWR('N', 0x85, struct ntsync_mutex_args)
 #define NTSYNC_IOC_MUTEX_KILL          _IOW ('N', 0x86, __u32)
 #define NTSYNC_IOC_EVENT_SET           _IOR ('N', 0x88, __u32)
+#define NTSYNC_IOC_EVENT_RESET         _IOR ('N', 0x89, __u32)
 
 #endif