Skip to content

Commit 89d6d85

Browse files
ukleineknunojsa
authored andcommitted
iio: adc: ad_pulsar: Ensure that all members of pwm_state are initialized
When just assigning some members of cnv_state which was declared without initialization, the unassigned members (here: .usage_power) have undefined content. Fix that by using an idiom that initializes unspecified values to their default value. Fixes: 44ffabe ("drivers: iio: adc: ad_pulsar: Add support for pulsar ADC's") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
1 parent 9227d69 commit 89d6d85

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

drivers/iio/adc/ad_pulsar.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,15 @@ static int ad_pulsar_set_samp_freq(struct ad_pulsar_adc *adc, int freq)
431431
target = DIV_ROUND_CLOSEST_ULL(adc->ref_clk_rate, freq);
432432
ref_clk_period_ps = DIV_ROUND_CLOSEST_ULL(1000000000000,
433433
adc->ref_clk_rate);
434-
cnv_state.period = ref_clk_period_ps * target;
435-
cnv_state.duty_cycle = ref_clk_period_ps;
436-
cnv_state.phase = ref_clk_period_ps;
437-
cnv_state.time_unit = PWM_UNIT_PSEC;
438-
cnv_state.enabled = true;
434+
435+
cnv_state = (struct pwm_state){
436+
.period = ref_clk_period_ps * target,
437+
.duty_cycle = ref_clk_period_ps,
438+
.phase = ref_clk_period_ps,
439+
.time_unit = PWM_UNIT_PSEC,
440+
.enabled = true,
441+
};
442+
439443
ret = pwm_apply_state(adc->cnv, &cnv_state);
440444
if (ret)
441445
return ret;

0 commit comments

Comments
 (0)