mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH RESEND] usb: gadget: dfu: Add missing get_alt callback
@ 2023-06-27 12:44 Jules Maselbas
  0 siblings, 0 replies; only message in thread
From: Jules Maselbas @ 2023-06-27 12:44 UTC (permalink / raw)


The DFU gadget use an alternate interface number to select the partition
to be worked on. Since the last update of the composite driver from Linux
the get_alt callback is now necessary for gadgets that may use an alt number
different than zero, which is the case for the DFU gadget.
Add the missing callback.

Fixes 4667c43c086 ("usb: gadget: update composite.c from Linux-6.3-rc2")

Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
 drivers/usb/gadget/function/dfu.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/usb/gadget/function/dfu.c b/drivers/usb/gadget/function/dfu.c
index 431480094b..4628b36b17 100644
--- a/drivers/usb/gadget/function/dfu.c
+++ b/drivers/usb/gadget/function/dfu.c
@@ -485,6 +485,20 @@ static int dfu_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
 	return -EINVAL;
 }
 
+static int dfu_get_alt(struct usb_function *f, unsigned intf)
+{
+	struct file_list_entry  *fentry;
+	int i = 0;
+
+	file_list_for_each_entry(dfu_files, fentry) {
+		if (fentry == dfu_file_entry)
+			return i;
+		i++;
+	}
+
+	return -EINVAL;
+}
+
 static int dfu_status(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
 {
 	struct f_dfu		*dfu = func_to_dfu(f);
@@ -830,6 +844,7 @@ static struct usb_function *dfu_alloc_func(struct usb_function_instance *fi)
 	/* descriptors are per-instance copies */
 	dfu->func.bind = dfu_bind;
 	dfu->func.set_alt = dfu_set_alt;
+	dfu->func.get_alt = dfu_get_alt;
 	dfu->func.setup = dfu_setup;
 	dfu->func.disable = dfu_disable;
 	dfu->func.unbind = dfu_unbind;
-- 
2.17.1







^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-27 14:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-27 12:44 [PATCH RESEND] usb: gadget: dfu: Add missing get_alt callback Jules Maselbas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox