hid-roccat-koneplus.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  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 DEVICE_ATTR(actual_profile, 0660,
  226. koneplus_sysfs_show_actual_profile,
  227. koneplus_sysfs_set_actual_profile);
  228. static DEVICE_ATTR(startup_profile, 0660,
  229. koneplus_sysfs_show_actual_profile,
  230. koneplus_sysfs_set_actual_profile);
  231. static ssize_t koneplus_sysfs_show_firmware_version(struct device *dev,
  232. struct device_attribute *attr, char *buf)
  233. {
  234. struct koneplus_device *koneplus;
  235. struct usb_device *usb_dev;
  236. struct koneplus_info info;
  237. dev = dev->parent->parent;
  238. koneplus = hid_get_drvdata(dev_get_drvdata(dev));
  239. usb_dev = interface_to_usbdev(to_usb_interface(dev));
  240. mutex_lock(&koneplus->koneplus_lock);
  241. roccat_common2_receive(usb_dev, KONEPLUS_COMMAND_INFO,
  242. &info, KONEPLUS_SIZE_INFO);
  243. mutex_unlock(&koneplus->koneplus_lock);
  244. return snprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version);
  245. }
  246. static DEVICE_ATTR(firmware_version, 0440,
  247. koneplus_sysfs_show_firmware_version, NULL);
  248. static struct attribute *koneplus_attrs[] = {
  249. &dev_attr_actual_profile.attr,
  250. &dev_attr_startup_profile.attr,
  251. &dev_attr_firmware_version.attr,
  252. NULL,
  253. };
  254. ATTRIBUTE_GROUPS(koneplus);
  255. static struct bin_attribute koneplus_bin_attributes[] = {
  256. KONEPLUS_BIN_ATTRIBUTE_W(control, CONTROL),
  257. KONEPLUS_BIN_ATTRIBUTE_RW(info, INFO),
  258. KONEPLUS_BIN_ATTRIBUTE_W(talk, TALK),
  259. KONEPLUS_BIN_ATTRIBUTE_W(macro, MACRO),
  260. KONEPLUS_BIN_ATTRIBUTE_RW(sensor, SENSOR),
  261. KONEPLUS_BIN_ATTRIBUTE_RW(tcu, TCU),
  262. KONEPLUS_BIN_ATTRIBUTE_R(tcu_image, TCU_IMAGE),
  263. KONEPLUS_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS),
  264. KONEPLUS_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS),
  265. {
  266. .attr = { .name = "profile1_settings", .mode = 0440 },
  267. .size = KONEPLUS_SIZE_PROFILE_SETTINGS,
  268. .read = koneplus_sysfs_read_profilex_settings,
  269. .private = &profile_numbers[0]
  270. },
  271. {
  272. .attr = { .name = "profile2_settings", .mode = 0440 },
  273. .size = KONEPLUS_SIZE_PROFILE_SETTINGS,
  274. .read = koneplus_sysfs_read_profilex_settings,
  275. .private = &profile_numbers[1]
  276. },
  277. {
  278. .attr = { .name = "profile3_settings", .mode = 0440 },
  279. .size = KONEPLUS_SIZE_PROFILE_SETTINGS,
  280. .read = koneplus_sysfs_read_profilex_settings,
  281. .private = &profile_numbers[2]
  282. },
  283. {
  284. .attr = { .name = "profile4_settings", .mode = 0440 },
  285. .size = KONEPLUS_SIZE_PROFILE_SETTINGS,
  286. .read = koneplus_sysfs_read_profilex_settings,
  287. .private = &profile_numbers[3]
  288. },
  289. {
  290. .attr = { .name = "profile5_settings", .mode = 0440 },
  291. .size = KONEPLUS_SIZE_PROFILE_SETTINGS,
  292. .read = koneplus_sysfs_read_profilex_settings,
  293. .private = &profile_numbers[4]
  294. },
  295. {
  296. .attr = { .name = "profile1_buttons", .mode = 0440 },
  297. .size = KONEPLUS_SIZE_PROFILE_BUTTONS,
  298. .read = koneplus_sysfs_read_profilex_buttons,
  299. .private = &profile_numbers[0]
  300. },
  301. {
  302. .attr = { .name = "profile2_buttons", .mode = 0440 },
  303. .size = KONEPLUS_SIZE_PROFILE_BUTTONS,
  304. .read = koneplus_sysfs_read_profilex_buttons,
  305. .private = &profile_numbers[1]
  306. },
  307. {
  308. .attr = { .name = "profile3_buttons", .mode = 0440 },
  309. .size = KONEPLUS_SIZE_PROFILE_BUTTONS,
  310. .read = koneplus_sysfs_read_profilex_buttons,
  311. .private = &profile_numbers[2]
  312. },
  313. {
  314. .attr = { .name = "profile4_buttons", .mode = 0440 },
  315. .size = KONEPLUS_SIZE_PROFILE_BUTTONS,
  316. .read = koneplus_sysfs_read_profilex_buttons,
  317. .private = &profile_numbers[3]
  318. },
  319. {
  320. .attr = { .name = "profile5_buttons", .mode = 0440 },
  321. .size = KONEPLUS_SIZE_PROFILE_BUTTONS,
  322. .read = koneplus_sysfs_read_profilex_buttons,
  323. .private = &profile_numbers[4]
  324. },
  325. __ATTR_NULL
  326. };
  327. static int koneplus_init_koneplus_device_struct(struct usb_device *usb_dev,
  328. struct koneplus_device *koneplus)
  329. {
  330. int retval;
  331. mutex_init(&koneplus->koneplus_lock);
  332. retval = koneplus_get_actual_profile(usb_dev);
  333. if (retval < 0)
  334. return retval;
  335. koneplus_profile_activated(koneplus, retval);
  336. return 0;
  337. }
  338. static int koneplus_init_specials(struct hid_device *hdev)
  339. {
  340. struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
  341. struct usb_device *usb_dev = interface_to_usbdev(intf);
  342. struct koneplus_device *koneplus;
  343. int retval;
  344. if (intf->cur_altsetting->desc.bInterfaceProtocol
  345. == USB_INTERFACE_PROTOCOL_MOUSE) {
  346. koneplus = kzalloc(sizeof(*koneplus), GFP_KERNEL);
  347. if (!koneplus) {
  348. hid_err(hdev, "can't alloc device descriptor\n");
  349. return -ENOMEM;
  350. }
  351. hid_set_drvdata(hdev, koneplus);
  352. retval = koneplus_init_koneplus_device_struct(usb_dev, koneplus);
  353. if (retval) {
  354. hid_err(hdev, "couldn't init struct koneplus_device\n");
  355. goto exit_free;
  356. }
  357. retval = roccat_connect(koneplus_class, hdev,
  358. sizeof(struct koneplus_roccat_report));
  359. if (retval < 0) {
  360. hid_err(hdev, "couldn't init char dev\n");
  361. } else {
  362. koneplus->chrdev_minor = retval;
  363. koneplus->roccat_claimed = 1;
  364. }
  365. } else {
  366. hid_set_drvdata(hdev, NULL);
  367. }
  368. return 0;
  369. exit_free:
  370. kfree(koneplus);
  371. return retval;
  372. }
  373. static void koneplus_remove_specials(struct hid_device *hdev)
  374. {
  375. struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
  376. struct koneplus_device *koneplus;
  377. if (intf->cur_altsetting->desc.bInterfaceProtocol
  378. == USB_INTERFACE_PROTOCOL_MOUSE) {
  379. koneplus = hid_get_drvdata(hdev);
  380. if (koneplus->roccat_claimed)
  381. roccat_disconnect(koneplus->chrdev_minor);
  382. kfree(koneplus);
  383. }
  384. }
  385. static int koneplus_probe(struct hid_device *hdev,
  386. const struct hid_device_id *id)
  387. {
  388. int retval;
  389. retval = hid_parse(hdev);
  390. if (retval) {
  391. hid_err(hdev, "parse failed\n");
  392. goto exit;
  393. }
  394. retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
  395. if (retval) {
  396. hid_err(hdev, "hw start failed\n");
  397. goto exit;
  398. }
  399. retval = koneplus_init_specials(hdev);
  400. if (retval) {
  401. hid_err(hdev, "couldn't install mouse\n");
  402. goto exit_stop;
  403. }
  404. return 0;
  405. exit_stop:
  406. hid_hw_stop(hdev);
  407. exit:
  408. return retval;
  409. }
  410. static void koneplus_remove(struct hid_device *hdev)
  411. {
  412. koneplus_remove_specials(hdev);
  413. hid_hw_stop(hdev);
  414. }
  415. static void koneplus_keep_values_up_to_date(struct koneplus_device *koneplus,
  416. u8 const *data)
  417. {
  418. struct koneplus_mouse_report_button const *button_report;
  419. switch (data[0]) {
  420. case KONEPLUS_MOUSE_REPORT_NUMBER_BUTTON:
  421. button_report = (struct koneplus_mouse_report_button const *)data;
  422. switch (button_report->type) {
  423. case KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_PROFILE:
  424. koneplus_profile_activated(koneplus, button_report->data1 - 1);
  425. break;
  426. }
  427. break;
  428. }
  429. }
  430. static void koneplus_report_to_chrdev(struct koneplus_device const *koneplus,
  431. u8 const *data)
  432. {
  433. struct koneplus_roccat_report roccat_report;
  434. struct koneplus_mouse_report_button const *button_report;
  435. if (data[0] != KONEPLUS_MOUSE_REPORT_NUMBER_BUTTON)
  436. return;
  437. button_report = (struct koneplus_mouse_report_button const *)data;
  438. if ((button_report->type == KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_QUICKLAUNCH ||
  439. button_report->type == KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_TIMER) &&
  440. button_report->data2 != KONEPLUS_MOUSE_REPORT_BUTTON_ACTION_PRESS)
  441. return;
  442. roccat_report.type = button_report->type;
  443. roccat_report.data1 = button_report->data1;
  444. roccat_report.data2 = button_report->data2;
  445. roccat_report.profile = koneplus->actual_profile + 1;
  446. roccat_report_event(koneplus->chrdev_minor,
  447. (uint8_t const *)&roccat_report);
  448. }
  449. static int koneplus_raw_event(struct hid_device *hdev,
  450. struct hid_report *report, u8 *data, int size)
  451. {
  452. struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
  453. struct koneplus_device *koneplus = hid_get_drvdata(hdev);
  454. if (intf->cur_altsetting->desc.bInterfaceProtocol
  455. != USB_INTERFACE_PROTOCOL_MOUSE)
  456. return 0;
  457. if (koneplus == NULL)
  458. return 0;
  459. koneplus_keep_values_up_to_date(koneplus, data);
  460. if (koneplus->roccat_claimed)
  461. koneplus_report_to_chrdev(koneplus, data);
  462. return 0;
  463. }
  464. static const struct hid_device_id koneplus_devices[] = {
  465. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) },
  466. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEXTD) },
  467. { }
  468. };
  469. MODULE_DEVICE_TABLE(hid, koneplus_devices);
  470. static struct hid_driver koneplus_driver = {
  471. .name = "koneplus",
  472. .id_table = koneplus_devices,
  473. .probe = koneplus_probe,
  474. .remove = koneplus_remove,
  475. .raw_event = koneplus_raw_event
  476. };
  477. static int __init koneplus_init(void)
  478. {
  479. int retval;
  480. /* class name has to be same as driver name */
  481. koneplus_class = class_create(THIS_MODULE, "koneplus");
  482. if (IS_ERR(koneplus_class))
  483. return PTR_ERR(koneplus_class);
  484. koneplus_class->dev_groups = koneplus_groups;
  485. koneplus_class->dev_bin_attrs = koneplus_bin_attributes;
  486. retval = hid_register_driver(&koneplus_driver);
  487. if (retval)
  488. class_destroy(koneplus_class);
  489. return retval;
  490. }
  491. static void __exit koneplus_exit(void)
  492. {
  493. hid_unregister_driver(&koneplus_driver);
  494. class_destroy(koneplus_class);
  495. }
  496. module_init(koneplus_init);
  497. module_exit(koneplus_exit);
  498. MODULE_AUTHOR("Stefan Achatz");
  499. MODULE_DESCRIPTION("USB Roccat Kone[+]/XTD driver");
  500. MODULE_LICENSE("GPL v2");