Skip to content

Commit 590fcb0

Browse files
committed
input: use single evaluation clamp
Use single evaluation clamp for few input drivers. No reason not to, make some sense for the input_kbd_matrix call since one of the arguments is a function. Signed-off-by: Fabio Baltieri <[email protected]>
1 parent 43084fe commit 590fcb0

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

drivers/input/input_analog_axis.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static void analog_axis_loop(const struct device *dev)
204204
out = analog_axis_out_linear(dev, i, raw_val);
205205
}
206206

207-
out = CLAMP(out, axis_cfg->out_min, axis_cfg->out_max);
207+
out = clamp(out, axis_cfg->out_min, axis_cfg->out_max);
208208

209209
if (axis_cfg->invert_output) {
210210
out = axis_cfg->out_max - out;

drivers/input/input_kbd_matrix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ static void input_kbd_matrix_poll(const struct device *dev)
309309
} else {
310310
poll_period_us = cfg->stable_poll_period_us;
311311
}
312-
wait_period_us = CLAMP(poll_period_us - k_cyc_to_us_floor32(cycles_diff),
312+
wait_period_us = clamp(poll_period_us - k_cyc_to_us_floor32(cycles_diff),
313313
USEC_PER_MSEC, poll_period_us);
314314

315315
LOG_DBG("wait_period_us: %d", wait_period_us);

drivers/input/input_stmpe811.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,8 @@ static void stmpe811_report_touch(const struct device *dev)
344344
y = (((int)data->touch_y - config->raw_y_min) * common->screen_height) /
345345
(config->raw_y_max - config->raw_y_min);
346346

347-
x = CLAMP(x, 0, common->screen_width);
348-
y = CLAMP(y, 0, common->screen_height);
347+
x = clamp(x, 0, common->screen_width);
348+
y = clamp(y, 0, common->screen_height);
349349
}
350350

351351
input_touchscreen_report_pos(dev, x, y, K_FOREVER);

0 commit comments

Comments
 (0)