24 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
27 #include <linux/poll.h>
28 #include <linux/sched.h>
30 #include <linux/module.h>
32 #define ROCCAT_FIRST_MINOR 0
33 #define ROCCAT_MAX_DEVICES 8
36 #define ROCCAT_CBUF_SIZE 16
69 static int roccat_major;
70 static struct cdev roccat_cdev;
77 size_t count, loff_t *ppos)
102 if (!device->
exist) {
140 static unsigned int roccat_poll(
struct file *file,
poll_table *
wait)
143 poll_wait(file, &reader->
device->wait, wait);
146 if (!reader->
device->exist)
151 static int roccat_open(
struct inode *
inode,
struct file *file)
153 unsigned int minor = iminor(inode);
164 device = devices[
minor];
167 pr_emerg(
"roccat device with minor %d doesn't exist\n", minor);
169 goto exit_err_devices;
174 if (!device->
open++) {
179 goto exit_err_readers;
182 error = hid_hw_open(device->
hid);
186 goto exit_err_readers;
206 static int roccat_release(
struct inode *inode,
struct file *file)
208 unsigned int minor = iminor(inode);
214 device = devices[
minor];
217 pr_emerg(
"roccat device with minor %d doesn't exist\n", minor);
226 if (!--device->
open) {
230 hid_hw_close(device->
hid);
258 device = devices[minor];
269 report->
value = new_value;
315 if (minor < ROCCAT_MAX_DEVICES) {
316 devices[
minor] = device;
325 "%s%s%d",
"roccat", hid->
driver->name, minor);
327 if (IS_ERR(device->
dev)) {
330 temp = PTR_ERR(device->
dev);
338 INIT_LIST_HEAD(&device->
readers);
359 device = devices[
minor];
371 hid_hw_close(device->
hid);
379 static long roccat_ioctl(
struct file *file,
unsigned int cmd,
unsigned long arg)
381 struct inode *inode = file->
f_path.dentry->d_inode;
383 unsigned int minor = iminor(inode);
388 device = devices[
minor];
412 .release = roccat_release,
414 .unlocked_ioctl = roccat_ioctl,
417 static int __init roccat_init(
void)
425 roccat_major =
MAJOR(dev_id);
428 pr_warn(
"can't get major number\n");
438 static void __exit roccat_exit(
void)