xref: /OK3568_Linux_fs/kernel/drivers/usb/gadget/function/u_tcm.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * u_tcm.h
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Utility definitions for the tcm function
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
8*4882a593Smuzhiyun  *		http://www.samsung.com
9*4882a593Smuzhiyun  *
10*4882a593Smuzhiyun  * Author: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx>
11*4882a593Smuzhiyun  */
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #ifndef U_TCM_H
14*4882a593Smuzhiyun #define U_TCM_H
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun #include <linux/usb/composite.h>
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun /**
19*4882a593Smuzhiyun  * @dependent: optional dependent module. Meant for legacy gadget.
20*4882a593Smuzhiyun  * If non-null its refcount will be increased when a tpg is created and
21*4882a593Smuzhiyun  * decreased when tpg is dropped.
22*4882a593Smuzhiyun  * @dep_lock: lock for dependent module operations.
23*4882a593Smuzhiyun  * @ready: true if the dependent module information is set.
24*4882a593Smuzhiyun  * @can_attach: true a function can be bound to gadget
25*4882a593Smuzhiyun  * @has_dep: true if there is a dependent module
26*4882a593Smuzhiyun  *
27*4882a593Smuzhiyun  */
28*4882a593Smuzhiyun struct f_tcm_opts {
29*4882a593Smuzhiyun 	struct usb_function_instance	func_inst;
30*4882a593Smuzhiyun 	struct module			*dependent;
31*4882a593Smuzhiyun 	struct mutex			dep_lock;
32*4882a593Smuzhiyun 	bool				ready;
33*4882a593Smuzhiyun 	bool				can_attach;
34*4882a593Smuzhiyun 	bool				has_dep;
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun 	/*
37*4882a593Smuzhiyun 	 * Callbacks to be removed when legacy tcm gadget disappears.
38*4882a593Smuzhiyun 	 *
39*4882a593Smuzhiyun 	 * If you use the new function registration interface
40*4882a593Smuzhiyun 	 * programmatically, you MUST set these callbacks to
41*4882a593Smuzhiyun 	 * something sensible (e.g. probe/remove the composite).
42*4882a593Smuzhiyun 	 */
43*4882a593Smuzhiyun 	int (*tcm_register_callback)(struct usb_function_instance *);
44*4882a593Smuzhiyun 	void (*tcm_unregister_callback)(struct usb_function_instance *);
45*4882a593Smuzhiyun };
46*4882a593Smuzhiyun 
47*4882a593Smuzhiyun #endif /* U_TCM_H */
48