@@ -166,7 +166,7 @@ extern void esp_panic_handler_feed_wdts(void);
166166static int spi_out_init_trans (spi_out_trans_cb_t * * trans_cb , uint16_t buf_size );
167167static void spi_out_deinit_trans (spi_out_trans_cb_t * * trans_cb );
168168static void spi_out_tx_done_cb (spi_transaction_t * ret_trans );
169- static inline int spi_out_append_trans (spi_out_trans_cb_t * trans_cb );
169+ static inline void spi_out_append_trans (spi_out_trans_cb_t * trans_cb );
170170
171171static int spi_out_log_cb_init (spi_out_log_cb_t * * log_cb , uint16_t buf_size , uint8_t type );
172172static void spi_out_log_cb_deinit (spi_out_log_cb_t * * log_cb );
@@ -282,30 +282,30 @@ IRAM_ATTR static void spi_out_pre_tx_cb(spi_transaction_t *ret_trans)
282282 while (esp_timer_get_time () - last_tx_done_ts < SPI_OUT_TRANS_ITVL_MIN_US ) {}
283283}
284284
285- IRAM_ATTR static inline int spi_out_append_trans (spi_out_trans_cb_t * trans_cb )
285+ IRAM_ATTR static inline void spi_out_append_trans (spi_out_trans_cb_t * trans_cb )
286286{
287287 if (trans_cb -> flag != TRANS_CB_FLAG_NEED_QUEUE || !trans_cb -> length ) {
288- return -1 ;
288+ return ;
289289 }
290290
291291 // Note: To support dump log when disabled
292292 if (!spi_out_enabled ) {
293- trans_cb -> length = 0 ;
294- trans_cb -> flag = TRANS_CB_FLAG_AVAILABLE ;
295- return 0 ;
293+ goto recycle ;
296294 }
297295
298296 // CRITICAL: Length unit conversion from bytes to bits
299297 trans_cb -> trans .length = trans_cb -> length * 8 ;
300298 trans_cb -> trans .rxlength = 0 ;
301- if (spi_device_queue_trans (spi_handle , & (trans_cb -> trans ), 0 ) == ESP_OK ) {
302- trans_cb -> flag = TRANS_CB_FLAG_IN_QUEUE ;
303- return 0 ;
304- } else {
305- trans_cb -> length = 0 ;
306- trans_cb -> flag = TRANS_CB_FLAG_AVAILABLE ;
307- return -1 ;
299+ trans_cb -> flag = TRANS_CB_FLAG_IN_QUEUE ;
300+ if (spi_device_queue_trans (spi_handle , & (trans_cb -> trans ), 0 ) != ESP_OK ) {
301+ goto recycle ;
308302 }
303+ return ;
304+
305+ recycle :
306+ trans_cb -> length = 0 ;
307+ trans_cb -> flag = TRANS_CB_FLAG_AVAILABLE ;
308+ return ;
309309}
310310
311311static int spi_out_log_cb_init (spi_out_log_cb_t * * log_cb , uint16_t buf_size , uint8_t type )
@@ -360,7 +360,7 @@ IRAM_ATTR static inline bool spi_out_log_cb_check_trans(spi_out_log_cb_t *log_cb
360360 goto failed ;
361361 }
362362 if (trans_cb -> flag == TRANS_CB_FLAG_AVAILABLE ) {
363- if ((trans_cb -> buf_size - trans_cb -> length ) >= ( len + SPI_OUT_FRAME_OVERHEAD ) ) {
363+ if ((trans_cb -> buf_size - trans_cb -> length ) >= frame_len ) {
364364 return true;
365365 } else {
366366 trans_cb -> flag = TRANS_CB_FLAG_NEED_QUEUE ;
0 commit comments