Patchwork [U-Boot,v3,4/5] usb, g_dnl: make bcdDevice value configurable

login
register
mail settings
Submitter Heiko Schocher
Date Nov. 4, 2013, 1:05 p.m.
Message ID <1383570303-26750-5-git-send-email-hs@denx.de>
Download mbox | patch
Permalink /patch/288172/
State Accepted
Delegated to: Tom Rini
Headers show

Comments

Heiko Schocher - Nov. 4, 2013, 1:05 p.m.
add the possibility to set the bcdDevice number board specific.
Therefore the weak function g_dnl_get_board_bcd_device_number()
is introduced. Used on the siemens boards.

Signed-off-by: Heiko Schocher <hs@denx.de>
Acked-by: Lukasz Majewski <l.majewski@samsung.com>
Cc: Marek Vasut <marek.vasut@gmail.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>

---
- changes for v3
  rebase against current u-boot/master
  509dca7a11aad394d781a9d31a7bfa6692562741
- changes for v2:
  add Acked-by from Lukasz Majewski
---
 drivers/usb/gadget/g_dnl.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)
Tom Rini - Nov. 12, 2013, 3:03 p.m.
On Mon, Nov 04, 2013 at 02:05:02PM +0100, Heiko Schocher wrote:
> add the possibility to set the bcdDevice number board specific.
> Therefore the weak function g_dnl_get_board_bcd_device_number()
> is introduced. Used on the siemens boards.
> 
> Signed-off-by: Heiko Schocher <hs@denx.de>
> Acked-by: Lukasz Majewski <l.majewski@samsung.com>
> Cc: Marek Vasut <marek.vasut@gmail.com>
> Cc: Kyungmin Park <kyungmin.park@samsung.com>

Applied to u-boot/master, thanks!

Patch

diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c
index 8dc3d9f..dd95afe 100644
--- a/drivers/usb/gadget/g_dnl.c
+++ b/drivers/usb/gadget/g_dnl.c
@@ -147,6 +147,23 @@  int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
 	return 0;
 }
 
+__weak int g_dnl_get_board_bcd_device_number(int gcnum)
+{
+	return gcnum;
+}
+
+static int g_dnl_get_bcd_device_number(struct usb_composite_dev *cdev)
+{
+	struct usb_gadget *gadget = cdev->gadget;
+	int gcnum;
+
+	gcnum = usb_gadget_controller_number(gadget);
+	if (gcnum > 0)
+		gcnum += 0x200;
+
+	return g_dnl_get_board_bcd_device_number(gcnum);
+}
+
 static int g_dnl_bind(struct usb_composite_dev *cdev)
 {
 	struct usb_gadget *gadget = cdev->gadget;
@@ -181,11 +198,9 @@  static int g_dnl_bind(struct usb_composite_dev *cdev)
 	if (ret)
 		goto error;
 
-	gcnum = usb_gadget_controller_number(gadget);
-
-	debug("gcnum: %d\n", gcnum);
+	gcnum = g_dnl_get_bcd_device_number(cdev);
 	if (gcnum >= 0)
-		device_desc.bcdDevice = cpu_to_le16(0x0200 + gcnum);
+		device_desc.bcdDevice = cpu_to_le16(gcnum);
 	else {
 		debug("%s: controller '%s' not recognized\n",
 			shortname, gadget->name);