Skip to content

Commit

Permalink
drivers: i2s_mcux_sai: use sai_sync_mode directly
Browse files Browse the repository at this point in the history
Simplify some code by using the sai_sync_mode_t type directly instead of
converting from boolean

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
  • Loading branch information
decsny authored and kartben committed Jan 9, 2025
1 parent cd334be commit 6cbba80
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions drivers/i2s/i2s_mcux_sai.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ struct i2s_mcux_config {
const struct device *ccm_dev;
const struct pinctrl_dev_config *pinctrl;
void (*irq_connect)(const struct device *dev);
bool rx_sync_mode;
bool tx_sync_mode;
sai_sync_mode_t rx_sync_mode;
sai_sync_mode_t tx_sync_mode;
};

/* Device run time data */
Expand Down Expand Up @@ -562,19 +562,9 @@ static int i2s_mcux_config(const struct device *dev, enum i2s_dir dir,

/* sync mode configurations */
if (dir == I2S_DIR_TX) {
/* TX */
if (dev_cfg->tx_sync_mode) {
config.syncMode = kSAI_ModeSync;
} else {
config.syncMode = kSAI_ModeAsync;
}
} else {
/* RX */
if (dev_cfg->rx_sync_mode) {
config.syncMode = kSAI_ModeSync;
} else {
config.syncMode = kSAI_ModeAsync;
}
config.syncMode = dev_cfg->tx_sync_mode;
} else if (dir == I2S_DIR_RX) {
config.syncMode = dev_cfg->rx_sync_mode;
}

if (i2s_cfg->options & I2S_OPT_FRAME_CLK_SLAVE) {
Expand Down Expand Up @@ -1191,8 +1181,10 @@ static DEVICE_API(i2s, i2s_mcux_driver_api) = {
.ccm_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(i2s_id)), \
.irq_connect = i2s_irq_connect_##i2s_id, \
.pinctrl = PINCTRL_DT_INST_DEV_CONFIG_GET(i2s_id), \
.tx_sync_mode = DT_INST_PROP(i2s_id, nxp_tx_sync_mode), \
.rx_sync_mode = DT_INST_PROP(i2s_id, nxp_rx_sync_mode), \
.tx_sync_mode = \
DT_INST_PROP(i2s_id, nxp_tx_sync_mode) ? kSAI_ModeSync : kSAI_ModeAsync, \
.rx_sync_mode = \
DT_INST_PROP(i2s_id, nxp_rx_sync_mode) ? kSAI_ModeSync : kSAI_ModeAsync, \
.tx_channel = DT_INST_PROP(i2s_id, nxp_tx_channel), \
}; \
\
Expand Down

0 comments on commit 6cbba80

Please sign in to comment.