Skip to content

Commit 3993a73

Browse files
titouanccfriedt
authored andcommitted
drivers: i2s: ll_stm32: fix missing implementation for i2s_config_get
This fixes system crashes in `i2s_buf_write`, because this function internally calls `i2s_config_get`, which resulted in a NULL pointer on stm32 i2s devices. Signed-off-by: Titouan Christophe <[email protected]>
1 parent 676673f commit 3993a73

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

drivers/i2s/i2s_ll_stm32.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,25 @@ static int i2s_stm32_configure(const struct device *dev, enum i2s_dir dir,
284284
return 0;
285285
}
286286

287+
static const struct i2s_config *i2s_stm32_config_get(const struct device *dev,
288+
enum i2s_dir dir)
289+
{
290+
struct i2s_stm32_data *const dev_data = dev->data;
291+
struct stream *stream = NULL;
292+
293+
if (dir == I2S_DIR_RX) {
294+
stream = &dev_data->rx;
295+
} else if (dir == I2S_DIR_TX) {
296+
stream = &dev_data->tx;
297+
}
298+
299+
if (stream != NULL && stream->state != I2S_STATE_NOT_READY) {
300+
return &stream->cfg;
301+
}
302+
303+
return NULL;
304+
}
305+
287306
static int i2s_stm32_trigger(const struct device *dev, enum i2s_dir dir,
288307
enum i2s_trigger_cmd cmd)
289308
{
@@ -441,6 +460,7 @@ static int i2s_stm32_write(const struct device *dev, void *mem_block,
441460

442461
static DEVICE_API(i2s, i2s_stm32_driver_api) = {
443462
.configure = i2s_stm32_configure,
463+
.config_get = i2s_stm32_config_get,
444464
.read = i2s_stm32_read,
445465
.write = i2s_stm32_write,
446466
.trigger = i2s_stm32_trigger,

0 commit comments

Comments
 (0)