Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Roccat Isku driver for Linux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (c) 2011 Stefan Achatz <erazor_de@users.sourceforge.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * Roccat Isku is a gamer keyboard with macro keys that can be configured in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * 5 profiles.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/hid.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/hid-roccat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include "hid-ids.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include "hid-roccat-common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include "hid-roccat-isku.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) static struct class *isku_class;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) static void isku_profile_activated(struct isku_device *isku, uint new_profile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	isku->actual_profile = new_profile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) static int isku_receive(struct usb_device *usb_dev, uint command,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 		void *buf, uint size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	return roccat_common2_receive(usb_dev, command, buf, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) static int isku_get_actual_profile(struct usb_device *usb_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	struct isku_actual_profile buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	retval = isku_receive(usb_dev, ISKU_COMMAND_ACTUAL_PROFILE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 			&buf, sizeof(struct isku_actual_profile));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	return retval ? retval : buf.actual_profile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) static int isku_set_actual_profile(struct usb_device *usb_dev, int new_profile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	struct isku_actual_profile buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	buf.command = ISKU_COMMAND_ACTUAL_PROFILE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	buf.size = sizeof(struct isku_actual_profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	buf.actual_profile = new_profile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	return roccat_common2_send_with_status(usb_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 			ISKU_COMMAND_ACTUAL_PROFILE, &buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 			sizeof(struct isku_actual_profile));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) static ssize_t isku_sysfs_show_actual_profile(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	struct isku_device *isku =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 			hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	return snprintf(buf, PAGE_SIZE, "%d\n", isku->actual_profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) static ssize_t isku_sysfs_set_actual_profile(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		struct device_attribute *attr, char const *buf, size_t size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	struct isku_device *isku;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	struct usb_device *usb_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	unsigned long profile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	struct isku_roccat_report roccat_report;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	dev = dev->parent->parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	isku = hid_get_drvdata(dev_get_drvdata(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	usb_dev = interface_to_usbdev(to_usb_interface(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	retval = kstrtoul(buf, 10, &profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	if (profile > 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	mutex_lock(&isku->isku_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	retval = isku_set_actual_profile(usb_dev, profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	if (retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		mutex_unlock(&isku->isku_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	isku_profile_activated(isku, profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	roccat_report.event = ISKU_REPORT_BUTTON_EVENT_PROFILE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	roccat_report.data1 = profile + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	roccat_report.data2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	roccat_report.profile = profile + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	roccat_report_event(isku->chrdev_minor, (uint8_t const *)&roccat_report);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	mutex_unlock(&isku->isku_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	return size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) static DEVICE_ATTR(actual_profile, 0660, isku_sysfs_show_actual_profile,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		   isku_sysfs_set_actual_profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) static struct attribute *isku_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	&dev_attr_actual_profile.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) static ssize_t isku_sysfs_read(struct file *fp, struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		char *buf, loff_t off, size_t count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		size_t real_size, uint command)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	struct device *dev = kobj_to_dev(kobj)->parent->parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	struct isku_device *isku = hid_get_drvdata(dev_get_drvdata(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	if (off >= real_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	if (off != 0 || count > real_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	mutex_lock(&isku->isku_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	retval = isku_receive(usb_dev, command, buf, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	mutex_unlock(&isku->isku_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	return retval ? retval : count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) static ssize_t isku_sysfs_write(struct file *fp, struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		void const *buf, loff_t off, size_t count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		size_t real_size, uint command)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	struct device *dev = kobj_to_dev(kobj)->parent->parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	struct isku_device *isku = hid_get_drvdata(dev_get_drvdata(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	if (off != 0 || count > real_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	mutex_lock(&isku->isku_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	retval = roccat_common2_send_with_status(usb_dev, command,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 			(void *)buf, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	mutex_unlock(&isku->isku_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	return retval ? retval : count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) #define ISKU_SYSFS_W(thingy, THINGY) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) static ssize_t isku_sysfs_write_ ## thingy(struct file *fp, struct kobject *kobj, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		struct bin_attribute *attr, char *buf, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		loff_t off, size_t count) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	return isku_sysfs_write(fp, kobj, buf, off, count, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 			ISKU_SIZE_ ## THINGY, ISKU_COMMAND_ ## THINGY); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) #define ISKU_SYSFS_R(thingy, THINGY) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) static ssize_t isku_sysfs_read_ ## thingy(struct file *fp, struct kobject *kobj, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		struct bin_attribute *attr, char *buf, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		loff_t off, size_t count) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	return isku_sysfs_read(fp, kobj, buf, off, count, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 			ISKU_SIZE_ ## THINGY, ISKU_COMMAND_ ## THINGY); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) #define ISKU_SYSFS_RW(thingy, THINGY) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) ISKU_SYSFS_R(thingy, THINGY) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) ISKU_SYSFS_W(thingy, THINGY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) #define ISKU_BIN_ATTR_RW(thingy, THINGY) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) ISKU_SYSFS_RW(thingy, THINGY); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) static struct bin_attribute bin_attr_##thingy = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	.attr = { .name = #thingy, .mode = 0660 }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	.size = ISKU_SIZE_ ## THINGY, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	.read = isku_sysfs_read_ ## thingy, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	.write = isku_sysfs_write_ ## thingy \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) #define ISKU_BIN_ATTR_R(thingy, THINGY) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) ISKU_SYSFS_R(thingy, THINGY); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) static struct bin_attribute bin_attr_##thingy = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	.attr = { .name = #thingy, .mode = 0440 }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	.size = ISKU_SIZE_ ## THINGY, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	.read = isku_sysfs_read_ ## thingy, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) #define ISKU_BIN_ATTR_W(thingy, THINGY) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) ISKU_SYSFS_W(thingy, THINGY); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) static struct bin_attribute bin_attr_##thingy = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	.attr = { .name = #thingy, .mode = 0220 }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	.size = ISKU_SIZE_ ## THINGY, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	.write = isku_sysfs_write_ ## thingy \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) ISKU_BIN_ATTR_RW(macro, MACRO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) ISKU_BIN_ATTR_RW(keys_function, KEYS_FUNCTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) ISKU_BIN_ATTR_RW(keys_easyzone, KEYS_EASYZONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) ISKU_BIN_ATTR_RW(keys_media, KEYS_MEDIA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) ISKU_BIN_ATTR_RW(keys_thumbster, KEYS_THUMBSTER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) ISKU_BIN_ATTR_RW(keys_macro, KEYS_MACRO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) ISKU_BIN_ATTR_RW(keys_capslock, KEYS_CAPSLOCK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) ISKU_BIN_ATTR_RW(light, LIGHT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) ISKU_BIN_ATTR_RW(key_mask, KEY_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) ISKU_BIN_ATTR_RW(last_set, LAST_SET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) ISKU_BIN_ATTR_W(talk, TALK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) ISKU_BIN_ATTR_W(talkfx, TALKFX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) ISKU_BIN_ATTR_W(control, CONTROL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) ISKU_BIN_ATTR_W(reset, RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) ISKU_BIN_ATTR_R(info, INFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) static struct bin_attribute *isku_bin_attributes[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	&bin_attr_macro,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	&bin_attr_keys_function,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	&bin_attr_keys_easyzone,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	&bin_attr_keys_media,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	&bin_attr_keys_thumbster,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	&bin_attr_keys_macro,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	&bin_attr_keys_capslock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	&bin_attr_light,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	&bin_attr_key_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	&bin_attr_last_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	&bin_attr_talk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	&bin_attr_talkfx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	&bin_attr_control,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	&bin_attr_reset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	&bin_attr_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) static const struct attribute_group isku_group = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	.attrs = isku_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	.bin_attrs = isku_bin_attributes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) static const struct attribute_group *isku_groups[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	&isku_group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) static int isku_init_isku_device_struct(struct usb_device *usb_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		struct isku_device *isku)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	mutex_init(&isku->isku_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	retval = isku_get_actual_profile(usb_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	if (retval < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	isku_profile_activated(isku, retval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) static int isku_init_specials(struct hid_device *hdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	struct usb_device *usb_dev = interface_to_usbdev(intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	struct isku_device *isku;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	if (intf->cur_altsetting->desc.bInterfaceProtocol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 			!= ISKU_USB_INTERFACE_PROTOCOL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		hid_set_drvdata(hdev, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	isku = kzalloc(sizeof(*isku), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	if (!isku) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 		hid_err(hdev, "can't alloc device descriptor\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	hid_set_drvdata(hdev, isku);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	retval = isku_init_isku_device_struct(usb_dev, isku);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	if (retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 		hid_err(hdev, "couldn't init struct isku_device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 		goto exit_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	retval = roccat_connect(isku_class, hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 			sizeof(struct isku_roccat_report));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	if (retval < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		hid_err(hdev, "couldn't init char dev\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 		isku->chrdev_minor = retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		isku->roccat_claimed = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) exit_free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	kfree(isku);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) static void isku_remove_specials(struct hid_device *hdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	struct isku_device *isku;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	if (intf->cur_altsetting->desc.bInterfaceProtocol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 			!= ISKU_USB_INTERFACE_PROTOCOL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	isku = hid_get_drvdata(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	if (isku->roccat_claimed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 		roccat_disconnect(isku->chrdev_minor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	kfree(isku);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) static int isku_probe(struct hid_device *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 		const struct hid_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	if (!hid_is_usb(hdev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	retval = hid_parse(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	if (retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 		hid_err(hdev, "parse failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 		goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	if (retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 		hid_err(hdev, "hw start failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 		goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	retval = isku_init_specials(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	if (retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 		hid_err(hdev, "couldn't install keyboard\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 		goto exit_stop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) exit_stop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	hid_hw_stop(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) static void isku_remove(struct hid_device *hdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	isku_remove_specials(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	hid_hw_stop(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) static void isku_keep_values_up_to_date(struct isku_device *isku,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 		u8 const *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	struct isku_report_button const *button_report;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	switch (data[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	case ISKU_REPORT_NUMBER_BUTTON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 		button_report = (struct isku_report_button const *)data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 		switch (button_report->event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 		case ISKU_REPORT_BUTTON_EVENT_PROFILE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 			isku_profile_activated(isku, button_report->data1 - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) static void isku_report_to_chrdev(struct isku_device const *isku,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 		u8 const *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	struct isku_roccat_report roccat_report;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	struct isku_report_button const *button_report;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	if (data[0] != ISKU_REPORT_NUMBER_BUTTON)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	button_report = (struct isku_report_button const *)data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	roccat_report.event = button_report->event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	roccat_report.data1 = button_report->data1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	roccat_report.data2 = button_report->data2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	roccat_report.profile = isku->actual_profile + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	roccat_report_event(isku->chrdev_minor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 			(uint8_t const *)&roccat_report);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) static int isku_raw_event(struct hid_device *hdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 		struct hid_report *report, u8 *data, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	struct isku_device *isku = hid_get_drvdata(hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	if (intf->cur_altsetting->desc.bInterfaceProtocol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 			!= ISKU_USB_INTERFACE_PROTOCOL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	if (isku == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	isku_keep_values_up_to_date(isku, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	if (isku->roccat_claimed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 		isku_report_to_chrdev(isku, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) static const struct hid_device_id isku_devices[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	{ HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ISKU) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	{ HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ISKUFX) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	{ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) MODULE_DEVICE_TABLE(hid, isku_devices);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) static struct hid_driver isku_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 		.name = "isku",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 		.id_table = isku_devices,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 		.probe = isku_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 		.remove = isku_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 		.raw_event = isku_raw_event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) static int __init isku_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	isku_class = class_create(THIS_MODULE, "isku");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	if (IS_ERR(isku_class))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 		return PTR_ERR(isku_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	isku_class->dev_groups = isku_groups;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	retval = hid_register_driver(&isku_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 		class_destroy(isku_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) static void __exit isku_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	hid_unregister_driver(&isku_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	class_destroy(isku_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) module_init(isku_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) module_exit(isku_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) MODULE_AUTHOR("Stefan Achatz");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) MODULE_DESCRIPTION("USB Roccat Isku/FX driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) MODULE_LICENSE("GPL v2");