static int arvo_init_specials(struct hid_device *hdev) { struct usb_interface *intf = to_usb_interface(hdev->dev.parent); struct usb_device *usb_dev = interface_to_usbdev(intf); struct arvo_device *arvo; int retval; if (intf->cur_altsetting->desc.bInterfaceProtocol == USB_INTERFACE_PROTOCOL_KEYBOARD) { hid_set_drvdata(hdev, NULL); return 0; } arvo = kzalloc(sizeof(*arvo), GFP_KERNEL); if (!arvo) { hid_err(hdev, "can't alloc device descriptor\n"); return -ENOMEM; } hid_set_drvdata(hdev, arvo); retval = arvo_init_arvo_device_struct(usb_dev, arvo); if (retval) { hid_err(hdev, "couldn't init struct arvo_device\n"); goto exit_free; } retval = roccat_connect(arvo_class, hdev, sizeof(struct arvo_roccat_report)); if (retval < 0) { hid_err(hdev, "couldn't init char dev\n"); } else { arvo->chrdev_minor = retval; arvo->roccat_claimed = 1; } return 0; exit_free: kfree(arvo); return retval; }
static ssize_t pyra_sysfs_write_settings(struct file *fp, struct kobject *kobj, struct bin_attribute *attr, char *buf, loff_t off, size_t count) { struct device *dev = container_of(kobj, struct device, kobj)->parent->parent; struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); int retval = 0; int difference; struct pyra_roccat_report roccat_report; if (off != 0 || count != sizeof(struct pyra_settings)) return -EINVAL; mutex_lock(&pyra->pyra_lock); difference = memcmp(buf, &pyra->settings, sizeof(struct pyra_settings)); if (difference) { retval = pyra_set_settings(usb_dev, (struct pyra_settings const *)buf); if (retval) { mutex_unlock(&pyra->pyra_lock); return retval; } memcpy(&pyra->settings, buf, sizeof(struct pyra_settings)); profile_activated(pyra, pyra->settings.startup_profile); roccat_report.type = PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_2; roccat_report.value = pyra->settings.startup_profile + 1; roccat_report.key = 0; roccat_report_event(pyra->chrdev_minor, (uint8_t const *)&roccat_report); } mutex_unlock(&pyra->pyra_lock); return sizeof(struct pyra_settings); }
static void razer_kbd_disconnect(struct hid_device *hdev) { struct razer_kbd_device *dev; struct usb_interface *intf = to_usb_interface(hdev->dev.parent); dev = hid_get_drvdata(hdev); device_remove_file(&hdev->dev, &dev_attr_mode_wave); device_remove_file(&hdev->dev, &dev_attr_mode_spectrum); device_remove_file(&hdev->dev, &dev_attr_mode_none); device_remove_file(&hdev->dev, &dev_attr_mode_reactive); device_remove_file(&hdev->dev, &dev_attr_mode_breath); device_remove_file(&hdev->dev, &dev_attr_mode_custom); device_remove_file(&hdev->dev, &dev_attr_mode_static); device_remove_file(&hdev->dev, &dev_attr_temp_clear_row); device_remove_file(&hdev->dev, &dev_attr_set_key_row); device_remove_file(&hdev->dev, &dev_attr_reset); device_remove_file(&hdev->dev, &dev_attr_macro_keys); device_remove_file(&hdev->dev, &dev_attr_set_brightness); hid_hw_stop(hdev); kfree(dev); dev_info(&intf->dev, "Razer Blackwidow Chroma disconnected\n"); }
static ssize_t razer_attr_write_set_key_row(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct usb_interface *intf = to_usb_interface(dev->parent); //struct razer_kbd_device *widow = usb_get_intfdata(intf); struct usb_device *usb_dev = interface_to_usbdev(intf); size_t buf_size = (RAZER_BLACKWIDOW_CHROMA_ROW_LEN+1)*3 + 1; //printk(KERN_ALERT "sizeof(razer_row_rgb): %d\n",sizeof(struct razer_row_rgb)); size_t offset = 0; while(offset<count) { unsigned char row_index = (unsigned char)buf[offset]; if(count-offset < buf_size) { printk(KERN_ALERT "Wrong Amount of RGB data provided: %d of %d\n",(int)count,(int)buf_size); return 0; } razer_set_key_row(usb_dev,row_index,(struct razer_row_rgb*)&buf[offset+1]); offset += buf_size; } return count; }
static int usb_port_runtime_suspend(struct device *dev) { struct usb_port *port_dev = to_usb_port(dev); struct usb_device *hdev = to_usb_device(dev->parent->parent); struct usb_interface *intf = to_usb_interface(dev->parent); struct usb_hub *hub = usb_hub_to_struct_hub(hdev); struct usb_port *peer = port_dev->peer; int port1 = port_dev->portnum; int retval; if (!hub) return -EINVAL; if (hub->in_reset) return -EBUSY; if (dev_pm_qos_flags(&port_dev->dev, PM_QOS_FLAG_NO_POWER_OFF) == PM_QOS_FLAGS_ALL) return -EAGAIN; if (usb_port_block_power_off) return -EBUSY; usb_autopm_get_interface(intf); retval = usb_hub_set_port_power(hdev, hub, port1, false); usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_CONNECTION); if (!port_dev->is_superspeed) usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_ENABLE); usb_autopm_put_interface(intf); /* * Our peer usb3 port may now be able to suspend, so * asynchronously queue a suspend request to observe that this * usb2 port is now off. */ if (!port_dev->is_superspeed && peer) pm_runtime_put(&peer->dev); return retval; }
static ssize_t konepure_sysfs_read(struct file *fp, struct kobject *kobj, char *buf, loff_t off, size_t count, size_t real_size, uint command) { struct device *dev = container_of(kobj, struct device, kobj)->parent->parent; struct konepure_device *konepure = hid_get_drvdata(dev_get_drvdata(dev)); struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); int retval; if (off >= real_size) return 0; if (off != 0 || count != real_size) return -EINVAL; mutex_lock(&konepure->konepure_lock); retval = roccat_common2_receive(usb_dev, command, buf, real_size); mutex_unlock(&konepure->konepure_lock); return retval ? retval : real_size; }
static void logi_dj_recv_add_djhid_device(struct dj_receiver_dev *djrcv_dev, struct dj_report *dj_report) { /* Called in delayed work context */ struct hid_device *djrcv_hdev = djrcv_dev->hdev; struct usb_interface *intf = to_usb_interface(djrcv_hdev->dev.parent); struct usb_device *usbdev = interface_to_usbdev(intf); struct hid_device *dj_hiddev; struct dj_device *dj_dev; /* Device index goes from 1 to 6, we need 3 bytes to store the * semicolon, the index, and a null terminator */ unsigned char tmpstr[3]; if (dj_report->report_params[DEVICE_PAIRED_PARAM_SPFUNCTION] & SPFUNCTION_DEVICE_LIST_EMPTY) { dbg_hid("%s: device list is empty\n", __func__); return; } <<<<<<< HEAD
static ssize_t isku_sysfs_read(struct file *fp, struct kobject *kobj, char *buf, loff_t off, size_t count, size_t real_size, uint command) { struct device *dev = container_of(kobj, struct device, kobj)->parent->parent; struct isku_device *isku = hid_get_drvdata(dev_get_drvdata(dev)); struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); int retval; if (off >= real_size) return 0; if (off != 0 || count > real_size) return -EINVAL; mutex_lock(&isku->isku_lock); retval = isku_receive(usb_dev, command, buf, count); mutex_unlock(&isku->isku_lock); return retval ? retval : count; }
static ssize_t show_modalias(struct device *dev, struct device_attribute *attr, char *buf) { struct usb_interface *intf; struct usb_device *udev; struct usb_host_interface *alt; intf = to_usb_interface(dev); udev = interface_to_usbdev(intf); alt = intf->cur_altsetting; return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02X" "ic%02Xisc%02Xip%02X\n", le16_to_cpu(udev->descriptor.idVendor), le16_to_cpu(udev->descriptor.idProduct), le16_to_cpu(udev->descriptor.bcdDevice), udev->descriptor.bDeviceClass, udev->descriptor.bDeviceSubClass, udev->descriptor.bDeviceProtocol, alt->desc.bInterfaceClass, alt->desc.bInterfaceSubClass, alt->desc.bInterfaceProtocol); }
/** * Write device file "mode_breath" */ static ssize_t razer_attr_write_mode_breath(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct usb_interface *intf = to_usb_interface(dev->parent); struct usb_device *usb_dev = interface_to_usbdev(intf); const char *alt_buf[6] = { 0 }; if(count == 3) { // Single colour mode razer_set_breath_mode(usb_dev, 0x01, (struct razer_rgb*)&buf[0], (struct razer_rgb*)&alt_buf[3]); } else if(count == 6) { // Dual colour mode razer_set_breath_mode(usb_dev, 0x02, (struct razer_rgb*)&buf[0], (struct razer_rgb*)&buf[3]); } else { // "Random" colour mode razer_set_breath_mode(usb_dev, 0x03, (struct razer_rgb*)&alt_buf[0], (struct razer_rgb*)&alt_buf[3]); } return count; }
static ssize_t koneplus_sysfs_write(struct file *fp, struct kobject *kobj, void const *buf, loff_t off, size_t count, size_t real_size, uint command) { struct device *dev = container_of(kobj, struct device, kobj)->parent->parent; struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev)); struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); int retval; if (off != 0 || count != real_size) return -EINVAL; mutex_lock(&koneplus->koneplus_lock); retval = koneplus_send(usb_dev, command, buf, real_size); mutex_unlock(&koneplus->koneplus_lock); if (retval) return retval; return real_size; }
/** * Unbind function */ static void razer_kraken_disconnect(struct hid_device *hdev) { struct razer_kraken_device *dev; struct usb_interface *intf = to_usb_interface(hdev->dev.parent); dev = hid_get_drvdata(hdev); if(dev->usb_interface_protocol == USB_INTERFACE_PROTOCOL_NONE) { device_remove_file(&hdev->dev, &dev_attr_version); // Get driver version device_remove_file(&hdev->dev, &dev_attr_test); // Test mode device_remove_file(&hdev->dev, &dev_attr_device_type); // Get string of device type device_remove_file(&hdev->dev, &dev_attr_device_serial); // Get string of device serial device_remove_file(&hdev->dev, &dev_attr_firmware_version); // Get string of device fw version device_remove_file(&hdev->dev, &dev_attr_device_mode); // Get device mode switch(dev->usb_pid) { case USB_DEVICE_ID_RAZER_KRAKEN_CLASSIC: case USB_DEVICE_ID_RAZER_KRAKEN_CLASSIC_ALT: device_remove_file(&hdev->dev, &dev_attr_matrix_effect_none); // No effect device_remove_file(&hdev->dev, &dev_attr_matrix_effect_static); // Static effect device_remove_file(&hdev->dev, &dev_attr_matrix_current_effect); // Get current effect break; case USB_DEVICE_ID_RAZER_KRAKEN: case USB_DEVICE_ID_RAZER_KRAKEN_V2: device_remove_file(&hdev->dev, &dev_attr_matrix_effect_none); // No effect device_remove_file(&hdev->dev, &dev_attr_matrix_effect_spectrum); // Spectrum effect device_remove_file(&hdev->dev, &dev_attr_matrix_effect_static); // Static effect device_remove_file(&hdev->dev, &dev_attr_matrix_effect_custom); // Custom effect device_remove_file(&hdev->dev, &dev_attr_matrix_effect_breath); // Brething effect device_remove_file(&hdev->dev, &dev_attr_matrix_current_effect); // Get current effect break; } } hid_hw_stop(hdev); kfree(dev); dev_info(&intf->dev, "Razer Device disconnected\n"); }
static int usb_port_runtime_resume(struct device *dev) { struct usb_port *port_dev = to_usb_port(dev); struct usb_device *hdev = to_usb_device(dev->parent->parent); struct usb_interface *intf = to_usb_interface(dev->parent); struct usb_hub *hub = usb_hub_to_struct_hub(hdev); int port1 = port_dev->portnum; int retval; if (!hub) return -EINVAL; usb_autopm_get_interface(intf); set_bit(port1, hub->busy_bits); retval = usb_hub_set_port_power(hdev, hub, port1, true); if (port_dev->child && !retval) { /* * Wait for usb hub port to be reconnected in order to make * the resume procedure successful. */ retval = hub_port_debounce_be_connected(hub, port1); if (retval < 0) { dev_dbg(&port_dev->dev, "can't get reconnection after setting port power on, status %d\n", retval); goto out; } usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_ENABLE); /* Set return value to 0 if debounce successful */ retval = 0; } out: clear_bit(port1, hub->busy_bits); usb_autopm_put_interface(intf); return retval; }
static int rt2x00usb_find_endpoints(struct rt2x00_dev *rt2x00dev) { struct usb_interface *intf = to_usb_interface(rt2x00dev->dev); struct usb_host_interface *intf_desc = intf->cur_altsetting; struct usb_endpoint_descriptor *ep_desc; struct data_queue *queue = rt2x00dev->tx; struct usb_endpoint_descriptor *tx_ep_desc = NULL; unsigned int i; for (i = 0; i < intf_desc->desc.bNumEndpoints; i++) { ep_desc = &intf_desc->endpoint[i].desc; if (usb_endpoint_is_bulk_in(ep_desc)) { rt2x00usb_assign_endpoint(rt2x00dev->rx, ep_desc); } else if (usb_endpoint_is_bulk_out(ep_desc) && (queue != queue_end(rt2x00dev))) { rt2x00usb_assign_endpoint(queue, ep_desc); queue = queue_next(queue); tx_ep_desc = ep_desc; } } if (!rt2x00dev->rx->usb_endpoint || !rt2x00dev->tx->usb_endpoint) { ERROR(rt2x00dev, "Bulk-in/Bulk-out endpoints not found\n"); return -EPIPE; } txall_queue_for_each(rt2x00dev, queue) { if (!queue->usb_endpoint) rt2x00usb_assign_endpoint(queue, tx_ep_desc); } return 0; }
/** * * Write device file "set_brightness" * * Sets the brightness to the ASCII number written to this file. */ static ssize_t razer_attr_write_set_brightness(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct usb_interface *intf = to_usb_interface(dev->parent); struct usb_device *usb_dev = interface_to_usbdev(intf); struct razer_report report = {0}; unsigned char brightness = (unsigned char)simple_strtoul(buf, NULL, 10); switch (usb_dev->descriptor.idProduct) { case USB_DEVICE_ID_RAZER_GOLIATHUS_CHROMA: case USB_DEVICE_ID_RAZER_GOLIATHUS_CHROMA_EXTENDED: report = razer_chroma_extended_matrix_brightness(VARSTORE, ZERO_LED, brightness); saved_brightness = brightness; break; default: report = razer_chroma_standard_set_led_brightness(VARSTORE, BACKLIGHT_LED, brightness); break; } razer_send_payload(usb_dev, &report); return count; }
/** * Read device file "set_brightness" * * Returns brightness or -1 if the initial brightness is not known */ static ssize_t razer_attr_read_set_brightness(struct device *dev, struct device_attribute *attr, char *buf) { struct usb_interface *intf = to_usb_interface(dev->parent); struct usb_device *usb_dev = interface_to_usbdev(intf); struct razer_report response = {0}; struct razer_report report = {0}; unsigned char brightness = 0; switch (usb_dev->descriptor.idProduct) { case USB_DEVICE_ID_RAZER_GOLIATHUS_CHROMA: case USB_DEVICE_ID_RAZER_GOLIATHUS_CHROMA_EXTENDED: brightness = saved_brightness; break; default: report = razer_chroma_standard_get_led_brightness(VARSTORE, BACKLIGHT_LED);; response = razer_send_payload(usb_dev, &report); brightness = response.arguments[2]; break; } return sprintf(buf, "%d\n", brightness); }
/** * Read device file "device_type" * * Returns friendly string of device type */ static ssize_t razer_attr_read_device_type(struct device *dev, struct device_attribute *attr, char *buf) { struct usb_interface *intf = to_usb_interface(dev->parent); //struct razer_kbd_device *widow = usb_get_intfdata(intf); struct usb_device *usb_dev = interface_to_usbdev(intf); int write_count = 0; if(usb_dev->descriptor.idProduct == USB_DEVICE_ID_RAZER_BLACKWIDOW_CHROMA) { write_count = sprintf(buf, "Razer BlackWidow Chroma\n"); } else if(usb_dev->descriptor.idProduct == USB_DEVICE_ID_RAZER_BLACKWIDOW_CHROMA_TE) { write_count = sprintf(buf, "Razer BlackWidow Chroma Tournament Edition\n"); } else if(usb_dev->descriptor.idProduct == USB_DEVICE_ID_RAZER_BLACKWIDOW_ULTIMATE_2013) { write_count = sprintf(buf, "Razer BlackWidow Ultimate 2013\n"); } else { write_count = sprintf(buf, "Unknown Device\n"); } return write_count; }
static int mt76u_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q, struct sk_buff *skb, struct mt76_wcid *wcid, struct ieee80211_sta *sta) { struct usb_interface *intf = to_usb_interface(dev->dev); struct usb_device *udev = interface_to_usbdev(intf); u8 ep = q2ep(q->hw_idx); struct mt76u_buf *buf; u16 idx = q->tail; unsigned int pipe; int err; if (q->queued == q->ndesc) return -ENOSPC; err = dev->drv->tx_prepare_skb(dev, NULL, skb, q, wcid, sta, NULL); if (err < 0) return err; buf = &q->entry[idx].ubuf; buf->done = false; err = mt76u_tx_build_sg(skb, buf->urb); if (err < 0) return err; pipe = usb_sndbulkpipe(udev, dev->usb.out_ep[ep]); usb_fill_bulk_urb(buf->urb, udev, pipe, NULL, skb->len, mt76u_complete_tx, buf); q->tail = (q->tail + 1) % q->ndesc; q->entry[idx].skb = skb; q->queued++; return idx; }
static ssize_t pyra_sysfs_write_settings(struct file *fp, struct kobject *kobj, struct bin_attribute *attr, char *buf, loff_t off, size_t count) { struct device *dev = kobj_to_dev(kobj)->parent->parent; struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); int retval = 0; struct pyra_roccat_report roccat_report; struct pyra_settings const *settings; if (off != 0 || count != PYRA_SIZE_SETTINGS) return -EINVAL; settings = (struct pyra_settings const *)buf; if (settings->startup_profile >= ARRAY_SIZE(pyra->profile_settings)) return -EINVAL; mutex_lock(&pyra->pyra_lock); retval = pyra_set_settings(usb_dev, settings); if (retval) { mutex_unlock(&pyra->pyra_lock); return retval; } profile_activated(pyra, settings->startup_profile); roccat_report.type = PYRA_MOUSE_EVENT_BUTTON_TYPE_PROFILE_2; roccat_report.value = settings->startup_profile + 1; roccat_report.key = 0; roccat_report_event(pyra->chrdev_minor, (uint8_t const *)&roccat_report); mutex_unlock(&pyra->pyra_lock); return PYRA_SIZE_SETTINGS; }
/** * Write device file "mode_static" * * Set the keyboard to static mode when 3 RGB bytes are written */ static ssize_t razer_attr_write_mode_static(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct usb_interface *intf = to_usb_interface(dev->parent); struct usb_device *usb_dev = interface_to_usbdev(intf); if(usb_dev->descriptor.idProduct == USB_DEVICE_ID_RAZER_BLACKWIDOW_ULTIMATE_2013) { // Set BlackWidow Ultimate to static colour razer_set_static_mode_blackwidow_ultimate(usb_dev); } else if(usb_dev->descriptor.idProduct == USB_DEVICE_ID_RAZER_BLACKWIDOW_CHROMA) { // Set BlackWidow Chroma to static colour if(count == 3) { razer_set_static_mode(usb_dev, (struct razer_rgb*)&buf[0]); } } else { printk(KERN_WARNING "razerkbd: Cannot set static mode for this device"); } return count; }
/** * Unbind function */ static void razer_kbd_disconnect(struct hid_device *hdev) { struct razer_kbd_device *dev; struct usb_interface *intf = to_usb_interface(hdev->dev.parent); struct usb_device *usb_dev = interface_to_usbdev(intf); dev = hid_get_drvdata(hdev); if(usb_dev->descriptor.idProduct == USB_DEVICE_ID_RAZER_BLACKWIDOW_ULTIMATE_2013) { device_remove_file(&hdev->dev, &dev_attr_mode_pulsate); } else { device_remove_file(&hdev->dev, &dev_attr_mode_wave); device_remove_file(&hdev->dev, &dev_attr_mode_spectrum); device_remove_file(&hdev->dev, &dev_attr_mode_none); device_remove_file(&hdev->dev, &dev_attr_mode_reactive); device_remove_file(&hdev->dev, &dev_attr_mode_breath); device_remove_file(&hdev->dev, &dev_attr_mode_custom); device_remove_file(&hdev->dev, &dev_attr_temp_clear_row); device_remove_file(&hdev->dev, &dev_attr_set_key_row); } device_remove_file(&hdev->dev, &dev_attr_mode_game); device_remove_file(&hdev->dev, &dev_attr_get_serial); device_remove_file(&hdev->dev, &dev_attr_mode_static); device_remove_file(&hdev->dev, &dev_attr_reset); device_remove_file(&hdev->dev, &dev_attr_macro_keys); device_remove_file(&hdev->dev, &dev_attr_set_brightness); device_remove_file(&hdev->dev, &dev_attr_test); device_remove_file(&hdev->dev, &dev_attr_device_type); hid_hw_stop(hdev); kfree(dev); dev_info(&intf->dev, "Razer Device disconnected\n"); }
static ssize_t pyra_sysfs_read(struct file *fp, struct kobject *kobj, char *buf, loff_t off, size_t count, size_t real_size, uint command) { struct device *dev = kobj_to_dev(kobj)->parent->parent; struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); int retval; if (off >= real_size) return 0; if (off != 0 || count != real_size) return -EINVAL; mutex_lock(&pyra->pyra_lock); retval = roccat_common2_receive(usb_dev, command, buf, real_size); mutex_unlock(&pyra->pyra_lock); if (retval) return retval; return real_size; }
static ssize_t kovaplus_sysfs_write_profile_settings(struct file *fp, struct kobject *kobj, struct bin_attribute *attr, char *buf, loff_t off, size_t count) { struct device *dev = container_of(kobj, struct device, kobj)->parent->parent; struct kovaplus_device *kovaplus = hid_get_drvdata(dev_get_drvdata(dev)); struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); int retval = 0; int difference; int profile_index; struct kovaplus_profile_settings *profile_settings; if (off != 0 || count != sizeof(struct kovaplus_profile_settings)) return -EINVAL; profile_index = ((struct kovaplus_profile_settings const *)buf)->profile_index; profile_settings = &kovaplus->profile_settings[profile_index]; mutex_lock(&kovaplus->kovaplus_lock); difference = memcmp(buf, profile_settings, sizeof(struct kovaplus_profile_settings)); if (difference) { retval = kovaplus_set_profile_settings(usb_dev, (struct kovaplus_profile_settings const *)buf); if (!retval) memcpy(profile_settings, buf, sizeof(struct kovaplus_profile_settings)); } mutex_unlock(&kovaplus->kovaplus_lock); if (retval) return retval; return sizeof(struct kovaplus_profile_settings); }
/** * Write device file "matrix_reactive_trigger" * * It triggers the mouse pad when written to */ static ssize_t razer_attr_write_mode_reactive_trigger(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct usb_interface *intf = to_usb_interface(dev->parent); struct usb_device *usb_dev = interface_to_usbdev(intf); struct razer_report report = {0}; struct razer_rgb rgb = {0}; switch (usb_dev->descriptor.idProduct) { case USB_DEVICE_ID_RAZER_GOLIATHUS_CHROMA: case USB_DEVICE_ID_RAZER_GOLIATHUS_CHROMA_EXTENDED: // TODO: Fix reactive trigger for Goliathus report = razer_chroma_extended_matrix_effect_reactive(VARSTORE, ZERO_LED, 0, &rgb); break; default: // TODO: Issue zeroed out razer_chroma_standard_matrix_effect_reactive report report = razer_chroma_misc_matrix_reactive_trigger(); break; } razer_send_payload(usb_dev, &report); return count; }
static ssize_t set_attr_decimals(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct usb_interface *intf = to_usb_interface(dev); struct usb_sevsegdev *mydev = usb_get_intfdata(intf); size_t end = my_memlen(buf, count); int i; if (end > sizeof(mydev->decimals)) return -EINVAL; for (i = 0; i < end; i++) if (buf[i] != '0' && buf[i] != '1') return -EINVAL; memset(mydev->decimals, 0, sizeof(mydev->decimals)); for (i = 0; i < end; i++) if (buf[i] == '1') mydev->decimals[end-1-i] = 1; update_display_visual(mydev, GFP_KERNEL); return count; }
static int pcan_usb_do_cleanup(struct device *dev, void *arg) { struct usb_interface *intf; struct pcan_usb_interface *usb_if; struct pcandev *pdev; int c; DPRINTK(KERN_DEBUG "%s: %s()\n", DEVICE_NAME, __FUNCTION__); intf = to_usb_interface(dev); usb_if = (struct pcan_usb_interface *)usb_get_intfdata(intf); /* Browse controllers list */ for (pdev=&usb_if->dev[c=0]; c < usb_if->dev_ctrl_count; c++, pdev++) { if (pdev->ucPhysicallyInstalled) /* Last chance for URB submitting */ if (usb_if->device_ctrl_cleanup) usb_if->device_ctrl_cleanup(pdev); } return 0; }
static ssize_t show_attr_textmode(struct device *dev, struct device_attribute *attr, char *buf) { struct usb_interface *intf = to_usb_interface(dev); struct usb_sevsegdev *mydev = usb_get_intfdata(intf); int i; buf[0] = 0; for (i = 0; display_textmodes[i]; i++) { if (mydev->textmode == i) { strcat(buf, " ["); strcat(buf, display_textmodes[i]); strcat(buf, "] "); } else { strcat(buf, " "); strcat(buf, display_textmodes[i]); strcat(buf, " "); } } strcat(buf, "\n"); return strlen(buf); }
/* * Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller * to "operational". Without this, the ps3 controller will not report any * events. */ static int sixaxis_set_operational_usb(struct hid_device *hdev) { struct usb_interface *intf = to_usb_interface(hdev->dev.parent); struct usb_device *dev = interface_to_usbdev(intf); __u16 ifnum = intf->cur_altsetting->desc.bInterfaceNumber; int ret; char *buf = kmalloc(18, GFP_KERNEL); if (!buf) return -ENOMEM; ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), HID_REQ_GET_REPORT, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, (3 << 8) | 0xf2, ifnum, buf, 17, USB_CTRL_GET_TIMEOUT); if (ret < 0) hid_err(hdev, "can't set operational mode\n"); kfree(buf); return ret; }
static ssize_t pyra_sysfs_write_profile_buttons(struct file *fp, struct kobject *kobj, struct bin_attribute *attr, char *buf, loff_t off, size_t count) { struct device *dev = container_of(kobj, struct device, kobj)->parent->parent; struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); int retval = 0; int difference; int profile_number; struct pyra_profile_buttons *profile_buttons; if (off != 0 || count != sizeof(struct pyra_profile_buttons)) return -EINVAL; profile_number = ((struct pyra_profile_buttons const *)buf)->number; profile_buttons = &pyra->profile_buttons[profile_number]; mutex_lock(&pyra->pyra_lock); difference = memcmp(buf, profile_buttons, sizeof(struct pyra_profile_buttons)); if (difference) { retval = pyra_set_profile_buttons(usb_dev, (struct pyra_profile_buttons const *)buf); if (!retval) memcpy(profile_buttons, buf, sizeof(struct pyra_profile_buttons)); } mutex_unlock(&pyra->pyra_lock); if (retval) return retval; return sizeof(struct pyra_profile_buttons); }
static int logi_dj_probe(struct hid_device *hdev, const struct hid_device_id *id) { struct usb_interface *intf = to_usb_interface(hdev->dev.parent); struct dj_receiver_dev *djrcv_dev; int retval; if (is_dj_device((struct dj_device *)hdev->driver_data)) return -ENODEV; dbg_hid("%s called for ifnum %d\n", __func__, intf->cur_altsetting->desc.bInterfaceNumber); /* Ignore interfaces 0 and 1, they will not carry any data, dont create * any hid_device for them */ if (intf->cur_altsetting->desc.bInterfaceNumber != LOGITECH_DJ_INTERFACE_NUMBER) { dbg_hid("%s: ignoring ifnum %d\n", __func__, intf->cur_altsetting->desc.bInterfaceNumber); return -ENODEV; } /* Treat interface 2 */ djrcv_dev = kzalloc(sizeof(struct dj_receiver_dev), GFP_KERNEL); if (!djrcv_dev) { dev_err(&hdev->dev, "%s:failed allocating dj_receiver_dev\n", __func__); return -ENOMEM; } djrcv_dev->hdev = hdev; INIT_WORK(&djrcv_dev->work, delayedwork_callback); spin_lock_init(&djrcv_dev->lock); if (kfifo_alloc(&djrcv_dev->notif_fifo, DJ_MAX_NUMBER_NOTIFICATIONS * sizeof(struct dj_report), GFP_KERNEL)) { dev_err(&hdev->dev, "%s:failed allocating notif_fifo\n", __func__); kfree(djrcv_dev); return -ENOMEM; } hid_set_drvdata(hdev, djrcv_dev); /* Call to usbhid to fetch the HID descriptors of interface 2 and * subsequently call to the hid/hid-core to parse the fetched * descriptors, this will in turn create the hidraw and hiddev nodes * for interface 2 of the receiver */ retval = hid_parse(hdev); if (retval) { dev_err(&hdev->dev, "%s:parse of interface 2 failed\n", __func__); goto hid_parse_fail; } /* Starts the usb device and connects to upper interfaces hiddev and * hidraw */ retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT); if (retval) { dev_err(&hdev->dev, "%s:hid_hw_start returned error\n", __func__); goto hid_hw_start_fail; } retval = logi_dj_recv_switch_to_dj_mode(djrcv_dev, 0); if (retval < 0) { dev_err(&hdev->dev, "%s:logi_dj_recv_switch_to_dj_mode returned error:%d\n", __func__, retval); goto switch_to_dj_mode_fail; } /* This is enabling the polling urb on the IN endpoint */ retval = hdev->ll_driver->open(hdev); if (retval < 0) { dev_err(&hdev->dev, "%s:hdev->ll_driver->open returned " "error:%d\n", __func__, retval); goto llopen_failed; } retval = logi_dj_recv_query_paired_devices(djrcv_dev); if (retval < 0) { dev_err(&hdev->dev, "%s:logi_dj_recv_query_paired_devices " "error:%d\n", __func__, retval); goto logi_dj_recv_query_paired_devices_failed; } return retval; logi_dj_recv_query_paired_devices_failed: hdev->ll_driver->close(hdev); llopen_failed: switch_to_dj_mode_fail: hid_hw_stop(hdev); hid_hw_start_fail: hid_parse_fail: kfifo_free(&djrcv_dev->notif_fifo); kfree(djrcv_dev); hid_set_drvdata(hdev, NULL); return retval; }