This is an automated email from Gerrit.

"Richard Pasek <[email protected]>" just uploaded a new patch set to Gerrit, 
which you can find at https://review.openocd.org/c/openocd/+/9576

-- gerrit

commit 95fe32a9b1c236d2eff790b2ffd446a414021261
Author: Richard Pasek <[email protected]>
Date:   Fri Apr 10 13:57:59 2026 -0400

    linuxspidev: Transition to LOG_CUSTOM_LEVEL_N()
    
    This change allows for printing spi_exchanges without having to
    enable compile time defines
    
    Change-Id: I4f434da519a4b0a28c12c14e562009c2dbf50f50
    Signed-off-by: Richard Pasek <[email protected]>

diff --git a/src/jtag/drivers/linuxspidev.c b/src/jtag/drivers/linuxspidev.c
index 396f1a19a9..d4e0f8646c 100644
--- a/src/jtag/drivers/linuxspidev.c
+++ b/src/jtag/drivers/linuxspidev.c
@@ -9,12 +9,11 @@
  * Implementation of SWD protocol with a Linux SPI device.
  */
 
-/* Uncomment to log SPI exchanges (very verbose, slows things down a lot)
- *
- * A quick note on interpreting SPI exchange messages:
+/* A quick note on interpreting SPI exchange messages (enabled with
+ * LOG_LVL_DEBUG_IO):
  *
  * This implementation works by performing SPI exchanges with MOSI and MISO
- * tied together with a 1K resistor. This combined signal becomes SWDIO.
+ * tied together with a 100 ohm resistor. This combined signal becomes SWDIO.
  *
  * Since we are performing SPI exchanges, (reading and writing at the same
  * time) this means when the target isn't driving SWDIO, what is written by
@@ -37,9 +36,7 @@
  *             ^^
  *             ||
  *     Command packet from host
- *
  */
-// #define LOG_SPI_EXCHANGE
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -111,9 +108,7 @@ static void spidev_swd_write_reg(uint8_t cmd, uint32_t 
value, uint32_t ap_delay_
 
 static void spi_exchange(const uint8_t *tx_data, uint8_t *rx_data, unsigned 
int len)
 {
-#ifdef LOG_SPI_EXCHANGE
-       LOG_OUTPUT("exchange: len=%u\n", len);
-#endif // LOG_SPI_EXCHANGE
+       LOG_DEBUG_IO("exchange: len=%u", len);
 
        if (len == 0) {
                LOG_DEBUG("exchange with no length");
@@ -135,14 +130,13 @@ static void spi_exchange(const uint8_t *tx_data, uint8_t 
*rx_data, unsigned int
                for (unsigned int i = 0; i < len; i++)
                        tx_flip_buf[i] = flip_u32(tx_data[i], 8);
 
-#ifdef LOG_SPI_EXCHANGE
                if (len != 0) {
-                       LOG_OUTPUT(" tx_buf=");
+                       LOG_CUSTOM_LEVEL_N(LOG_LVL_DEBUG_IO, " tx_buf=");
                        for (unsigned int i = 0; i < len; i++)
-                               LOG_OUTPUT("%.2" PRIx8 " ", tx_flip_buf[i]);
+                               LOG_CUSTOM_LEVEL_N(LOG_LVL_DEBUG_IO, "%.2" 
PRIx8 " ", tx_flip_buf[i]);
+
+                       LOG_CUSTOM_LEVEL_N(LOG_LVL_DEBUG_IO, "\n");
                }
-               LOG_OUTPUT("\n");
-#endif // LOG_SPI_EXCHANGE
        }
        // Transmit the MSB buffer to SPI device.
        struct spi_ioc_transfer tr = {
@@ -165,14 +159,11 @@ static void spi_exchange(const uint8_t *tx_data, uint8_t 
*rx_data, unsigned int
        }
 
        if (rx_data) {
-#ifdef LOG_SPI_EXCHANGE
-               if (len != 0) {
-                       LOG_OUTPUT(" rx_buf=");
-                       for (unsigned int i = 0; i < len; i++)
-                               LOG_OUTPUT("%.2" PRIx8 " ", rx_data[i]);
-               }
-               LOG_OUTPUT("\n");
-#endif // LOG_SPI_EXCHANGE
+               LOG_CUSTOM_LEVEL_N(LOG_LVL_DEBUG_IO, " rx_buf=");
+               for (unsigned int i = 0; i < len; i++)
+                       LOG_CUSTOM_LEVEL_N(LOG_LVL_DEBUG_IO, "%.2" PRIx8 " ", 
rx_data[i]);
+
+               LOG_CUSTOM_LEVEL_N(LOG_LVL_DEBUG_IO, "\n");
 
                // Reverse MSB to LSB
                for (unsigned int i = 0; i < len; i++)

-- 

Reply via email to