/*
* Configurable Composite Gadget
*
* Initially contributed as "Android Composite Gdaget" by:
*
* Copyright (C) 2008 Google, Inc.
* Author: Mike Lockwood <lockwood@android.com>
* Benoit Goby <benoit@android.com>
*
* Tailoring it to become a generic Configurable Composite Gadget is
*
* Copyright (C) 2012 Samsung Electronics
* Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/delay.h>
#include <linux/kernel.h>
#include <linux/utsname.h>
#include <linux/platform_device.h>
#include <linux/usb/ch9.h>
#include <linux/usb/composite.h>
#include <linux/usb/gadget.h>
#include "gadget_chips.h"
/*
* Kbuild is not very cooperative with respect to linking separately
* compiled library objects into one module. So for now we won't use
* separate compilation ... ensuring init/exit sections work to shrink
* the runtime footprint, and giving us at least some parts of what
* a "gcc --combine ... part1.c part2.c part3.c ... " build would.
*/
#include "../../usb/gadget/usbstring.c"
#include "../../usb/gadget/config.c"
#include "../../usb/gadget/epautoconf.c"
#include "../../usb/gadget/composite.c"
#include "../../usb/gadget/f_mass_storage.c"
#include "../../usb/gadget/u_serial.c"
#include "../../usb/gadget/f_acm.c"
#define USB_ETH_RNDIS y
#include "../../usb/gadget/f_rndis.c"
#include "../../usb/gadget/rndis.c"
#include "../../usb/gadget/u_ether.c"
#include "../../usb/gadget/f_fs.c"
MODULE_AUTHOR("Mike Lockwood, Andrzej Pietrasiewicz");
MODULE_DESCRIPTION("Configurable Composite USB Gadget");
MODULE_LICENSE("GPL");
MODULE_VERSION("1.0");
static const char longname[] = "Configurable Composite Gadget";
/* Default vendor and product IDs, overridden by userspace */
#define VENDOR_ID 0x1d6b /* Linux Foundation */
#define PRODUCT_ID 0x0107
#define GFS_MAX_DEVS 10
struct ccg_usb_function {
char *name;
void *config;
struct device *dev;
char *dev_name;
struct device_attribute **attributes;
/* for ccg_dev.enabled_functions */
struct list_head enabled_list;
/* Optional: initialization during gadget bind */
int (*init)(struct ccg_usb_function *, struct usb_composite_dev *);
/* Optional: cleanup during gadget unbind */
void (*cleanup)(struct ccg_usb_function *);
int (*bind_config)(struct ccg_usb_function *,
struct usb_configuration *);
/* Optional: called when the configuration is removed */
void (*unbind_config)(struct ccg_usb_function *,
struct usb_configuration *);
/* Optional: handle ctrl requests before the device is configured */
int (*ctrlrequest)(struct ccg_usb_function *,
struct usb_composite_dev *,
const struct usb_ctrlrequest *);
};
struct ffs_obj {
const char *name;
bool mounted;
bool desc_ready;
bool used;
struct ffs_data *ffs_data;
};
struct ccg_dev {
struct ccg_usb_function **functions;
struct list_head enabled_functions;
struct usb_composite_dev *cdev;