Skip to content

Commit 8be4f34

Browse files
committed
drivers: spi: spi_max32: Return proper error codes in spi_configure
spi_configure was returning HAL error codes that are incompatible with Zephyr error definitions straight back to the caller. Replace these with error codes that Zephyr can correctly interpret. Signed-off-by: Tahsin Mutlugun <Tahsin.Mutlugun@analog.com>
1 parent 14741d1 commit 8be4f34

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/spi/spi_max32.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static int spi_configure(const struct device *dev, const struct spi_config *conf
103103

104104
ret = Wrap_MXC_SPI_Init(regs, master_mode, quad_mode, num_slaves, ss_polarity, spi_speed);
105105
if (ret) {
106-
return ret;
106+
return -EINVAL;
107107
}
108108

109109
int cpol = (SPI_MODE_GET(config->operation) & SPI_MODE_CPOL) ? 1 : 0;
@@ -119,12 +119,12 @@ static int spi_configure(const struct device *dev, const struct spi_config *conf
119119
ret = MXC_SPI_SetMode(regs, SPI_MODE_0);
120120
}
121121
if (ret) {
122-
return ret;
122+
return -EINVAL;
123123
}
124124

125125
ret = MXC_SPI_SetDataSize(regs, SPI_WORD_SIZE_GET(config->operation));
126126
if (ret) {
127-
return ret;
127+
return -ENOTSUP;
128128
}
129129

130130
#if defined(CONFIG_SPI_EXTENDED_MODES)
@@ -145,7 +145,7 @@ static int spi_configure(const struct device *dev, const struct spi_config *conf
145145
}
146146

147147
if (ret) {
148-
return ret;
148+
return -EINVAL;
149149
}
150150
#endif
151151

@@ -377,7 +377,7 @@ static int transceive(const struct device *dev, const struct spi_config *config,
377377
ret = spi_configure(dev, config);
378378
if (ret != 0) {
379379
spi_context_release(ctx, ret);
380-
return -EIO;
380+
return ret;
381381
}
382382

383383
spi_context_buffers_setup(ctx, tx_bufs, rx_bufs, 1);
@@ -574,7 +574,6 @@ static int transceive_dma(const struct device *dev, const struct spi_config *con
574574

575575
ret = spi_configure(dev, config);
576576
if (ret != 0) {
577-
ret = -EIO;
578577
goto unlock;
579578
}
580579

0 commit comments

Comments
 (0)