Skip to content

iio: adc: ltc2387: Update calculation of duty_offset_ns value #2728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions drivers/iio/adc/ltc2387.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@
clk_gate_wf.duty_length_ns = ref_clk_period_ns * clk_en_time;
clk_gate_wf.duty_offset_ns = LTC2387_T_FIRSTCLK_NS;

if (clk_gate_wf.duty_offset_ns > clk_gate_wf.period_length_ns)
div64_u64_rem(clk_gate_wf.duty_offset_ns, clk_gate_wf.period_length_ns,
&clk_gate_wf.duty_offset_ns);

ret = pwm_set_waveform_might_sleep(ltc->clk_en, &clk_gate_wf, false);
if (ret < 0)
return ret;
Expand Down Expand Up @@ -238,7 +242,7 @@
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE:
temp = regulator_get_voltage(ltc->vref);
if (temp < 0)

Check warning on line 245 in drivers/iio/adc/ltc2387.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

smatch: unsigned 'temp' is never less than zero.

Check warning on line 245 in drivers/iio/adc/ltc2387.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 6-10 WARNING Unsigned expression compared with zero temp < 0
return temp;

*val = (temp * 2) / 1000;
Expand Down
Loading