• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright 2024 Google LLC
4  */
5 #ifndef _ANDROID_USB_CONFIGFS_UEVENT_H
6 #define _ANDROID_USB_CONFIGFS_UEVENT_H
7 
8 #ifdef CONFIG_ANDROID_USB_CONFIGFS_UEVENT
9 #include <linux/device.h>
10 #include <linux/workqueue.h>
11 #include <linux/mutex.h>
12 
13 struct android_uevent_opts {
14 	struct device *dev;
15 	int device_id;
16 	bool connected;
17 	bool configured;
18 	bool sw_connected;
19 	struct work_struct work;
20 	struct ida function_ida;
21 };
22 
23 /**
24  * android_create_function_device - creates a device within the android_usb
25  * class with a new minor number.
26  * @name: the name for the device which is to be created
27  * @drvdata: the data to be added to the device for callbacks, can be NULL
28  * @groups: NULL-terminated list of attribute groups to be created, can be NULL
29  *
30  * This should be called by function drivers which wish to register a device
31  * within the android_usb class.
32  *
33  * Returns: a pointer to the newly created device upon success, or an ERR_PTR
34  * for the encountered error.
35  */
36 struct device *android_create_function_device(char *name, void *drvdata,
37 		const struct attribute_group **groups);
38 
39 /**
40  * android_remove_function_device - destroys a device which was created by
41  * calling android_create_function_device, and performs any necessary cleanup.
42  * @dev: the device to be destroyed
43  */
44 void android_remove_function_device(struct device *dev);
45 #else
46 
47 struct android_uevent_opts {};
48 
android_create_function_device(char * name)49 static inline struct device *android_create_function_device(char *name)
50 {
51 	return ERR_PTR(-ENODEV);
52 }
53 
android_remove_function_device(struct device * dev)54 static inline void android_remove_function_device(struct device *dev)
55 {
56 }
57 #endif /* CONFIG_ANDROID_USB_CONFIGFS_UEVENT */
58 #endif /* _ANDROID_USB_CONFIGFS_UEVENT_H */
59