drivers: flash: spi_nor: fix build when a reset gpio is present
Fix a few issues with the reset-gpio functionality in spi_nor, missing header, missing semicolon, unnecessary and not working condition on a struct field that is not a pointer. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit is contained in:
parent
0fbbe02f07
commit
755bdf80c6
1 changed files with 13 additions and 14 deletions
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <zephyr/drivers/flash.h>
|
#include <zephyr/drivers/flash.h>
|
||||||
|
#include <zephyr/drivers/gpio.h>
|
||||||
#include <zephyr/drivers/spi.h>
|
#include <zephyr/drivers/spi.h>
|
||||||
#include <zephyr/init.h>
|
#include <zephyr/init.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -1149,20 +1150,18 @@ static int spi_nor_configure(const struct device *dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DT_INST_NODE_HAS_PROP(0, reset_gpios)
|
#if DT_INST_NODE_HAS_PROP(0, reset_gpios)
|
||||||
if (cfg->reset) {
|
if (!gpio_is_ready_dt(&cfg->reset)) {
|
||||||
if (!device_is_ready(cfg->reset->port)) {
|
|
||||||
LOG_ERR("Reset pin not ready");
|
LOG_ERR("Reset pin not ready");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
if (gpio_pin_configure_dt(cfg->reset, GPIO_OUTPUT_ACTIVE)) {
|
if (gpio_pin_configure_dt(&cfg->reset, GPIO_OUTPUT_ACTIVE)) {
|
||||||
LOG_ERR("Couldn't configure reset pin");
|
LOG_ERR("Couldn't configure reset pin");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
rc = gpio_pin_set_dt(cfg->reset, 0);
|
rc = gpio_pin_set_dt(&cfg->reset, 0);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* After a soft-reset the flash might be in DPD or busy writing/erasing.
|
/* After a soft-reset the flash might be in DPD or busy writing/erasing.
|
||||||
|
@ -1427,7 +1426,7 @@ static const struct spi_nor_config spi_nor_config_0 = {
|
||||||
.spi = SPI_DT_SPEC_INST_GET(0, SPI_WORD_SET(8),
|
.spi = SPI_DT_SPEC_INST_GET(0, SPI_WORD_SET(8),
|
||||||
CONFIG_SPI_NOR_CS_WAIT_DELAY),
|
CONFIG_SPI_NOR_CS_WAIT_DELAY),
|
||||||
#if DT_INST_NODE_HAS_PROP(0, reset_gpios)
|
#if DT_INST_NODE_HAS_PROP(0, reset_gpios)
|
||||||
.reset = GPIO_DT_SPEC_INST_GET(0, reset_gpios)
|
.reset = GPIO_DT_SPEC_INST_GET(0, reset_gpios),
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(CONFIG_SPI_NOR_SFDP_RUNTIME)
|
#if !defined(CONFIG_SPI_NOR_SFDP_RUNTIME)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue