drivers: use DT_INST_PROP over DT_INST_PROP_OR if possible

It might happens that DT(_INST)_PROP_OR is used with boolean properties.
For instance:

	.single_wire = DT_INST_PROP_OR(index, single_wire, false),	\
	.tx_rx_swap = DT_INST_PROP_OR(index, tx_rx_swap, false),	\

This is not required as boolean properties are generated with false
value when not present, so the _OR macro extension is superflous
and the above code can be replaced by:

	.single_wire = DT_INST_PROP(index, single_wire),		\
	.tx_rx_swap = DT_INST_PROP(index, tx_rx_swap),			\

Signed-off-by: Roman Studenikin <srv@meta.com>
This commit is contained in:
Roman Studenikin 2024-01-24 16:06:47 +00:00 committed by Fabio Baltieri
parent 1799a2bf0c
commit 260fc89643
7 changed files with 14 additions and 14 deletions

View file

@ -887,7 +887,7 @@ static struct sai_config sai_config_##inst = { \
.clk_data = SAI_CLOCK_DATA_DECLARE(inst), \
.rx_fifo_watermark = SAI_RX_FIFO_WATERMARK(inst), \
.tx_fifo_watermark = SAI_TX_FIFO_WATERMARK(inst), \
.mclk_is_output = DT_INST_PROP_OR(inst, mclk_is_output, false), \
.mclk_is_output = DT_INST_PROP(inst, mclk_is_output), \
.tx_props = &sai_tx_props_##inst, \
.rx_props = &sai_rx_props_##inst, \
.irq_config = irq_config_##inst, \

View file

@ -311,12 +311,12 @@ static const struct fuel_gauge_driver_api sbs_gauge_driver_api = {
/* Conditionally defined battery config based on battery cutoff support */
#define SBS_GAUGE_CONFIG_DEFINE(index) \
COND_CODE_1(DT_INST_PROP_OR(index, battery_cutoff_support, false), \
COND_CODE_1(DT_INST_PROP(index, battery_cutoff_support), \
(_SBS_GAUGE_CONFIG_DEFINE(index)), (;))
/* Conditionally get the battery config variable name or NULL based on battery cutoff support */
#define SBS_GAUGE_GET_BATTERY_CONFIG_NAME(index) \
COND_CODE_1(DT_INST_PROP_OR(index, battery_cutoff_support, false), \
COND_CODE_1(DT_INST_PROP(index, battery_cutoff_support), \
(&_SBS_GAUGE_BATT_CUTOFF_CFG_VAR_NAME(index)), (NULL))
#define SBS_GAUGE_INIT(index) \

View file

@ -2104,7 +2104,7 @@ static const struct i3c_driver_api mcux_i3c_driver_api = {
.common.dev_list.num_i2c = ARRAY_SIZE(mcux_i3c_i2c_device_array_##id), \
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(id), \
.disable_open_drain_high_pp = \
DT_INST_PROP_OR(id, disable_open_drain_high_pp, false), \
DT_INST_PROP(id, disable_open_drain_high_pp), \
}; \
static struct mcux_i3c_data mcux_i3c_data_##id = { \
.clocks.i3c_od_scl_hz = DT_INST_PROP_OR(id, i3c_od_scl_hz, 0), \

View file

@ -1270,7 +1270,7 @@ static void uart_sam0_irq_config_##n(const struct device *dev) \
(DT_INST_PROP(n, txpo) << SERCOM_USART_CTRLA_TXPO_Pos)
#define UART_SAM0_SERCOM_COLLISION_DETECT(n) \
(DT_INST_PROP_OR(n, collision_detection, false))
(DT_INST_PROP(n, collision_detection))
#ifdef MCLK
#define UART_SAM0_CONFIG_DEFN(n) \

View file

@ -2345,8 +2345,8 @@ static const struct uart_stm32_config uart_stm32_cfg_##index = { \
.pclken = pclken_##index, \
.pclk_len = DT_INST_NUM_CLOCKS(index), \
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(index), \
.single_wire = DT_INST_PROP_OR(index, single_wire, false), \
.tx_rx_swap = DT_INST_PROP_OR(index, tx_rx_swap, false), \
.single_wire = DT_INST_PROP(index, single_wire), \
.tx_rx_swap = DT_INST_PROP(index, tx_rx_swap), \
.rx_invert = DT_INST_PROP(index, rx_invert), \
.tx_invert = DT_INST_PROP(index, tx_invert), \
.de_enable = DT_INST_PROP(index, de_enable), \

View file

@ -336,13 +336,13 @@ static int ifx_cat1_spi_init(const struct device *dev)
.subMode = DT_INST_PROP_OR(n, sub_mode, CY_SCB_SPI_MOTOROLA), \
.oversample = \
DT_INST_PROP_OR(n, oversample, IFX_CAT1_SPI_DEFAULT_OVERSAMPLE), \
.enableFreeRunSclk = DT_INST_PROP_OR(n, enable_free_run_sclk, false), \
.enableInputFilter = DT_INST_PROP_OR(n, enable_input_filter, false), \
.enableFreeRunSclk = DT_INST_PROP(n, enable_free_run_sclk), \
.enableInputFilter = DT_INST_PROP(n, enable_input_filter), \
.enableMisoLateSample = \
DT_INST_PROP_OR(n, enable_miso_late_sample, true), \
.enableTransferSeperation = \
DT_INST_PROP_OR(n, enable_transfer_seperation, false), \
.enableWakeFromSleep = DT_INST_PROP_OR(n, enableWakeFromSleep, false), \
DT_INST_PROP(n, enable_transfer_seperation), \
.enableWakeFromSleep = DT_INST_PROP(n, enableWakeFromSleep), \
.ssPolarity = DT_INST_PROP_OR(n, ss_polarity, CY_SCB_SPI_ACTIVE_LOW), \
.rxFifoTriggerLevel = DT_INST_PROP_OR(n, rx_fifo_trigger_level, 0), \
.rxFifoIntEnableMask = DT_INST_PROP_OR(n, rx_fifo_int_enable_mask, 0), \

View file

@ -1204,7 +1204,7 @@ static const struct uart_driver_api cdc_acm_driver_api = {
.line_coding = CDC_ACM_DEFAULT_BAUDRATE, \
.rx_ringbuf = &cdc_acm_rx_rb_##x, \
.tx_ringbuf = &cdc_acm_tx_rb_##x, \
.flow_ctrl = DT_INST_PROP_OR(x, hw_flow_control, false),\
.flow_ctrl = DT_INST_PROP(x, hw_flow_control), \
};
#define DT_DRV_COMPAT zephyr_cdc_acm_uart