hid-roccat-pyra.c 16 KB

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