From dc3edca5a74a09ec11029339a95b0c9562f023df Mon Sep 17 00:00:00 2001 From: Juha Niskanen Date: Thu, 31 Oct 2019 07:43:21 -0600 Subject: [PATCH] drivers/mtd/gd25.c: spi_devid argument was not used in initialization. Commit 4fc41b55b to GD25 driver was always using priv->spi_devid initialized to zero by kmm_zalloc(). This commit initializes it from the supplied function argument. --- drivers/mtd/gd25.c | 3 ++- drivers/mtd/gd5f.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/gd25.c b/drivers/mtd/gd25.c index 3163eea572..96bf5e6097 100644 --- a/drivers/mtd/gd25.c +++ b/drivers/mtd/gd25.c @@ -153,9 +153,9 @@ struct gd25_dev_s { struct mtd_dev_s mtd; /* MTD interface */ FAR struct spi_dev_s *spi; /* Saved SPI interface instance */ + uint32_t spi_devid; /* Chip select inputs */ uint16_t nsectors; /* Number of erase sectors */ uint8_t prev_instr; /* Previous instruction given to GD25 device */ - uint32_t spi_devid; /* Chip select inputs */ bool addr_4byte; /* True: Use Four-byte address */ }; @@ -975,6 +975,7 @@ FAR struct mtd_dev_s *gd25_initialize(FAR struct spi_dev_s *spi, #endif priv->mtd.name = "gd25"; priv->spi = spi; + priv->spi_devid = spi_devid; /* Deselect the FLASH */ diff --git a/drivers/mtd/gd5f.c b/drivers/mtd/gd5f.c index 896c93216f..d4a48c7584 100644 --- a/drivers/mtd/gd5f.c +++ b/drivers/mtd/gd5f.c @@ -165,11 +165,11 @@ struct gd5f_dev_s { struct mtd_dev_s mtd; /* MTD interface */ FAR struct spi_dev_s *dev; /* Saved SPI interface instance */ - uint8_t sectorshift; /* 17 */ + uint32_t spi_devid; /* Chip select inputs */ uint16_t nsectors; /* 1024 or 2048 */ + uint8_t sectorshift; /* 17 */ uint8_t pageshift; /* 11 */ uint8_t eccstatus; /* Internal ECC status */ - uint32_t spi_devid; /* Chip select inputs */ }; /************************************************************************************