19 #include <linux/device.h>
20 #include <linux/input.h>
21 #include <linux/hid.h>
22 #include <linux/module.h>
23 #include <linux/slab.h>
29 static struct class *arvo_class;
36 struct usb_device *usb_dev =
37 interface_to_usbdev(to_usb_interface(dev->
parent->parent));
56 struct usb_device *usb_dev =
57 interface_to_usbdev(to_usb_interface(dev->
parent->parent));
67 temp_buf.state =
state;
84 struct usb_device *usb_dev =
85 interface_to_usbdev(to_usb_interface(dev->
parent->parent));
104 struct usb_device *usb_dev =
105 interface_to_usbdev(to_usb_interface(dev->
parent->parent));
128 static int arvo_get_actual_profile(
struct usb_device *usb_dev)
139 return temp_buf.actual_profile;
142 static ssize_t arvo_sysfs_show_actual_profile(
struct device *dev,
151 static ssize_t arvo_sysfs_set_actual_profile(
struct device *dev,
156 struct usb_device *usb_dev =
157 interface_to_usbdev(to_usb_interface(dev->
parent->parent));
166 if (profile < 1 || profile > 5)
170 temp_buf.actual_profile =
profile;
184 struct kobject *kobj,
void const *buf,
190 struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
193 if (off != 0 || count != real_size)
200 return (retval ? retval : real_size);
204 struct kobject *kobj,
void *buf, loff_t off,
205 size_t count,
size_t real_size,
uint command)
210 struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
213 if (off >= real_size)
216 if (off != 0 || count != real_size)
223 return (retval ? retval : real_size);
226 static ssize_t arvo_sysfs_write_button(
struct file *fp,
228 loff_t off,
size_t count)
230 return arvo_sysfs_write(fp, kobj, buf, off, count,
234 static ssize_t arvo_sysfs_read_info(
struct file *fp,
236 loff_t off,
size_t count)
238 return arvo_sysfs_read(fp, kobj, buf, off, count,
245 arvo_sysfs_show_mode_key, arvo_sysfs_set_mode_key),
247 arvo_sysfs_show_key_mask, arvo_sysfs_set_key_mask),
249 arvo_sysfs_show_actual_profile,
250 arvo_sysfs_set_actual_profile),
256 .attr = { .name =
"button", .mode = 0220 },
258 .
write = arvo_sysfs_write_button
261 .attr = { .name =
"info", .mode = 0440 },
263 .
read = arvo_sysfs_read_info
268 static int arvo_init_arvo_device_struct(
struct usb_device *usb_dev,
275 retval = arvo_get_actual_profile(usb_dev);
283 static int arvo_init_specials(
struct hid_device *hdev)
286 struct usb_device *usb_dev = interface_to_usbdev(intf);
290 if (intf->cur_altsetting->desc.bInterfaceProtocol
292 hid_set_drvdata(hdev,
NULL);
298 hid_err(hdev,
"can't alloc device descriptor\n");
301 hid_set_drvdata(hdev, arvo);
303 retval = arvo_init_arvo_device_struct(usb_dev, arvo);
305 hid_err(hdev,
"couldn't init struct arvo_device\n");
312 hid_err(hdev,
"couldn't init char dev\n");
324 static void arvo_remove_specials(
struct hid_device *hdev)
329 if (intf->cur_altsetting->desc.bInterfaceProtocol
333 arvo = hid_get_drvdata(hdev);
339 static int arvo_probe(
struct hid_device *hdev,
344 retval = hid_parse(hdev);
346 hid_err(hdev,
"parse failed\n");
352 hid_err(hdev,
"hw start failed\n");
356 retval = arvo_init_specials(hdev);
358 hid_err(hdev,
"couldn't install keyboard\n");
370 static void arvo_remove(
struct hid_device *hdev)
372 arvo_remove_specials(hdev);
376 static void arvo_report_to_chrdev(
struct arvo_device const *arvo,
397 static int arvo_raw_event(
struct hid_device *hdev,
406 arvo_report_to_chrdev(arvo, data);
420 .id_table = arvo_devices,
422 .remove = arvo_remove,
423 .raw_event = arvo_raw_event
426 static int __init arvo_init(
void)
431 if (IS_ERR(arvo_class))
432 return PTR_ERR(arvo_class);
442 static void __exit arvo_exit(
void)