All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spi: ti_qspi: Fix "spi-max-frequency" error path in ti_qspi_ofdata_to_platdata
@ 2020-11-28  8:11 Ovidiu Panait
  2020-12-23  8:15 ` Lokesh Vutla
  0 siblings, 1 reply; 2+ messages in thread
From: Ovidiu Panait @ 2020-11-28  8:11 UTC (permalink / raw)
  To: u-boot

struct ti_qspi_priv->max_hz is declared as unsigned int, so the following
error path check will always be false, even when "spi-max-frequency"
property is invalid/missing:
  priv->max_hz = fdtdec_get_int(blob, node, "spi-max-frequency", -1);
  if (priv->max_hz < 0) {
    ...
  }

Replace the fdtdec call with dev_read_u32_default() and use 0 as the
default value. Error out if max_hz is zero.

Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
---

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

diff --git a/drivers/spi/ti_qspi.c b/drivers/spi/ti_qspi.c
index 5fdbb49442..91be18e0a7 100644
--- a/drivers/spi/ti_qspi.c
+++ b/drivers/spi/ti_qspi.c
@@ -467,8 +467,8 @@ static int ti_qspi_ofdata_to_platdata(struct udevice *bus)
 	priv->memory_map = map_physmem(mmap_addr, mmap_size, MAP_NOCACHE);
 	priv->mmap_size = mmap_size;
 
-	priv->max_hz = fdtdec_get_int(blob, node, "spi-max-frequency", -1);
-	if (priv->max_hz < 0) {
+	priv->max_hz = dev_read_u32_default(bus, "spi-max-frequency", 0);
+	if (!priv->max_hz) {
 		debug("Error: Max frequency missing\n");
 		return -ENODEV;
 	}
-- 
2.17.1

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

* [PATCH] spi: ti_qspi: Fix "spi-max-frequency" error path in ti_qspi_ofdata_to_platdata
  2020-11-28  8:11 [PATCH] spi: ti_qspi: Fix "spi-max-frequency" error path in ti_qspi_ofdata_to_platdata Ovidiu Panait
@ 2020-12-23  8:15 ` Lokesh Vutla
  0 siblings, 0 replies; 2+ messages in thread
From: Lokesh Vutla @ 2020-12-23  8:15 UTC (permalink / raw)
  To: u-boot



On 28/11/20 1:41 pm, Ovidiu Panait wrote:
> struct ti_qspi_priv->max_hz is declared as unsigned int, so the following
> error path check will always be false, even when "spi-max-frequency"
> property is invalid/missing:
>   priv->max_hz = fdtdec_get_int(blob, node, "spi-max-frequency", -1);
>   if (priv->max_hz < 0) {
>     ...
>   }
> 
> Replace the fdtdec call with dev_read_u32_default() and use 0 as the
> default value. Error out if max_hz is zero.
> 
> Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>


Applied to u-boot-ti/for-next

Thanks and regards,
Lokesh

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

end of thread, other threads:[~2020-12-23  8:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-28  8:11 [PATCH] spi: ti_qspi: Fix "spi-max-frequency" error path in ti_qspi_ofdata_to_platdata Ovidiu Panait
2020-12-23  8:15 ` Lokesh Vutla

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.