All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] spi: soft_spi: Fix data abort if slave is not probed
@ 2019-08-02 13:46 Patrice Chotard
  2019-09-06 18:37 ` Jagan Teki
  0 siblings, 1 reply; 2+ messages in thread
From: Patrice Chotard @ 2019-08-02 13:46 UTC (permalink / raw)
  To: u-boot

From: Christophe Kerello <christophe.kerello@st.com>

In case spi_get_bus_and_cs callback is used, spi bus is first probed
then slave devices are probed. To avoid a data abort in soft_spi probe
function, we need to check that (slave != NULL).

If slave is NULL, cs_flags and clk_flags will be initialized with
respectively GPIOD_ACTIVE_LOW and 0.

Signed-off-by: Christophe Kerello <christophe.kerello@st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---

 drivers/spi/soft_spi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/soft_spi.c b/drivers/spi/soft_spi.c
index b06883f9d0..b80f810bd1 100644
--- a/drivers/spi/soft_spi.c
+++ b/drivers/spi/soft_spi.c
@@ -215,8 +215,8 @@ static int soft_spi_probe(struct udevice *dev)
 	int cs_flags, clk_flags;
 	int ret;
 
-	cs_flags = (slave->mode & SPI_CS_HIGH) ? 0 : GPIOD_ACTIVE_LOW;
-	clk_flags = (slave->mode & SPI_CPOL) ? GPIOD_ACTIVE_LOW : 0;
+	cs_flags = (slave && slave->mode & SPI_CS_HIGH) ? 0 : GPIOD_ACTIVE_LOW;
+	clk_flags = (slave && slave->mode & SPI_CPOL) ? GPIOD_ACTIVE_LOW : 0;
 
 	if (gpio_request_by_name(dev, "cs-gpios", 0, &plat->cs,
 				 GPIOD_IS_OUT | cs_flags) ||
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH] spi: soft_spi: Fix data abort if slave is not probed
  2019-08-02 13:46 [U-Boot] [PATCH] spi: soft_spi: Fix data abort if slave is not probed Patrice Chotard
@ 2019-09-06 18:37 ` Jagan Teki
  0 siblings, 0 replies; 2+ messages in thread
From: Jagan Teki @ 2019-09-06 18:37 UTC (permalink / raw)
  To: u-boot

On Fri, Aug 2, 2019 at 7:16 PM Patrice Chotard <patrice.chotard@st.com> wrote:
>
> From: Christophe Kerello <christophe.kerello@st.com>
>
> In case spi_get_bus_and_cs callback is used, spi bus is first probed
> then slave devices are probed. To avoid a data abort in soft_spi probe
> function, we need to check that (slave != NULL).
>
> If slave is NULL, cs_flags and clk_flags will be initialized with
> respectively GPIOD_ACTIVE_LOW and 0.
>
> Signed-off-by: Christophe Kerello <christophe.kerello@st.com>
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> ---

Applied to u-boot-spi/master

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-09-06 18:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-02 13:46 [U-Boot] [PATCH] spi: soft_spi: Fix data abort if slave is not probed Patrice Chotard
2019-09-06 18:37 ` Jagan Teki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.