Set the spi_device pointer accordingly to allow drivers to use it.

While on it, set the actual_length to 0 before passing the message to
the .transfer() hook as well.

Signed-off-by: Marco Felsch <[email protected]>
---
Changelog:
v2:
 - no changes

 drivers/spi/spi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index c627d88954a7..36d0653a191c 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -321,6 +321,8 @@ static int __spi_validate(struct spi_device *spi, struct 
spi_message *message)
        if (list_empty(&message->transfers))
                return -EINVAL;
 
+       message->spi = spi;
+
        list_for_each_entry(xfer, &message->transfers, transfer_list) {
                if (!xfer->bits_per_word)
                        xfer->bits_per_word = spi->bits_per_word;
@@ -347,6 +349,7 @@ static int __spi_validate(struct spi_device *spi, struct 
spi_message *message)
                        return -EINVAL;
        }
 
+       message->actual_length = 0;
        message->status = -EINPROGRESS;
 
        return 0;
-- 
2.39.5


Reply via email to