From 62735eec55c5fbe5609d3f0d2217e941d49277be Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 17 Jul 2014 07:53:09 +0200 Subject: USB: gadget: specify vendor/product id with device parameters This introduces the device parameters: usbgadget.product usbgadget.vendor usbgadget.manufacturer usbgadget.productname These variables are used to configure the USB vendor id, product id, manufacturer name and product name. Previously these were configured with arguments to the usbserial and dfu command. The parameters are device static, so it's nice to configure it somewhere in the environment instead of when calling dfu/usbserial. Also when other gadget drivers are added we do not have to duplicate the option parsing further. Signed-off-by: Sascha Hauer --- drivers/usb/gadget/dfu.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'drivers/usb/gadget/dfu.c') diff --git a/drivers/usb/gadget/dfu.c b/drivers/usb/gadget/dfu.c index a2b4c0d658..85d99e9c99 100644 --- a/drivers/usb/gadget/dfu.c +++ b/drivers/usb/gadget/dfu.c @@ -655,8 +655,20 @@ static struct usb_device_descriptor dfu_dev_descriptor = { static int dfu_driver_bind(struct usb_composite_dev *cdev) { + struct usb_gadget *gadget = cdev->gadget; int status; + if (gadget->vendor_id && gadget->product_id) { + dfu_dev_descriptor.idVendor = cpu_to_le16(gadget->vendor_id); + dfu_dev_descriptor.idProduct = cpu_to_le16(gadget->product_id); + } else { + dfu_dev_descriptor.idVendor = cpu_to_le16(0x1d50); /* Openmoko, Inc */ + dfu_dev_descriptor.idProduct = cpu_to_le16(0x60a2); /* barebox bootloader USB DFU Mode */ + } + + strings_dev[STRING_MANUFACTURER_IDX].s = gadget->manufacturer; + strings_dev[STRING_PRODUCT_IDX].s = gadget->productname; + status = usb_string_id(cdev); if (status < 0) goto fail; @@ -698,10 +710,6 @@ int usb_dfu_register(struct usb_dfu_pdata *pdata) dfu_devs = pdata->alts; dfu_num_alt = pdata->num_alts; - dfu_dev_descriptor.idVendor = pdata->idVendor; - dfu_dev_descriptor.idProduct = pdata->idProduct; - strings_dev[STRING_MANUFACTURER_IDX].s = pdata->manufacturer; - strings_dev[STRING_PRODUCT_IDX].s = pdata->productname; ret = usb_composite_probe(&dfu_driver); if (ret) -- cgit v1.2.3