[RFC PATCH 2/5] USB: MUSB: Change srp sysfs entry to session

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

 



From: ext Felipe Balbi <felipe.balbi@xxxxxxxxx>

The name session is more generic as this interface could
be used also by host side to turn vbus on.

Signed-off-by: Felipe Balbi <felipe.balbi@xxxxxxxxx>
---
 drivers/usb/musb/musb_core.c |   42 +++++++++++++++++++++---------------------
 1 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 019898a..5b58d18 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1736,32 +1736,36 @@ musb_vbus_show(struct device *dev, struct device_attribute *attr, char *buf)
 }
 static DEVICE_ATTR(vbus, 0644, musb_vbus_show, musb_vbus_store);
 
-#ifdef CONFIG_USB_GADGET_MUSB_HDRC
-
-/* Gadget drivers can't know that a host is connected so they might want
- * to start SRP, but users can.  This allows userspace to trigger SRP.
- */
 static ssize_t
-musb_srp_store(struct device *dev, struct device_attribute *attr,
+musb_session_store(struct device *dev, struct device_attribute *attr,
 		const char *buf, size_t n)
 {
 	struct musb	*musb = dev_to_musb(dev);
-	unsigned short	srp;
+	unsigned short	session;
 
-	if (sscanf(buf, "%hu", &srp) != 1
-			|| (srp != 1)) {
-		printk(KERN_ERR "SRP: Value must be 1\n");
+	if (sscanf(buf, "%hu", &session) != 1
+			|| (session != 1)) {
+		printk(KERN_ERR "Value must be 1\n");
 		return -EINVAL;
 	}
 
-	if (srp == 1)
-		musb_g_wakeup(musb);
+	if (session == 1) {
+		switch (musb->xceiv.state) {
+		case OTG_STATE_B_IDLE:
+			musb_g_wakeup(musb);
+			break;
+		case OTG_STATE_A_IDLE:
+			musb_set_vbus(musb, 1);
+			break;
+		default:
+			printk(KERN_INFO "Vbus might be on already\n");
+			break;
+		}
+	}
 
 	return n;
 }
-static DEVICE_ATTR(srp, 0644, NULL, musb_srp_store);
-
-#endif /* CONFIG_USB_GADGET_MUSB_HDRC */
+static DEVICE_ATTR(session, 0644, NULL, musb_session_store);
 
 #endif	/* sysfs */
 
@@ -1839,9 +1843,7 @@ static void musb_free(struct musb *musb)
 #ifdef CONFIG_SYSFS
 	device_remove_file(musb->controller, &dev_attr_mode);
 	device_remove_file(musb->controller, &dev_attr_vbus);
-#ifdef CONFIG_USB_MUSB_OTG
-	device_remove_file(musb->controller, &dev_attr_srp);
-#endif
+	device_remove_file(musb->controller, &dev_attr_session);
 #endif
 
 #ifdef CONFIG_USB_GADGET_MUSB_HDRC
@@ -2075,9 +2077,7 @@ fail:
 #ifdef CONFIG_SYSFS
 	status = device_create_file(dev, &dev_attr_mode);
 	status = device_create_file(dev, &dev_attr_vbus);
-#ifdef CONFIG_USB_GADGET_MUSB_HDRC
-	status = device_create_file(dev, &dev_attr_srp);
-#endif /* CONFIG_USB_GADGET_MUSB_HDRC */
+	status = device_create_file(dev, &dev_attr_session);
 	status = 0;
 #endif
 
-- 
1.5.5.1.125.gc697a

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

[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux