ARM: virt: allow the kernel to be entered in HYP mode
[linux-2.6/btrfs-unstable.git] / drivers / hid / hid-roccat-koneplus.c
blobf5602fec48655016ca0fabdad1b743f71c17ae52
1 /*
2 * Roccat Kone[+] driver for Linux
4 * Copyright (c) 2010 Stefan Achatz <erazor_de@users.sourceforge.net>
5 */
7 /*
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
15 * Roccat Kone[+] is an updated/improved version of the Kone with more memory
16 * and functionality and without the non-standard behaviours the Kone had.
19 #include <linux/device.h>
20 #include <linux/input.h>
21 #include <linux/hid.h>
22 #include <linux/module.h>
23 #include <linux/slab.h>
24 #include <linux/hid-roccat.h>
25 #include "hid-ids.h"
26 #include "hid-roccat-common.h"
27 #include "hid-roccat-koneplus.h"
29 static uint profile_numbers[5] = {0, 1, 2, 3, 4};
31 static struct class *koneplus_class;
33 static void koneplus_profile_activated(struct koneplus_device *koneplus,
34 uint new_profile)
36 koneplus->actual_profile = new_profile;
39 static int koneplus_send_control(struct usb_device *usb_dev, uint value,
40 enum koneplus_control_requests request)
42 struct roccat_common2_control control;
44 if ((request == KONEPLUS_CONTROL_REQUEST_PROFILE_SETTINGS ||
45 request == KONEPLUS_CONTROL_REQUEST_PROFILE_BUTTONS) &&
46 value > 4)
47 return -EINVAL;
49 control.command = ROCCAT_COMMON_COMMAND_CONTROL;
50 control.value = value;
51 control.request = request;
53 return roccat_common2_send_with_status(usb_dev,
54 ROCCAT_COMMON_COMMAND_CONTROL,
55 &control, sizeof(struct roccat_common2_control));
58 static int koneplus_get_info(struct usb_device *usb_dev,
59 struct koneplus_info *buf)
61 return roccat_common2_receive(usb_dev, KONEPLUS_COMMAND_INFO,
62 buf, sizeof(struct koneplus_info));
65 static int koneplus_get_profile_settings(struct usb_device *usb_dev,
66 struct koneplus_profile_settings *buf, uint number)
68 int retval;
70 retval = koneplus_send_control(usb_dev, number,
71 KONEPLUS_CONTROL_REQUEST_PROFILE_SETTINGS);
72 if (retval)
73 return retval;
75 return roccat_common2_receive(usb_dev, KONEPLUS_COMMAND_PROFILE_SETTINGS,
76 buf, sizeof(struct koneplus_profile_settings));
79 static int koneplus_set_profile_settings(struct usb_device *usb_dev,
80 struct koneplus_profile_settings const *settings)
82 return roccat_common2_send_with_status(usb_dev,
83 KONEPLUS_COMMAND_PROFILE_SETTINGS,
84 settings, sizeof(struct koneplus_profile_settings));
87 static int koneplus_get_profile_buttons(struct usb_device *usb_dev,
88 struct koneplus_profile_buttons *buf, int number)
90 int retval;
92 retval = koneplus_send_control(usb_dev, number,
93 KONEPLUS_CONTROL_REQUEST_PROFILE_BUTTONS);
94 if (retval)
95 return retval;
97 return roccat_common2_receive(usb_dev, KONEPLUS_COMMAND_PROFILE_BUTTONS,
98 buf, sizeof(struct koneplus_profile_buttons));
101 static int koneplus_set_profile_buttons(struct usb_device *usb_dev,
102 struct koneplus_profile_buttons const *buttons)
104 return roccat_common2_send_with_status(usb_dev,
105 KONEPLUS_COMMAND_PROFILE_BUTTONS,
106 buttons, sizeof(struct koneplus_profile_buttons));
109 /* retval is 0-4 on success, < 0 on error */
110 static int koneplus_get_actual_profile(struct usb_device *usb_dev)
112 struct koneplus_actual_profile buf;
113 int retval;
115 retval = roccat_common2_receive(usb_dev, KONEPLUS_COMMAND_ACTUAL_PROFILE,
116 &buf, sizeof(struct koneplus_actual_profile));
118 return retval ? retval : buf.actual_profile;
121 static int koneplus_set_actual_profile(struct usb_device *usb_dev,
122 int new_profile)
124 struct koneplus_actual_profile buf;
126 buf.command = KONEPLUS_COMMAND_ACTUAL_PROFILE;
127 buf.size = sizeof(struct koneplus_actual_profile);
128 buf.actual_profile = new_profile;
130 return roccat_common2_send_with_status(usb_dev,
131 KONEPLUS_COMMAND_ACTUAL_PROFILE,
132 &buf, sizeof(struct koneplus_actual_profile));
135 static ssize_t koneplus_sysfs_read(struct file *fp, struct kobject *kobj,
136 char *buf, loff_t off, size_t count,
137 size_t real_size, uint command)
139 struct device *dev =
140 container_of(kobj, struct device, kobj)->parent->parent;
141 struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev));
142 struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
143 int retval;
145 if (off >= real_size)
146 return 0;
148 if (off != 0 || count != real_size)
149 return -EINVAL;
151 mutex_lock(&koneplus->koneplus_lock);
152 retval = roccat_common2_receive(usb_dev, command, buf, real_size);
153 mutex_unlock(&koneplus->koneplus_lock);
155 if (retval)
156 return retval;
158 return real_size;
161 static ssize_t koneplus_sysfs_write(struct file *fp, struct kobject *kobj,
162 void const *buf, loff_t off, size_t count,
163 size_t real_size, uint command)
165 struct device *dev =
166 container_of(kobj, struct device, kobj)->parent->parent;
167 struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev));
168 struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
169 int retval;
171 if (off != 0 || count != real_size)
172 return -EINVAL;
174 mutex_lock(&koneplus->koneplus_lock);
175 retval = roccat_common2_send_with_status(usb_dev, command,
176 buf, real_size);
177 mutex_unlock(&koneplus->koneplus_lock);
179 if (retval)
180 return retval;
182 return real_size;
185 static ssize_t koneplus_sysfs_write_talk(struct file *fp,
186 struct kobject *kobj, struct bin_attribute *attr, char *buf,
187 loff_t off, size_t count)
189 return koneplus_sysfs_write(fp, kobj, buf, off, count,
190 sizeof(struct koneplus_talk), KONEPLUS_COMMAND_TALK);
193 static ssize_t koneplus_sysfs_write_macro(struct file *fp,
194 struct kobject *kobj, struct bin_attribute *attr, char *buf,
195 loff_t off, size_t count)
197 return koneplus_sysfs_write(fp, kobj, buf, off, count,
198 sizeof(struct koneplus_macro), KONEPLUS_COMMAND_MACRO);
201 static ssize_t koneplus_sysfs_read_sensor(struct file *fp,
202 struct kobject *kobj, struct bin_attribute *attr, char *buf,
203 loff_t off, size_t count)
205 return koneplus_sysfs_read(fp, kobj, buf, off, count,
206 sizeof(struct koneplus_sensor), KONEPLUS_COMMAND_SENSOR);
209 static ssize_t koneplus_sysfs_write_sensor(struct file *fp,
210 struct kobject *kobj, struct bin_attribute *attr, char *buf,
211 loff_t off, size_t count)
213 return koneplus_sysfs_write(fp, kobj, buf, off, count,
214 sizeof(struct koneplus_sensor), KONEPLUS_COMMAND_SENSOR);
217 static ssize_t koneplus_sysfs_write_tcu(struct file *fp,
218 struct kobject *kobj, struct bin_attribute *attr, char *buf,
219 loff_t off, size_t count)
221 return koneplus_sysfs_write(fp, kobj, buf, off, count,
222 sizeof(struct koneplus_tcu), KONEPLUS_COMMAND_TCU);
225 static ssize_t koneplus_sysfs_read_tcu_image(struct file *fp,
226 struct kobject *kobj, struct bin_attribute *attr, char *buf,
227 loff_t off, size_t count)
229 return koneplus_sysfs_read(fp, kobj, buf, off, count,
230 sizeof(struct koneplus_tcu_image), KONEPLUS_COMMAND_TCU);
233 static ssize_t koneplus_sysfs_read_profilex_settings(struct file *fp,
234 struct kobject *kobj, struct bin_attribute *attr, char *buf,
235 loff_t off, size_t count)
237 struct device *dev =
238 container_of(kobj, struct device, kobj)->parent->parent;
239 struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev));
241 if (off >= sizeof(struct koneplus_profile_settings))
242 return 0;
244 if (off + count > sizeof(struct koneplus_profile_settings))
245 count = sizeof(struct koneplus_profile_settings) - off;
247 mutex_lock(&koneplus->koneplus_lock);
248 memcpy(buf, ((char const *)&koneplus->profile_settings[*(uint *)(attr->private)]) + off,
249 count);
250 mutex_unlock(&koneplus->koneplus_lock);
252 return count;
255 static ssize_t koneplus_sysfs_write_profile_settings(struct file *fp,
256 struct kobject *kobj, struct bin_attribute *attr, char *buf,
257 loff_t off, size_t count)
259 struct device *dev =
260 container_of(kobj, struct device, kobj)->parent->parent;
261 struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev));
262 struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
263 int retval = 0;
264 int difference;
265 int profile_number;
266 struct koneplus_profile_settings *profile_settings;
268 if (off != 0 || count != sizeof(struct koneplus_profile_settings))
269 return -EINVAL;
271 profile_number = ((struct koneplus_profile_settings const *)buf)->number;
272 profile_settings = &koneplus->profile_settings[profile_number];
274 mutex_lock(&koneplus->koneplus_lock);
275 difference = memcmp(buf, profile_settings,
276 sizeof(struct koneplus_profile_settings));
277 if (difference) {
278 retval = koneplus_set_profile_settings(usb_dev,
279 (struct koneplus_profile_settings const *)buf);
280 if (!retval)
281 memcpy(profile_settings, buf,
282 sizeof(struct koneplus_profile_settings));
284 mutex_unlock(&koneplus->koneplus_lock);
286 if (retval)
287 return retval;
289 return sizeof(struct koneplus_profile_settings);
292 static ssize_t koneplus_sysfs_read_profilex_buttons(struct file *fp,
293 struct kobject *kobj, struct bin_attribute *attr, char *buf,
294 loff_t off, size_t count)
296 struct device *dev =
297 container_of(kobj, struct device, kobj)->parent->parent;
298 struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev));
300 if (off >= sizeof(struct koneplus_profile_buttons))
301 return 0;
303 if (off + count > sizeof(struct koneplus_profile_buttons))
304 count = sizeof(struct koneplus_profile_buttons) - off;
306 mutex_lock(&koneplus->koneplus_lock);
307 memcpy(buf, ((char const *)&koneplus->profile_buttons[*(uint *)(attr->private)]) + off,
308 count);
309 mutex_unlock(&koneplus->koneplus_lock);
311 return count;
314 static ssize_t koneplus_sysfs_write_profile_buttons(struct file *fp,
315 struct kobject *kobj, struct bin_attribute *attr, char *buf,
316 loff_t off, size_t count)
318 struct device *dev =
319 container_of(kobj, struct device, kobj)->parent->parent;
320 struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev));
321 struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
322 int retval = 0;
323 int difference;
324 uint profile_number;
325 struct koneplus_profile_buttons *profile_buttons;
327 if (off != 0 || count != sizeof(struct koneplus_profile_buttons))
328 return -EINVAL;
330 profile_number = ((struct koneplus_profile_buttons const *)buf)->number;
331 profile_buttons = &koneplus->profile_buttons[profile_number];
333 mutex_lock(&koneplus->koneplus_lock);
334 difference = memcmp(buf, profile_buttons,
335 sizeof(struct koneplus_profile_buttons));
336 if (difference) {
337 retval = koneplus_set_profile_buttons(usb_dev,
338 (struct koneplus_profile_buttons const *)buf);
339 if (!retval)
340 memcpy(profile_buttons, buf,
341 sizeof(struct koneplus_profile_buttons));
343 mutex_unlock(&koneplus->koneplus_lock);
345 if (retval)
346 return retval;
348 return sizeof(struct koneplus_profile_buttons);
351 static ssize_t koneplus_sysfs_show_actual_profile(struct device *dev,
352 struct device_attribute *attr, char *buf)
354 struct koneplus_device *koneplus =
355 hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
356 return snprintf(buf, PAGE_SIZE, "%d\n", koneplus->actual_profile);
359 static ssize_t koneplus_sysfs_set_actual_profile(struct device *dev,
360 struct device_attribute *attr, char const *buf, size_t size)
362 struct koneplus_device *koneplus;
363 struct usb_device *usb_dev;
364 unsigned long profile;
365 int retval;
366 struct koneplus_roccat_report roccat_report;
368 dev = dev->parent->parent;
369 koneplus = hid_get_drvdata(dev_get_drvdata(dev));
370 usb_dev = interface_to_usbdev(to_usb_interface(dev));
372 retval = strict_strtoul(buf, 10, &profile);
373 if (retval)
374 return retval;
376 if (profile > 4)
377 return -EINVAL;
379 mutex_lock(&koneplus->koneplus_lock);
381 retval = koneplus_set_actual_profile(usb_dev, profile);
382 if (retval) {
383 mutex_unlock(&koneplus->koneplus_lock);
384 return retval;
387 koneplus_profile_activated(koneplus, profile);
389 roccat_report.type = KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_PROFILE;
390 roccat_report.data1 = profile + 1;
391 roccat_report.data2 = 0;
392 roccat_report.profile = profile + 1;
393 roccat_report_event(koneplus->chrdev_minor,
394 (uint8_t const *)&roccat_report);
396 mutex_unlock(&koneplus->koneplus_lock);
398 return size;
401 static ssize_t koneplus_sysfs_show_firmware_version(struct device *dev,
402 struct device_attribute *attr, char *buf)
404 struct koneplus_device *koneplus =
405 hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
406 return snprintf(buf, PAGE_SIZE, "%d\n", koneplus->info.firmware_version);
409 static struct device_attribute koneplus_attributes[] = {
410 __ATTR(actual_profile, 0660,
411 koneplus_sysfs_show_actual_profile,
412 koneplus_sysfs_set_actual_profile),
413 __ATTR(startup_profile, 0660,
414 koneplus_sysfs_show_actual_profile,
415 koneplus_sysfs_set_actual_profile),
416 __ATTR(firmware_version, 0440,
417 koneplus_sysfs_show_firmware_version, NULL),
418 __ATTR_NULL
421 static struct bin_attribute koneplus_bin_attributes[] = {
423 .attr = { .name = "sensor", .mode = 0660 },
424 .size = sizeof(struct koneplus_sensor),
425 .read = koneplus_sysfs_read_sensor,
426 .write = koneplus_sysfs_write_sensor
429 .attr = { .name = "tcu", .mode = 0220 },
430 .size = sizeof(struct koneplus_tcu),
431 .write = koneplus_sysfs_write_tcu
434 .attr = { .name = "tcu_image", .mode = 0440 },
435 .size = sizeof(struct koneplus_tcu_image),
436 .read = koneplus_sysfs_read_tcu_image
439 .attr = { .name = "profile_settings", .mode = 0220 },
440 .size = sizeof(struct koneplus_profile_settings),
441 .write = koneplus_sysfs_write_profile_settings
444 .attr = { .name = "profile1_settings", .mode = 0440 },
445 .size = sizeof(struct koneplus_profile_settings),
446 .read = koneplus_sysfs_read_profilex_settings,
447 .private = &profile_numbers[0]
450 .attr = { .name = "profile2_settings", .mode = 0440 },
451 .size = sizeof(struct koneplus_profile_settings),
452 .read = koneplus_sysfs_read_profilex_settings,
453 .private = &profile_numbers[1]
456 .attr = { .name = "profile3_settings", .mode = 0440 },
457 .size = sizeof(struct koneplus_profile_settings),
458 .read = koneplus_sysfs_read_profilex_settings,
459 .private = &profile_numbers[2]
462 .attr = { .name = "profile4_settings", .mode = 0440 },
463 .size = sizeof(struct koneplus_profile_settings),
464 .read = koneplus_sysfs_read_profilex_settings,
465 .private = &profile_numbers[3]
468 .attr = { .name = "profile5_settings", .mode = 0440 },
469 .size = sizeof(struct koneplus_profile_settings),
470 .read = koneplus_sysfs_read_profilex_settings,
471 .private = &profile_numbers[4]
474 .attr = { .name = "profile_buttons", .mode = 0220 },
475 .size = sizeof(struct koneplus_profile_buttons),
476 .write = koneplus_sysfs_write_profile_buttons
479 .attr = { .name = "profile1_buttons", .mode = 0440 },
480 .size = sizeof(struct koneplus_profile_buttons),
481 .read = koneplus_sysfs_read_profilex_buttons,
482 .private = &profile_numbers[0]
485 .attr = { .name = "profile2_buttons", .mode = 0440 },
486 .size = sizeof(struct koneplus_profile_buttons),
487 .read = koneplus_sysfs_read_profilex_buttons,
488 .private = &profile_numbers[1]
491 .attr = { .name = "profile3_buttons", .mode = 0440 },
492 .size = sizeof(struct koneplus_profile_buttons),
493 .read = koneplus_sysfs_read_profilex_buttons,
494 .private = &profile_numbers[2]
497 .attr = { .name = "profile4_buttons", .mode = 0440 },
498 .size = sizeof(struct koneplus_profile_buttons),
499 .read = koneplus_sysfs_read_profilex_buttons,
500 .private = &profile_numbers[3]
503 .attr = { .name = "profile5_buttons", .mode = 0440 },
504 .size = sizeof(struct koneplus_profile_buttons),
505 .read = koneplus_sysfs_read_profilex_buttons,
506 .private = &profile_numbers[4]
509 .attr = { .name = "macro", .mode = 0220 },
510 .size = sizeof(struct koneplus_macro),
511 .write = koneplus_sysfs_write_macro
514 .attr = { .name = "talk", .mode = 0220 },
515 .size = sizeof(struct koneplus_talk),
516 .write = koneplus_sysfs_write_talk
518 __ATTR_NULL
521 static int koneplus_init_koneplus_device_struct(struct usb_device *usb_dev,
522 struct koneplus_device *koneplus)
524 int retval, i;
525 static uint wait = 200;
527 mutex_init(&koneplus->koneplus_lock);
529 retval = koneplus_get_info(usb_dev, &koneplus->info);
530 if (retval)
531 return retval;
533 for (i = 0; i < 5; ++i) {
534 msleep(wait);
535 retval = koneplus_get_profile_settings(usb_dev,
536 &koneplus->profile_settings[i], i);
537 if (retval)
538 return retval;
540 msleep(wait);
541 retval = koneplus_get_profile_buttons(usb_dev,
542 &koneplus->profile_buttons[i], i);
543 if (retval)
544 return retval;
547 msleep(wait);
548 retval = koneplus_get_actual_profile(usb_dev);
549 if (retval < 0)
550 return retval;
551 koneplus_profile_activated(koneplus, retval);
553 return 0;
556 static int koneplus_init_specials(struct hid_device *hdev)
558 struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
559 struct usb_device *usb_dev = interface_to_usbdev(intf);
560 struct koneplus_device *koneplus;
561 int retval;
563 if (intf->cur_altsetting->desc.bInterfaceProtocol
564 == USB_INTERFACE_PROTOCOL_MOUSE) {
566 koneplus = kzalloc(sizeof(*koneplus), GFP_KERNEL);
567 if (!koneplus) {
568 hid_err(hdev, "can't alloc device descriptor\n");
569 return -ENOMEM;
571 hid_set_drvdata(hdev, koneplus);
573 retval = koneplus_init_koneplus_device_struct(usb_dev, koneplus);
574 if (retval) {
575 hid_err(hdev, "couldn't init struct koneplus_device\n");
576 goto exit_free;
579 retval = roccat_connect(koneplus_class, hdev,
580 sizeof(struct koneplus_roccat_report));
581 if (retval < 0) {
582 hid_err(hdev, "couldn't init char dev\n");
583 } else {
584 koneplus->chrdev_minor = retval;
585 koneplus->roccat_claimed = 1;
587 } else {
588 hid_set_drvdata(hdev, NULL);
591 return 0;
592 exit_free:
593 kfree(koneplus);
594 return retval;
597 static void koneplus_remove_specials(struct hid_device *hdev)
599 struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
600 struct koneplus_device *koneplus;
602 if (intf->cur_altsetting->desc.bInterfaceProtocol
603 == USB_INTERFACE_PROTOCOL_MOUSE) {
604 koneplus = hid_get_drvdata(hdev);
605 if (koneplus->roccat_claimed)
606 roccat_disconnect(koneplus->chrdev_minor);
607 kfree(koneplus);
611 static int koneplus_probe(struct hid_device *hdev,
612 const struct hid_device_id *id)
614 int retval;
616 retval = hid_parse(hdev);
617 if (retval) {
618 hid_err(hdev, "parse failed\n");
619 goto exit;
622 retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
623 if (retval) {
624 hid_err(hdev, "hw start failed\n");
625 goto exit;
628 retval = koneplus_init_specials(hdev);
629 if (retval) {
630 hid_err(hdev, "couldn't install mouse\n");
631 goto exit_stop;
634 return 0;
636 exit_stop:
637 hid_hw_stop(hdev);
638 exit:
639 return retval;
642 static void koneplus_remove(struct hid_device *hdev)
644 koneplus_remove_specials(hdev);
645 hid_hw_stop(hdev);
648 static void koneplus_keep_values_up_to_date(struct koneplus_device *koneplus,
649 u8 const *data)
651 struct koneplus_mouse_report_button const *button_report;
653 switch (data[0]) {
654 case KONEPLUS_MOUSE_REPORT_NUMBER_BUTTON:
655 button_report = (struct koneplus_mouse_report_button const *)data;
656 switch (button_report->type) {
657 case KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_PROFILE:
658 koneplus_profile_activated(koneplus, button_report->data1 - 1);
659 break;
661 break;
665 static void koneplus_report_to_chrdev(struct koneplus_device const *koneplus,
666 u8 const *data)
668 struct koneplus_roccat_report roccat_report;
669 struct koneplus_mouse_report_button const *button_report;
671 if (data[0] != KONEPLUS_MOUSE_REPORT_NUMBER_BUTTON)
672 return;
674 button_report = (struct koneplus_mouse_report_button const *)data;
676 if ((button_report->type == KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_QUICKLAUNCH ||
677 button_report->type == KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_TIMER) &&
678 button_report->data2 != KONEPLUS_MOUSE_REPORT_BUTTON_ACTION_PRESS)
679 return;
681 roccat_report.type = button_report->type;
682 roccat_report.data1 = button_report->data1;
683 roccat_report.data2 = button_report->data2;
684 roccat_report.profile = koneplus->actual_profile + 1;
685 roccat_report_event(koneplus->chrdev_minor,
686 (uint8_t const *)&roccat_report);
689 static int koneplus_raw_event(struct hid_device *hdev,
690 struct hid_report *report, u8 *data, int size)
692 struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
693 struct koneplus_device *koneplus = hid_get_drvdata(hdev);
695 if (intf->cur_altsetting->desc.bInterfaceProtocol
696 != USB_INTERFACE_PROTOCOL_MOUSE)
697 return 0;
699 if (koneplus == NULL)
700 return 0;
702 koneplus_keep_values_up_to_date(koneplus, data);
704 if (koneplus->roccat_claimed)
705 koneplus_report_to_chrdev(koneplus, data);
707 return 0;
710 static const struct hid_device_id koneplus_devices[] = {
711 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) },
715 MODULE_DEVICE_TABLE(hid, koneplus_devices);
717 static struct hid_driver koneplus_driver = {
718 .name = "koneplus",
719 .id_table = koneplus_devices,
720 .probe = koneplus_probe,
721 .remove = koneplus_remove,
722 .raw_event = koneplus_raw_event
725 static int __init koneplus_init(void)
727 int retval;
729 /* class name has to be same as driver name */
730 koneplus_class = class_create(THIS_MODULE, "koneplus");
731 if (IS_ERR(koneplus_class))
732 return PTR_ERR(koneplus_class);
733 koneplus_class->dev_attrs = koneplus_attributes;
734 koneplus_class->dev_bin_attrs = koneplus_bin_attributes;
736 retval = hid_register_driver(&koneplus_driver);
737 if (retval)
738 class_destroy(koneplus_class);
739 return retval;
742 static void __exit koneplus_exit(void)
744 hid_unregister_driver(&koneplus_driver);
745 class_destroy(koneplus_class);
748 module_init(koneplus_init);
749 module_exit(koneplus_exit);
751 MODULE_AUTHOR("Stefan Achatz");
752 MODULE_DESCRIPTION("USB Roccat Kone[+] driver");
753 MODULE_LICENSE("GPL v2");