diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2022-07-14 09:27:20 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-08-08 14:19:15 +0200 |
commit | adc29829771a20b9b92960f046c61303a3a9d183 (patch) | |
tree | 2d52ce207984cc738ecbb609ec2daf5e8982a083 /scripts | |
parent | fc919d24b9ba448b455ee667e17268fba9bb550a (diff) | |
download | barebox-adc29829771a20b9b92960f046c61303a3a9d183.tar.gz |
imx-usb-loader: simplify read_memory()
In read_memory() we transfer at maximum 64 bytes, so the returned number
of actually sent bytes will never be greater than 64 and we can drop the
corresponding checks. Then it is checked if there are really 64 bytes
transferred. We don't do this elsewhere, so drop it here as well.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Link: https://lore.barebox.org/20220714072722.2863571-11-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/imx/imx-usb-loader.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c index be764a48a1..1d6755e24d 100644 --- a/scripts/imx/imx-usb-loader.c +++ b/scripts/imx/imx-usb-loader.c @@ -619,17 +619,10 @@ static int read_memory(unsigned addr, void *dest, unsigned cnt) err, last_trans, tmp[0], tmp[1], tmp[2], tmp[3], cnt, rem); break; } - if ((last_trans > rem) || (last_trans > 64)) { - if ((last_trans == 64) && (rem < 64)) { - /* Last transfer is expected to be too large for HID */ - } else { - printf("err: %02x %02x %02x %02x cnt=%u rem=%d last_trans=%i\n", - tmp[0], tmp[1], tmp[2], tmp[3], cnt, rem, last_trans); - } + + if (last_trans > rem) last_trans = rem; - if (last_trans > 64) - last_trans = 64; - } + memcpy(dest, tmp, last_trans); dest += last_trans; rem -= last_trans; |