@@ -1143,6 +1143,21 @@ static void __spi_pump_messages(struct spi_master *master, bool in_kthread)
trace_spi_message_start(master->cur_msg);
+ /* under some circumstances (i.e: when queuing a message) this
+ * could get moved to a separate thread to reduce latencies
+ * this could also handle the mapping of spi_transfers
+ */
+ if (master->translate_message) {
+ ret = master->translate_message(master, master->cur_msg);
+ if (ret) {
+ dev_err(&master->dev,
+ "failed to translate message: %d\n", ret);
+ master->cur_msg->status = ret;
+ spi_finalize_current_message(master);
+ return;
+ }
+ }
+
if (master->prepare_message) {
ret = master->prepare_message(master, master->cur_msg);
if (ret) {
@@ -363,6 +363,8 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
* @handle_err: the subsystem calls the driver to handle an error that occurs
* in the generic implementation of transfer_one_message().
* @unprepare_message: undo any work done by prepare_message().
+ * @translate_message: apply some message translations to optimize for the
+ * spi_master
* @cs_gpios: Array of GPIOs to use as chip select lines; one per CS
* number. Any individual value may be -ENOENT for CS lines that
* are not GPIOs (driven by the SPI controller itself).
@@ -509,6 +511,8 @@ struct spi_master {
struct spi_message *message);
int (*unprepare_message)(struct spi_master *master,
struct spi_message *message);
+ int (*translate_message)(struct spi_master *master,
+ struct spi_message *message);
/*
* These hooks are for drivers that use a generic implementation