From 097c78098d33f19aecdd4ed41d7af7edd5ab9be3 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 23 Sep 2022 23:28:47 +0100 Subject: [PATCH] Change printf() to avrdude_message() in linuxgio.c --- src/linuxgpio.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/linuxgpio.c b/src/linuxgpio.c index 36687612..0d4057e7 100644 --- a/src/linuxgpio.c +++ b/src/linuxgpio.c @@ -299,24 +299,27 @@ static int linuxgpio_open(PROGRAMMER *pgm, char *port) /* Write direction, looping in case of EACCES errors due to delayed * udev permission rule application after export */ - for (retry_count = GPIO_SYSFS_OPEN_RETRIES; retry_count > 0; retry_count--) { + for (retry_count = 0; retry_count < GPIO_SYSFS_OPEN_RETRIES; retry_count++) { usleep(GPIO_SYSFS_OPEN_DELAY); if (i == PIN_AVR_MISO) r=linuxgpio_dir_in(pin); else r=linuxgpio_dir_out(pin); - if (r >= 0) { + if (r >= 0) break; - } else if (errno != EACCES) { + + if (errno != EACCES) { linuxgpio_unexport(pin); return r; } - if (retry_count > 1) { - printf("Retrying...\n"); - } } + if (retry_count) + avrdude_message(MSG_NOTICE2, "%s: needed %d retr%s for linuxgpio_dir_%s(%s)\n", + progname, retry_count, retry_count > 1? "ies": "y", + i == PIN_AVR_MISO? "in": "out", avr_pin_name(pin)); + if (r < 0) { linuxgpio_unexport(pin); return r;