summaryrefslogtreecommitdiff
path: root/util/spkmodem_recv
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-12 04:55:18 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-12 04:55:18 +0000
commit62a496ec9e02553ce3c662e1d019e4e7655d1fa1 (patch)
treeb8ad8930dab7e5d5c23ab467df1e408f414b922c /util/spkmodem_recv
parent1953812efd3544934b7d1df8f6c5aa300f012a80 (diff)
util/spkmodem-recv: tidy up pulse decoding
make it clearer about next/old, in the loop. this also improves performance on older systems (cache the values first, don't re-calculate) again, this is GNU code. but you wouldn't know it, in my current version. i forked this from GRUB several years ago and started cleaning it for fun. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/spkmodem_recv')
-rw-r--r--util/spkmodem_recv/spkmodem-recv.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/util/spkmodem_recv/spkmodem-recv.c b/util/spkmodem_recv/spkmodem-recv.c
index 58f59294..bbf73384 100644
--- a/util/spkmodem_recv/spkmodem-recv.c
+++ b/util/spkmodem_recv/spkmodem-recv.c
@@ -152,10 +152,14 @@ static void
decode_pulse(struct decoder_state *st)
{
size_t n;
+ unsigned char old_ring, old_sep;
- st->freq_data -= st->pulse[st->ringpos];
- st->freq_data += st->pulse[st->sep_pos];
- st->freq_separator -= st->pulse[st->sep_pos];
+ old_ring = st->pulse[st->ringpos];
+ old_sep = st->pulse[st->sep_pos];
+
+ st->freq_data -= old_ring;
+ st->freq_data += old_sep;
+ st->freq_separator -= old_sep;
n = fread(&st->frame[st->ringpos], sizeof(st->frame[0]), 1, stdin);
if (n != 1) {