From 9a21b2d946d3dfde68d1c0d44c0e676b2b2fd166 Mon Sep 17 00:00:00 2001 From: hselasky Date: Sat, 25 Jun 2011 15:22:44 +0000 Subject: - Need to respect the module name and the USB mode when accumulating device ID's. - Be more verbose on file seek failures. Allow a file size of zero. - Improve the wrapper shell. MFC after: 14 days --- tools/tools/bus_autoconf/bus_autoconf.sh | 18 ++++++++++++------ tools/tools/bus_autoconf/bus_load_file.c | 12 ++++++++---- tools/tools/bus_autoconf/bus_usb.c | 4 ++++ 3 files changed, 24 insertions(+), 10 deletions(-) (limited to 'tools') diff --git a/tools/tools/bus_autoconf/bus_autoconf.sh b/tools/tools/bus_autoconf/bus_autoconf.sh index 1d1d038..c99df91 100644 --- a/tools/tools/bus_autoconf/bus_autoconf.sh +++ b/tools/tools/bus_autoconf/bus_autoconf.sh @@ -28,6 +28,7 @@ OS=FreeBSD DOLLAR=$ +OBJCOPY=objcopy cat < /dev/null -[ -f temp.ids ] && cat temp.ids >> bus_autoconf_format.bin +${OBJCOPY} -j bus_autoconf_format -O binary ${F} bus_autoconf.ids 2> /dev/null +[ -f bus_autoconf.ids ] && cat bus_autoconf.ids >> bus_autoconf_format.bin # USB Host mode -objcopy -j usb_host_id -O binary ${F} "usb_host_id,${G}" 2> /dev/null +${OBJCOPY} -j usb_host_id -O binary ${F} "usb_host_id,${G}" 2> /dev/null [ -f "usb_host_id,${G}" ] && (echo -n " -i usb_host_id,${G}" >> bus_autoconf_args.txt) # USB Device mode -objcopy -j usb_device_id -O binary ${F} "usb_device_id,${G}" 2> /dev/null +${OBJCOPY} -j usb_device_id -O binary ${F} "usb_device_id,${G}" 2> /dev/null [ -f "usb_device_id,${G}" ] && (echo -n " -i usb_device_id,${G}" >> bus_autoconf_args.txt) # USB Dual mode -objcopy -j usb_dual_id -O binary ${F} "usb_dual_id,${G}" 2> /dev/null +${OBJCOPY} -j usb_dual_id -O binary ${F} "usb_dual_id,${G}" 2> /dev/null [ -f "usb_dual_id,${G}" ] && (echo -n " -i usb_dual_id,${G}" >> bus_autoconf_args.txt) done @@ -69,4 +71,8 @@ done bus_autoconf -F bus_autoconf_format.bin $(cat bus_autoconf_args.txt) # Cleanup -rm -f -- bus_autoconf_format.bin $(cat bus_autoconf_args.txt) +rm -f -- \ + $(cat bus_autoconf_args.txt) \ + bus_autoconf_args.txt \ + bus_autoconf_format.bin \ + bus_autoconf.ids diff --git a/tools/tools/bus_autoconf/bus_load_file.c b/tools/tools/bus_autoconf/bus_load_file.c index 88f806a..527e5bc 100644 --- a/tools/tools/bus_autoconf/bus_load_file.c +++ b/tools/tools/bus_autoconf/bus_load_file.c @@ -48,11 +48,15 @@ load_file(const char *fname, uint8_t **pptr, uint32_t *plen) err(EX_NOINPUT, "Cannot open file '%s'", fname); off = lseek(f, 0, SEEK_END); - if (off <= 0) - err(EX_NOINPUT, "Cannot seek to end of file"); + if (off < 0) { + err(EX_NOINPUT, "Cannot seek to " + "end of file '%s'", fname); + } - if (lseek(f, 0, SEEK_SET) < 0) - err(EX_NOINPUT, "Cannot seek to beginning of file"); + if (lseek(f, 0, SEEK_SET) < 0) { + err(EX_NOINPUT, "Cannot seek to " + "beginning of file '%s'", fname); + } len = off; if (len != off) diff --git a/tools/tools/bus_autoconf/bus_usb.c b/tools/tools/bus_autoconf/bus_usb.c index e3d60e8..ab794c1 100644 --- a/tools/tools/bus_autoconf/bus_usb.c +++ b/tools/tools/bus_autoconf/bus_usb.c @@ -276,6 +276,10 @@ usb_dump(struct usb_device_id *id, uint32_t nid) break; if (id[n].idVendor != id[0].idVendor) break; + if (strcmp(id[n].module_name, id[0].module_name)) + break; + if (strcmp(id[n].module_mode, id[0].module_mode)) + break; n++; } } -- cgit v1.1