18 #include <linux/device.h>
19 #include <linux/input.h>
20 #include <linux/hid.h>
21 #include <linux/module.h>
22 #include <linux/slab.h>
28 static struct class *savu_class;
37 struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
43 if (off != 0 || count != real_size)
50 return retval ? retval : real_size;
54 void const *buf, loff_t off,
size_t count,
55 size_t real_size,
uint command)
60 struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
63 if (off != 0 || count != real_size)
68 (
void *)buf, real_size);
71 return retval ? retval : real_size;
74 #define SAVU_SYSFS_W(thingy, THINGY) \
75 static ssize_t savu_sysfs_write_ ## thingy(struct file *fp, \
76 struct kobject *kobj, struct bin_attribute *attr, char *buf, \
77 loff_t off, size_t count) \
79 return savu_sysfs_write(fp, kobj, buf, off, count, \
80 SAVU_SIZE_ ## THINGY, SAVU_COMMAND_ ## THINGY); \
83 #define SAVU_SYSFS_R(thingy, THINGY) \
84 static ssize_t savu_sysfs_read_ ## thingy(struct file *fp, \
85 struct kobject *kobj, struct bin_attribute *attr, char *buf, \
86 loff_t off, size_t count) \
88 return savu_sysfs_read(fp, kobj, buf, off, count, \
89 SAVU_SIZE_ ## THINGY, SAVU_COMMAND_ ## THINGY); \
92 #define SAVU_SYSFS_RW(thingy, THINGY) \
93 SAVU_SYSFS_W(thingy, THINGY) \
94 SAVU_SYSFS_R(thingy, THINGY)
96 #define SAVU_BIN_ATTRIBUTE_RW(thingy, THINGY) \
98 .attr = { .name = #thingy, .mode = 0660 }, \
99 .size = SAVU_SIZE_ ## THINGY, \
100 .read = savu_sysfs_read_ ## thingy, \
101 .write = savu_sysfs_write_ ## thingy \
104 #define SAVU_BIN_ATTRIBUTE_R(thingy, THINGY) \
106 .attr = { .name = #thingy, .mode = 0440 }, \
107 .size = SAVU_SIZE_ ## THINGY, \
108 .read = savu_sysfs_read_ ## thingy, \
111 #define SAVU_BIN_ATTRIBUTE_W(thingy, THINGY) \
113 .attr = { .name = #thingy, .mode = 0220 }, \
114 .size = SAVU_SIZE_ ## THINGY, \
115 .write = savu_sysfs_write_ ## thingy \
137 static int savu_init_savu_device_struct(
struct usb_device *usb_dev,
145 static int savu_init_specials(
struct hid_device *hdev)
148 struct usb_device *usb_dev = interface_to_usbdev(intf);
152 if (intf->cur_altsetting->desc.bInterfaceProtocol
154 hid_set_drvdata(hdev,
NULL);
160 hid_err(hdev,
"can't alloc device descriptor\n");
163 hid_set_drvdata(hdev, savu);
165 retval = savu_init_savu_device_struct(usb_dev, savu);
167 hid_err(hdev,
"couldn't init struct savu_device\n");
174 hid_err(hdev,
"couldn't init char dev\n");
186 static void savu_remove_specials(
struct hid_device *hdev)
191 if (intf->cur_altsetting->desc.bInterfaceProtocol
195 savu = hid_get_drvdata(hdev);
201 static int savu_probe(
struct hid_device *hdev,
206 retval = hid_parse(hdev);
208 hid_err(hdev,
"parse failed\n");
214 hid_err(hdev,
"hw start failed\n");
218 retval = savu_init_specials(hdev);
220 hid_err(hdev,
"couldn't install mouse\n");
232 static void savu_remove(
struct hid_device *hdev)
234 savu_remove_specials(hdev);
238 static void savu_report_to_chrdev(
struct savu_device const *savu,
256 static int savu_raw_event(
struct hid_device *hdev,
262 if (intf->cur_altsetting->desc.bInterfaceProtocol
270 savu_report_to_chrdev(savu, data);
284 .id_table = savu_devices,
286 .remove = savu_remove,
287 .raw_event = savu_raw_event
290 static int __init savu_init(
void)
295 if (IS_ERR(savu_class))
296 return PTR_ERR(savu_class);
305 static void __exit savu_exit(
void)