#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/ioport.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/hrtimer.h>
#include <linux/list.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/usb.h>
#include <linux/usb/gadget.h>
#include <linux/usb/hcd.h>
#include <linux/scatterlist.h>
#include <asm/byteorder.h>
#include <linux/io.h>
#include <asm/irq.h>
#include <asm/unaligned.h>
#define DRIVER_DESC …
#define DRIVER_VERSION …
#define POWER_BUDGET …
#define POWER_BUDGET_3 …
#define DUMMY_TIMER_INT_NSECS …
static const char driver_name[] = …;
static const char driver_desc[] = …;
static const char gadget_name[] = …;
MODULE_DESCRIPTION(…);
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;
struct dummy_hcd_module_parameters { … };
static struct dummy_hcd_module_parameters mod_data = …;
module_param_named(is_super_speed, mod_data.is_super_speed, bool, S_IRUGO);
MODULE_PARM_DESC(…) …;
module_param_named(is_high_speed, mod_data.is_high_speed, bool, S_IRUGO);
MODULE_PARM_DESC(…) …;
module_param_named(num, mod_data.num, uint, S_IRUGO);
MODULE_PARM_DESC(…) …;
struct dummy_ep { … };
struct dummy_request { … };
static inline struct dummy_ep *usb_ep_to_dummy_ep(struct usb_ep *_ep)
{ … }
static inline struct dummy_request *usb_request_to_dummy_request
(struct usb_request *_req)
{ … }
static const char ep0name[] = …;
static const struct { … } ep_info[] = …;
#define DUMMY_ENDPOINTS …
#define FIFO_SIZE …
struct urbp { … };
enum dummy_rh_state { … };
struct dummy_hcd { … };
struct dummy { … };
static inline struct dummy_hcd *hcd_to_dummy_hcd(struct usb_hcd *hcd)
{ … }
static inline struct usb_hcd *dummy_hcd_to_hcd(struct dummy_hcd *dum)
{ … }
static inline struct device *dummy_dev(struct dummy_hcd *dum)
{ … }
static inline struct device *udc_dev(struct dummy *dum)
{ … }
static inline struct dummy *ep_to_dummy(struct dummy_ep *ep)
{ … }
static inline struct dummy_hcd *gadget_to_dummy_hcd(struct usb_gadget *gadget)
{ … }
static inline struct dummy *gadget_dev_to_dummy(struct device *dev)
{ … }
static void nuke(struct dummy *dum, struct dummy_ep *ep)
{ … }
static void stop_activity(struct dummy *dum)
{ … }
static void set_link_state_by_speed(struct dummy_hcd *dum_hcd)
{ … }
static void set_link_state(struct dummy_hcd *dum_hcd)
__must_hold(&dum->lock)
{ … }
#define is_enabled …
static int dummy_enable(struct usb_ep *_ep,
const struct usb_endpoint_descriptor *desc)
{ … }
static int dummy_disable(struct usb_ep *_ep)
{ … }
static struct usb_request *dummy_alloc_request(struct usb_ep *_ep,
gfp_t mem_flags)
{ … }
static void dummy_free_request(struct usb_ep *_ep, struct usb_request *_req)
{ … }
static void fifo_complete(struct usb_ep *ep, struct usb_request *req)
{ … }
static int dummy_queue(struct usb_ep *_ep, struct usb_request *_req,
gfp_t mem_flags)
{ … }
static int dummy_dequeue(struct usb_ep *_ep, struct usb_request *_req)
{ … }
static int
dummy_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged)
{ … }
static int
dummy_set_halt(struct usb_ep *_ep, int value)
{ … }
static int dummy_set_wedge(struct usb_ep *_ep)
{ … }
static const struct usb_ep_ops dummy_ep_ops = …;
static int dummy_g_get_frame(struct usb_gadget *_gadget)
{ … }
static int dummy_wakeup(struct usb_gadget *_gadget)
{ … }
static int dummy_set_selfpowered(struct usb_gadget *_gadget, int value)
{ … }
static void dummy_udc_update_ep0(struct dummy *dum)
{ … }
static int dummy_pullup(struct usb_gadget *_gadget, int value)
{ … }
static void dummy_udc_set_speed(struct usb_gadget *_gadget,
enum usb_device_speed speed)
{ … }
static void dummy_udc_async_callbacks(struct usb_gadget *_gadget, bool enable)
{ … }
static int dummy_udc_start(struct usb_gadget *g,
struct usb_gadget_driver *driver);
static int dummy_udc_stop(struct usb_gadget *g);
static const struct usb_gadget_ops dummy_ops = …;
static ssize_t function_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(function);
static int dummy_udc_start(struct usb_gadget *g,
struct usb_gadget_driver *driver)
{ … }
static int dummy_udc_stop(struct usb_gadget *g)
{ … }
#undef is_enabled
static void init_dummy_udc_hw(struct dummy *dum)
{ … }
static int dummy_udc_probe(struct platform_device *pdev)
{ … }
static void dummy_udc_remove(struct platform_device *pdev)
{ … }
static void dummy_udc_pm(struct dummy *dum, struct dummy_hcd *dum_hcd,
int suspend)
{ … }
static int dummy_udc_suspend(struct platform_device *pdev, pm_message_t state)
{ … }
static int dummy_udc_resume(struct platform_device *pdev)
{ … }
static struct platform_driver dummy_udc_driver = …;
static unsigned int dummy_get_ep_idx(const struct usb_endpoint_descriptor *desc)
{ … }
static int dummy_ep_stream_en(struct dummy_hcd *dum_hcd, struct urb *urb)
{ … }
static int get_max_streams_for_pipe(struct dummy_hcd *dum_hcd,
unsigned int pipe)
{ … }
static void set_max_streams_for_pipe(struct dummy_hcd *dum_hcd,
unsigned int pipe, unsigned int streams)
{ … }
static int dummy_validate_stream(struct dummy_hcd *dum_hcd, struct urb *urb)
{ … }
static int dummy_urb_enqueue(
struct usb_hcd *hcd,
struct urb *urb,
gfp_t mem_flags
) { … }
static int dummy_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
{ … }
static int dummy_perform_transfer(struct urb *urb, struct dummy_request *req,
u32 len)
{ … }
static int transfer(struct dummy_hcd *dum_hcd, struct urb *urb,
struct dummy_ep *ep, int limit, int *status)
{ … }
static int periodic_bytes(struct dummy *dum, struct dummy_ep *ep)
{ … }
#define is_active …
static struct dummy_ep *find_endpoint(struct dummy *dum, u8 address)
{ … }
#undef is_active
#define Dev_Request …
#define Dev_InRequest …
#define Intf_Request …
#define Intf_InRequest …
#define Ep_Request …
#define Ep_InRequest …
static int handle_control_request(struct dummy_hcd *dum_hcd, struct urb *urb,
struct usb_ctrlrequest *setup,
int *status)
{ … }
static enum hrtimer_restart dummy_timer(struct hrtimer *t)
{ … }
#define PORT_C_MASK …
static int dummy_hub_status(struct usb_hcd *hcd, char *buf)
{ … }
static struct { … } __packed usb3_bos_desc = …;
static inline void
ss_hub_descriptor(struct usb_hub_descriptor *desc)
{ … }
static inline void hub_descriptor(struct usb_hub_descriptor *desc)
{ … }
static int dummy_hub_control(
struct usb_hcd *hcd,
u16 typeReq,
u16 wValue,
u16 wIndex,
char *buf,
u16 wLength
) { … }
static int dummy_bus_suspend(struct usb_hcd *hcd)
{ … }
static int dummy_bus_resume(struct usb_hcd *hcd)
{ … }
static inline ssize_t show_urb(char *buf, size_t size, struct urb *urb)
{ … }
static ssize_t urbs_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(urbs);
static int dummy_start_ss(struct dummy_hcd *dum_hcd)
{ … }
static int dummy_start(struct usb_hcd *hcd)
{ … }
static void dummy_stop(struct usb_hcd *hcd)
{ … }
static int dummy_h_get_frame(struct usb_hcd *hcd)
{ … }
static int dummy_setup(struct usb_hcd *hcd)
{ … }
static int dummy_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev,
struct usb_host_endpoint **eps, unsigned int num_eps,
unsigned int num_streams, gfp_t mem_flags)
{ … }
static int dummy_free_streams(struct usb_hcd *hcd, struct usb_device *udev,
struct usb_host_endpoint **eps, unsigned int num_eps,
gfp_t mem_flags)
{ … }
static struct hc_driver dummy_hcd = …;
static int dummy_hcd_probe(struct platform_device *pdev)
{ … }
static void dummy_hcd_remove(struct platform_device *pdev)
{ … }
static int dummy_hcd_suspend(struct platform_device *pdev, pm_message_t state)
{ … }
static int dummy_hcd_resume(struct platform_device *pdev)
{ … }
static struct platform_driver dummy_hcd_driver = …;
#define MAX_NUM_UDC …
static struct platform_device *the_udc_pdev[MAX_NUM_UDC];
static struct platform_device *the_hcd_pdev[MAX_NUM_UDC];
static int __init dummy_hcd_init(void)
{ … }
module_init(…) …;
static void __exit dummy_hcd_cleanup(void)
{ … }
module_exit(dummy_hcd_cleanup);