hid-roccat-pyra.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Roccat Pyra driver for Linux
  4. *
  5. * Copyright (c) 2010 Stefan Achatz <erazor_de@users.sourceforge.net>
  6. */
  7. /*
  8. */
  9. /*
  10. * Roccat Pyra is a mobile gamer mouse which comes in wired and wireless
  11. * variant. Wireless variant is not tested.
  12. * Userland tools can be found at http://sourceforge.net/projects/roccat
  13. */
  14. #include <linux/device.h>
  15. #include <linux/input.h>
  16. #include <linux/hid.h>
  17. #include <linux/module.h>
  18. #include <linux/slab.h>
  19. #include <linux/hid-roccat.h>
  20. #include "hid-ids.h"
  21. #include "hid-roccat-common.h"
  22. #include "hid-roccat-pyra.h"
  23. static uint profile_numbers[5] = {0, 1, 2, 3, 4};
  24. /* pyra_class is used for creating sysfs attributes via roccat char device */
  25. static struct class *pyra_class;
  26. static void profile_activated(struct pyra_device *pyra,
  27. unsigned int new_profile)
  28. {
  29. if (new_profile >= ARRAY_SIZE(pyra->profile_settings))
  30. return;
  31. pyra->actual_profile = new_profile;
  32. pyra->actual_cpi = pyra->profile_settings[pyra->actual_profile].y_cpi;
  33. }
  34. static int pyra_send_control(struct usb_device *usb_dev, int value,
  35. enum pyra_control_requests request)
  36. {
  37. struct roccat_common2_control control;
  38. if ((request == PYRA_CONTROL_REQUEST_PROFILE_SETTINGS ||
  39. request == PYRA_CONTROL_REQUEST_PROFILE_BUTTONS) &&
  40. (value < 0 || value > 4))
  41. return -EINVAL;
  42. control.command = ROCCAT_COMMON_COMMAND_CONTROL;
  43. control.value = value;
  44. control.request = request;
  45. return roccat_common2_send(usb_dev, ROCCAT_COMMON_COMMAND_CONTROL,
  46. &control, sizeof(struct roccat_common2_control));
  47. }
  48. static int pyra_get_profile_settings(struct usb_device *usb_dev,
  49. struct pyra_profile_settings *buf, int number)
  50. {
  51. int retval;
  52. retval = pyra_send_control(usb_dev, number,
  53. PYRA_CONTROL_REQUEST_PROFILE_SETTINGS);
  54. if (retval)
  55. return retval;
  56. return roccat_common2_receive(usb_dev, PYRA_COMMAND_PROFILE_SETTINGS,
  57. buf, PYRA_SIZE_PROFILE_SETTINGS);
  58. }
  59. static int pyra_get_settings(struct usb_device *usb_dev,
  60. struct pyra_settings *buf)
  61. {
  62. return roccat_common2_receive(usb_dev, PYRA_COMMAND_SETTINGS,
  63. buf, PYRA_SIZE_SETTINGS);
  64. }
  65. static int pyra_set_settings(struct usb_device *usb_dev,
  66. struct pyra_settings const *settings)
  67. {
  68. return roccat_common2_send_with_status(usb_dev,
  69. PYRA_COMMAND_SETTINGS, settings,
  70. PYRA_SIZE_SETTINGS);
  71. }
  72. static ssize_t pyra_sysfs_read(struct file *fp, struct kobject *kobj,
  73. char *buf, loff_t off, size_t count,
  74. size_t real_size, uint command)
  75. {
  76. struct device *dev = kobj_to_dev(kobj)->parent->parent;
  77. struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev));
  78. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  79. int retval;
  80. if (off >= real_size)
  81. return 0;
  82. if (off != 0 || count != real_size)
  83. return -EINVAL;
  84. mutex_lock(&pyra->pyra_lock);
  85. retval = roccat_common2_receive(usb_dev, command, buf, real_size);
  86. mutex_unlock(&pyra->pyra_lock);
  87. if (retval)
  88. return retval;
  89. return real_size;
  90. }
  91. static ssize_t pyra_sysfs_write(struct file *fp, struct kobject *kobj,
  92. void const *buf, loff_t off, size_t count,
  93. size_t real_size, uint command)
  94. {
  95. struct device *dev = kobj_to_dev(kobj)->parent->parent;
  96. struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev));
  97. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  98. int retval;
  99. if (off != 0 || count != real_size)
  100. return -EINVAL;
  101. mutex_lock(&pyra->pyra_lock);
  102. retval = roccat_common2_send_with_status(usb_dev, command, (void *)buf, real_size);
  103. mutex_unlock(&pyra->pyra_lock);
  104. if (retval)
  105. return retval;
  106. return real_size;
  107. }
  108. #define PYRA_SYSFS_W(thingy, THINGY) \
  109. static ssize_t pyra_sysfs_write_ ## thingy(struct file *fp, \
  110. struct kobject *kobj, struct bin_attribute *attr, char *buf, \
  111. loff_t off, size_t count) \
  112. { \
  113. return pyra_sysfs_write(fp, kobj, buf, off, count, \
  114. PYRA_SIZE_ ## THINGY, PYRA_COMMAND_ ## THINGY); \
  115. }
  116. #define PYRA_SYSFS_R(thingy, THINGY) \
  117. static ssize_t pyra_sysfs_read_ ## thingy(struct file *fp, \
  118. struct kobject *kobj, struct bin_attribute *attr, char *buf, \
  119. loff_t off, size_t count) \
  120. { \
  121. return pyra_sysfs_read(fp, kobj, buf, off, count, \
  122. PYRA_SIZE_ ## THINGY, PYRA_COMMAND_ ## THINGY); \
  123. }
  124. #define PYRA_SYSFS_RW(thingy, THINGY) \
  125. PYRA_SYSFS_W(thingy, THINGY) \
  126. PYRA_SYSFS_R(thingy, THINGY)
  127. #define PYRA_BIN_ATTRIBUTE_RW(thingy, THINGY) \
  128. PYRA_SYSFS_RW(thingy, THINGY); \
  129. static struct bin_attribute bin_attr_##thingy = { \
  130. .attr = { .name = #thingy, .mode = 0660 }, \
  131. .size = PYRA_SIZE_ ## THINGY, \
  132. .read = pyra_sysfs_read_ ## thingy, \
  133. .write = pyra_sysfs_write_ ## thingy \
  134. }
  135. #define PYRA_BIN_ATTRIBUTE_R(thingy, THINGY) \
  136. PYRA_SYSFS_R(thingy, THINGY); \
  137. static struct bin_attribute bin_attr_##thingy = { \
  138. .attr = { .name = #thingy, .mode = 0440 }, \
  139. .size = PYRA_SIZE_ ## THINGY, \
  140. .read = pyra_sysfs_read_ ## thingy, \
  141. }
  142. #define PYRA_BIN_ATTRIBUTE_W(thingy, THINGY) \
  143. PYRA_SYSFS_W(thingy, THINGY); \
  144. static struct bin_attribute bin_attr_##thingy = { \
  145. .attr = { .name = #thingy, .mode = 0220 }, \
  146. .size = PYRA_SIZE_ ## THINGY, \
  147. .write = pyra_sysfs_write_ ## thingy \
  148. }
  149. PYRA_BIN_ATTRIBUTE_W(control, CONTROL);
  150. PYRA_BIN_ATTRIBUTE_RW(info, INFO);
  151. PYRA_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS);
  152. PYRA_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS);
  153. static ssize_t pyra_sysfs_read_profilex_settings(struct file *fp,
  154. struct kobject *kobj, struct bin_attribute *attr, char *buf,
  155. loff_t off, size_t count)
  156. {
  157. struct device *dev = kobj_to_dev(kobj)->parent->parent;
  158. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  159. ssize_t retval;
  160. retval = pyra_send_control(usb_dev, *(uint *)(attr->private),
  161. PYRA_CONTROL_REQUEST_PROFILE_SETTINGS);
  162. if (retval)
  163. return retval;
  164. return pyra_sysfs_read(fp, kobj, buf, off, count,
  165. PYRA_SIZE_PROFILE_SETTINGS,
  166. PYRA_COMMAND_PROFILE_SETTINGS);
  167. }
  168. static ssize_t pyra_sysfs_read_profilex_buttons(struct file *fp,
  169. struct kobject *kobj, struct bin_attribute *attr, char *buf,
  170. loff_t off, size_t count)
  171. {
  172. struct device *dev = kobj_to_dev(kobj)->parent->parent;
  173. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  174. ssize_t retval;
  175. retval = pyra_send_control(usb_dev, *(uint *)(attr->private),
  176. PYRA_CONTROL_REQUEST_PROFILE_BUTTONS);
  177. if (retval)
  178. return retval;
  179. return pyra_sysfs_read(fp, kobj, buf, off, count,
  180. PYRA_SIZE_PROFILE_BUTTONS,
  181. PYRA_COMMAND_PROFILE_BUTTONS);
  182. }
  183. #define PROFILE_ATTR(number) \
  184. static struct bin_attribute bin_attr_profile##number##_settings = { \
  185. .attr = { .name = "profile" #number "_settings", .mode = 0440 }, \
  186. .size = PYRA_SIZE_PROFILE_SETTINGS, \
  187. .read = pyra_sysfs_read_profilex_settings, \
  188. .private = &profile_numbers[number-1], \
  189. }; \
  190. static struct bin_attribute bin_attr_profile##number##_buttons = { \
  191. .attr = { .name = "profile" #number "_buttons", .mode = 0440 }, \
  192. .size = PYRA_SIZE_PROFILE_BUTTONS, \
  193. .read = pyra_sysfs_read_profilex_buttons, \
  194. .private = &profile_numbers[number-1], \
  195. };
  196. PROFILE_ATTR(1);
  197. PROFILE_ATTR(2);
  198. PROFILE_ATTR(3);
  199. PROFILE_ATTR(4);
  200. PROFILE_ATTR(5);
  201. static ssize_t pyra_sysfs_write_settings(struct file *fp,
  202. struct kobject *kobj, struct bin_attribute *attr, char *buf,
  203. loff_t off, size_t count)
  204. {
  205. struct device *dev = kobj_to_dev(kobj)->parent->parent;
  206. struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev));
  207. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  208. int retval = 0;
  209. struct pyra_roccat_report roccat_report;
  210. struct pyra_settings const *settings;
  211. if (off != 0 || count != PYRA_SIZE_SETTINGS)
  212. return -EINVAL;
  213. settings = (struct pyra_settings const *)buf;
  214. if (settings->startup_profile >= ARRAY_SIZE(pyra->profile_settings))
  215. return -EINVAL;
  216. mutex_lock(&pyra->pyra_lock);
  217. retval = pyra_set_settings(usb_dev, settings);
  218. if (retval) {
  219. mutex_unlock(&pyra->pyra_lock);
  220. return retval;
  221. }
  222. profile_activated(pyra, settings->startup_profile);
  223. roccat_report.type = PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_2;
  224. roccat_report.value = settings->startup_profile + 1;
  225. roccat_report.key = 0;
  226. roccat_report_event(pyra->chrdev_minor,
  227. (uint8_t const *)&roccat_report);
  228. mutex_unlock(&pyra->pyra_lock);
  229. return PYRA_SIZE_SETTINGS;
  230. }
  231. PYRA_SYSFS_R(settings, SETTINGS);
  232. static struct bin_attribute bin_attr_settings =
  233. __BIN_ATTR(settings, (S_IWUSR | S_IRUGO),
  234. pyra_sysfs_read_settings, pyra_sysfs_write_settings,
  235. PYRA_SIZE_SETTINGS);
  236. static ssize_t pyra_sysfs_show_actual_cpi(struct device *dev,
  237. struct device_attribute *attr, char *buf)
  238. {
  239. struct pyra_device *pyra =
  240. hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
  241. return snprintf(buf, PAGE_SIZE, "%d\n", pyra->actual_cpi);
  242. }
  243. static DEVICE_ATTR(actual_cpi, 0440, pyra_sysfs_show_actual_cpi, NULL);
  244. static ssize_t pyra_sysfs_show_actual_profile(struct device *dev,
  245. struct device_attribute *attr, char *buf)
  246. {
  247. struct pyra_device *pyra =
  248. hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
  249. struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
  250. struct pyra_settings settings;
  251. mutex_lock(&pyra->pyra_lock);
  252. roccat_common2_receive(usb_dev, PYRA_COMMAND_SETTINGS,
  253. &settings, PYRA_SIZE_SETTINGS);
  254. mutex_unlock(&pyra->pyra_lock);
  255. return snprintf(buf, PAGE_SIZE, "%d\n", settings.startup_profile);
  256. }
  257. static DEVICE_ATTR(actual_profile, 0440, pyra_sysfs_show_actual_profile, NULL);
  258. static DEVICE_ATTR(startup_profile, 0440, pyra_sysfs_show_actual_profile, NULL);
  259. static ssize_t pyra_sysfs_show_firmware_version(struct device *dev,
  260. struct device_attribute *attr, char *buf)
  261. {
  262. struct pyra_device *pyra;
  263. struct usb_device *usb_dev;
  264. struct pyra_info info;
  265. dev = dev->parent->parent;
  266. pyra = hid_get_drvdata(dev_get_drvdata(dev));
  267. usb_dev = interface_to_usbdev(to_usb_interface(dev));
  268. mutex_lock(&pyra->pyra_lock);
  269. roccat_common2_receive(usb_dev, PYRA_COMMAND_INFO,
  270. &info, PYRA_SIZE_INFO);
  271. mutex_unlock(&pyra->pyra_lock);
  272. return snprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version);
  273. }
  274. static DEVICE_ATTR(firmware_version, 0440, pyra_sysfs_show_firmware_version,
  275. NULL);
  276. static struct attribute *pyra_attrs[] = {
  277. &dev_attr_actual_cpi.attr,
  278. &dev_attr_actual_profile.attr,
  279. &dev_attr_firmware_version.attr,
  280. &dev_attr_startup_profile.attr,
  281. NULL,
  282. };
  283. static struct bin_attribute *pyra_bin_attributes[] = {
  284. &bin_attr_control,
  285. &bin_attr_info,
  286. &bin_attr_profile_settings,
  287. &bin_attr_profile_buttons,
  288. &bin_attr_settings,
  289. &bin_attr_profile1_settings,
  290. &bin_attr_profile2_settings,
  291. &bin_attr_profile3_settings,
  292. &bin_attr_profile4_settings,
  293. &bin_attr_profile5_settings,
  294. &bin_attr_profile1_buttons,
  295. &bin_attr_profile2_buttons,
  296. &bin_attr_profile3_buttons,
  297. &bin_attr_profile4_buttons,
  298. &bin_attr_profile5_buttons,
  299. NULL,
  300. };
  301. static const struct attribute_group pyra_group = {
  302. .attrs = pyra_attrs,
  303. .bin_attrs = pyra_bin_attributes,
  304. };
  305. static const struct attribute_group *pyra_groups[] = {
  306. &pyra_group,
  307. NULL,
  308. };
  309. static int pyra_init_pyra_device_struct(struct usb_device *usb_dev,
  310. struct pyra_device *pyra)
  311. {
  312. struct pyra_settings settings;
  313. int retval, i;
  314. mutex_init(&pyra->pyra_lock);
  315. retval = pyra_get_settings(usb_dev, &settings);
  316. if (retval)
  317. return retval;
  318. for (i = 0; i < 5; ++i) {
  319. retval = pyra_get_profile_settings(usb_dev,
  320. &pyra->profile_settings[i], i);
  321. if (retval)
  322. return retval;
  323. }
  324. profile_activated(pyra, settings.startup_profile);
  325. return 0;
  326. }
  327. static int pyra_init_specials(struct hid_device *hdev)
  328. {
  329. struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
  330. struct usb_device *usb_dev = interface_to_usbdev(intf);
  331. struct pyra_device *pyra;
  332. int retval;
  333. if (intf->cur_altsetting->desc.bInterfaceProtocol
  334. == USB_INTERFACE_PROTOCOL_MOUSE) {
  335. pyra = kzalloc(sizeof(*pyra), GFP_KERNEL);
  336. if (!pyra) {
  337. hid_err(hdev, "can't alloc device descriptor\n");
  338. return -ENOMEM;
  339. }
  340. hid_set_drvdata(hdev, pyra);
  341. retval = pyra_init_pyra_device_struct(usb_dev, pyra);
  342. if (retval) {
  343. hid_err(hdev, "couldn't init struct pyra_device\n");
  344. goto exit_free;
  345. }
  346. retval = roccat_connect(pyra_class, hdev,
  347. sizeof(struct pyra_roccat_report));
  348. if (retval < 0) {
  349. hid_err(hdev, "couldn't init char dev\n");
  350. } else {
  351. pyra->chrdev_minor = retval;
  352. pyra->roccat_claimed = 1;
  353. }
  354. } else {
  355. hid_set_drvdata(hdev, NULL);
  356. }
  357. return 0;
  358. exit_free:
  359. kfree(pyra);
  360. return retval;
  361. }
  362. static void pyra_remove_specials(struct hid_device *hdev)
  363. {
  364. struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
  365. struct pyra_device *pyra;
  366. if (intf->cur_altsetting->desc.bInterfaceProtocol
  367. == USB_INTERFACE_PROTOCOL_MOUSE) {
  368. pyra = hid_get_drvdata(hdev);
  369. if (pyra->roccat_claimed)
  370. roccat_disconnect(pyra->chrdev_minor);
  371. kfree(hid_get_drvdata(hdev));
  372. }
  373. }
  374. static int pyra_probe(struct hid_device *hdev, const struct hid_device_id *id)
  375. {
  376. int retval;
  377. if (!hid_is_usb(hdev))
  378. return -EINVAL;
  379. retval = hid_parse(hdev);
  380. if (retval) {
  381. hid_err(hdev, "parse failed\n");
  382. goto exit;
  383. }
  384. retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
  385. if (retval) {
  386. hid_err(hdev, "hw start failed\n");
  387. goto exit;
  388. }
  389. retval = pyra_init_specials(hdev);
  390. if (retval) {
  391. hid_err(hdev, "couldn't install mouse\n");
  392. goto exit_stop;
  393. }
  394. return 0;
  395. exit_stop:
  396. hid_hw_stop(hdev);
  397. exit:
  398. return retval;
  399. }
  400. static void pyra_remove(struct hid_device *hdev)
  401. {
  402. pyra_remove_specials(hdev);
  403. hid_hw_stop(hdev);
  404. }
  405. static void pyra_keep_values_up_to_date(struct pyra_device *pyra,
  406. u8 const *data)
  407. {
  408. struct pyra_mouse_event_button const *button_event;
  409. switch (data[0]) {
  410. case PYRA_MOUSE_REPORT_NUMBER_BUTTON:
  411. button_event = (struct pyra_mouse_event_button const *)data;
  412. switch (button_event->type) {
  413. case PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_2:
  414. profile_activated(pyra, button_event->data1 - 1);
  415. break;
  416. case PYRA_MOUSE_EVENT_BUTTON_TYPE_CPI:
  417. pyra->actual_cpi = button_event->data1;
  418. break;
  419. }
  420. break;
  421. }
  422. }
  423. static void pyra_report_to_chrdev(struct pyra_device const *pyra,
  424. u8 const *data)
  425. {
  426. struct pyra_roccat_report roccat_report;
  427. struct pyra_mouse_event_button const *button_event;
  428. if (data[0] != PYRA_MOUSE_REPORT_NUMBER_BUTTON)
  429. return;
  430. button_event = (struct pyra_mouse_event_button const *)data;
  431. switch (button_event->type) {
  432. case PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_2:
  433. case PYRA_MOUSE_EVENT_BUTTON_TYPE_CPI:
  434. roccat_report.type = button_event->type;
  435. roccat_report.value = button_event->data1;
  436. roccat_report.key = 0;
  437. roccat_report_event(pyra->chrdev_minor,
  438. (uint8_t const *)&roccat_report);
  439. break;
  440. case PYRA_MOUSE_EVENT_BUTTON_TYPE_MACRO:
  441. case PYRA_MOUSE_EVENT_BUTTON_TYPE_SHORTCUT:
  442. case PYRA_MOUSE_EVENT_BUTTON_TYPE_QUICKLAUNCH:
  443. if (button_event->data2 == PYRA_MOUSE_EVENT_BUTTON_PRESS) {
  444. roccat_report.type = button_event->type;
  445. roccat_report.key = button_event->data1;
  446. /*
  447. * pyra reports profile numbers with range 1-5.
  448. * Keeping this behaviour.
  449. */
  450. roccat_report.value = pyra->actual_profile + 1;
  451. roccat_report_event(pyra->chrdev_minor,
  452. (uint8_t const *)&roccat_report);
  453. }
  454. break;
  455. }
  456. }
  457. static int pyra_raw_event(struct hid_device *hdev, struct hid_report *report,
  458. u8 *data, int size)
  459. {
  460. struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
  461. struct pyra_device *pyra = hid_get_drvdata(hdev);
  462. if (intf->cur_altsetting->desc.bInterfaceProtocol
  463. != USB_INTERFACE_PROTOCOL_MOUSE)
  464. return 0;
  465. if (pyra == NULL)
  466. return 0;
  467. pyra_keep_values_up_to_date(pyra, data);
  468. if (pyra->roccat_claimed)
  469. pyra_report_to_chrdev(pyra, data);
  470. return 0;
  471. }
  472. static const struct hid_device_id pyra_devices[] = {
  473. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT,
  474. USB_DEVICE_ID_ROCCAT_PYRA_WIRED) },
  475. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT,
  476. USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS) },
  477. { }
  478. };
  479. MODULE_DEVICE_TABLE(hid, pyra_devices);
  480. static struct hid_driver pyra_driver = {
  481. .name = "pyra",
  482. .id_table = pyra_devices,
  483. .probe = pyra_probe,
  484. .remove = pyra_remove,
  485. .raw_event = pyra_raw_event
  486. };
  487. static int __init pyra_init(void)
  488. {
  489. int retval;
  490. /* class name has to be same as driver name */
  491. pyra_class = class_create(THIS_MODULE, "pyra");
  492. if (IS_ERR(pyra_class))
  493. return PTR_ERR(pyra_class);
  494. pyra_class->dev_groups = pyra_groups;
  495. retval = hid_register_driver(&pyra_driver);
  496. if (retval)
  497. class_destroy(pyra_class);
  498. return retval;
  499. }
  500. static void __exit pyra_exit(void)
  501. {
  502. hid_unregister_driver(&pyra_driver);
  503. class_destroy(pyra_class);
  504. }
  505. module_init(pyra_init);
  506. module_exit(pyra_exit);
  507. MODULE_AUTHOR("Stefan Achatz");
  508. MODULE_DESCRIPTION("USB Roccat Pyra driver");
  509. MODULE_LICENSE("GPL v2");