1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-29 07:53:44 +02:00

pickit2_spi.c: Use a variable to store the total packetsize

Instead of calculating the total packetsize multiple times, use a
variable instead.

Signed-off-by: Felix Singer <felixsinger@posteo.net>
Change-Id: I714054669e16dcf531a57174f9522b3af72d2754
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66251
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Felix Singer 2022-07-29 03:16:19 +02:00 committed by Thomas Heijligen
parent 9e04991dc4
commit 36299dbab2

View File

@ -202,13 +202,14 @@ static int pickit2_spi_send_command(const struct flashctx *flash, unsigned int w
const unsigned char *writearr, unsigned char *readarr) const unsigned char *writearr, unsigned char *readarr)
{ {
struct pickit2_spi_data *pickit2_data = flash->mst->spi.data; struct pickit2_spi_data *pickit2_data = flash->mst->spi.data;
const unsigned int total_packetsize = writecnt + readcnt + 20;
/* Maximum number of bytes per transaction (including command overhead) is 64. Lets play it safe /* Maximum number of bytes per transaction (including command overhead) is 64. Lets play it safe
* and always assume the worst case scenario of 20 bytes command overhead. * and always assume the worst case scenario of 20 bytes command overhead.
*/ */
if (writecnt + readcnt + 20 > CMD_LENGTH) { if (total_packetsize > CMD_LENGTH) {
msg_perr("\nTotal packetsize (%i) is greater than %i supported, aborting.\n", msg_perr("\nTotal packetsize (%i) is greater than %i supported, aborting.\n",
writecnt + readcnt + 20, CMD_LENGTH); total_packetsize, CMD_LENGTH);
return 1; return 1;
} }