Use an accessor for cc_line Instead of constantly playing games with cc_line being a boolean that we need to convert to an integer, add a CC() macro returning 1 or 2, depending on the value of cc_line. Signed-off-by: Marc Zyngier <maz@kernel.org>
diff --git a/vdmtool.c b/vdmtool.c index a9d73bc..57be132 100644 --- a/vdmtool.c +++ b/vdmtool.c
@@ -40,6 +40,7 @@ #define PIN(cxt, idx) (cxt)->hw->pins[(idx)].pin #define PORT(cxt) ((cxt) - vdm_contexts) #define UART(cxt) (cxt)->hw->uart +#define CC(cxt) ((cxt)->cc_line + 1) #define HIGH true #define LOW false @@ -104,12 +105,12 @@ cxt->cc_line = !(cc1 > cc2); fusb302_tcpm_set_polarity(PORT(cxt), cxt->cc_line); cprintf(cxt, "Polarity: CC%d (%s)\n", - (int)cxt->cc_line + 1, cxt->cc_line ? "flipped" : "normal"); + CC(cxt), CC(cxt) == 2 ? "flipped" : "normal"); /* If none of the CCs are disconnected, enable VCONN */ if (cc1 && cc2) { fusb302_tcpm_set_vconn(PORT(cxt), 1); - cprintf(cxt, "VCONN on CC%d\n", !cxt->cc_line + 1); + cprintf(cxt, "VCONN on CC%d\n", (CC(cxt) == 1) + 1); } fusb302_tcpm_set_rx_enable(PORT(cxt), 1); @@ -468,7 +469,7 @@ tmp->hw ? "present" : "absent"); if (tmp->hw) cprintf_cont(cxt, ",cc%d,%s,%s%s", - tmp->cc_line + 1, + CC(tmp), pinsets[tmp->serial_pin_set], upstream_is_serial() ? "serial" : "USB", tmp->verbose ? ",debug" : "");