Skip to content

Commit

Permalink
winesync: Introduce the winesync driver and character device
Browse files Browse the repository at this point in the history
  • Loading branch information
Zebediah Figura authored and xanmod committed May 30, 2022
1 parent 54dcaa9 commit 2946fd9
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/misc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,17 @@ config OPEN_DICE

If unsure, say N.

config WINESYNC
tristate "Synchronization primitives for Wine"
help
This module provides kernel support for synchronization primitives
used by Wine. It is not a hardware driver.

To compile this driver as a module, choose M here: the
module will be called winesync.

If unsure, say N.

source "drivers/misc/c2port/Kconfig"
source "drivers/misc/eeprom/Kconfig"
source "drivers/misc/cb710/Kconfig"
Expand Down
1 change: 1 addition & 0 deletions drivers/misc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ obj-$(CONFIG_HABANA_AI) += habanalabs/
obj-$(CONFIG_UACCE) += uacce/
obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o
obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o
obj-$(CONFIG_WINESYNC) += winesync.o
obj-$(CONFIG_HI6421V600_IRQ) += hi6421v600-irq.o
obj-$(CONFIG_OPEN_DICE) += open-dice.o
64 changes: 64 additions & 0 deletions drivers/misc/winesync.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* winesync.c - Kernel driver for Wine synchronization primitives
*
* Copyright (C) 2021 Zebediah Figura
*/

#include <linux/fs.h>
#include <linux/miscdevice.h>
#include <linux/module.h>

#define WINESYNC_NAME "winesync"

static int winesync_char_open(struct inode *inode, struct file *file)
{
return nonseekable_open(inode, file);
}

static int winesync_char_release(struct inode *inode, struct file *file)
{
return 0;
}

static long winesync_char_ioctl(struct file *file, unsigned int cmd,
unsigned long parm)
{
switch (cmd) {
default:
return -ENOSYS;
}
}

static const struct file_operations winesync_fops = {
.owner = THIS_MODULE,
.open = winesync_char_open,
.release = winesync_char_release,
.unlocked_ioctl = winesync_char_ioctl,
.compat_ioctl = winesync_char_ioctl,
.llseek = no_llseek,
};

static struct miscdevice winesync_misc = {
.minor = MISC_DYNAMIC_MINOR,
.name = WINESYNC_NAME,
.fops = &winesync_fops,
};

static int __init winesync_init(void)
{
return misc_register(&winesync_misc);
}

static void __exit winesync_exit(void)
{
misc_deregister(&winesync_misc);
}

module_init(winesync_init);
module_exit(winesync_exit);

MODULE_AUTHOR("Zebediah Figura");
MODULE_DESCRIPTION("Kernel driver for Wine synchronization primitives");
MODULE_LICENSE("GPL");
MODULE_ALIAS("devname:" WINESYNC_NAME);

0 comments on commit 2946fd9

Please sign in to comment.