Path: blob/master/drivers/hid/hid-roccat-koneplus.c
15111 views
/*1* Roccat Kone[+] driver for Linux2*3* Copyright (c) 2010 Stefan Achatz <[email protected]>4*/56/*7* This program is free software; you can redistribute it and/or modify it8* under the terms of the GNU General Public License as published by the Free9* Software Foundation; either version 2 of the License, or (at your option)10* any later version.11*/1213/*14* Roccat Kone[+] is an updated/improved version of the Kone with more memory15* and functionality and without the non-standard behaviours the Kone had.16*/1718#include <linux/device.h>19#include <linux/input.h>20#include <linux/hid.h>21#include <linux/module.h>22#include <linux/slab.h>23#include <linux/hid-roccat.h>24#include "hid-ids.h"25#include "hid-roccat-common.h"26#include "hid-roccat-koneplus.h"2728static uint profile_numbers[5] = {0, 1, 2, 3, 4};2930static struct class *koneplus_class;3132static void koneplus_profile_activated(struct koneplus_device *koneplus,33uint new_profile)34{35koneplus->actual_profile = new_profile;36}3738static int koneplus_send_control(struct usb_device *usb_dev, uint value,39enum koneplus_control_requests request)40{41struct koneplus_control control;4243if ((request == KONEPLUS_CONTROL_REQUEST_PROFILE_SETTINGS ||44request == KONEPLUS_CONTROL_REQUEST_PROFILE_BUTTONS) &&45value > 4)46return -EINVAL;4748control.command = KONEPLUS_COMMAND_CONTROL;49control.value = value;50control.request = request;5152return roccat_common_send(usb_dev, KONEPLUS_USB_COMMAND_CONTROL,53&control, sizeof(struct koneplus_control));54}5556static int koneplus_receive_control_status(struct usb_device *usb_dev)57{58int retval;59struct koneplus_control control;6061do {62retval = roccat_common_receive(usb_dev, KONEPLUS_USB_COMMAND_CONTROL,63&control, sizeof(struct koneplus_control));6465/* check if we get a completely wrong answer */66if (retval)67return retval;6869if (control.value == KONEPLUS_CONTROL_REQUEST_STATUS_OK)70return 0;7172/* indicates that hardware needs some more time to complete action */73if (control.value == KONEPLUS_CONTROL_REQUEST_STATUS_WAIT) {74msleep(500); /* windows driver uses 1000 */75continue;76}7778/* seems to be critical - replug necessary */79if (control.value == KONEPLUS_CONTROL_REQUEST_STATUS_OVERLOAD)80return -EINVAL;8182hid_err(usb_dev, "koneplus_receive_control_status: "83"unknown response value 0x%x\n", control.value);84return -EINVAL;85} while (1);86}8788static int koneplus_send(struct usb_device *usb_dev, uint command,89void const *buf, uint size)90{91int retval;9293retval = roccat_common_send(usb_dev, command, buf, size);94if (retval)95return retval;9697return koneplus_receive_control_status(usb_dev);98}99100static int koneplus_select_profile(struct usb_device *usb_dev, uint number,101enum koneplus_control_requests request)102{103int retval;104105retval = koneplus_send_control(usb_dev, number, request);106if (retval)107return retval;108109/* allow time to settle things - windows driver uses 500 */110msleep(100);111112retval = koneplus_receive_control_status(usb_dev);113if (retval)114return retval;115116return 0;117}118119static int koneplus_get_info(struct usb_device *usb_dev,120struct koneplus_info *buf)121{122return roccat_common_receive(usb_dev, KONEPLUS_USB_COMMAND_INFO,123buf, sizeof(struct koneplus_info));124}125126static int koneplus_get_profile_settings(struct usb_device *usb_dev,127struct koneplus_profile_settings *buf, uint number)128{129int retval;130131retval = koneplus_select_profile(usb_dev, number,132KONEPLUS_CONTROL_REQUEST_PROFILE_SETTINGS);133if (retval)134return retval;135136return roccat_common_receive(usb_dev, KONEPLUS_USB_COMMAND_PROFILE_SETTINGS,137buf, sizeof(struct koneplus_profile_settings));138}139140static int koneplus_set_profile_settings(struct usb_device *usb_dev,141struct koneplus_profile_settings const *settings)142{143return koneplus_send(usb_dev, KONEPLUS_USB_COMMAND_PROFILE_SETTINGS,144settings, sizeof(struct koneplus_profile_settings));145}146147static int koneplus_get_profile_buttons(struct usb_device *usb_dev,148struct koneplus_profile_buttons *buf, int number)149{150int retval;151152retval = koneplus_select_profile(usb_dev, number,153KONEPLUS_CONTROL_REQUEST_PROFILE_BUTTONS);154if (retval)155return retval;156157return roccat_common_receive(usb_dev, KONEPLUS_USB_COMMAND_PROFILE_BUTTONS,158buf, sizeof(struct koneplus_profile_buttons));159}160161static int koneplus_set_profile_buttons(struct usb_device *usb_dev,162struct koneplus_profile_buttons const *buttons)163{164return koneplus_send(usb_dev, KONEPLUS_USB_COMMAND_PROFILE_BUTTONS,165buttons, sizeof(struct koneplus_profile_buttons));166}167168/* retval is 0-4 on success, < 0 on error */169static int koneplus_get_actual_profile(struct usb_device *usb_dev)170{171struct koneplus_actual_profile buf;172int retval;173174retval = roccat_common_receive(usb_dev, KONEPLUS_USB_COMMAND_ACTUAL_PROFILE,175&buf, sizeof(struct koneplus_actual_profile));176177return retval ? retval : buf.actual_profile;178}179180static int koneplus_set_actual_profile(struct usb_device *usb_dev,181int new_profile)182{183struct koneplus_actual_profile buf;184185buf.command = KONEPLUS_COMMAND_ACTUAL_PROFILE;186buf.size = sizeof(struct koneplus_actual_profile);187buf.actual_profile = new_profile;188189return koneplus_send(usb_dev, KONEPLUS_USB_COMMAND_ACTUAL_PROFILE,190&buf, sizeof(struct koneplus_actual_profile));191}192193static ssize_t koneplus_sysfs_read(struct file *fp, struct kobject *kobj,194char *buf, loff_t off, size_t count,195size_t real_size, uint command)196{197struct device *dev =198container_of(kobj, struct device, kobj)->parent->parent;199struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev));200struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));201int retval;202203if (off >= real_size)204return 0;205206if (off != 0 || count != real_size)207return -EINVAL;208209mutex_lock(&koneplus->koneplus_lock);210retval = roccat_common_receive(usb_dev, command, buf, real_size);211mutex_unlock(&koneplus->koneplus_lock);212213if (retval)214return retval;215216return real_size;217}218219static ssize_t koneplus_sysfs_write(struct file *fp, struct kobject *kobj,220void const *buf, loff_t off, size_t count,221size_t real_size, uint command)222{223struct device *dev =224container_of(kobj, struct device, kobj)->parent->parent;225struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev));226struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));227int retval;228229if (off != 0 || count != real_size)230return -EINVAL;231232mutex_lock(&koneplus->koneplus_lock);233retval = koneplus_send(usb_dev, command, buf, real_size);234mutex_unlock(&koneplus->koneplus_lock);235236if (retval)237return retval;238239return real_size;240}241242static ssize_t koneplus_sysfs_write_macro(struct file *fp,243struct kobject *kobj, struct bin_attribute *attr, char *buf,244loff_t off, size_t count)245{246return koneplus_sysfs_write(fp, kobj, buf, off, count,247sizeof(struct koneplus_macro), KONEPLUS_USB_COMMAND_MACRO);248}249250static ssize_t koneplus_sysfs_read_sensor(struct file *fp,251struct kobject *kobj, struct bin_attribute *attr, char *buf,252loff_t off, size_t count)253{254return koneplus_sysfs_read(fp, kobj, buf, off, count,255sizeof(struct koneplus_sensor), KONEPLUS_USB_COMMAND_SENSOR);256}257258static ssize_t koneplus_sysfs_write_sensor(struct file *fp,259struct kobject *kobj, struct bin_attribute *attr, char *buf,260loff_t off, size_t count)261{262return koneplus_sysfs_write(fp, kobj, buf, off, count,263sizeof(struct koneplus_sensor), KONEPLUS_USB_COMMAND_SENSOR);264}265266static ssize_t koneplus_sysfs_write_tcu(struct file *fp,267struct kobject *kobj, struct bin_attribute *attr, char *buf,268loff_t off, size_t count)269{270return koneplus_sysfs_write(fp, kobj, buf, off, count,271sizeof(struct koneplus_tcu), KONEPLUS_USB_COMMAND_TCU);272}273274static ssize_t koneplus_sysfs_read_tcu_image(struct file *fp,275struct kobject *kobj, struct bin_attribute *attr, char *buf,276loff_t off, size_t count)277{278return koneplus_sysfs_read(fp, kobj, buf, off, count,279sizeof(struct koneplus_tcu_image), KONEPLUS_USB_COMMAND_TCU);280}281282static ssize_t koneplus_sysfs_read_profilex_settings(struct file *fp,283struct kobject *kobj, struct bin_attribute *attr, char *buf,284loff_t off, size_t count)285{286struct device *dev =287container_of(kobj, struct device, kobj)->parent->parent;288struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev));289290if (off >= sizeof(struct koneplus_profile_settings))291return 0;292293if (off + count > sizeof(struct koneplus_profile_settings))294count = sizeof(struct koneplus_profile_settings) - off;295296mutex_lock(&koneplus->koneplus_lock);297memcpy(buf, ((char const *)&koneplus->profile_settings[*(uint *)(attr->private)]) + off,298count);299mutex_unlock(&koneplus->koneplus_lock);300301return count;302}303304static ssize_t koneplus_sysfs_write_profile_settings(struct file *fp,305struct kobject *kobj, struct bin_attribute *attr, char *buf,306loff_t off, size_t count)307{308struct device *dev =309container_of(kobj, struct device, kobj)->parent->parent;310struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev));311struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));312int retval = 0;313int difference;314int profile_number;315struct koneplus_profile_settings *profile_settings;316317if (off != 0 || count != sizeof(struct koneplus_profile_settings))318return -EINVAL;319320profile_number = ((struct koneplus_profile_settings const *)buf)->number;321profile_settings = &koneplus->profile_settings[profile_number];322323mutex_lock(&koneplus->koneplus_lock);324difference = memcmp(buf, profile_settings,325sizeof(struct koneplus_profile_settings));326if (difference) {327retval = koneplus_set_profile_settings(usb_dev,328(struct koneplus_profile_settings const *)buf);329if (!retval)330memcpy(profile_settings, buf,331sizeof(struct koneplus_profile_settings));332}333mutex_unlock(&koneplus->koneplus_lock);334335if (retval)336return retval;337338return sizeof(struct koneplus_profile_settings);339}340341static ssize_t koneplus_sysfs_read_profilex_buttons(struct file *fp,342struct kobject *kobj, struct bin_attribute *attr, char *buf,343loff_t off, size_t count)344{345struct device *dev =346container_of(kobj, struct device, kobj)->parent->parent;347struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev));348349if (off >= sizeof(struct koneplus_profile_buttons))350return 0;351352if (off + count > sizeof(struct koneplus_profile_buttons))353count = sizeof(struct koneplus_profile_buttons) - off;354355mutex_lock(&koneplus->koneplus_lock);356memcpy(buf, ((char const *)&koneplus->profile_buttons[*(uint *)(attr->private)]) + off,357count);358mutex_unlock(&koneplus->koneplus_lock);359360return count;361}362363static ssize_t koneplus_sysfs_write_profile_buttons(struct file *fp,364struct kobject *kobj, struct bin_attribute *attr, char *buf,365loff_t off, size_t count)366{367struct device *dev =368container_of(kobj, struct device, kobj)->parent->parent;369struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev));370struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));371int retval = 0;372int difference;373uint profile_number;374struct koneplus_profile_buttons *profile_buttons;375376if (off != 0 || count != sizeof(struct koneplus_profile_buttons))377return -EINVAL;378379profile_number = ((struct koneplus_profile_buttons const *)buf)->number;380profile_buttons = &koneplus->profile_buttons[profile_number];381382mutex_lock(&koneplus->koneplus_lock);383difference = memcmp(buf, profile_buttons,384sizeof(struct koneplus_profile_buttons));385if (difference) {386retval = koneplus_set_profile_buttons(usb_dev,387(struct koneplus_profile_buttons const *)buf);388if (!retval)389memcpy(profile_buttons, buf,390sizeof(struct koneplus_profile_buttons));391}392mutex_unlock(&koneplus->koneplus_lock);393394if (retval)395return retval;396397return sizeof(struct koneplus_profile_buttons);398}399400static ssize_t koneplus_sysfs_show_actual_profile(struct device *dev,401struct device_attribute *attr, char *buf)402{403struct koneplus_device *koneplus =404hid_get_drvdata(dev_get_drvdata(dev->parent->parent));405return snprintf(buf, PAGE_SIZE, "%d\n", koneplus->actual_profile);406}407408static ssize_t koneplus_sysfs_set_actual_profile(struct device *dev,409struct device_attribute *attr, char const *buf, size_t size)410{411struct koneplus_device *koneplus;412struct usb_device *usb_dev;413unsigned long profile;414int retval;415struct koneplus_roccat_report roccat_report;416417dev = dev->parent->parent;418koneplus = hid_get_drvdata(dev_get_drvdata(dev));419usb_dev = interface_to_usbdev(to_usb_interface(dev));420421retval = strict_strtoul(buf, 10, &profile);422if (retval)423return retval;424425mutex_lock(&koneplus->koneplus_lock);426427retval = koneplus_set_actual_profile(usb_dev, profile);428if (retval) {429mutex_unlock(&koneplus->koneplus_lock);430return retval;431}432433koneplus->actual_profile = profile;434435roccat_report.type = KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_PROFILE;436roccat_report.data1 = profile + 1;437roccat_report.data2 = 0;438roccat_report.profile = profile + 1;439roccat_report_event(koneplus->chrdev_minor,440(uint8_t const *)&roccat_report);441442mutex_unlock(&koneplus->koneplus_lock);443444return size;445}446447static ssize_t koneplus_sysfs_show_firmware_version(struct device *dev,448struct device_attribute *attr, char *buf)449{450struct koneplus_device *koneplus =451hid_get_drvdata(dev_get_drvdata(dev->parent->parent));452return snprintf(buf, PAGE_SIZE, "%d\n", koneplus->info.firmware_version);453}454455static struct device_attribute koneplus_attributes[] = {456__ATTR(actual_profile, 0660,457koneplus_sysfs_show_actual_profile,458koneplus_sysfs_set_actual_profile),459__ATTR(startup_profile, 0660,460koneplus_sysfs_show_actual_profile,461koneplus_sysfs_set_actual_profile),462__ATTR(firmware_version, 0440,463koneplus_sysfs_show_firmware_version, NULL),464__ATTR_NULL465};466467static struct bin_attribute koneplus_bin_attributes[] = {468{469.attr = { .name = "sensor", .mode = 0660 },470.size = sizeof(struct koneplus_sensor),471.read = koneplus_sysfs_read_sensor,472.write = koneplus_sysfs_write_sensor473},474{475.attr = { .name = "tcu", .mode = 0220 },476.size = sizeof(struct koneplus_tcu),477.write = koneplus_sysfs_write_tcu478},479{480.attr = { .name = "tcu_image", .mode = 0440 },481.size = sizeof(struct koneplus_tcu_image),482.read = koneplus_sysfs_read_tcu_image483},484{485.attr = { .name = "profile_settings", .mode = 0220 },486.size = sizeof(struct koneplus_profile_settings),487.write = koneplus_sysfs_write_profile_settings488},489{490.attr = { .name = "profile1_settings", .mode = 0440 },491.size = sizeof(struct koneplus_profile_settings),492.read = koneplus_sysfs_read_profilex_settings,493.private = &profile_numbers[0]494},495{496.attr = { .name = "profile2_settings", .mode = 0440 },497.size = sizeof(struct koneplus_profile_settings),498.read = koneplus_sysfs_read_profilex_settings,499.private = &profile_numbers[1]500},501{502.attr = { .name = "profile3_settings", .mode = 0440 },503.size = sizeof(struct koneplus_profile_settings),504.read = koneplus_sysfs_read_profilex_settings,505.private = &profile_numbers[2]506},507{508.attr = { .name = "profile4_settings", .mode = 0440 },509.size = sizeof(struct koneplus_profile_settings),510.read = koneplus_sysfs_read_profilex_settings,511.private = &profile_numbers[3]512},513{514.attr = { .name = "profile5_settings", .mode = 0440 },515.size = sizeof(struct koneplus_profile_settings),516.read = koneplus_sysfs_read_profilex_settings,517.private = &profile_numbers[4]518},519{520.attr = { .name = "profile_buttons", .mode = 0220 },521.size = sizeof(struct koneplus_profile_buttons),522.write = koneplus_sysfs_write_profile_buttons523},524{525.attr = { .name = "profile1_buttons", .mode = 0440 },526.size = sizeof(struct koneplus_profile_buttons),527.read = koneplus_sysfs_read_profilex_buttons,528.private = &profile_numbers[0]529},530{531.attr = { .name = "profile2_buttons", .mode = 0440 },532.size = sizeof(struct koneplus_profile_buttons),533.read = koneplus_sysfs_read_profilex_buttons,534.private = &profile_numbers[1]535},536{537.attr = { .name = "profile3_buttons", .mode = 0440 },538.size = sizeof(struct koneplus_profile_buttons),539.read = koneplus_sysfs_read_profilex_buttons,540.private = &profile_numbers[2]541},542{543.attr = { .name = "profile4_buttons", .mode = 0440 },544.size = sizeof(struct koneplus_profile_buttons),545.read = koneplus_sysfs_read_profilex_buttons,546.private = &profile_numbers[3]547},548{549.attr = { .name = "profile5_buttons", .mode = 0440 },550.size = sizeof(struct koneplus_profile_buttons),551.read = koneplus_sysfs_read_profilex_buttons,552.private = &profile_numbers[4]553},554{555.attr = { .name = "macro", .mode = 0220 },556.size = sizeof(struct koneplus_macro),557.write = koneplus_sysfs_write_macro558},559__ATTR_NULL560};561562static int koneplus_init_koneplus_device_struct(struct usb_device *usb_dev,563struct koneplus_device *koneplus)564{565int retval, i;566static uint wait = 200;567568mutex_init(&koneplus->koneplus_lock);569570retval = koneplus_get_info(usb_dev, &koneplus->info);571if (retval)572return retval;573574for (i = 0; i < 5; ++i) {575msleep(wait);576retval = koneplus_get_profile_settings(usb_dev,577&koneplus->profile_settings[i], i);578if (retval)579return retval;580581msleep(wait);582retval = koneplus_get_profile_buttons(usb_dev,583&koneplus->profile_buttons[i], i);584if (retval)585return retval;586}587588msleep(wait);589retval = koneplus_get_actual_profile(usb_dev);590if (retval < 0)591return retval;592koneplus_profile_activated(koneplus, retval);593594return 0;595}596597static int koneplus_init_specials(struct hid_device *hdev)598{599struct usb_interface *intf = to_usb_interface(hdev->dev.parent);600struct usb_device *usb_dev = interface_to_usbdev(intf);601struct koneplus_device *koneplus;602int retval;603604if (intf->cur_altsetting->desc.bInterfaceProtocol605== USB_INTERFACE_PROTOCOL_MOUSE) {606607koneplus = kzalloc(sizeof(*koneplus), GFP_KERNEL);608if (!koneplus) {609hid_err(hdev, "can't alloc device descriptor\n");610return -ENOMEM;611}612hid_set_drvdata(hdev, koneplus);613614retval = koneplus_init_koneplus_device_struct(usb_dev, koneplus);615if (retval) {616hid_err(hdev, "couldn't init struct koneplus_device\n");617goto exit_free;618}619620retval = roccat_connect(koneplus_class, hdev,621sizeof(struct koneplus_roccat_report));622if (retval < 0) {623hid_err(hdev, "couldn't init char dev\n");624} else {625koneplus->chrdev_minor = retval;626koneplus->roccat_claimed = 1;627}628} else {629hid_set_drvdata(hdev, NULL);630}631632return 0;633exit_free:634kfree(koneplus);635return retval;636}637638static void koneplus_remove_specials(struct hid_device *hdev)639{640struct usb_interface *intf = to_usb_interface(hdev->dev.parent);641struct koneplus_device *koneplus;642643if (intf->cur_altsetting->desc.bInterfaceProtocol644== USB_INTERFACE_PROTOCOL_MOUSE) {645koneplus = hid_get_drvdata(hdev);646if (koneplus->roccat_claimed)647roccat_disconnect(koneplus->chrdev_minor);648kfree(koneplus);649}650}651652static int koneplus_probe(struct hid_device *hdev,653const struct hid_device_id *id)654{655int retval;656657retval = hid_parse(hdev);658if (retval) {659hid_err(hdev, "parse failed\n");660goto exit;661}662663retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT);664if (retval) {665hid_err(hdev, "hw start failed\n");666goto exit;667}668669retval = koneplus_init_specials(hdev);670if (retval) {671hid_err(hdev, "couldn't install mouse\n");672goto exit_stop;673}674675return 0;676677exit_stop:678hid_hw_stop(hdev);679exit:680return retval;681}682683static void koneplus_remove(struct hid_device *hdev)684{685koneplus_remove_specials(hdev);686hid_hw_stop(hdev);687}688689static void koneplus_keep_values_up_to_date(struct koneplus_device *koneplus,690u8 const *data)691{692struct koneplus_mouse_report_button const *button_report;693694switch (data[0]) {695case KONEPLUS_MOUSE_REPORT_NUMBER_BUTTON:696button_report = (struct koneplus_mouse_report_button const *)data;697switch (button_report->type) {698case KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_PROFILE:699koneplus_profile_activated(koneplus, button_report->data1 - 1);700break;701}702break;703}704}705706static void koneplus_report_to_chrdev(struct koneplus_device const *koneplus,707u8 const *data)708{709struct koneplus_roccat_report roccat_report;710struct koneplus_mouse_report_button const *button_report;711712if (data[0] != KONEPLUS_MOUSE_REPORT_NUMBER_BUTTON)713return;714715button_report = (struct koneplus_mouse_report_button const *)data;716717if ((button_report->type == KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_QUICKLAUNCH ||718button_report->type == KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_TIMER) &&719button_report->data2 != KONEPLUS_MOUSE_REPORT_BUTTON_ACTION_PRESS)720return;721722roccat_report.type = button_report->type;723roccat_report.data1 = button_report->data1;724roccat_report.data2 = button_report->data2;725roccat_report.profile = koneplus->actual_profile + 1;726roccat_report_event(koneplus->chrdev_minor,727(uint8_t const *)&roccat_report);728}729730static int koneplus_raw_event(struct hid_device *hdev,731struct hid_report *report, u8 *data, int size)732{733struct usb_interface *intf = to_usb_interface(hdev->dev.parent);734struct koneplus_device *koneplus = hid_get_drvdata(hdev);735736if (intf->cur_altsetting->desc.bInterfaceProtocol737!= USB_INTERFACE_PROTOCOL_MOUSE)738return 0;739740koneplus_keep_values_up_to_date(koneplus, data);741742if (koneplus->roccat_claimed)743koneplus_report_to_chrdev(koneplus, data);744745return 0;746}747748static const struct hid_device_id koneplus_devices[] = {749{ HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) },750{ }751};752753MODULE_DEVICE_TABLE(hid, koneplus_devices);754755static struct hid_driver koneplus_driver = {756.name = "koneplus",757.id_table = koneplus_devices,758.probe = koneplus_probe,759.remove = koneplus_remove,760.raw_event = koneplus_raw_event761};762763static int __init koneplus_init(void)764{765int retval;766767/* class name has to be same as driver name */768koneplus_class = class_create(THIS_MODULE, "koneplus");769if (IS_ERR(koneplus_class))770return PTR_ERR(koneplus_class);771koneplus_class->dev_attrs = koneplus_attributes;772koneplus_class->dev_bin_attrs = koneplus_bin_attributes;773774retval = hid_register_driver(&koneplus_driver);775if (retval)776class_destroy(koneplus_class);777return retval;778}779780static void __exit koneplus_exit(void)781{782hid_unregister_driver(&koneplus_driver);783class_destroy(koneplus_class);784}785786module_init(koneplus_init);787module_exit(koneplus_exit);788789MODULE_AUTHOR("Stefan Achatz");790MODULE_DESCRIPTION("USB Roccat Kone[+] driver");791MODULE_LICENSE("GPL v2");792793794