Skip to content

Commit bf9b074

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 6b36211 commit bf9b074

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
@@ -108,7 +108,7 @@ static int spi_configure(const struct device *dev, const struct spi_config *conf
108108

109109
ret = Wrap_MXC_SPI_Init(regs, master_mode, quad_mode, num_slaves, ss_polarity, spi_speed);
110110
if (ret) {
111-
return ret;
111+
return -EINVAL;
112112
}
113113

114114
int cpol = (SPI_MODE_GET(config->operation) & SPI_MODE_CPOL) ? 1 : 0;
@@ -124,12 +124,12 @@ static int spi_configure(const struct device *dev, const struct spi_config *conf
124124
ret = MXC_SPI_SetMode(regs, SPI_MODE_0);
125125
}
126126
if (ret) {
127-
return ret;
127+
return -EINVAL;
128128
}
129129

130130
ret = MXC_SPI_SetDataSize(regs, SPI_WORD_SIZE_GET(config->operation));
131131
if (ret) {
132-
return ret;
132+
return -ENOTSUP;
133133
}
134134

135135
#if defined(CONFIG_SPI_EXTENDED_MODES)
@@ -150,7 +150,7 @@ static int spi_configure(const struct device *dev, const struct spi_config *conf
150150
}
151151

152152
if (ret) {
153-
return ret;
153+
return -EINVAL;
154154
}
155155
#endif
156156

@@ -390,7 +390,7 @@ static int transceive(const struct device *dev, const struct spi_config *config,
390390
ret = spi_configure(dev, config);
391391
if (ret != 0) {
392392
spi_context_release(ctx, ret);
393-
return -EIO;
393+
return ret;
394394
}
395395

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

599599
ret = spi_configure(dev, config);
600600
if (ret != 0) {
601-
ret = -EIO;
602601
goto unlock;
603602
}
604603

0 commit comments

Comments
 (0)