summaryrefslogtreecommitdiffstats
path: root/src/nolo.c
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2012-09-23 14:02:52 +0200
committerPali Rohár <pali.rohar@gmail.com>2012-09-23 14:02:52 +0200
commit26c1c2914ea7836e1a9ad06ef14b51b24556bb4c (patch)
tree2a52f98f4700035faee2e882b194fbcba5b14ad3 /src/nolo.c
parent230d45c9e30d41a5854121fab50dd5718a1a45e5 (diff)
download0xFFFF-26c1c2914ea7836e1a9ad06ef14b51b24556bb4c.tar.bz2
nolo: In nolo_init check if device match to usb device, remove detected_ prefix
Diffstat (limited to 'src/nolo.c')
-rw-r--r--src/nolo.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/nolo.c b/src/nolo.c
index e60146d..22a1704 100644
--- a/src/nolo.c
+++ b/src/nolo.c
@@ -159,12 +159,26 @@ static int nolo_get_version_string(struct usb_device_info * dev, const char * st
int nolo_init(struct usb_device_info * dev) {
uint32_t val = 1;
+ enum device device;
printf("Initializing NOLO...\n");
+
while ( val != 0 )
if ( usb_control_msg(dev->udev, NOLO_QUERY, NOLO_STATUS, 0, 0, (char *)&val, 4, 2000) == -1 )
ERROR_RETURN("NOLO_STATUS failed", -1);
+ device = nolo_get_device(dev);
+
+ if ( ! dev->device )
+ dev->device = device;
+
+ if ( dev->device && device && dev->device != device ) {
+ ERROR("Device mishmash, expected %s, got %s", device_to_string(dev->device), device_to_string(device));
+ return -1;
+ }
+
+ dev->hwrev = nolo_get_hwrev(dev);
+
return 0;
}
@@ -247,7 +261,7 @@ static int nolo_send_image(struct usb_device_info * dev, struct image * image, i
struct device_list * device = image->devices;
while ( device ) {
- if ( device->device == dev->detected_device && hwrev_is_valid(device->hwrevs, dev->detected_hwrev) )
+ if ( device->device == dev->device && hwrev_is_valid(device->hwrevs, dev->hwrev) )
break;
device = device->next;
}
@@ -258,7 +272,7 @@ static int nolo_send_image(struct usb_device_info * dev, struct image * image, i
if ( bufs ) {
memset(buf, 0, sizeof(buf));
- snprintf(buf, 8, "%d", dev->detected_hwrev);
+ snprintf(buf, 8, "%d", dev->hwrev);
for ( i = 0; bufs[i]; ++i ) {
len = ((uint8_t*)bufs[i])[0];