[PATCH 1/2] usb: gadget: print a meaningful error message

Sascha Hauer s.hauer at pengutronix.de
Thu Mar 9 00:37:58 PST 2017


We can only register one USB multi gadget, so check for it being
already registered and print a meaningful error message if it is.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/usb/gadget/multi.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c
index 13fa622f01..a2cfc8d850 100644
--- a/drivers/usb/gadget/multi.c
+++ b/drivers/usb/gadget/multi.c
@@ -234,6 +234,11 @@ static struct usb_composite_driver multi_driver = {
 
 int usb_multi_register(struct f_multi_opts *opts)
 {
+	if (gadget_multi_opts) {
+		pr_err("USB multi gadget already registered\n");
+		return -EBUSY;
+	}
+
 	gadget_multi_opts = opts;
 
 	return usb_composite_probe(&multi_driver);
-- 
2.11.0




More information about the barebox mailing list