samples: drivers: espi: Ensure sample code thread exits

Fix #32457 by decreasing iterations on failure too.

Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
This commit is contained in:
Jose Alberto Meza 2021-04-13 12:40:20 -07:00 committed by Anas Nashif
commit 11cb2e5ec6
2 changed files with 8 additions and 6 deletions

View file

@ -45,6 +45,7 @@ struct thread_context {
}; };
static struct thread_context context; static struct thread_context context;
static bool need_temp;
#endif #endif
static struct espi_oob_packet resp_pckt; static struct espi_oob_packet resp_pckt;
@ -164,8 +165,6 @@ void oob_rx_handler(const struct device *dev, struct espi_callback *cb,
} }
bool need_temp;
void temperature_timer(struct k_timer *timer_id) void temperature_timer(struct k_timer *timer_id)
{ {
LOG_WRN("%s", __func__); LOG_WRN("%s", __func__);
@ -196,19 +195,23 @@ void espihub_thread(void *p1, void *p2, void *p3)
LOG_ERR("Incorrect size response"); LOG_ERR("Incorrect size response");
} }
context.cycles--;
break; break;
default: default:
LOG_INF("Other host sender %x", sender); LOG_INF("Other host sender %x", sender);
} }
} else {
LOG_ERR("Failure to retrieve temp %d", ret);
} }
/* Decrease cycles in both cases failure/success */
context.cycles--;
if (need_temp) { if (need_temp) {
request_temp(context.espi_dev); request_temp(context.espi_dev);
need_temp = false; need_temp = false;
} }
} }
k_timer_stop(&temp_timer); k_timer_stop(&temp_timer);
} }
#endif /* CONFIG_ESPI_OOB_CHANNEL_RX_ASYNC */ #endif /* CONFIG_ESPI_OOB_CHANNEL_RX_ASYNC */

View file

@ -14,9 +14,8 @@
#include <drivers/spi.h> #include <drivers/spi.h>
#include <logging/log_ctrl.h> #include <logging/log_ctrl.h>
#include <logging/log.h> #include <logging/log.h>
#ifdef CONFIG_ESPI_OOB_CHANNEL /* OOB operations will be attempted regardless of channel enabled or not */
#include "espi_oob_handler.h" #include "espi_oob_handler.h"
#endif
LOG_MODULE_DECLARE(espi, CONFIG_ESPI_LOG_LEVEL); LOG_MODULE_DECLARE(espi, CONFIG_ESPI_LOG_LEVEL);
/* eSPI flash parameters */ /* eSPI flash parameters */