Skip to content

Commit 1bcae0e

Browse files
ndrs-psthenrikbrixandersen
authored andcommitted
style: drivers: comply with MISRA C:2012 Rule 15.6
Add missing braces to comply with MISRA C:2012 Rule 15.6 and also following Zephyr's style guideline. Signed-off-by: Pisit Sawangvonganan <[email protected]>
1 parent 535b854 commit 1bcae0e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+247
-131
lines changed

drivers/adc/adc_rpi_pico.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ static inline void adc_clear_errors(void)
9191
static inline void adc_enable(void)
9292
{
9393
adc_hw->cs = ADC_CS_EN_BITS;
94-
while (!(adc_hw->cs & ADC_CS_READY_BITS))
94+
while (!(adc_hw->cs & ADC_CS_READY_BITS)) {
9595
;
96+
}
9697
}
9798

9899
static int adc_rpi_channel_setup(const struct device *dev,

drivers/adc/adc_smartbond_sdadc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ static void adc_context_start_sampling(struct adc_context *ctx)
150150
int current_channel = u32_count_trailing_zeros(data->channel_read_mask);
151151

152152
/* Wait until the SDADC LDO stabilizes */
153-
while (!(SDADC->SDADC_CTRL_REG & SDADC_SDADC_CTRL_REG_SDADC_LDO_OK_Msk))
153+
while (!(SDADC->SDADC_CTRL_REG & SDADC_SDADC_CTRL_REG_SDADC_LDO_OK_Msk)) {
154154
__NOP();
155+
}
155156

156157
if (ctx->sequence.calibrate) {
157158
/* TODO: Add calibration code */

drivers/clock_control/clock_control_npcx.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,9 @@ static int npcx_clock_control_init(const struct device *dev)
223223
/* Load M and N values into the frequency multiplier */
224224
inst_cdcg->HFCGCTRL |= BIT(NPCX_HFCGCTRL_LOAD);
225225
/* Wait for stable */
226-
while (IS_BIT_SET(inst_cdcg->HFCGCTRL, NPCX_HFCGCTRL_CLK_CHNG))
226+
while (IS_BIT_SET(inst_cdcg->HFCGCTRL, NPCX_HFCGCTRL_CLK_CHNG)) {
227227
;
228+
}
228229
}
229230

230231
/* Set all clock prescalers of core and peripherals. */

drivers/counter/counter_gecko_stimer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ static int counter_gecko_start(const struct device *dev)
110110
bool is_top_timer_running = false;
111111

112112
error_code = sl_sleeptimer_is_timer_running(&top_timer, &is_top_timer_running);
113-
if ((error_code == SL_STATUS_OK) && (is_top_timer_running == true))
113+
if ((error_code == SL_STATUS_OK) && (is_top_timer_running == true)) {
114114
return 0;
115+
}
115116
struct counter_gecko_data *const dev_data = (struct counter_gecko_data *const)(dev)->data;
116117

117118
error_code = sl_sleeptimer_start_timer(&top_timer, dev_data->top_data.ticks, top_callback,

drivers/counter/counter_native_posix.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,9 @@ static int ctr_set_alarm(const struct device *dev, uint8_t chan_id,
181181
{
182182
ARG_UNUSED(dev);
183183

184-
if (is_alarm_pending[chan_id])
184+
if (is_alarm_pending[chan_id]) {
185185
return -EBUSY;
186+
}
186187

187188
uint32_t ticks = alarm_cfg->ticks;
188189

drivers/dai/intel/dmic/dmic.c

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,13 @@ static int32_t exp_fixed(int32_t x)
7676
int i;
7777
int n = 0;
7878

79-
if (x < Q_CONVERT_FLOAT(-11.5, 27))
79+
if (x < Q_CONVERT_FLOAT(-11.5, 27)) {
8080
return 0;
81+
}
8182

82-
if (x > Q_CONVERT_FLOAT(7.6245, 27))
83+
if (x > Q_CONVERT_FLOAT(7.6245, 27)) {
8384
return INT32_MAX;
85+
}
8486

8587
/* x is Q5.27 */
8688
xs = x;
@@ -94,8 +96,9 @@ static int32_t exp_fixed(int32_t x)
9496
*/
9597
z = Q_SHIFT_RND(exp_small_fixed(Q_SHIFT_LEFT(xs, 27, 29)), 23, 20);
9698
y = ONE_Q20;
97-
for (i = 0; i < (1 << n); i++)
99+
for (i = 0; i < (1 << n); i++) {
98100
y = (int32_t)Q_MULTSR_32X32((int64_t)y, z, 20, 20, 20);
101+
}
99102

100103
return y;
101104
}
@@ -104,8 +107,9 @@ static int32_t db2lin_fixed(int32_t db)
104107
{
105108
int32_t arg;
106109

107-
if (db < Q_CONVERT_FLOAT(-100.0, 24))
110+
if (db < Q_CONVERT_FLOAT(-100.0, 24)) {
108111
return 0;
112+
}
109113

110114
/* Q8.24 x Q5.27, result needs to be Q5.27 */
111115
arg = (int32_t)Q_MULTSR_32X32((int64_t)db, LOG10_DIV20_Q27, 24, 27, 27);
@@ -383,8 +387,9 @@ static int dai_dmic_remove(struct dai_intel_dmic *dmic)
383387
* Note: dai_put() function that calls remove() applies the spinlock
384388
* so it is not needed here to protect access to mask bits.
385389
*/
386-
if (active_fifos_mask || pause_mask)
390+
if (active_fifos_mask || pause_mask) {
387391
return 0;
392+
}
388393

389394
/* Disable DMIC clock and power */
390395
dai_dmic_en_clk_gating(dmic);
@@ -442,8 +447,9 @@ static int dai_timestamp_dmic_get(const struct device *dev, struct dai_ts_cfg *c
442447

443448
/* Read SSP timestamp registers */
444449
ntk = sys_read32(tsctrl) & TS_LOCAL_TSCTRL_NTK;
445-
if (!ntk)
450+
if (!ntk) {
446451
goto out;
452+
}
447453

448454
/* NTK was set, get wall clock */
449455
tsd->walclk = sys_read64(TS_DMIC_LOCAL_WALCLK);
@@ -456,8 +462,9 @@ static int dai_timestamp_dmic_get(const struct device *dev, struct dai_ts_cfg *c
456462

457463
out:
458464
tsd->walclk_rate = cfg->walclk_rate;
459-
if (!ntk)
465+
if (!ntk) {
460466
return -ENODATA;
467+
}
461468

462469
return 0;
463470
}
@@ -484,8 +491,9 @@ static void dai_dmic_gain_ramp(struct dai_intel_dmic *dmic)
484491
* task associated with each DAI, so we don't need to hold the lock to
485492
* read the value here.
486493
*/
487-
if (dmic->gain == DMIC_HW_FIR_GAIN_MAX << 11)
494+
if (dmic->gain == DMIC_HW_FIR_GAIN_MAX << 11) {
488495
return;
496+
}
489497

490498
key = k_spin_lock(&dmic->lock);
491499

@@ -659,10 +667,11 @@ static void dai_dmic_stop(struct dai_intel_dmic *dmic, bool stop_is_pause)
659667
* If stop is not for pausing, it is safe to clear the pause bit.
660668
*/
661669
dai_dmic_global.active_fifos_mask &= ~BIT(dmic->dai_config_params.dai_index);
662-
if (stop_is_pause)
670+
if (stop_is_pause) {
663671
dai_dmic_global.pause_mask |= BIT(dmic->dai_config_params.dai_index);
664-
else
672+
} else {
665673
dai_dmic_global.pause_mask &= ~BIT(dmic->dai_config_params.dai_index);
674+
}
666675

667676
for (i = 0; i < CONFIG_DAI_DMIC_HW_CONTROLLERS; i++) {
668677
/* Don't stop CIC yet if one FIFO remains active */

drivers/dai/intel/dmic/dmic.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,13 @@ static inline int dmic_get_unmute_ramp_from_samplerate(int rate)
205205

206206
time_ms = Q_MULTSR_32X32((int32_t)rate, LOGRAMP_TIME_COEF_Q15, 0, 15, 0) +
207207
LOGRAMP_TIME_OFFS_Q0;
208-
if (time_ms > LOGRAMP_TIME_MAX_MS)
208+
if (time_ms > LOGRAMP_TIME_MAX_MS) {
209209
return LOGRAMP_TIME_MAX_MS;
210+
}
210211

211-
if (time_ms < LOGRAMP_TIME_MIN_MS)
212+
if (time_ms < LOGRAMP_TIME_MIN_MS) {
212213
return LOGRAMP_TIME_MIN_MS;
214+
}
213215

214216
return time_ms;
215217
}

drivers/dai/intel/dmic/dmic_nhlt.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -668,8 +668,9 @@ int dai_dmic_set_config_nhlt(struct dai_intel_dmic *dmic, const void *bespoke_cf
668668

669669
/* Configure clock source */
670670
ret = dai_dmic_set_clock(dmic, dmic_cfg->clock_source);
671-
if (ret)
671+
if (ret) {
672672
return ret;
673+
}
673674

674675
/* Get OUTCONTROLx configuration */
675676
if (num_fifos < 1 || num_fifos > DMIC_HW_FIFOS_MAX) {
@@ -678,8 +679,9 @@ int dai_dmic_set_config_nhlt(struct dai_intel_dmic *dmic, const void *bespoke_cf
678679
}
679680

680681
for (n = 0; n < DMIC_HW_FIFOS_MAX; n++) {
681-
if (!(channel_ctrl_mask & (1 << n)))
682+
if (!(channel_ctrl_mask & (1 << n))) {
682683
continue;
684+
}
683685

684686
val = *(uint32_t *)p;
685687
ret = print_outcontrol(val);
@@ -802,8 +804,9 @@ int dai_dmic_set_config_nhlt(struct dai_intel_dmic *dmic, const void *bespoke_cf
802804
#else
803805
ret = dai_nhlt_dmic_dai_params_get(dmic);
804806
#endif
805-
if (ret)
807+
if (ret) {
806808
return ret;
809+
}
807810

808811
LOG_INF("dmic_set_config_nhlt(): enable0 %u, enable1 %u",
809812
dmic->enable[0], dmic->enable[1]);

drivers/dai/intel/hda/hda.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@ static int dai_hda_set_config_tplg(struct dai_intel_hda *dp, const void *spec_co
3232
struct dai_intel_hda_pdata *hda = dai_get_drvdata(dp);
3333
const struct dai_intel_ipc_hda_params *config = spec_config;
3434

35-
if (config->channels)
35+
if (config->channels) {
3636
hda->params.channels = config->channels;
37-
if (config->rate)
37+
}
38+
39+
if (config->rate) {
3840
hda->params.rate = config->rate;
41+
}
3942

4043
return 0;
4144
}
@@ -65,8 +68,9 @@ static int dai_hda_config_set(const struct device *dev, const struct dai_config
6568
{
6669
struct dai_intel_hda *dp = (struct dai_intel_hda *)dev->data;
6770

68-
if (cfg->type == DAI_INTEL_HDA)
71+
if (cfg->type == DAI_INTEL_HDA) {
6972
return dai_hda_set_config_tplg(dp, bespoke_cfg);
73+
}
7074

7175
return 0;
7276
}

drivers/dai/intel/ssp/ssp.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,8 +1999,9 @@ static int dai_ssp_parse_aux_data(struct dai_intel_ssp *dp, const void *spec_con
19991999
aux_len = cfg_len - pre_aux_len;
20002000
aux_ptr = (uint8_t *)blob + pre_aux_len;
20012001

2002-
if (aux_len <= 0)
2002+
if (aux_len <= 0) {
20032003
return 0;
2004+
}
20042005

20052006
return dai_ssp_parse_tlv(dp, aux_ptr, aux_len);
20062007
}
@@ -2132,17 +2133,20 @@ static int dai_ssp_set_config_blob(struct dai_intel_ssp *dp, const struct dai_co
21322133

21332134
if (blob15->version == SSP_BLOB_VER_1_5) {
21342135
err = dai_ssp_parse_aux_data(dp, spec_config);
2135-
if (err)
2136+
if (err) {
21362137
return err;
2138+
}
21372139
dai_ssp_set_reg_config(dp, cfg, &blob15->i2s_ssp_config);
21382140
err = dai_ssp_set_clock_control_ver_1_5(dp, &blob15->i2s_mclk_control);
2139-
if (err)
2141+
if (err) {
21402142
return err;
2143+
}
21412144
} else {
21422145
dai_ssp_set_reg_config(dp, cfg, &blob->i2s_driver_config.i2s_config);
21432146
err = dai_ssp_set_clock_control_ver_1(dp, &blob->i2s_driver_config.mclk_config);
2144-
if (err)
2147+
if (err) {
21452148
return err;
2149+
}
21462150
}
21472151

21482152
ssp_plat_data->clk_active |= SSP_CLK_MCLK_ES_REQ;

0 commit comments

Comments
 (0)