This is an automated email from Gerrit.

Spencer Oliver ([email protected]) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/2328

-- gerrit

commit 95b9e7b44b8a605ed31ae5b2ddbea125dfde9893
Author: Spencer Oliver <[email protected]>
Date:   Thu Oct 2 21:47:22 2014 +0100

    cmsis-dap: refactor HID PID/VID check loop
    
    In preparation for adding serial number support.
    
    Change-Id: I3c9fb411b79d54a4d2de067039255436ba6708c7
    Signed-off-by: Spencer Oliver <[email protected]>

diff --git a/src/jtag/drivers/cmsis_dap_usb.c b/src/jtag/drivers/cmsis_dap_usb.c
index b8f004c..79712d0 100644
--- a/src/jtag/drivers/cmsis_dap_usb.c
+++ b/src/jtag/drivers/cmsis_dap_usb.c
@@ -163,14 +163,16 @@ static int cmsis_dap_usb_open(void)
        struct hid_device_info *devs, *cur_dev;
        unsigned short target_vid, target_pid;
 
+       bool found = false;
+
        target_vid = 0;
        target_pid = 0;
 
        /*
-       The CMSIS-DAP specification stipulates:
-       "The Product String must contain "CMSIS-DAP" somewhere in the string. 
This is used by the
-       debuggers to idenify a CMSIS-DAP compliant Debug Unit that is connected 
to a host computer."
-       */
+        * The CMSIS-DAP specification stipulates:
+        * "The Product String must contain "CMSIS-DAP" somewhere in the 
string. This is used by the
+        * debuggers to identify a CMSIS-DAP compliant Debug Unit that is 
connected to a host computer."
+        */
        devs = hid_enumerate(0x0, 0x0);
        cur_dev = devs;
        while (NULL != cur_dev) {
@@ -179,23 +181,27 @@ static int cmsis_dap_usb_open(void)
                                LOG_DEBUG("Cannot read product string of device 
0x%x:0x%x",
                                          cur_dev->vendor_id, 
cur_dev->product_id);
                        } else {
-                               if (wcsstr(cur_dev->product_string, 
L"CMSIS-DAP"))
-                                       /*
-                                       if the user hasn't specified VID:PID 
*and*
-                                       product string contains "CMSIS-DAP", 
pick it
-                                       */
-                                       break;
+                               if (wcsstr(cur_dev->product_string, 
L"CMSIS-DAP")) {
+                                       /* if the user hasn't specified VID:PID 
*and*
+                                        * product string contains "CMSIS-DAP", 
pick it
+                                        */
+                                       found = true;
+                               }
                        }
                } else {
-                       /*
-                       otherwise, exhaustively compare against all VID:PID in 
list
-                       */
+                       /* otherwise, exhaustively compare against all VID:PID 
in list */
                        for (i = 0; cmsis_dap_vid[i] || cmsis_dap_pid[i]; i++) {
                                if ((cmsis_dap_vid[i] == cur_dev->vendor_id) && 
(cmsis_dap_pid[i] == cur_dev->product_id))
-                                       break;
+                                       found = true;
                        }
+
                        if (cmsis_dap_vid[i] || cmsis_dap_pid[i])
-                               break;
+                               found = true;
+               }
+
+               if (found) {
+                       /* we have found an adapter, so exit further checks */
+                       break;
                }
 
                cur_dev = cur_dev->next;

-- 

------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to