LMS 2012
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
computil.c File Reference
#include <linux/kallsyms.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/device.h>
#include <linux/usb/composite.h>

Go to the source code of this file.

Macros

#define USB_BUFSIZ   1024
 

Functions

 module_param (idVendor, ushort, 0)
 
 MODULE_PARM_DESC (idVendor,"USB Vendor ID")
 
 module_param (idProduct, ushort, 0)
 
 MODULE_PARM_DESC (idProduct,"USB Product ID")
 
 module_param (bcdDevice, ushort, 0)
 
 MODULE_PARM_DESC (bcdDevice,"USB Device version (BCD)")
 
 module_param (iManufacturer, charp, 0)
 
 MODULE_PARM_DESC (iManufacturer,"USB Manufacturer string")
 
 module_param (iProduct, charp, 0)
 
 MODULE_PARM_DESC (iProduct,"USB Product string")
 
 module_param (iSerialNumber, charp, 0)
 
 MODULE_PARM_DESC (iSerialNumber,"SerialNumber string")
 
int usb_add_function (struct usb_configuration *config, struct usb_function *function)
 
int usb_function_deactivate (struct usb_function *function)
 
int usb_function_activate (struct usb_function *function)
 
int usb_interface_id (struct usb_configuration *config, struct usb_function *function)
 
int usb_add_config (struct usb_composite_dev *cdev, struct usb_configuration *config)
 
int usb_string_id (struct usb_composite_dev *cdev)
 
int usb_composite_register (struct usb_composite_driver *driver)
 
void usb_composite_unregister (struct usb_composite_driver *driver)
 

Variables

USB_SPEED UsbSpeed
 

Macro Definition Documentation

#define USB_BUFSIZ   1024

Definition at line 42 of file computil.c.

Function Documentation

module_param ( idVendor  ,
ushort  ,
 
)
module_param ( idProduct  ,
ushort  ,
 
)
module_param ( bcdDevice  ,
ushort  ,
 
)
module_param ( iManufacturer  ,
charp  ,
 
)
module_param ( iProduct  ,
charp  ,
 
)
module_param ( iSerialNumber  ,
charp  ,
 
)
MODULE_PARM_DESC ( idVendor  ,
"USB Vendor ID"   
)
MODULE_PARM_DESC ( idProduct  ,
"USB Product ID"   
)
MODULE_PARM_DESC ( bcdDevice  ,
"USB Device version (BCD)"   
)
MODULE_PARM_DESC ( iManufacturer  ,
"USB Manufacturer string"   
)
MODULE_PARM_DESC ( iProduct  ,
"USB Product string"   
)
MODULE_PARM_DESC ( iSerialNumber  ,
"SerialNumber string"   
)
int usb_add_config ( struct usb_composite_dev *  cdev,
struct usb_configuration *  config 
)

usb_add_config() - add a configuration to a device. : wraps the USB gadget : the configuration, with bConfigurationValue assigned Context: single threaded during gadget setup

One of the main tasks of a composite driver's bind() routine is to add each of the configurations it supports, using this routine.

This function returns the value of the configuration's bind(), which is zero for success else a negative errno value. Binding configurations assigns global resources including string IDs, and per-configuration resources such as interface IDs and endpoints.

Definition at line 614 of file computil.c.

int usb_add_function ( struct usb_configuration *  config,
struct usb_function *  function 
)

usb_add_function() - add a function to a configuration : the configuration : the function being added Context: single threaded during gadget setup

After initialization, each configuration must have one or more functions added to it. Adding a function involves calling its () method to allocate resources such as interface and string identifiers and endpoints.

This function returns the value of the function's bind(), which is zero for success else a negative errno value.

Definition at line 156 of file computil.c.

int usb_composite_register ( struct usb_composite_driver *  driver)

usb_composite_register() - register a composite driver : the driver to register Context: single threaded during gadget setup

This function is used to register drivers using the composite driver framework. The return value is zero, or a negative errno value. Those values normally come from the driver's method, which does all the work of setting up the driver to match the hardware.

On successful return, the gadget is ready to respond to requests from the host, unless one of its components invokes usb_gadget_disconnect() while it was binding. That would usually be done in order to wait for some userspace participation.

Definition at line 1343 of file computil.c.

void usb_composite_unregister ( struct usb_composite_driver *  driver)

usb_composite_unregister() - unregister a composite driver : the driver to unregister

This function is used to unregister drivers using the composite driver framework.

Definition at line 1364 of file computil.c.

int usb_function_activate ( struct usb_function *  function)

Definition at line 244 of file computil.c.

int usb_function_deactivate ( struct usb_function *  function)

Definition at line 217 of file computil.c.

int usb_interface_id ( struct usb_configuration *  config,
struct usb_function *  function 
)

usb_interface_id() - allocate an unused interface ID : configuration associated with the interface : function handling the interface Context: single threaded during gadget setup

usb_interface_id() is called from usb_function.bind() callbacks to allocate new interface IDs. The function driver will then store that ID in interface, association, CDC union, and other descriptors. It will also handle any control requests targetted at that interface, particularly changing its altsetting via set_alt(). There may also be class-specific or vendor-specific requests to handle.

All interface identifier should be allocated using this routine, to ensure that for example different functions don't wrongly assign different meanings to the same identifier. Note that since interface identifers are configuration-specific, functions used in more than one configuration (or more than once in a given configuration) need multiple versions of the relevant descriptors.

Returns the interface ID which was allocated; or -ENODEV if no more interface IDs can be allocated.

Definition at line 287 of file computil.c.

int usb_string_id ( struct usb_composite_dev *  cdev)

usb_string_id() - allocate an unused string ID : the device whose string descriptor IDs are being allocated Context: single threaded during gadget setup

() is called from bind() callbacks to allocate string IDs. Drivers for functions, configurations, or gadgets will then store that ID in the appropriate descriptors and string table.

All string identifier should be allocated using this routine, to ensure that for example different functions don't wrongly assign different meanings to the same identifier.

Definition at line 819 of file computil.c.

Variable Documentation

USB_SPEED UsbSpeed

Definition at line 44 of file computil.c.