summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-07-17 07:53:09 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-07-22 08:09:28 +0200
commit62735eec55c5fbe5609d3f0d2217e941d49277be (patch)
tree18adf87dcfd056128e69df56ff4a030b624b9422 /commands
parent32f4bd130c9c46ad7404a3e600dcea8d05008d32 (diff)
downloadbarebox-62735eec55c5fbe5609d3f0d2217e941d49277be.tar.gz
barebox-62735eec55c5fbe5609d3f0d2217e941d49277be.tar.xz
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 <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/dfu.c44
-rw-r--r--commands/usbserial.c27
2 files changed, 4 insertions, 67 deletions
diff --git a/commands/dfu.c b/commands/dfu.c
index 354625260d..a8948f1e3e 100644
--- a/commands/dfu.c
+++ b/commands/dfu.c
@@ -97,47 +97,17 @@ static int dfu_do_parse_one(char *partstr, char **endstr, struct usb_dfu_dev *df
*/
static int do_dfu(int argc, char *argv[])
{
- int opt, n = 0;
+ int n = 0;
struct usb_dfu_pdata pdata;
char *endptr, *argstr;
struct usb_dfu_dev *dfu_alts = NULL;
- char *manufacturer = "barebox";
- const char *productname = barebox_get_model();
- u16 idVendor = 0, idProduct = 0;
int ret;
- while((opt = getopt(argc, argv, "m:p:V:P:")) > 0) {
- switch(opt) {
- case 'm':
- manufacturer = optarg;
- break;
- case 'p':
- productname = optarg;
- break;
- case 'V':
- idVendor = simple_strtoul(optarg, NULL, 0);
- break;
- case 'P':
- idProduct = simple_strtoul(optarg, NULL, 0);
- break;
- }
- }
-
if (argc != optind + 1)
return COMMAND_ERROR_USAGE;
argstr = argv[optind];
- if (!idProduct && !idVendor) {
- idVendor = 0x1d50; /* Openmoko, Inc */
- idProduct = 0x60a2; /* barebox bootloader USB DFU Mode */
- }
-
- if ((idProduct && !idVendor) || (!idProduct && idVendor)) {
- printf("Only one of vendor id or product id given\n");
- return -EINVAL;
- }
-
for (n = 0; *argstr; n++) {
dfu_alts = xrealloc(dfu_alts, sizeof(*dfu_alts) * (n + 1));
if (dfu_do_parse_one(argstr, &endptr, &dfu_alts[n])) {
@@ -151,11 +121,6 @@ static int do_dfu(int argc, char *argv[])
pdata.alts = dfu_alts;
pdata.num_alts = n;
- pdata.manufacturer = manufacturer;
- pdata.productname = productname;
- pdata.idVendor = idVendor;
- pdata.idProduct = idProduct;
-
ret = usb_dfu_register(&pdata);
out:
@@ -179,17 +144,12 @@ BAREBOX_CMD_HELP_TEXT("- 's' safe mode (download the complete image before flash
BAREBOX_CMD_HELP_TEXT("- 'r' readback of the firmware is allowed")
BAREBOX_CMD_HELP_TEXT("- 'c' the file will be created (for use with regular files)")
BAREBOX_CMD_HELP_TEXT("")
-BAREBOX_CMD_HELP_TEXT("Options:")
-BAREBOX_CMD_HELP_OPT ("-m STR", "Manufacturer string (barebox)")
-BAREBOX_CMD_HELP_OPT ("-p STR", "product string")
-BAREBOX_CMD_HELP_OPT ("-V ID", "vendor id")
-BAREBOX_CMD_HELP_OPT ("-P ID", "product id")
BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(dfu)
.cmd = do_dfu,
BAREBOX_CMD_DESC("device firmware update")
- BAREBOX_CMD_OPTS("[-mpVP] DESC")
+ BAREBOX_CMD_OPTS("DESC")
BAREBOX_CMD_GROUP(CMD_GRP_MISC)
BAREBOX_CMD_HELP(cmd_dfu_help)
BAREBOX_CMD_END
diff --git a/commands/usbserial.c b/commands/usbserial.c
index 7e82112df0..e80b315250 100644
--- a/commands/usbserial.c
+++ b/commands/usbserial.c
@@ -31,25 +31,10 @@ static int do_usbserial(int argc, char *argv[])
{
int opt;
struct usb_serial_pdata pdata;
- char *manufacturer = "barebox";
- const char *productname = barebox_get_model();
- u16 idVendor = 0, idProduct = 0;
int acm = 1;
- while ((opt = getopt(argc, argv, "m:p:V:P:asd")) > 0) {
+ while ((opt = getopt(argc, argv, "asd")) > 0) {
switch (opt) {
- case 'm':
- manufacturer = optarg;
- break;
- case 'p':
- productname = optarg;
- break;
- case 'V':
- idVendor = simple_strtoul(optarg, NULL, 0);
- break;
- case 'P':
- idProduct = simple_strtoul(optarg, NULL, 0);
- break;
case 'a':
acm = 1;
break;
@@ -62,10 +47,6 @@ static int do_usbserial(int argc, char *argv[])
}
}
- pdata.manufacturer = manufacturer;
- pdata.productname = productname;
- pdata.idVendor = idVendor;
- pdata.idProduct = idProduct;
pdata.acm = acm;
return usb_serial_register(&pdata);
@@ -75,10 +56,6 @@ BAREBOX_CMD_HELP_START(usbserial)
BAREBOX_CMD_HELP_TEXT("Enable / disable a serial gadget on the USB device interface.")
BAREBOX_CMD_HELP_TEXT("")
BAREBOX_CMD_HELP_TEXT("Options:")
-BAREBOX_CMD_HELP_OPT ("-m STR", "Manufacturer string (barebox)")
-BAREBOX_CMD_HELP_OPT ("-p STR", "product string")
-BAREBOX_CMD_HELP_OPT ("-V ID", "vendor id")
-BAREBOX_CMD_HELP_OPT ("-P ID", "product id")
BAREBOX_CMD_HELP_OPT ("-a", "CDC ACM (default)")
BAREBOX_CMD_HELP_OPT ("-s", "Generic Serial")
BAREBOX_CMD_HELP_OPT ("-d", "Disable the serial gadget")
@@ -87,7 +64,7 @@ BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(usbserial)
.cmd = do_usbserial,
BAREBOX_CMD_DESC("serial gadget enable/disable")
- BAREBOX_CMD_OPTS("[-mpVPasd] <description>")
+ BAREBOX_CMD_OPTS("[-asd] <description>")
BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP)
BAREBOX_CMD_HELP(cmd_usbserial_help)
BAREBOX_CMD_END