#include <linux/configfs.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/device.h>
#include <linux/kstrtox.h>
#include <linux/nls.h>
#include <linux/usb/composite.h>
#include <linux/usb/gadget_configfs.h>
#include <linux/usb/webusb.h>
#include "configfs.h"
#include "u_f.h"
#include "u_os_desc.h"
int check_user_usb_string(const char *name,
struct usb_gadget_strings *stringtab_dev)
{ … }
#define MAX_NAME_LEN …
#define MAX_USB_STRING_LANGS …
static const struct usb_descriptor_header *otg_desc[2];
struct gadget_info { … };
static inline struct gadget_info *to_gadget_info(struct config_item *item)
{ … }
struct config_usb_cfg { … };
static inline struct config_usb_cfg *to_config_usb_cfg(struct config_item *item)
{ … }
static inline struct gadget_info *cfg_to_gadget_info(struct config_usb_cfg *cfg)
{ … }
struct gadget_language { … };
struct gadget_config_name { … };
#define USB_MAX_STRING_WITH_NULL_LEN …
static int usb_string_copy(const char *s, char **s_copy)
{ … }
#define GI_DEVICE_DESC_SIMPLE_R_u8(__name) …
#define GI_DEVICE_DESC_SIMPLE_R_u16(__name) …
#define GI_DEVICE_DESC_SIMPLE_W_u8(_name) …
#define GI_DEVICE_DESC_SIMPLE_W_u16(_name) …
#define GI_DEVICE_DESC_SIMPLE_RW(_name, _type) …
GI_DEVICE_DESC_SIMPLE_R_u16(bcdUSB);
GI_DEVICE_DESC_SIMPLE_RW(bDeviceClass, u8);
GI_DEVICE_DESC_SIMPLE_RW(bDeviceSubClass, u8);
GI_DEVICE_DESC_SIMPLE_RW(bDeviceProtocol, u8);
GI_DEVICE_DESC_SIMPLE_RW(bMaxPacketSize0, u8);
GI_DEVICE_DESC_SIMPLE_RW(idVendor, u16);
GI_DEVICE_DESC_SIMPLE_RW(idProduct, u16);
GI_DEVICE_DESC_SIMPLE_R_u16(bcdDevice);
static ssize_t is_valid_bcd(u16 bcd_val)
{ … }
static ssize_t gadget_dev_desc_bcdDevice_store(struct config_item *item,
const char *page, size_t len)
{ … }
static ssize_t gadget_dev_desc_bcdUSB_store(struct config_item *item,
const char *page, size_t len)
{ … }
static ssize_t gadget_dev_desc_UDC_show(struct config_item *item, char *page)
{ … }
static int unregister_gadget(struct gadget_info *gi)
{ … }
static ssize_t gadget_dev_desc_UDC_store(struct config_item *item,
const char *page, size_t len)
{ … }
static ssize_t gadget_dev_desc_max_speed_show(struct config_item *item,
char *page)
{ … }
static ssize_t gadget_dev_desc_max_speed_store(struct config_item *item,
const char *page, size_t len)
{ … }
CONFIGFS_ATTR(…);
CONFIGFS_ATTR(…);
CONFIGFS_ATTR(…);
CONFIGFS_ATTR(…);
CONFIGFS_ATTR(…);
CONFIGFS_ATTR(…);
CONFIGFS_ATTR(…);
CONFIGFS_ATTR(…);
CONFIGFS_ATTR(…);
CONFIGFS_ATTR(…);
static struct configfs_attribute *gadget_root_attrs[] = …;
static inline struct gadget_language *to_gadget_language(struct config_item *item)
{ … }
static inline struct gadget_config_name *to_gadget_config_name(
struct config_item *item)
{ … }
static inline struct usb_function_instance *to_usb_function_instance(
struct config_item *item)
{ … }
static void gadget_info_attr_release(struct config_item *item)
{ … }
static struct configfs_item_operations gadget_root_item_ops = …;
static void gadget_config_attr_release(struct config_item *item)
{ … }
static int config_usb_cfg_link(
struct config_item *usb_cfg_ci,
struct config_item *usb_func_ci)
{ … }
static void config_usb_cfg_unlink(
struct config_item *usb_cfg_ci,
struct config_item *usb_func_ci)
{ … }
static struct configfs_item_operations gadget_config_item_ops = …;
static ssize_t gadget_config_desc_MaxPower_show(struct config_item *item,
char *page)
{ … }
static ssize_t gadget_config_desc_MaxPower_store(struct config_item *item,
const char *page, size_t len)
{ … }
static ssize_t gadget_config_desc_bmAttributes_show(struct config_item *item,
char *page)
{ … }
static ssize_t gadget_config_desc_bmAttributes_store(struct config_item *item,
const char *page, size_t len)
{ … }
CONFIGFS_ATTR(…);
CONFIGFS_ATTR(…);
static struct configfs_attribute *gadget_config_attrs[] = …;
static const struct config_item_type gadget_config_type = …;
static const struct config_item_type gadget_root_type = …;
static void composite_init_dev(struct usb_composite_dev *cdev)
{ … }
static struct config_group *function_make(
struct config_group *group,
const char *name)
{ … }
static void function_drop(
struct config_group *group,
struct config_item *item)
{ … }
static struct configfs_group_operations functions_ops = …;
static const struct config_item_type functions_type = …;
GS_STRINGS_RW(…);
static struct configfs_attribute *gadget_config_name_langid_attrs[] = …;
static void gadget_config_name_attr_release(struct config_item *item)
{ … }
USB_CONFIG_STRING_RW_OPS(…);
USB_CONFIG_STRINGS_LANG(…);
static struct config_group *config_desc_make(
struct config_group *group,
const char *name)
{ … }
static void config_desc_drop(
struct config_group *group,
struct config_item *item)
{ … }
static struct configfs_group_operations config_desc_ops = …;
static const struct config_item_type config_desc_type = …;
GS_STRINGS_RW(…);
GS_STRINGS_RW(…);
GS_STRINGS_RW(…);
static struct configfs_attribute *gadget_language_langid_attrs[] = …;
static void gadget_language_attr_release(struct config_item *item)
{ … }
static struct configfs_item_operations gadget_language_langid_item_ops = …;
static ssize_t gadget_string_id_show(struct config_item *item, char *page)
{ … }
CONFIGFS_ATTR_RO(…);
static ssize_t gadget_string_s_show(struct config_item *item, char *page)
{ … }
static ssize_t gadget_string_s_store(struct config_item *item, const char *page,
size_t len)
{ … }
CONFIGFS_ATTR(…);
static struct configfs_attribute *gadget_string_attrs[] = …;
static void gadget_string_release(struct config_item *item)
{ … }
static struct configfs_item_operations gadget_string_item_ops = …;
static const struct config_item_type gadget_string_type = …;
static struct config_item *gadget_language_string_make(struct config_group *group,
const char *name)
{ … }
static void gadget_language_string_drop(struct config_group *group,
struct config_item *item)
{ … }
static struct configfs_group_operations gadget_language_langid_group_ops = …;
static struct config_item_type gadget_language_type = …;
static struct config_group *gadget_language_make(struct config_group *group,
const char *name)
{ … }
static void gadget_language_drop(struct config_group *group,
struct config_item *item)
{ … }
static struct configfs_group_operations gadget_language_group_ops = …;
static struct config_item_type gadget_language_strings_type = …;
static inline struct gadget_info *webusb_item_to_gadget_info(
struct config_item *item)
{ … }
static ssize_t webusb_use_show(struct config_item *item, char *page)
{ … }
static ssize_t webusb_use_store(struct config_item *item, const char *page,
size_t len)
{ … }
static ssize_t webusb_bcdVersion_show(struct config_item *item, char *page)
{ … }
static ssize_t webusb_bcdVersion_store(struct config_item *item,
const char *page, size_t len)
{ … }
static ssize_t webusb_bVendorCode_show(struct config_item *item, char *page)
{ … }
static ssize_t webusb_bVendorCode_store(struct config_item *item,
const char *page, size_t len)
{ … }
static ssize_t webusb_landingPage_show(struct config_item *item, char *page)
{ … }
static ssize_t webusb_landingPage_store(struct config_item *item, const char *page,
size_t len)
{ … }
CONFIGFS_ATTR(…);
CONFIGFS_ATTR(…);
CONFIGFS_ATTR(…);
CONFIGFS_ATTR(…);
static struct configfs_attribute *webusb_attrs[] = …;
static struct config_item_type webusb_type = …;
static inline struct gadget_info *os_desc_item_to_gadget_info(
struct config_item *item)
{ … }
static ssize_t os_desc_use_show(struct config_item *item, char *page)
{ … }
static ssize_t os_desc_use_store(struct config_item *item, const char *page,
size_t len)
{ … }
static ssize_t os_desc_b_vendor_code_show(struct config_item *item, char *page)
{ … }
static ssize_t os_desc_b_vendor_code_store(struct config_item *item,
const char *page, size_t len)
{ … }
static ssize_t os_desc_qw_sign_show(struct config_item *item, char *page)
{ … }
static ssize_t os_desc_qw_sign_store(struct config_item *item, const char *page,
size_t len)
{ … }
CONFIGFS_ATTR(…);
CONFIGFS_ATTR(…);
CONFIGFS_ATTR(…);
static struct configfs_attribute *os_desc_attrs[] = …;
static int os_desc_link(struct config_item *os_desc_ci,
struct config_item *usb_cfg_ci)
{ … }
static void os_desc_unlink(struct config_item *os_desc_ci,
struct config_item *usb_cfg_ci)
{ … }
static struct configfs_item_operations os_desc_ops = …;
static struct config_item_type os_desc_type = …;
static inline struct usb_os_desc_ext_prop
*to_usb_os_desc_ext_prop(struct config_item *item)
{ … }
static ssize_t ext_prop_type_show(struct config_item *item, char *page)
{ … }
static ssize_t ext_prop_type_store(struct config_item *item,
const char *page, size_t len)
{ … }
static ssize_t ext_prop_data_show(struct config_item *item, char *page)
{ … }
static ssize_t ext_prop_data_store(struct config_item *item,
const char *page, size_t len)
{ … }
CONFIGFS_ATTR(…);
CONFIGFS_ATTR(…);
static struct configfs_attribute *ext_prop_attrs[] = …;
static void usb_os_desc_ext_prop_release(struct config_item *item)
{ … }
static struct configfs_item_operations ext_prop_ops = …;
static struct config_item *ext_prop_make(
struct config_group *group,
const char *name)
{ … }
static void ext_prop_drop(struct config_group *group, struct config_item *item)
{ … }
static struct configfs_group_operations interf_grp_ops = …;
static ssize_t interf_grp_compatible_id_show(struct config_item *item,
char *page)
{ … }
static ssize_t interf_grp_compatible_id_store(struct config_item *item,
const char *page, size_t len)
{ … }
static ssize_t interf_grp_sub_compatible_id_show(struct config_item *item,
char *page)
{ … }
static ssize_t interf_grp_sub_compatible_id_store(struct config_item *item,
const char *page, size_t len)
{ … }
CONFIGFS_ATTR(…);
CONFIGFS_ATTR(…);
static struct configfs_attribute *interf_grp_attrs[] = …;
struct config_group *usb_os_desc_prepare_interf_dir(
struct config_group *parent,
int n_interf,
struct usb_os_desc **desc,
char **names,
struct module *owner)
{ … }
EXPORT_SYMBOL(…);
static int configfs_do_nothing(struct usb_composite_dev *cdev)
{ … }
int composite_dev_prepare(struct usb_composite_driver *composite,
struct usb_composite_dev *dev);
int composite_os_desc_req_prepare(struct usb_composite_dev *cdev,
struct usb_ep *ep0);
static void purge_configs_funcs(struct gadget_info *gi)
{ … }
static struct usb_string *
configfs_attach_gadget_strings(struct gadget_info *gi)
{ … }
static int configfs_composite_bind(struct usb_gadget *gadget,
struct usb_gadget_driver *gdriver)
{ … }
static void configfs_composite_unbind(struct usb_gadget *gadget)
{ … }
static int configfs_composite_setup(struct usb_gadget *gadget,
const struct usb_ctrlrequest *ctrl)
{ … }
static void configfs_composite_disconnect(struct usb_gadget *gadget)
{ … }
static void configfs_composite_reset(struct usb_gadget *gadget)
{ … }
static void configfs_composite_suspend(struct usb_gadget *gadget)
{ … }
static void configfs_composite_resume(struct usb_gadget *gadget)
{ … }
static const struct usb_gadget_driver configfs_driver_template = …;
static struct config_group *gadgets_make(
struct config_group *group,
const char *name)
{ … }
static void gadgets_drop(struct config_group *group, struct config_item *item)
{ … }
static struct configfs_group_operations gadgets_ops = …;
static const struct config_item_type gadgets_type = …;
static struct configfs_subsystem gadget_subsys = …;
void unregister_gadget_item(struct config_item *item)
{ … }
EXPORT_SYMBOL_GPL(…);
static int __init gadget_cfs_init(void)
{ … }
module_init(…) …;
static void __exit gadget_cfs_exit(void)
{ … }
module_exit(gadget_cfs_exit);