Skip to content

Commit 1714582

Browse files
yopebroonie
authored andcommitted
spi: Move ctlr->cur_msg_prepared to struct spi_message
This enables the possibility to transfer a message that is not at the current tip of the async message queue. This is in preparation of the next patch(es) which enable spi_sync messages to skip the queue altogether. Signed-off-by: David Jander <david@protonic.nl> Link: https://lore.kernel.org/r/20220621061234.3626638-2-david@protonic.nl Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 40308f9 commit 1714582

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

drivers/spi/spi.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,7 +1684,7 @@ static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread)
16841684
spi_finalize_current_message(ctlr);
16851685
goto out;
16861686
}
1687-
ctlr->cur_msg_prepared = true;
1687+
msg->prepared = true;
16881688
}
16891689

16901690
ret = spi_map_msg(ctlr, msg);
@@ -1926,17 +1926,18 @@ void spi_finalize_current_message(struct spi_controller *ctlr)
19261926
*/
19271927
spi_res_release(ctlr, mesg);
19281928

1929-
if (ctlr->cur_msg_prepared && ctlr->unprepare_message) {
1929+
if (mesg->prepared && ctlr->unprepare_message) {
19301930
ret = ctlr->unprepare_message(ctlr, mesg);
19311931
if (ret) {
19321932
dev_err(&ctlr->dev, "failed to unprepare message: %d\n",
19331933
ret);
19341934
}
19351935
}
19361936

1937+
mesg->prepared = false;
1938+
19371939
spin_lock_irqsave(&ctlr->queue_lock, flags);
19381940
ctlr->cur_msg = NULL;
1939-
ctlr->cur_msg_prepared = false;
19401941
ctlr->fallback = false;
19411942
kthread_queue_work(ctlr->kworker, &ctlr->pump_messages);
19421943
spin_unlock_irqrestore(&ctlr->queue_lock, flags);

include/linux/spi/spi.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,6 @@ extern struct spi_device *spi_new_ancillary_device(struct spi_device *spi, u8 ch
385385
* @queue: message queue
386386
* @idling: the device is entering idle state
387387
* @cur_msg: the currently in-flight message
388-
* @cur_msg_prepared: spi_prepare_message was called for the currently
389-
* in-flight message
390388
* @cur_msg_mapped: message has been mapped for DMA
391389
* @last_cs: the last chip_select that is recorded by set_cs, -1 on non chip
392390
* selected
@@ -621,7 +619,6 @@ struct spi_controller {
621619
bool running;
622620
bool rt;
623621
bool auto_runtime_pm;
624-
bool cur_msg_prepared;
625622
bool cur_msg_mapped;
626623
char last_cs;
627624
bool last_cs_mode_high;
@@ -988,6 +985,7 @@ struct spi_transfer {
988985
* @queue: for use by whichever driver currently owns the message
989986
* @state: for use by whichever driver currently owns the message
990987
* @resources: for resource management when the spi message is processed
988+
* @prepared: spi_prepare_message was called for the this message
991989
*
992990
* A @spi_message is used to execute an atomic sequence of data transfers,
993991
* each represented by a struct spi_transfer. The sequence is "atomic"
@@ -1037,6 +1035,9 @@ struct spi_message {
10371035

10381036
/* list of spi_res reources when the spi message is processed */
10391037
struct list_head resources;
1038+
1039+
/* spi_prepare_message was called for this message */
1040+
bool prepared;
10401041
};
10411042

10421043
static inline void spi_message_init_no_memset(struct spi_message *m)

0 commit comments

Comments
 (0)