@@ -383,38 +383,42 @@ int dtmcontrol_scan_via_bscan(struct target *target, uint32_t out, uint32_t *in_
383383 return ERROR_OK ;
384384}
385385
386- static int dtmcontrol_scan (struct target * target , uint32_t out , uint32_t * in_ptr )
386+ /* TODO: rename "dtmcontrol"-> "dtmcs" */
387+ int dtmcontrol_scan (struct target * target , uint32_t out , uint32_t * in_ptr )
387388{
388- struct scan_field field ;
389- uint8_t in_value [4 ];
390- uint8_t out_value [4 ] = { 0 };
389+ uint8_t value [4 ];
391390
392391 if (bscan_tunnel_ir_width != 0 )
393392 return dtmcontrol_scan_via_bscan (target , out , in_ptr );
394393
395- buf_set_u32 (out_value , 0 , 32 , out );
394+ buf_set_u32 (value , 0 , 32 , out );
396395
397396 jtag_add_ir_scan (target -> tap , & select_dtmcontrol , TAP_IDLE );
398397
399- field .num_bits = 32 ;
400- field .out_value = out_value ;
401- field .in_value = in_value ;
398+ struct scan_field field = {
399+ .num_bits = 32 ,
400+ .out_value = value ,
401+ .in_value = in_ptr ? value : NULL
402+ };
402403 jtag_add_dr_scan (target -> tap , 1 , & field , TAP_IDLE );
403404
404405 /* Always return to dbus. */
405406 jtag_add_ir_scan (target -> tap , & select_dbus , TAP_IDLE );
406407
407408 int retval = jtag_execute_queue ();
408409 if (retval != ERROR_OK ) {
409- LOG_TARGET_ERROR (target , "dtmcontrol scan failed, error code = %d" , retval );
410+ LOG_TARGET_ERROR (target , "dtmcs scan failed, error code = %d" , retval );
410411 return retval ;
411412 }
412413
413- uint32_t in = buf_get_u32 ( field . in_value , 0 , 32 );
414- LOG_DEBUG ( "DTMCONTROL: 0x%x -> 0x%x" , out , in );
415-
416- if ( in_ptr )
414+ if ( in_ptr ) {
415+ assert ( field . in_value );
416+ uint32_t in = buf_get_u32 ( field . in_value , 0 , 32 );
417+ LOG_TARGET_DEBUG ( target , "DTMCS: 0x%" PRIx32 " -> 0x%" PRIx32 , out , in );
417418 * in_ptr = in ;
419+ } else {
420+ LOG_TARGET_DEBUG (target , "DTMCS: 0x%" PRIx32 " -> ?" , out );
421+ }
418422 return ERROR_OK ;
419423}
420424
0 commit comments