Skip to content

Commit 6cbba80

Browse files
decsnykartben
authored andcommitted
drivers: i2s_mcux_sai: use sai_sync_mode directly
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>
1 parent cd334be commit 6cbba80

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

drivers/i2s/i2s_mcux_sai.c

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ struct i2s_mcux_config {
102102
const struct device *ccm_dev;
103103
const struct pinctrl_dev_config *pinctrl;
104104
void (*irq_connect)(const struct device *dev);
105-
bool rx_sync_mode;
106-
bool tx_sync_mode;
105+
sai_sync_mode_t rx_sync_mode;
106+
sai_sync_mode_t tx_sync_mode;
107107
};
108108

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

563563
/* sync mode configurations */
564564
if (dir == I2S_DIR_TX) {
565-
/* TX */
566-
if (dev_cfg->tx_sync_mode) {
567-
config.syncMode = kSAI_ModeSync;
568-
} else {
569-
config.syncMode = kSAI_ModeAsync;
570-
}
571-
} else {
572-
/* RX */
573-
if (dev_cfg->rx_sync_mode) {
574-
config.syncMode = kSAI_ModeSync;
575-
} else {
576-
config.syncMode = kSAI_ModeAsync;
577-
}
565+
config.syncMode = dev_cfg->tx_sync_mode;
566+
} else if (dir == I2S_DIR_RX) {
567+
config.syncMode = dev_cfg->rx_sync_mode;
578568
}
579569

580570
if (i2s_cfg->options & I2S_OPT_FRAME_CLK_SLAVE) {
@@ -1191,8 +1181,10 @@ static DEVICE_API(i2s, i2s_mcux_driver_api) = {
11911181
.ccm_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(i2s_id)), \
11921182
.irq_connect = i2s_irq_connect_##i2s_id, \
11931183
.pinctrl = PINCTRL_DT_INST_DEV_CONFIG_GET(i2s_id), \
1194-
.tx_sync_mode = DT_INST_PROP(i2s_id, nxp_tx_sync_mode), \
1195-
.rx_sync_mode = DT_INST_PROP(i2s_id, nxp_rx_sync_mode), \
1184+
.tx_sync_mode = \
1185+
DT_INST_PROP(i2s_id, nxp_tx_sync_mode) ? kSAI_ModeSync : kSAI_ModeAsync, \
1186+
.rx_sync_mode = \
1187+
DT_INST_PROP(i2s_id, nxp_rx_sync_mode) ? kSAI_ModeSync : kSAI_ModeAsync, \
11961188
.tx_channel = DT_INST_PROP(i2s_id, nxp_tx_channel), \
11971189
}; \
11981190
\

0 commit comments

Comments
 (0)