From: Martin Sperl <kernel@xxxxxxxxxxxxxxxx> Add a warning about a potential cleanup inconsistency when both prepare_message and unprepare_message are defined by the bus driver and prepare_message is using spi_res_add. Signed-off-by: Martin Sperl <kernel@xxxxxxxxxxxxxxxx> --- drivers/spi/spi.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 1dfb19140bbe..78fe46bf6f41 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1317,6 +1317,7 @@ static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread) trace_spi_message_start(ctlr->cur_msg); if (ctlr->prepare_message) { + struct list_head *tail = ctlr->cur_msg->resources.prev; ret = ctlr->prepare_message(ctlr, ctlr->cur_msg); if (ret) { dev_err(&ctlr->dev, "failed to prepare message: %d\n", @@ -1325,6 +1326,11 @@ static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread) spi_finalize_current_message(ctlr); goto out; } + /* warn about possible issues on finalize */ + if (ctlr->unprepare_message && + tail != ctlr->cur_msg->resources.prev) + dev_warn_once(&ctlr->dev, + "spi_message.resource is modified and unprepare_message is defined - this can give unexpected results during finalize\n"); ctlr->cur_msg_prepared = true; } -- 2.11.0