hid-roccat-pyra.c 16 KB

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