Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
usbstring.c File Reference
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/list.h>
#include <linux/string.h>
#include <linux/device.h>
#include <linux/init.h>
#include <linux/nls.h>
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>

Go to the source code of this file.


int usb_gadget_get_string (struct usb_gadget_strings *table, int id, u8 *buf)
 EXPORT_SYMBOL_GPL (usb_gadget_get_string)

Function Documentation

EXPORT_SYMBOL_GPL ( usb_gadget_get_string  )
int usb_gadget_get_string ( struct usb_gadget_strings table,
int  id,
u8 buf 

usb_gadget_get_string - fill out a string descriptor : of c strings encoded using UTF-8 : string id, from low byte of wValue in get string descriptor : at least 256 bytes, must be 16-bit aligned

Finds the UTF-8 string matching the ID, and converts it into a string descriptor in utf16-le. Returns length of descriptor (always even) or negative errno

If your driver needs stings in multiple languages, you'll probably "switch (wIndex) { ... }" in your ep0 string descriptor logic, using this routine after choosing which set of UTF-8 strings to use. Note that US-ASCII is a strict subset of UTF-8; any string bytes with the eighth bit set will be multibyte UTF-8 characters, not ISO-8859/1 characters (which are also widely used in C strings).

Definition at line 41 of file usbstring.c.