spi: ti_qspi: Fix "spi-max-frequency" error path in ti_qspi_ofdata_to_platdata
PATCH 1/1 spi: ti_qspi: Fix "spi-max-frequency" error path in ti_qspi_ofdata_to_platdata
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.
---
drivers/spi/ti_qspi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/ti_qspi.c +2 -2
@@ -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 ; }
Signature · 1 line
2.17.1
PATCH 1/1 spi: ti_qspi: Fix "spi-max-frequency" error path in ti_qspi_ofdata_to_platdata
Quoted 4 lines · Ovidiu Panait
struct
ti_qspi_priv->max_hzis 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);
Quoted 8 lines
if (priv->max_hz < 0) { ...}
Replace the fdtdec call with
dev_read_u32_default()and use 0 as the default value. Error out ifmax_hzis zero.Signed-off-by Ovidiu Panait <[email protected]>
Applied to u-boot-ti/for-next
Thanks and regards,
Lokesh