[PATCH v4 4/4] usb: gadget: add get_alt function for f_sourcesink

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

 



From: Pratyush Anand <pratyush.anand@xxxxxx>

This patch is based on patch "usb: gadget: add isochronous support to
gadget zero" from Paul Zimmerman.
Above patch adds one more interface with Alternate Setting '1'. Now, if
get_alt is not defined then, composite driver always returns alternate
setting '0'. So, implemented get_alt to return correct alternate
settings.

Signed-off-by: Pratyush Anand <pratyush.anand@xxxxxx>
Signed-off-by: Paul Zimmerman <paulz@xxxxxxxxxxxx>
---
 drivers/usb/gadget/f_sourcesink.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c
index 911e6f3..5c1b68b 100644
--- a/drivers/usb/gadget/f_sourcesink.c
+++ b/drivers/usb/gadget/f_sourcesink.c
@@ -53,6 +53,7 @@ struct f_sourcesink {
 	struct usb_ep		*out_ep;
 	struct usb_ep		*iso_in_ep;
 	struct usb_ep		*iso_out_ep;
+	int			cur_alt;
 };
 
 static inline struct f_sourcesink *func_to_ss(struct usb_function *f)
@@ -729,6 +730,8 @@ fail3:
 		}
 	}
 out:
+	ss->cur_alt = alt;
+
 	DBG(cdev, "%s enabled, alt intf %d\n", ss->function.name, alt);
 	return result;
 }
@@ -744,6 +747,13 @@ static int sourcesink_set_alt(struct usb_function *f,
 	return enable_source_sink(cdev, ss, alt);
 }
 
+static int sourcesink_get_alt(struct usb_function *f, unsigned intf)
+{
+	struct f_sourcesink		*ss = func_to_ss(f);
+
+	return ss->cur_alt;
+}
+
 static void sourcesink_disable(struct usb_function *f)
 {
 	struct f_sourcesink	*ss = func_to_ss(f);
@@ -767,6 +777,7 @@ static int __init sourcesink_bind_config(struct usb_configuration *c)
 	ss->function.bind = sourcesink_bind;
 	ss->function.unbind = sourcesink_unbind;
 	ss->function.set_alt = sourcesink_set_alt;
+	ss->function.get_alt = sourcesink_get_alt;
 	ss->function.disable = sourcesink_disable;
 
 	status = usb_add_function(c, &ss->function);
-- 
1.7.1

--
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