drivers/usb/gadget/function/u_fs.h

Source file repositories/reference/linux-study-clean/drivers/usb/gadget/function/u_fs.h

File Facts

System
Linux kernel
Corpus path
drivers/usb/gadget/function/u_fs.h
Extension
.h
Size
8354 bytes
Lines
302
Domain
Driver Families
Bucket
drivers/usb
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct ffs_dev {
	struct ffs_data *ffs_data;
	struct f_fs_opts *opts;
	struct list_head entry;

	char name[41];

	bool mounted;
	bool desc_ready;
	bool single;

	int (*ffs_ready_callback)(struct ffs_data *ffs);
	void (*ffs_closed_callback)(struct ffs_data *ffs);
	void *(*ffs_acquire_dev_callback)(struct ffs_dev *dev);
	void (*ffs_release_dev_callback)(struct ffs_dev *dev);
};

extern struct mutex ffs_lock;

static inline void ffs_dev_lock(void)
{
	mutex_lock(&ffs_lock);
}

static inline void ffs_dev_unlock(void)
{
	mutex_unlock(&ffs_lock);
}

int ffs_name_dev(struct ffs_dev *dev, const char *name);
int ffs_single_dev(struct ffs_dev *dev);

struct ffs_epfile;
struct ffs_function;

enum ffs_state {
	/*
	 * Waiting for descriptors and strings.
	 *
	 * In this state no open(2), read(2) or write(2) on epfiles
	 * may succeed (which should not be the problem as there
	 * should be no such files opened in the first place).
	 */
	FFS_READ_DESCRIPTORS,
	FFS_READ_STRINGS,

	/*
	 * We've got descriptors and strings.  We are or have called
	 * functionfs_ready_callback().  functionfs_bind() may have
	 * been called but we don't know.
	 *
	 * This is the only state in which operations on epfiles may
	 * succeed.
	 */
	FFS_ACTIVE,

	/*
	 * Function is visible to host, but it's not functional. All
	 * setup requests are stalled and transfers on another endpoints
	 * are refused. All epfiles, except ep0, are deleted so there
	 * is no way to perform any operations on them.
	 *
	 * This state is set after closing all functionfs files, when
	 * mount parameter "no_disconnect=1" has been set. Function will
	 * remain in deactivated state until filesystem is umounted or
	 * ep0 is opened again. In the second case functionfs state will
	 * be reset, and it will be ready for descriptors and strings
	 * writing.
	 *
	 * This is useful only when functionfs is composed to gadget
	 * with another function which can perform some critical
	 * operations, and it's strongly desired to have this operations
	 * completed, even after functionfs files closure.
	 */
	FFS_DEACTIVATED,

	/*
	 * All endpoints have been closed.  This state is also set if
	 * we encounter an unrecoverable error.  The only
	 * unrecoverable error is situation when after reading strings
	 * from user space we fail to initialise epfiles or
	 * functionfs_ready_callback() returns with error (<0).
	 *
	 * In this state no open(2), read(2) or write(2) (both on ep0
	 * as well as epfile) may succeed (at this point epfiles are
	 * unlinked and all closed so this is not a problem; ep0 is
	 * also closed but ep0 file exists and so open(2) on ep0 must
	 * fail).
	 */
	FFS_CLOSING

Annotation

Implementation Notes