// SPDX-License-Identifier: GPL-2.0+ /* * mass_storage.c -- Mass Storage USB Gadget * * Copyright (C) 2003-2008 Alan Stern * Copyright (C) 2009 Samsung Electronics * Author: Michal Nazarewicz <[email protected]> * All rights reserved. */ /* * The Mass Storage Gadget acts as a USB Mass Storage device, * appearing to the host as a disk drive or as a CD-ROM drive. In * addition to providing an example of a genuinely useful gadget * driver for a USB device, it also illustrates a technique of * double-buffering for increased throughput. Last but not least, it * gives an easy way to probe the behavior of the Mass Storage drivers * in a USB host. * * Since this file serves only administrative purposes and all the * business logic is implemented in f_mass_storage.* file. Read * comments in this file for more detailed description. */ #include <linux/kernel.h> #include <linux/usb/ch9.h> #include <linux/module.h> /*-------------------------------------------------------------------------*/ #define DRIVER_DESC … #define DRIVER_VERSION … /* * Thanks to NetChip Technologies for donating this product ID. * * DO NOT REUSE THESE IDs with any other driver!! Ever!! * Instead: allocate your own, using normal USB-IF procedures. */ #define FSG_VENDOR_ID … #define FSG_PRODUCT_ID … #include "f_mass_storage.h" /*-------------------------------------------------------------------------*/ USB_GADGET_COMPOSITE_OPTIONS(…); static struct usb_device_descriptor msg_device_desc = …; static const struct usb_descriptor_header *otg_desc[2]; static struct usb_string strings_dev[] = …; static struct usb_gadget_strings stringtab_dev = …; static struct usb_gadget_strings *dev_strings[] = …; static struct usb_function_instance *fi_msg; static struct usb_function *f_msg; /****************************** Configurations ******************************/ static struct fsg_module_parameters mod_data = …; #ifdef CONFIG_USB_GADGET_DEBUG_FILES static unsigned int fsg_num_buffers = …; #else /* * Number of buffers we will use. * 2 is usually enough for good buffering pipeline */ #define fsg_num_buffers … #endif /* CONFIG_USB_GADGET_DEBUG_FILES */ FSG_MODULE_PARAMETERS(…); static int msg_do_config(struct usb_configuration *c) { … } static struct usb_configuration msg_config_driver = …; /****************************** Gadget Bind ******************************/ static int msg_bind(struct usb_composite_dev *cdev) { … } static int msg_unbind(struct usb_composite_dev *cdev) { … } /****************************** Some noise ******************************/ static struct usb_composite_driver msg_driver = …; module_usb_composite_driver(…); MODULE_DESCRIPTION(…); MODULE_AUTHOR(…) …; MODULE_LICENSE(…) …;