Display phase-adjust-min, phase-adjust-max and phase-adjust values with ps unit. Add DPLL_PR_PHASE_OFFSET macro that properly formats phase-offset as fractional picoseconds by dividing the raw kernel value by DPLL_PHASE_OFFSET_DIVIDER. Reviewed-by: Petr Oros Signed-off-by: Ivan Vecera --- dpll/dpll.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/dpll/dpll.c b/dpll/dpll.c index b6ba3283e0ba..e8056ff6a24b 100644 --- a/dpll/dpll.c +++ b/dpll/dpll.c @@ -410,6 +410,21 @@ static __s64 mnl_attr_get_sint(const struct nlattr *attr) } \ } while (0) +/* Phase offset - JSON prints raw sub-ps value, FP prints fractional ps */ +#define DPLL_PR_PHASE_OFFSET(tb, attr_id) \ + do { \ + if (tb[attr_id]) { \ + __s64 val = mnl_attr_get_sint(tb[attr_id]); \ + lldiv_t d = lldiv(llabs(val), \ + DPLL_PHASE_OFFSET_DIVIDER); \ + print_s64(PRINT_JSON, "phase-offset", NULL, val); \ + print_string(PRINT_FP, NULL, " phase-offset %s", \ + val < 0 ? "-" : ""); \ + print_s64(PRINT_FP, NULL, "%lld.", d.quot); \ + print_s64(PRINT_FP, NULL, "%03lld ps", d.rem); \ + } \ + } while (0) + /* Generic version with custom format */ #define DPLL_PR_ENUM_STR_FMT(tb, attr_id, name, format_str, name_func) \ do { \ @@ -1507,8 +1522,7 @@ static void dpll_pin_print_parent_devices(struct nlattr *attr) " prio %u"); DPLL_PR_ENUM_STR_FMT(tb_parent, DPLL_A_PIN_STATE, "state", " state %s", dpll_pin_state_name); - DPLL_PR_SINT_FMT(tb_parent, DPLL_A_PIN_PHASE_OFFSET, - "phase-offset", " phase-offset %" PRId64); + DPLL_PR_PHASE_OFFSET(tb_parent, DPLL_A_PIN_PHASE_OFFSET); print_nl(); close_json_object(); @@ -1592,10 +1606,13 @@ static void dpll_pin_print_attrs(struct nlattr **tb) dpll_pin_print_capabilities(tb[DPLL_A_PIN_CAPABILITIES]); - DPLL_PR_INT(tb, DPLL_A_PIN_PHASE_ADJUST_MIN, "phase-adjust-min"); - DPLL_PR_INT(tb, DPLL_A_PIN_PHASE_ADJUST_MAX, "phase-adjust-max"); + DPLL_PR_INT_FMT(tb, DPLL_A_PIN_PHASE_ADJUST_MIN, "phase-adjust-min", + " phase-adjust-min: %d ps\n"); + DPLL_PR_INT_FMT(tb, DPLL_A_PIN_PHASE_ADJUST_MAX, "phase-adjust-max", + " phase-adjust-max: %d ps\n"); DPLL_PR_UINT(tb, DPLL_A_PIN_PHASE_ADJUST_GRAN, "phase-adjust-gran"); - DPLL_PR_INT(tb, DPLL_A_PIN_PHASE_ADJUST, "phase-adjust"); + DPLL_PR_INT_FMT(tb, DPLL_A_PIN_PHASE_ADJUST, "phase-adjust", + " phase-adjust: %d ps\n"); if (json || !tb[DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET_PPT]) DPLL_PR_SINT(tb, DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET, -- 2.53.0