Skip to content

Commit 452f2b1

Browse files
quytranpzzdkalowsk
authored andcommitted
drivers: spi: Update unsupported bit width in SPI driver
Add condition to check the unsupported bit width for Renesas RA spi and spi_b driver Signed-off-by: Quy Tran <[email protected]>
1 parent dbdfd96 commit 452f2b1

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

drivers/spi/spi_b_renesas_ra8.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ static int ra_spi_b_configure(const struct device *dev, const struct spi_config
8686
{
8787
struct ra_spi_data *data = dev->data;
8888
fsp_err_t fsp_err;
89+
uint8_t word_size = SPI_WORD_SIZE_GET(config->operation);
8990

9091
if (spi_context_configured(&data->ctx, config)) {
9192
/* Nothing to do */
@@ -100,6 +101,11 @@ static int ra_spi_b_configure(const struct device *dev, const struct spi_config
100101
return -ENOTSUP;
101102
}
102103

104+
if (word_size < 4 || word_size > 32) {
105+
LOG_ERR("Unsupported SPI word size: %u", word_size);
106+
return -ENOTSUP;
107+
}
108+
103109
if (config->operation & SPI_OP_MODE_SLAVE) {
104110
data->fsp_config.operating_mode = SPI_MODE_SLAVE;
105111
} else {

drivers/spi/spi_renesas_ra.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ static int ra_spi_configure(const struct device *dev, const struct spi_config *c
8282
{
8383
struct ra_spi_data *data = dev->data;
8484
fsp_err_t fsp_err;
85+
uint8_t word_size = SPI_WORD_SIZE_GET(config->operation);
8586

8687
if (spi_context_configured(&data->ctx, config)) {
8788
/* Nothing to do */
@@ -96,6 +97,12 @@ static int ra_spi_configure(const struct device *dev, const struct spi_config *c
9697
return -ENOTSUP;
9798
}
9899

100+
if (!((word_size >= 8 && word_size <= 16) || word_size == 20 || word_size == 24 ||
101+
word_size == 32)) {
102+
LOG_ERR("Unsupported SPI word size: %u", word_size);
103+
return -ENOTSUP;
104+
}
105+
99106
if (config->operation & SPI_OP_MODE_SLAVE) {
100107
data->fsp_config.operating_mode = SPI_MODE_SLAVE;
101108
} else {

0 commit comments

Comments
 (0)