From 755bdf80c696832d3c1ba9d0077650e09431aada Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Mon, 28 Aug 2023 08:40:51 +0000 Subject: [PATCH] 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 --- drivers/flash/spi_nor.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/flash/spi_nor.c b/drivers/flash/spi_nor.c index f4b74451acf..c0d67af7250 100644 --- a/drivers/flash/spi_nor.c +++ b/drivers/flash/spi_nor.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -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 @@ -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)