Signed-off-by: Nico Huber nico.huber@secunet.com --- dediprog.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/dediprog.c b/dediprog.c index 019de46..b7276e5 100644 --- a/dediprog.c +++ b/dediprog.c @@ -942,7 +942,7 @@ int dediprog_init(void) int spispeed_idx = 1; int millivolt = 3500; long usedevice = 0; - long target = 1; + long target = FLASH_TYPE_APPLICATION_FLASH_1; int i, ret;
spispeed = extract_programmer_param("spispeed"); @@ -1014,7 +1014,18 @@ int dediprog_init(void) free(target_str); return 1; } - msg_pinfo("Using target %li.\n", target); + switch (target) { + case 1: + msg_pinfo("Using target %s.\n", "FLASH_TYPE_APPLICATION_FLASH_1"); + target = FLASH_TYPE_APPLICATION_FLASH_1; + break; + case 2: + msg_pinfo("Using target %s.\n", "FLASH_TYPE_APPLICATION_FLASH_2"); + target = FLASH_TYPE_APPLICATION_FLASH_2; + break; + default: + break; + } } free(target_str);
@@ -1073,7 +1084,7 @@ int dediprog_init(void) dediprog_set_leds(LED_ALL);
/* Select target/socket, frequency and VCC. */ - if (set_target_flash(FLASH_TYPE_APPLICATION_FLASH_1) || + if (set_target_flash(target) || dediprog_set_spi_speed(spispeed_idx) || dediprog_set_spi_voltage(millivolt)) { dediprog_set_leds(LED_ERROR);
We didn't check the total number of queued transfers in the inner most loop. Up to DEDIPROG_ASYNC_TRANSFERS - 1 invalid transfers could be queued therefore. So add another check on the total number.
Signed-off-by: Nico Huber nico.huber@secunet.com --- dediprog.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dediprog.c b/dediprog.c index b7276e5..6f82772 100644 --- a/dediprog.c +++ b/dediprog.c @@ -462,7 +462,9 @@ static int dediprog_spi_bulk_read(struct flashctx *flash, uint8_t *buf, unsigned
/* Now transfer requested chunks using libusb's asynchronous interface. */ while (!status.error && (status.queued_idx < count)) { - while ((status.queued_idx - status.finished_idx) < DEDIPROG_ASYNC_TRANSFERS) { + while ((status.queued_idx < count) && + (status.queued_idx - status.finished_idx) < DEDIPROG_ASYNC_TRANSFERS) + { transfer = transfers[status.queued_idx % DEDIPROG_ASYNC_TRANSFERS]; libusb_fill_bulk_transfer(transfer, dediprog_handle, 0x80 | dediprog_in_endpoint, (unsigned char *)buf + status.queued_idx * chunksize, chunksize,
Looks good to me.
Acked-by: David Hendricks david.hendricks@gmail.com
On Wed, May 4, 2016 at 4:37 AM, Nico Huber nico.huber@secunet.com wrote:
We didn't check the total number of queued transfers in the inner most loop. Up to DEDIPROG_ASYNC_TRANSFERS - 1 invalid transfers could be queued therefore. So add another check on the total number.
Signed-off-by: Nico Huber nico.huber@secunet.com
dediprog.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dediprog.c b/dediprog.c index b7276e5..6f82772 100644 --- a/dediprog.c +++ b/dediprog.c @@ -462,7 +462,9 @@ static int dediprog_spi_bulk_read(struct flashctx *flash, uint8_t *buf, unsigned
/* Now transfer requested chunks using libusb's asynchronous
interface. */ while (!status.error && (status.queued_idx < count)) {
while ((status.queued_idx - status.finished_idx) <
DEDIPROG_ASYNC_TRANSFERS) {
while ((status.queued_idx < count) &&
(status.queued_idx - status.finished_idx) <
DEDIPROG_ASYNC_TRANSFERS)
{ transfer = transfers[status.queued_idx %
DEDIPROG_ASYNC_TRANSFERS]; libusb_fill_bulk_transfer(transfer, dediprog_handle, 0x80 | dediprog_in_endpoint, (unsigned char *)buf + status.queued_idx * chunksize, chunksize, -- 2.7.0
flashrom mailing list flashrom@flashrom.org https://www.flashrom.org/mailman/listinfo/flashrom
Looks good to me.
Acked-by: David Hendricks david.hendricks@gmail.com
On Wed, May 4, 2016 at 4:37 AM, Nico Huber nico.huber@secunet.com wrote:
Signed-off-by: Nico Huber nico.huber@secunet.com
dediprog.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/dediprog.c b/dediprog.c index 019de46..b7276e5 100644 --- a/dediprog.c +++ b/dediprog.c @@ -942,7 +942,7 @@ int dediprog_init(void) int spispeed_idx = 1; int millivolt = 3500; long usedevice = 0;
long target = 1;
long target = FLASH_TYPE_APPLICATION_FLASH_1; int i, ret; spispeed = extract_programmer_param("spispeed");
@@ -1014,7 +1014,18 @@ int dediprog_init(void) free(target_str); return 1; }
msg_pinfo("Using target %li.\n", target);
switch (target) {
case 1:
msg_pinfo("Using target %s.\n",
"FLASH_TYPE_APPLICATION_FLASH_1");
target = FLASH_TYPE_APPLICATION_FLASH_1;
break;
case 2:
msg_pinfo("Using target %s.\n",
"FLASH_TYPE_APPLICATION_FLASH_2");
target = FLASH_TYPE_APPLICATION_FLASH_2;
break;
default:
break;
} } free(target_str);
@@ -1073,7 +1084,7 @@ int dediprog_init(void) dediprog_set_leds(LED_ALL);
/* Select target/socket, frequency and VCC. */
if (set_target_flash(FLASH_TYPE_APPLICATION_FLASH_1) ||
if (set_target_flash(target) || dediprog_set_spi_speed(spispeed_idx) || dediprog_set_spi_voltage(millivolt)) { dediprog_set_leds(LED_ERROR);
-- 2.7.0
flashrom mailing list flashrom@flashrom.org https://www.flashrom.org/mailman/listinfo/flashrom