Skip to content

Commit

Permalink
spi: Use an abbreviated pointer to ctlr->cur_msg in __spi_pump_messages
Browse files Browse the repository at this point in the history
This helps a bit with line fitting now (the list_first_entry call) as
well as during the next patch which needs to iterate through all
transfers of ctlr->cur_msg so it timestamps them.

Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Link: https://lore.kernel.org/r/20190905010114.26718-2-olteanv@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Vladimir Oltean authored and Mark Brown committed Sep 5, 2019
1 parent a0ce1fd commit d1c44c9
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions drivers/spi/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1265,8 +1265,9 @@ EXPORT_SYMBOL_GPL(spi_finalize_current_transfer);
*/
static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread)
{
unsigned long flags;
struct spi_message *msg;
bool was_busy = false;
unsigned long flags;
int ret;

/* Lock queue */
Expand Down Expand Up @@ -1325,10 +1326,10 @@ static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread)
}

/* Extract head of queue */
ctlr->cur_msg =
list_first_entry(&ctlr->queue, struct spi_message, queue);
msg = list_first_entry(&ctlr->queue, struct spi_message, queue);
ctlr->cur_msg = msg;

list_del_init(&ctlr->cur_msg->queue);
list_del_init(&msg->queue);
if (ctlr->busy)
was_busy = true;
else
Expand Down Expand Up @@ -1361,36 +1362,36 @@ static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread)
if (ctlr->auto_runtime_pm)
pm_runtime_put(ctlr->dev.parent);

ctlr->cur_msg->status = ret;
msg->status = ret;
spi_finalize_current_message(ctlr);

mutex_unlock(&ctlr->io_mutex);
return;
}
}

trace_spi_message_start(ctlr->cur_msg);
trace_spi_message_start(msg);

if (ctlr->prepare_message) {
ret = ctlr->prepare_message(ctlr, ctlr->cur_msg);
ret = ctlr->prepare_message(ctlr, msg);
if (ret) {
dev_err(&ctlr->dev, "failed to prepare message: %d\n",
ret);
ctlr->cur_msg->status = ret;
msg->status = ret;
spi_finalize_current_message(ctlr);
goto out;
}
ctlr->cur_msg_prepared = true;
}

ret = spi_map_msg(ctlr, ctlr->cur_msg);
ret = spi_map_msg(ctlr, msg);
if (ret) {
ctlr->cur_msg->status = ret;
msg->status = ret;
spi_finalize_current_message(ctlr);
goto out;
}

ret = ctlr->transfer_one_message(ctlr, ctlr->cur_msg);
ret = ctlr->transfer_one_message(ctlr, msg);
if (ret) {
dev_err(&ctlr->dev,
"failed to transfer one message from queue\n");
Expand Down

0 comments on commit d1c44c9

Please sign in to comment.