这篇教程C++ to_usb_interface函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中to_usb_interface函数的典型用法代码示例。如果您正苦于以下问题:C++ to_usb_interface函数的具体用法?C++ to_usb_interface怎么用?C++ to_usb_interface使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了to_usb_interface函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: arvo_init_specialsstatic 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;}
开发者ID:03199618,项目名称:linux,代码行数:40,
示例2: pyra_sysfs_write_settingsstatic 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);}
开发者ID:openube,项目名称:android_kernel_sony_c2305,代码行数:39,
示例3: razer_kbd_disconnectstatic 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");}
开发者ID:angelog,项目名称:razer_blackwidow_chroma_driver,代码行数:22,
示例4: razer_attr_write_set_key_rowstatic 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; }
开发者ID:angelog,项目名称:razer_blackwidow_chroma_driver,代码行数:22,
示例5: usb_port_runtime_suspendstatic 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;}
开发者ID:abhinav90,项目名称:linux,代码行数:39,
示例6: konepure_sysfs_readstatic 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;}
开发者ID:vasishath,项目名称:kernel_cancro,代码行数:22,
示例7: logi_dj_recv_add_djhid_devicestatic 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
开发者ID:civato,项目名称:9005-LL-DEV,代码行数:22,
示例8: isku_sysfs_readstatic 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;}
开发者ID:212006949,项目名称:linux,代码行数:22,
示例9: razer_attr_write_mode_breath/** * 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;}
开发者ID:minneyar,项目名称:razer_chroma_drivers,代码行数:25,
示例10: koneplus_sysfs_writestatic 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;}
开发者ID:DirtyDroidX,项目名称:android_kernel_htc_m8ul,代码行数:22,
示例11: razer_kraken_disconnect/** * 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");}
开发者ID:openrazer,项目名称:openrazer,代码行数:42,
示例12: usb_port_runtime_resumestatic 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;}
开发者ID:AD5GB,项目名称:kernel_n5_3.10-experimental,代码行数:38,
示例13: razer_attr_write_set_brightness/** * * 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;}
开发者ID:openrazer,项目名称:openrazer,代码行数:29,
示例14: razer_attr_read_set_brightness/** * 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);}
开发者ID:openrazer,项目名称:openrazer,代码行数:28,
示例15: razer_attr_read_device_type/** * 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;}
开发者ID:minneyar,项目名称:razer_chroma_drivers,代码行数:28,
示例16: mt76u_tx_queue_skbstatic intmt76u_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;}
开发者ID:markus-oberhumer,项目名称:linux,代码行数:37,
示例17: pyra_sysfs_write_settingsstatic 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;}
开发者ID:020gzh,项目名称:linux,代码行数:37,
示例18: razer_attr_write_mode_static/** * 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;}
开发者ID:minneyar,项目名称:razer_chroma_drivers,代码行数:29,
示例19: razer_kbd_disconnect/** * 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");}
开发者ID:minneyar,项目名称:razer_chroma_drivers,代码行数:39,
示例20: pyra_sysfs_readstatic 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;}
开发者ID:020gzh,项目名称:linux,代码行数:24,
示例21: kovaplus_sysfs_write_profile_settingsstatic 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);}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:36,
示例22: razer_attr_write_mode_reactive_trigger/** * 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;}
开发者ID:openrazer,项目名称:openrazer,代码行数:29,
示例23: set_attr_decimalsstatic 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;}
开发者ID:JackWangCUMT,项目名称:linux,代码行数:24,
示例24: pcan_usb_do_cleanupstatic 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;}
开发者ID:ESE519,项目名称:LemonAid,代码行数:24,
示例25: sixaxis_set_operational_usb/* * 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;}
开发者ID:119-org,项目名称:lamobo-d1,代码行数:29,
示例26: pyra_sysfs_write_profile_buttonsstatic 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);}
开发者ID:JonnyH,项目名称:pandora-kernel,代码行数:36,
注:本文中的to_usb_interface函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ to_utf8函数代码示例 C++ to_usb_device函数代码示例 |