Skip to content

Commit cd334be

Browse files
decsnykartben
authored andcommitted
drivers: i2s_mcux_sai: optimize purge_stream
There's no need to put an if before i2s_purge_stream_buffers, because this is handled already by the boolean values entered to the function Also remove the inline of the function, which allowed the compiler to make optimizations and save some bytes. Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
1 parent 693abfe commit cd334be

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

drivers/i2s/i2s_mcux_sai.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ struct i2s_dev_data {
117117
void *rx_out_msgs[CONFIG_I2S_RX_BLOCK_COUNT];
118118
};
119119

120-
static inline void i2s_purge_stream_buffers(struct stream *strm, struct k_mem_slab *mem_slab,
121-
bool in_drop, bool out_drop)
120+
static void i2s_purge_stream_buffers(struct stream *strm, struct k_mem_slab *mem_slab, bool in_drop,
121+
bool out_drop)
122122
{
123123
void *buffer;
124124

@@ -167,9 +167,7 @@ static void i2s_tx_stream_disable(const struct device *dev, bool drop)
167167
}
168168

169169
/* purge buffers queued in the stream */
170-
if (drop) {
171-
i2s_purge_stream_buffers(strm, dev_data->tx.cfg.mem_slab, true, true);
172-
}
170+
i2s_purge_stream_buffers(strm, dev_data->tx.cfg.mem_slab, drop, drop);
173171
}
174172

175173
static void i2s_rx_stream_disable(const struct device *dev, bool in_drop, bool out_drop)
@@ -200,9 +198,7 @@ static void i2s_rx_stream_disable(const struct device *dev, bool in_drop, bool o
200198
dev_cfg->base->RCSR &= ~I2S_RCSR_SR_MASK;
201199

202200
/* purge buffers queued in the stream */
203-
if (in_drop || out_drop) {
204-
i2s_purge_stream_buffers(strm, dev_data->rx.cfg.mem_slab, in_drop, out_drop);
205-
}
201+
i2s_purge_stream_buffers(strm, dev_data->rx.cfg.mem_slab, in_drop, out_drop);
206202
}
207203

208204
static int i2s_tx_reload_multiple_dma_blocks(const struct device *dev, uint8_t *blocks_queued)

0 commit comments

Comments
 (0)