[RFC/PATCH v2 1/3] usb: gadget: introduce start() and stop()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



these two methods will be used to tell
controller driver to prepare for starting/stopping
operation with a gadget driver. They will
be implemented and used by the new usb udc
class which will come in later patches.

Signed-off-by: Felipe Balbi <balbi@xxxxxx>
---
 include/linux/usb/gadget.h |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index d3ef42d..b5c0527 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -430,6 +430,8 @@ struct usb_gadget_ops {
 	int	(*pullup) (struct usb_gadget *, int is_on);
 	int	(*ioctl)(struct usb_gadget *,
 				unsigned code, unsigned long param);
+	int	(*start)(struct usb_gadget *);
+	void	(*stop)(struct usb_gadget *);
 };
 
 /**
@@ -641,6 +643,44 @@ static inline int usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)
 }
 
 /**
+ * usb_gadget_start - tells usb device controller to start up
+ * @gadget: The device we want to get started
+ *
+ * This call is issued by the UDC Class driver when it's about
+ * to register a gadget driver to the device controller, before
+ * calling gadget driver's bind() method.
+ *
+ * It allows the controller to be powered off until extrictly
+ * necessary to have it powered on.
+ *
+ * Returns zero on success, else negative errno.
+ */
+static inline int usb_gadget_start(struct usb_gadget *gadget)
+{
+	if (!gadget->ops->start)
+		return -EOPNOTSUPP;
+	return gadget->ops->start(gadget);
+}
+
+/**
+ * usb_gadget_stop - tells usb device controller we don't need it anymore
+ * @gadget: The device we want to stop activity
+ *
+ * This call is issued by the UDC Class driver after calling
+ * gadget driver's unbind() method.
+ *
+ * The details are implementation specific, but it can go as
+ * far as powering off UDC completely and disable its data
+ * line pullups.
+ */
+static inline void usb_gadget_stop(struct usb_gadget *gadget)
+{
+	if (!gadget->ops->stop)
+		return;
+	gadget->ops->stop(gadget);
+}
+
+/**
  * usb_gadget_vbus_disconnect - notify controller about VBUS session end
  * @gadget:the device whose VBUS supply is being described
  * Context: can sleep
-- 
1.7.3.rc0.35.g8ac8c

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux