mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jules Maselbas <jmaselbas@kalray.eu>
Subject: [PATCH] usb: gadget: dfu: Add missing get_alt callback
Date: Tue, 27 Jun 2023 14:44:42 +0200	[thread overview]
Message-ID: <PAZP264MB3119F3C1EE3DE7D44146C9E3B127A@PAZP264MB3119.FRAP264.PROD.OUTLOOK.COM> (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







                 reply	other threads:[~2023-06-27 13:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PAZP264MB3119F3C1EE3DE7D44146C9E3B127A@PAZP264MB3119.FRAP264.PROD.OUTLOOK.COM \
    --to=jmaselbas@kalray.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox