hid-roccat-koneplus.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. /*
  2. * Roccat Kone[+] driver for Linux
  3. *
  4. * Copyright (c) 2010 Stefan Achatz <erazor_de@users.sourceforge.net>
  5. */
  6. /*
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the Free
  9. * Software Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. */
  12. /*
  13. * Roccat Kone[+] is an updated/improved version of the Kone with more memory
  14. * and functionality and without the non-standard behaviours the Kone had.
  15. * KoneXTD has same capabilities but updated sensor.
  16. */
  17. #include <linux/device.h>
  18. #include <linux/input.h>
  19. #include <linux/hid.h>
  20. #include <linux/module.h>
  21. #include <linux/slab.h>
  22. #include <linux/hid-roccat.h>
  23. #include "hid-ids.h"
  24. #include "hid-roccat-common.h"
  25. #include "hid-roccat-koneplus.h"
  26. static uint profile_numbers[5] = {0, 1, 2, 3, 4};
  27. static struct class *koneplus_class;
  28. static void koneplus_profile_activated(struct koneplus_device *koneplus,
  29. uint new_profile)
  30. {
  31. koneplus->actual_profile = new_profile;
  32. }
  33. static int koneplus_send_control(struct usb_device *usb_dev, uint value,
  34. enum koneplus_control_requests request)
  35. {
  36. struct roccat_common2_control control;
  37. if ((request == KONEPLUS_CONTROL_REQUEST_PROFILE_SETTINGS ||
  38. request == KONEPLUS_CONTROL_REQUEST_PROFILE_BUTTONS) &&
  39. value > 4)
  40. return -EINVAL;
  41. control.command = ROCCAT_COMMON_COMMAND_CONTROL;
  42. control.value = value;
  43. control.request = request;
  44. return roccat_common2_send_with_status(usb_dev,
  45. ROCCAT_COMMON_COMMAND_CONTROL,
  46. &control, sizeof(struct roccat_common2_control));
  47. }
  48. /* retval is 0-4 on success, < 0 on error */
  49. static int koneplus_get_actual_profile(struct usb_device *usb_dev)
  50. {
  51. struct koneplus_actual_profile buf;
  52. int retval;
  53. retval = roccat_common2_receive(usb_dev, KONEPLUS_COMMAND_ACTUAL_PROFILE,
  54. &buf, KONEPLUS_SIZE_ACTUAL_PROFILE);
  55. return retval ? retval : buf.actual_profile;
  56. }
  57. static int koneplus_set_actual_profile(struct usb_device *usb_dev,
  58. int new_profile)
  59. {
  60. struct koneplus_actual_profile buf;
  61. buf.command = KONEPLUS_COMMAND_ACTUAL_PROFILE;
  62. buf.size = KONEPLUS_SIZE_ACTUAL_PROFILE;
  63. buf.actual_profile = new_profile;
  64. return roccat_common2_send_with_status(usb_dev,
  65. KONEPLUS_COMMAND_ACTUAL_PROFILE,
  66. &buf, KONEPLUS_SIZE_ACTUAL_PROFILE);
  67. }
  68. static ssize_t koneplus_sysfs_read(struct file *fp, struct kobject *kobj,
  69. char *buf, loff_t off, size_t count,
  70. size_t real_size, uint command)
  71. {
  72. struct device *dev =
  73. container_of(kobj, struct device, kobj)->parent->parent;
  74. struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev));
  75. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  76. int retval;
  77. if (off >= real_size)
  78. return 0;
  79. if (off != 0 || count != real_size)
  80. return -EINVAL;
  81. mutex_lock(&koneplus->koneplus_lock);
  82. retval = roccat_common2_receive(usb_dev, command, buf, real_size);
  83. mutex_unlock(&koneplus->koneplus_lock);
  84. if (retval)
  85. return retval;
  86. return real_size;
  87. }
  88. static ssize_t koneplus_sysfs_write(struct file *fp, struct kobject *kobj,
  89. void const *buf, loff_t off, size_t count,
  90. size_t real_size, uint command)
  91. {
  92. struct device *dev =
  93. container_of(kobj, struct device, kobj)->parent->parent;
  94. struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev));
  95. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  96. int retval;
  97. if (off != 0 || count != real_size)
  98. return -EINVAL;
  99. mutex_lock(&koneplus->koneplus_lock);
  100. retval = roccat_common2_send_with_status(usb_dev, command,
  101. buf, real_size);
  102. mutex_unlock(&koneplus->koneplus_lock);
  103. if (retval)
  104. return retval;
  105. return real_size;
  106. }
  107. #define KONEPLUS_SYSFS_W(thingy, THINGY) \
  108. static ssize_t koneplus_sysfs_write_ ## thingy(struct file *fp, \
  109. struct kobject *kobj, struct bin_attribute *attr, char *buf, \
  110. loff_t off, size_t count) \
  111. { \
  112. return koneplus_sysfs_write(fp, kobj, buf, off, count, \
  113. KONEPLUS_SIZE_ ## THINGY, KONEPLUS_COMMAND_ ## THINGY); \
  114. }
  115. #define KONEPLUS_SYSFS_R(thingy, THINGY) \
  116. static ssize_t koneplus_sysfs_read_ ## thingy(struct file *fp, \
  117. struct kobject *kobj, struct bin_attribute *attr, char *buf, \
  118. loff_t off, size_t count) \
  119. { \
  120. return koneplus_sysfs_read(fp, kobj, buf, off, count, \
  121. KONEPLUS_SIZE_ ## THINGY, KONEPLUS_COMMAND_ ## THINGY); \
  122. }
  123. #define KONEPLUS_SYSFS_RW(thingy, THINGY) \
  124. KONEPLUS_SYSFS_W(thingy, THINGY) \
  125. KONEPLUS_SYSFS_R(thingy, THINGY)
  126. #define KONEPLUS_BIN_ATTRIBUTE_RW(thingy, THINGY) \
  127. { \
  128. .attr = { .name = #thingy, .mode = 0660 }, \
  129. .size = KONEPLUS_SIZE_ ## THINGY, \
  130. .read = koneplus_sysfs_read_ ## thingy, \
  131. .write = koneplus_sysfs_write_ ## thingy \
  132. }
  133. #define KONEPLUS_BIN_ATTRIBUTE_R(thingy, THINGY) \
  134. { \
  135. .attr = { .name = #thingy, .mode = 0440 }, \
  136. .size = KONEPLUS_SIZE_ ## THINGY, \
  137. .read = koneplus_sysfs_read_ ## thingy, \
  138. }
  139. #define KONEPLUS_BIN_ATTRIBUTE_W(thingy, THINGY) \
  140. { \
  141. .attr = { .name = #thingy, .mode = 0220 }, \
  142. .size = KONEPLUS_SIZE_ ## THINGY, \
  143. .write = koneplus_sysfs_write_ ## thingy \
  144. }
  145. KONEPLUS_SYSFS_W(control, CONTROL)
  146. KONEPLUS_SYSFS_RW(info, INFO)
  147. KONEPLUS_SYSFS_W(talk, TALK)
  148. KONEPLUS_SYSFS_W(macro, MACRO)
  149. KONEPLUS_SYSFS_RW(sensor, SENSOR)
  150. KONEPLUS_SYSFS_RW(tcu, TCU)
  151. KONEPLUS_SYSFS_R(tcu_image, TCU_IMAGE)
  152. KONEPLUS_SYSFS_RW(profile_settings, PROFILE_SETTINGS)
  153. KONEPLUS_SYSFS_RW(profile_buttons, PROFILE_BUTTONS)
  154. static ssize_t koneplus_sysfs_read_profilex_settings(struct file *fp,
  155. struct kobject *kobj, struct bin_attribute *attr, char *buf,
  156. loff_t off, size_t count)
  157. {
  158. struct device *dev =
  159. container_of(kobj, struct device, kobj)->parent->parent;
  160. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  161. ssize_t retval;
  162. retval = koneplus_send_control(usb_dev, *(uint *)(attr->private),
  163. KONEPLUS_CONTROL_REQUEST_PROFILE_SETTINGS);
  164. if (retval)
  165. return retval;
  166. return koneplus_sysfs_read(fp, kobj, buf, off, count,
  167. KONEPLUS_SIZE_PROFILE_SETTINGS,
  168. KONEPLUS_COMMAND_PROFILE_SETTINGS);
  169. }
  170. static ssize_t koneplus_sysfs_read_profilex_buttons(struct file *fp,
  171. struct kobject *kobj, struct bin_attribute *attr, char *buf,
  172. loff_t off, size_t count)
  173. {
  174. struct device *dev =
  175. container_of(kobj, struct device, kobj)->parent->parent;
  176. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  177. ssize_t retval;
  178. retval = koneplus_send_control(usb_dev, *(uint *)(attr->private),
  179. KONEPLUS_CONTROL_REQUEST_PROFILE_BUTTONS);
  180. if (retval)
  181. return retval;
  182. return koneplus_sysfs_read(fp, kobj, buf, off, count,
  183. KONEPLUS_SIZE_PROFILE_BUTTONS,
  184. KONEPLUS_COMMAND_PROFILE_BUTTONS);
  185. }
  186. static ssize_t koneplus_sysfs_show_actual_profile(struct device *dev,
  187. struct device_attribute *attr, char *buf)
  188. {
  189. struct koneplus_device *koneplus =
  190. hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
  191. return snprintf(buf, PAGE_SIZE, "%d\n", koneplus->actual_profile);
  192. }
  193. static ssize_t koneplus_sysfs_set_actual_profile(struct device *dev,
  194. struct device_attribute *attr, char const *buf, size_t size)
  195. {
  196. struct koneplus_device *koneplus;
  197. struct usb_device *usb_dev;
  198. unsigned long profile;
  199. int retval;
  200. struct koneplus_roccat_report roccat_report;
  201. dev = dev->parent->parent;
  202. koneplus = hid_get_drvdata(dev_get_drvdata(dev));
  203. usb_dev = interface_to_usbdev(to_usb_interface(dev));
  204. retval = strict_strtoul(buf, 10, &profile);
  205. if (retval)
  206. return retval;
  207. if (profile > 4)
  208. return -EINVAL;
  209. mutex_lock(&koneplus->koneplus_lock);
  210. retval = koneplus_set_actual_profile(usb_dev, profile);
  211. if (retval) {
  212. mutex_unlock(&koneplus->koneplus_lock);
  213. return retval;
  214. }
  215. koneplus_profile_activated(koneplus, profile);
  216. roccat_report.type = KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_PROFILE;
  217. roccat_report.data1 = profile + 1;
  218. roccat_report.data2 = 0;
  219. roccat_report.profile = profile + 1;
  220. roccat_report_event(koneplus->chrdev_minor,
  221. (uint8_t const *)&roccat_report);
  222. mutex_unlock(&koneplus->koneplus_lock);
  223. return size;
  224. }
  225. static ssize_t koneplus_sysfs_show_firmware_version(struct device *dev,
  226. struct device_attribute *attr, char *buf)
  227. {
  228. struct koneplus_device *koneplus;
  229. struct usb_device *usb_dev;
  230. struct koneplus_info info;
  231. dev = dev->parent->parent;
  232. koneplus = hid_get_drvdata(dev_get_drvdata(dev));
  233. usb_dev = interface_to_usbdev(to_usb_interface(dev));
  234. mutex_lock(&koneplus->koneplus_lock);
  235. roccat_common2_receive(usb_dev, KONEPLUS_COMMAND_INFO,
  236. &info, KONEPLUS_SIZE_INFO);
  237. mutex_unlock(&koneplus->koneplus_lock);
  238. return snprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version);
  239. }
  240. static struct device_attribute koneplus_attributes[] = {
  241. __ATTR(actual_profile, 0660,
  242. koneplus_sysfs_show_actual_profile,
  243. koneplus_sysfs_set_actual_profile),
  244. __ATTR(startup_profile, 0660,
  245. koneplus_sysfs_show_actual_profile,
  246. koneplus_sysfs_set_actual_profile),
  247. __ATTR(firmware_version, 0440,
  248. koneplus_sysfs_show_firmware_version, NULL),
  249. __ATTR_NULL
  250. };
  251. static struct bin_attribute koneplus_bin_attributes[] = {
  252. KONEPLUS_BIN_ATTRIBUTE_W(control, CONTROL),
  253. KONEPLUS_BIN_ATTRIBUTE_RW(info, INFO),
  254. KONEPLUS_BIN_ATTRIBUTE_W(talk, TALK),
  255. KONEPLUS_BIN_ATTRIBUTE_W(macro, MACRO),
  256. KONEPLUS_BIN_ATTRIBUTE_RW(sensor, SENSOR),
  257. KONEPLUS_BIN_ATTRIBUTE_RW(tcu, TCU),
  258. KONEPLUS_BIN_ATTRIBUTE_R(tcu_image, TCU_IMAGE),
  259. KONEPLUS_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS),
  260. KONEPLUS_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS),
  261. {
  262. .attr = { .name = "profile1_settings", .mode = 0440 },
  263. .size = KONEPLUS_SIZE_PROFILE_SETTINGS,
  264. .read = koneplus_sysfs_read_profilex_settings,
  265. .private = &profile_numbers[0]
  266. },
  267. {
  268. .attr = { .name = "profile2_settings", .mode = 0440 },
  269. .size = KONEPLUS_SIZE_PROFILE_SETTINGS,
  270. .read = koneplus_sysfs_read_profilex_settings,
  271. .private = &profile_numbers[1]
  272. },
  273. {
  274. .attr = { .name = "profile3_settings", .mode = 0440 },
  275. .size = KONEPLUS_SIZE_PROFILE_SETTINGS,
  276. .read = koneplus_sysfs_read_profilex_settings,
  277. .private = &profile_numbers[2]
  278. },
  279. {
  280. .attr = { .name = "profile4_settings", .mode = 0440 },
  281. .size = KONEPLUS_SIZE_PROFILE_SETTINGS,
  282. .read = koneplus_sysfs_read_profilex_settings,
  283. .private = &profile_numbers[3]
  284. },
  285. {
  286. .attr = { .name = "profile5_settings", .mode = 0440 },
  287. .size = KONEPLUS_SIZE_PROFILE_SETTINGS,
  288. .read = koneplus_sysfs_read_profilex_settings,
  289. .private = &profile_numbers[4]
  290. },
  291. {
  292. .attr = { .name = "profile1_buttons", .mode = 0440 },
  293. .size = KONEPLUS_SIZE_PROFILE_BUTTONS,
  294. .read = koneplus_sysfs_read_profilex_buttons,
  295. .private = &profile_numbers[0]
  296. },
  297. {
  298. .attr = { .name = "profile2_buttons", .mode = 0440 },
  299. .size = KONEPLUS_SIZE_PROFILE_BUTTONS,
  300. .read = koneplus_sysfs_read_profilex_buttons,
  301. .private = &profile_numbers[1]
  302. },
  303. {
  304. .attr = { .name = "profile3_buttons", .mode = 0440 },
  305. .size = KONEPLUS_SIZE_PROFILE_BUTTONS,
  306. .read = koneplus_sysfs_read_profilex_buttons,
  307. .private = &profile_numbers[2]
  308. },
  309. {
  310. .attr = { .name = "profile4_buttons", .mode = 0440 },
  311. .size = KONEPLUS_SIZE_PROFILE_BUTTONS,
  312. .read = koneplus_sysfs_read_profilex_buttons,
  313. .private = &profile_numbers[3]
  314. },
  315. {
  316. .attr = { .name = "profile5_buttons", .mode = 0440 },
  317. .size = KONEPLUS_SIZE_PROFILE_BUTTONS,
  318. .read = koneplus_sysfs_read_profilex_buttons,
  319. .private = &profile_numbers[4]
  320. },
  321. __ATTR_NULL
  322. };
  323. static int koneplus_init_koneplus_device_struct(struct usb_device *usb_dev,
  324. struct koneplus_device *koneplus)
  325. {
  326. int retval;
  327. mutex_init(&koneplus->koneplus_lock);
  328. retval = koneplus_get_actual_profile(usb_dev);
  329. if (retval < 0)
  330. return retval;
  331. koneplus_profile_activated(koneplus, retval);
  332. return 0;
  333. }
  334. static int koneplus_init_specials(struct hid_device *hdev)
  335. {
  336. struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
  337. struct usb_device *usb_dev = interface_to_usbdev(intf);
  338. struct koneplus_device *koneplus;
  339. int retval;
  340. if (intf->cur_altsetting->desc.bInterfaceProtocol
  341. == USB_INTERFACE_PROTOCOL_MOUSE) {
  342. koneplus = kzalloc(sizeof(*koneplus), GFP_KERNEL);
  343. if (!koneplus) {
  344. hid_err(hdev, "can't alloc device descriptor\n");
  345. return -ENOMEM;
  346. }
  347. hid_set_drvdata(hdev, koneplus);
  348. retval = koneplus_init_koneplus_device_struct(usb_dev, koneplus);
  349. if (retval) {
  350. hid_err(hdev, "couldn't init struct koneplus_device\n");
  351. goto exit_free;
  352. }
  353. retval = roccat_connect(koneplus_class, hdev,
  354. sizeof(struct koneplus_roccat_report));
  355. if (retval < 0) {
  356. hid_err(hdev, "couldn't init char dev\n");
  357. } else {
  358. koneplus->chrdev_minor = retval;
  359. koneplus->roccat_claimed = 1;
  360. }
  361. } else {
  362. hid_set_drvdata(hdev, NULL);
  363. }
  364. return 0;
  365. exit_free:
  366. kfree(koneplus);
  367. return retval;
  368. }
  369. static void koneplus_remove_specials(struct hid_device *hdev)
  370. {
  371. struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
  372. struct koneplus_device *koneplus;
  373. if (intf->cur_altsetting->desc.bInterfaceProtocol
  374. == USB_INTERFACE_PROTOCOL_MOUSE) {
  375. koneplus = hid_get_drvdata(hdev);
  376. if (koneplus->roccat_claimed)
  377. roccat_disconnect(koneplus->chrdev_minor);
  378. kfree(koneplus);
  379. }
  380. }
  381. static int koneplus_probe(struct hid_device *hdev,
  382. const struct hid_device_id *id)
  383. {
  384. int retval;
  385. retval = hid_parse(hdev);
  386. if (retval) {
  387. hid_err(hdev, "parse failed\n");
  388. goto exit;
  389. }
  390. retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
  391. if (retval) {
  392. hid_err(hdev, "hw start failed\n");
  393. goto exit;
  394. }
  395. retval = koneplus_init_specials(hdev);
  396. if (retval) {
  397. hid_err(hdev, "couldn't install mouse\n");
  398. goto exit_stop;
  399. }
  400. return 0;
  401. exit_stop:
  402. hid_hw_stop(hdev);
  403. exit:
  404. return retval;
  405. }
  406. static void koneplus_remove(struct hid_device *hdev)
  407. {
  408. koneplus_remove_specials(hdev);
  409. hid_hw_stop(hdev);
  410. }
  411. static void koneplus_keep_values_up_to_date(struct koneplus_device *koneplus,
  412. u8 const *data)
  413. {
  414. struct koneplus_mouse_report_button const *button_report;
  415. switch (data[0]) {
  416. case KONEPLUS_MOUSE_REPORT_NUMBER_BUTTON:
  417. button_report = (struct koneplus_mouse_report_button const *)data;
  418. switch (button_report->type) {
  419. case KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_PROFILE:
  420. koneplus_profile_activated(koneplus, button_report->data1 - 1);
  421. break;
  422. }
  423. break;
  424. }
  425. }
  426. static void koneplus_report_to_chrdev(struct koneplus_device const *koneplus,
  427. u8 const *data)
  428. {
  429. struct koneplus_roccat_report roccat_report;
  430. struct koneplus_mouse_report_button const *button_report;
  431. if (data[0] != KONEPLUS_MOUSE_REPORT_NUMBER_BUTTON)
  432. return;
  433. button_report = (struct koneplus_mouse_report_button const *)data;
  434. if ((button_report->type == KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_QUICKLAUNCH ||
  435. button_report->type == KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_TIMER) &&
  436. button_report->data2 != KONEPLUS_MOUSE_REPORT_BUTTON_ACTION_PRESS)
  437. return;
  438. roccat_report.type = button_report->type;
  439. roccat_report.data1 = button_report->data1;
  440. roccat_report.data2 = button_report->data2;
  441. roccat_report.profile = koneplus->actual_profile + 1;
  442. roccat_report_event(koneplus->chrdev_minor,
  443. (uint8_t const *)&roccat_report);
  444. }
  445. static int koneplus_raw_event(struct hid_device *hdev,
  446. struct hid_report *report, u8 *data, int size)
  447. {
  448. struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
  449. struct koneplus_device *koneplus = hid_get_drvdata(hdev);
  450. if (intf->cur_altsetting->desc.bInterfaceProtocol
  451. != USB_INTERFACE_PROTOCOL_MOUSE)
  452. return 0;
  453. if (koneplus == NULL)
  454. return 0;
  455. koneplus_keep_values_up_to_date(koneplus, data);
  456. if (koneplus->roccat_claimed)
  457. koneplus_report_to_chrdev(koneplus, data);
  458. return 0;
  459. }
  460. static const struct hid_device_id koneplus_devices[] = {
  461. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) },
  462. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEXTD) },
  463. { }
  464. };
  465. MODULE_DEVICE_TABLE(hid, koneplus_devices);
  466. static struct hid_driver koneplus_driver = {
  467. .name = "koneplus",
  468. .id_table = koneplus_devices,
  469. .probe = koneplus_probe,
  470. .remove = koneplus_remove,
  471. .raw_event = koneplus_raw_event
  472. };
  473. static int __init koneplus_init(void)
  474. {
  475. int retval;
  476. /* class name has to be same as driver name */
  477. koneplus_class = class_create(THIS_MODULE, "koneplus");
  478. if (IS_ERR(koneplus_class))
  479. return PTR_ERR(koneplus_class);
  480. koneplus_class->dev_attrs = koneplus_attributes;
  481. koneplus_class->dev_bin_attrs = koneplus_bin_attributes;
  482. retval = hid_register_driver(&koneplus_driver);
  483. if (retval)
  484. class_destroy(koneplus_class);
  485. return retval;
  486. }
  487. static void __exit koneplus_exit(void)
  488. {
  489. hid_unregister_driver(&koneplus_driver);
  490. class_destroy(koneplus_class);
  491. }
  492. module_init(koneplus_init);
  493. module_exit(koneplus_exit);
  494. MODULE_AUTHOR("Stefan Achatz");
  495. MODULE_DESCRIPTION("USB Roccat Kone[+]/XTD driver");
  496. MODULE_LICENSE("GPL v2");