[rtems commit] dev/spi-memdrv: Fix use of uninit mem_param_ptr
Sebastian Huber
sebh at rtems.org
Mon Aug 3 06:53:44 UTC 2020
Module: rtems
Branch: master
Commit: 29e7a069f8b33021799f432ff977d21a163ffafe
Changeset: http://git.rtems.org/rtems/commit/?id=29e7a069f8b33021799f432ff977d21a163ffafe
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Sat Aug 1 14:30:10 2020 +0200
dev/spi-memdrv: Fix use of uninit mem_param_ptr
---
bsps/shared/dev/i2c/spi-memdrv.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/bsps/shared/dev/i2c/spi-memdrv.c b/bsps/shared/dev/i2c/spi-memdrv.c
index 5930297..f3308e8 100644
--- a/bsps/shared/dev/i2c/spi-memdrv.c
+++ b/bsps/shared/dev/i2c/spi-memdrv.c
@@ -365,26 +365,23 @@ rtems_status_code spi_memdrv_read
rc = rtems_libi2c_send_addr(minor,TRUE);
}
- if (off >= mem_param_ptr->mem_size) {
+ if (rc == RTEMS_SUCCESSFUL) {
/*
* HACK: beyond size of memory array? then read status register instead
*/
- /*
- * send read status register command
- */
- if (rc == RTEMS_SUCCESSFUL) {
+ if (off >= mem_param_ptr->mem_size) {
+ /*
+ * send read status register command
+ */
cmdbuf[0] = SPI_MEM_CMD_RDSR;
ret_cnt = rtems_libi2c_write_bytes(minor,cmdbuf,1);
if (ret_cnt < 0) {
rc = -ret_cnt;
}
- }
- }
- else {
- /*
- * send read command and address
- */
- if (rc == RTEMS_SUCCESSFUL) {
+ } else {
+ /*
+ * send read command and address
+ */
cmdbuf[0] = SPI_MEM_CMD_READ;
if (mem_param_ptr->mem_size > 0x10000 /* 256*256 */) {
cmdbuf[1] = (off >> 16) & 0xff;
More information about the vc
mailing list