USB: gadget: composite: Add userspace notifications for USB state changes
Add switch to notify current USB configuration. This can be used to detect
USB connect and disconnect events.
Broadcast a change via the usb_composite class when a USB function is
enabled or disabled.
Rename usb_function.hidden to usb_function.disabled.
Signed-off-by: Mike Lockwood <lockwood@android.com>
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index a521e8c..0b2d291 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -36,6 +36,7 @@
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
+#include <linux/switch.h>
/*
* USB function drivers should return USB_GADGET_DELAYED_STATUS if they
@@ -108,7 +109,9 @@
struct usb_descriptor_header **hs_descriptors;
struct usb_configuration *config;
- int hidden;
+
+ /* disabled is zero if the function is enabled */
+ int disabled;
/* REVISIT: bind() functions can be marked __init, which
* makes trouble for section mismatch analysis. See if
@@ -147,6 +150,8 @@
int usb_interface_id(struct usb_configuration *, struct usb_function *);
+void usb_function_set_enabled(struct usb_function *, int);
+
/**
* ep_choose - select descriptor endpoint at current device speed
* @g: gadget, connected and running at some speed
@@ -365,6 +370,8 @@
/* protects deactivations and delayed_status counts*/
spinlock_t lock;
+
+ struct switch_dev sdev;
};
extern int usb_string_id(struct usb_composite_dev *c);