When dm_spi_claim_bus() claims a bus, sometimes plat->mode and/or
plat->max_hz have not been copied to the priv object yet. This can lead
to an SPI bus malfunction.

To fix this, use the object returned by dev_get_parent_plat() instead,
which is set by spi_slave_of_to_plat() on spi_child_post_bind().

Signed-off-by: Hironori KIKUCHI <[email protected]>
---
 drivers/spi/spi-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
index d604975374..0b3f29b6d8 100644
--- a/drivers/spi/spi-uclass.c
+++ b/drivers/spi/spi-uclass.c
@@ -54,7 +54,7 @@ int dm_spi_claim_bus(struct udevice *dev)
        struct udevice *bus = dev->parent;
        struct dm_spi_ops *ops = spi_get_ops(bus);
        struct dm_spi_bus *spi = dev_get_uclass_priv(bus);
-       struct spi_slave *slave = dev_get_parent_priv(dev);
+       struct dm_spi_slave_plat *slave = dev_get_parent_plat(dev);
        uint speed, mode;
 
        speed = slave->max_hz;
-- 
2.47.1

Reply via email to