1 /* SPDX-License-Identifier: GPL-2.0 */
3 * win_minmax.h: windowed min/max tracker by Kathleen Nichols.
9 #include <linux/types.h>
11 /* A single data point for our parameterized min-max tracker */
12 struct minmax_sample
{
13 u32 t
; /* time measurement was taken */
14 u32 v
; /* value measured */
17 /* State for the parameterized min-max tracker */
19 struct minmax_sample s
[3];
22 static inline u32
minmax_get(const struct minmax
*m
)
27 static inline u32
minmax_reset(struct minmax
*m
, u32 t
, u32 meas
)
29 struct minmax_sample val
= { .t
= t
, .v
= meas
};
31 m
->s
[2] = m
->s
[1] = m
->s
[0] = val
;
35 u32
minmax_running_max(struct minmax
*m
, u32 win
, u32 t
, u32 meas
);
36 u32
minmax_running_min(struct minmax
*m
, u32 win
, u32 t
, u32 meas
);