Skip to content

Commit

Permalink
drivers: flash: spi_nor: fix build when a reset gpio is present
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
fabiobaltieri authored and carlescufi committed Aug 28, 2023
1 parent 0fbbe02 commit 755bdf8
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions drivers/flash/spi_nor.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <errno.h>
#include <zephyr/drivers/flash.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/spi.h>
#include <zephyr/init.h>
#include <string.h>
Expand Down Expand Up @@ -1149,19 +1150,17 @@ static int spi_nor_configure(const struct device *dev)
}

#if DT_INST_NODE_HAS_PROP(0, reset_gpios)
if (cfg->reset) {
if (!device_is_ready(cfg->reset->port)) {
LOG_ERR("Reset pin not ready");
return -ENODEV;
}
if (gpio_pin_configure_dt(cfg->reset, GPIO_OUTPUT_ACTIVE)) {
LOG_ERR("Couldn't configure reset pin");
return -ENODEV;
}
rc = gpio_pin_set_dt(cfg->reset, 0);
if (rc) {
return rc;
}
if (!gpio_is_ready_dt(&cfg->reset)) {
LOG_ERR("Reset pin not ready");
return -ENODEV;
}
if (gpio_pin_configure_dt(&cfg->reset, GPIO_OUTPUT_ACTIVE)) {
LOG_ERR("Couldn't configure reset pin");
return -ENODEV;
}
rc = gpio_pin_set_dt(&cfg->reset, 0);
if (rc) {
return rc;
}
#endif

Expand Down Expand Up @@ -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),
CONFIG_SPI_NOR_CS_WAIT_DELAY),
#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

#if !defined(CONFIG_SPI_NOR_SFDP_RUNTIME)
Expand Down

0 comments on commit 755bdf8

Please sign in to comment.