/***************************************************************************
  *   Copyright (C) 2008 digenius technology GmbH.                          *
+ *   
+ *   Copyright (C) 2008 Oyvind Harboe oyvind.harboe@zylin.com              *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
                LOG_ERROR("use 'arm11 memwrite burst disable' to disable fast burst mode");
 
            if (arm11_config_memwrite_error_fatal)
-               exit(-1);
+               return ERROR_FAIL;
        }
     }
 #endif
 
     if (argc < 4)
     {
-       LOG_ERROR("'target arm11' 4th argument <jtag chain pos>");
-       exit(-1);
+       return ERROR_COMMAND_SYNTAX_ERROR;
     }
 
     int chain_pos = strtoul(args[3], NULL, 0);
 
     if (device->ir_length != 5)
     {
-       LOG_ERROR("'target arm11' expects 'jtag_device 5 0x01 0x1F 0x1E'");
-       exit(-1);
+               LOG_ERROR("'target arm11' expects 'jtag_device 5 0x01 0x1F 0x1E'");
+               return ERROR_COMMAND_SYNTAX_ERROR;
     }
 
     target->arch_info = arm11;
     case 0x07B76000:   LOG_INFO("found ARM1176"); break;
     default:
     {
-       LOG_ERROR("'target arm11' expects IDCODE 0x*7B*7****");
-       exit(-1);
+               LOG_ERROR("'target arm11' expects IDCODE 0x*7B*7****");
+               return ERROR_FAIL;
     }
     }
 
        arm11->debug_version != ARM11_DEBUG_V61)
     {
        LOG_ERROR("Only ARMv6 v6 and v6.1 architectures supported.");
-       exit(-1);
+       return ERROR_FAIL;
     }
 
 
        ARM11_REGCACHE_COUNT != asizeof(arm11_reg_defs) ||
        ARM11_REGCACHE_COUNT != ARM11_RC_MAX)
     {
-       LOG_ERROR("arm11->reg_values inconsistent (%d " ZU " " ZU " %d)", ARM11_REGCACHE_COUNT, asizeof(arm11->reg_values), asizeof(arm11_reg_defs), ARM11_RC_MAX);
+       LOG_ERROR("BUG: arm11->reg_values inconsistent (%d " ZU " " ZU " %d)", ARM11_REGCACHE_COUNT, asizeof(arm11->reg_values), asizeof(arm11_reg_defs), ARM11_RC_MAX);
        exit(-1);
     }
 
 
 /***************************************************************************
  *   Copyright (C) 2008 digenius technology GmbH.                          *
  *                                                                         *
+ *   Copyright (C) 2008 Oyvind Harboe oyvind.harboe@zylin.com              *
+ *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
     if (v != 0x10)
     {
         LOG_ERROR("'arm11 target' JTAG communication error SCREG SCAN OUT 0x%02x (expected 0x10)", v);
-        exit(-1);
+        return ERROR_FAIL;
     }
 
     JTAG_DEBUG("SCREG SCAN OUT 0x%02x", v);