build: cleanup src/pld directory
[openocd.git] / src / pld / pld.c
index 08a537c..a9431f4 100644 (file)
@@ -17,6 +17,7 @@
  *   Free Software Foundation, Inc.,                                       *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -30,8 +31,7 @@
  */
 extern struct pld_driver virtex2_pld;
 
-static struct pld_driver *pld_drivers[] =
-{
+static struct pld_driver *pld_drivers[] = {
        &virtex2_pld,
        NULL,
 };
@@ -43,12 +43,9 @@ struct pld_device *get_pld_device_by_num(int num)
        struct pld_device *p;
        int i = 0;
 
-       for (p = pld_devices; p; p = p->next)
-       {
+       for (p = pld_devices; p; p = p->next) {
                if (i++ == num)
-               {
                        return p;
-               }
        }
 
        return NULL;
@@ -62,14 +59,10 @@ COMMAND_HANDLER(handle_pld_device_command)
        int found = 0;
 
        if (CMD_ARGC < 1)
-       {
                return ERROR_COMMAND_SYNTAX_ERROR;
-       }
 
-       for (i = 0; pld_drivers[i]; i++)
-       {
-               if (strcmp(CMD_ARGV[0], pld_drivers[i]->name) == 0)
-               {
+       for (i = 0; pld_drivers[i]; i++) {
+               if (strcmp(CMD_ARGV[0], pld_drivers[i]->name) == 0) {
                        struct pld_device *p, *c;
 
                        /* register pld specific commands */
@@ -77,8 +70,7 @@ COMMAND_HANDLER(handle_pld_device_command)
                        if (pld_drivers[i]->commands) {
                                retval = register_commands(CMD_CTX, NULL,
                                                pld_drivers[i]->commands);
-                               if (ERROR_OK != retval)
-                               {
+                               if (ERROR_OK != retval) {
                                        LOG_ERROR("couldn't register '%s' commands", CMD_ARGV[0]);
                                        return ERROR_FAIL;
                                }
@@ -90,34 +82,29 @@ COMMAND_HANDLER(handle_pld_device_command)
 
                        retval = CALL_COMMAND_HANDLER(
                                        pld_drivers[i]->pld_device_command, c);
-                       if (ERROR_OK != retval)
-                       {
+                       if (ERROR_OK != retval) {
                                LOG_ERROR("'%s' driver rejected pld device",
-                                               CMD_ARGV[0]);
+                                       CMD_ARGV[0]);
                                free(c);
                                return ERROR_OK;
                        }
 
                        /* put pld device in linked list */
-                       if (pld_devices)
-                       {
+                       if (pld_devices) {
                                /* find last pld device */
-                               for (p = pld_devices; p && p->next; p = p->next);
+                               for (p = pld_devices; p && p->next; p = p->next)
+                                       ;
                                if (p)
                                        p->next = c;
-                       }
-                       else
-                       {
+                       } else
                                pld_devices = c;
-                       }
 
                        found = 1;
                }
        }
 
        /* no matching pld driver found */
-       if (!found)
-       {
+       if (!found) {
                LOG_ERROR("pld driver '%s' not found", CMD_ARGV[0]);
                exit(-1);
        }
@@ -130,16 +117,13 @@ COMMAND_HANDLER(handle_pld_devices_command)
        struct pld_device *p;
        int i = 0;
 
-       if (!pld_devices)
-       {
+       if (!pld_devices) {
                command_print(CMD_CTX, "no pld devices configured");
                return ERROR_OK;
        }
 
        for (p = pld_devices; p; p = p->next)
-       {
                command_print(CMD_CTX, "#%i: %s", i++, p->driver->name);
-       }
 
        return ERROR_OK;
 }
@@ -153,30 +137,24 @@ COMMAND_HANDLER(handle_pld_load_command)
        gettimeofday(&start, NULL);
 
        if (CMD_ARGC < 2)
-       {
                return ERROR_COMMAND_SYNTAX_ERROR;
-       }
 
        unsigned dev_id;
        COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], dev_id);
        p = get_pld_device_by_num(dev_id);
-       if (!p)
-       {
+       if (!p) {
                command_print(CMD_CTX, "pld device '#%s' is out of bounds", CMD_ARGV[0]);
                return ERROR_OK;
        }
 
-       if ((retval = p->driver->load(p, CMD_ARGV[1])) != ERROR_OK)
-       {
+       retval = p->driver->load(p, CMD_ARGV[1]);
+       if (retval != ERROR_OK) {
                command_print(CMD_CTX, "failed loading file %s to pld device %u",
                        CMD_ARGV[1], dev_id);
-               switch (retval)
-               {
+               switch (retval) {
                }
                return retval;
-       }
-       else
-       {
+       } else {
                gettimeofday(&end, NULL);
                timeval_subtract(&duration, &end, &start);
 
@@ -219,9 +197,8 @@ COMMAND_HANDLER(handle_pld_init_command)
        if (CMD_ARGC != 0)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
-       static bool pld_initialized = false;
-       if (pld_initialized)
-       {
+       static bool pld_initialized;
+       if (pld_initialized) {
                LOG_INFO("'pld init' has already been called");
                return ERROR_OK;
        }