Change error messages in linuxspi.c to maintain single style

This commit is contained in:
Stefan Rueger 2022-09-22 10:39:31 +01:00
parent 93df07866a
commit aa789d4662
No known key found for this signature in database
GPG Key ID: B0B4F1FD86B1EC55
1 changed files with 16 additions and 17 deletions

View File

@ -86,13 +86,13 @@ static int linuxspi_spi_duplex(const PROGRAMMER *pgm, const unsigned char *tx, u
.rx_buf = (unsigned long)rx, .rx_buf = (unsigned long)rx,
.len = len, .len = len,
.delay_usecs = 1, .delay_usecs = 1,
.speed_hz = 1.0 / pgm->bitclock, // seconds to Hz .speed_hz = 1.0 / pgm->bitclock,
.bits_per_word = 8, .bits_per_word = 8,
}; };
ret = ioctl(fd_spidev, SPI_IOC_MESSAGE(1), &tr); ret = ioctl(fd_spidev, SPI_IOC_MESSAGE(1), &tr);
if (ret != len) if (ret != len)
avrdude_message(MSG_INFO, "\n%s: error: Unable to send SPI message\n", progname); avrdude_message(MSG_INFO, "\n%s: error, unable to send SPI message\n", progname);
return (ret == -1) ? -1 : 0; return (ret == -1) ? -1 : 0;
} }
@ -127,7 +127,7 @@ static int linuxspi_reset_mcu(const PROGRAMMER *pgm, bool active) {
#endif #endif
if (ret == -1) { if (ret == -1) {
ret = -errno; ret = -errno;
avrdude_message(MSG_INFO, "%s error: Unable to set GPIO line %d value\n", avrdude_message(MSG_INFO, "%s: error, unable to set GPIO line %d value\n",
progname, pgm->pinno[PIN_AVR_RESET] & ~PIN_INVERSE); progname, pgm->pinno[PIN_AVR_RESET] & ~PIN_INVERSE);
return ret; return ret;
} }
@ -137,8 +137,8 @@ static int linuxspi_reset_mcu(const PROGRAMMER *pgm, bool active) {
static int linuxspi_open(PROGRAMMER *pgm, const char *pt) { static int linuxspi_open(PROGRAMMER *pgm, const char *pt) {
const char *port_error = const char *port_error =
"%s: error: Unknown port specification. " "%s: error, unknown port specification; "
"Please use the format /dev/spidev:/dev/gpiochip[:resetno]\n"; "please use the format /dev/spidev:/dev/gpiochip[:resetno]\n";
char port_default[] = "/dev/spidev0.0:/dev/gpiochip0"; char port_default[] = "/dev/spidev0.0:/dev/gpiochip0";
char *spidev, *gpiochip, *reset_pin; char *spidev, *gpiochip, *reset_pin;
char *port = cfg_strdup("linuxspi_open()", pt); char *port = cfg_strdup("linuxspi_open()", pt);
@ -169,7 +169,7 @@ static int linuxspi_open(PROGRAMMER *pgm, const char *pt) {
strcpy(pgm->port, port); strcpy(pgm->port, port);
fd_spidev = open(pgm->port, O_RDWR); fd_spidev = open(pgm->port, O_RDWR);
if (fd_spidev < 0) { if (fd_spidev < 0) {
avrdude_message(MSG_INFO, "\n%s: error: Unable to open the spidev device %s", progname, pgm->port); avrdude_message(MSG_INFO, "\n%s: error, unable to open the spidev device %s", progname, pgm->port);
return -1; return -1;
} }
@ -180,7 +180,7 @@ static int linuxspi_open(PROGRAMMER *pgm, const char *pt) {
ret = ioctl(fd_spidev, SPI_IOC_WR_MODE32, &mode); ret = ioctl(fd_spidev, SPI_IOC_WR_MODE32, &mode);
if (ret == -1) { if (ret == -1) {
int ioctl_errno = errno; int ioctl_errno = errno;
avrdude_message(MSG_INFO, "%s: error: Unable to set SPI mode %0X on %s\n", avrdude_message(MSG_INFO, "%s: error, unable to set SPI mode %02X on %s\n",
progname, mode, spidev); progname, mode, spidev);
if(ioctl_errno == EINVAL || !PDATA(pgm)->disable_no_cs) if(ioctl_errno == EINVAL || !PDATA(pgm)->disable_no_cs)
avrdude_message(MSG_INFO, "%s: try -x disable_no_cs\n", progname); avrdude_message(MSG_INFO, "%s: try -x disable_no_cs\n", progname);
@ -188,7 +188,7 @@ static int linuxspi_open(PROGRAMMER *pgm, const char *pt) {
} }
fd_gpiochip = open(gpiochip, 0); fd_gpiochip = open(gpiochip, 0);
if (fd_gpiochip < 0) { if (fd_gpiochip < 0) {
avrdude_message(MSG_INFO, "\n%s error: Unable to open the gpiochip %s", progname, gpiochip); avrdude_message(MSG_INFO, "\n%s: error, unable to open the gpiochip %s", progname, gpiochip);
ret = -1; ret = -1;
goto close_spidev; goto close_spidev;
} }
@ -223,7 +223,7 @@ static int linuxspi_open(PROGRAMMER *pgm, const char *pt) {
#endif #endif
if (ret == -1) { if (ret == -1) {
ret = -errno; ret = -errno;
avrdude_message(MSG_INFO, "%s error: Unable to get GPIO line %d\n", avrdude_message(MSG_INFO, "%s: error, unable to get GPIO line %d\n",
progname, pgm->pinno[PIN_AVR_RESET] & ~PIN_INVERSE); progname, pgm->pinno[PIN_AVR_RESET] & ~PIN_INVERSE);
goto close_gpiochip; goto close_gpiochip;
} }
@ -234,14 +234,13 @@ static int linuxspi_open(PROGRAMMER *pgm, const char *pt) {
if (pgm->baudrate != 0) { if (pgm->baudrate != 0) {
avrdude_message(MSG_INFO, avrdude_message(MSG_INFO,
"%s: obsolete use of -b <clock> option for bit clock; use -B <clock>\n", "%s: obsolete use of -b <clock> option for bit clock; use -B <clock>\n",
progname); progname);
pgm->bitclock = 1.0 / pgm->baudrate; pgm->bitclock = 1.0 / pgm->baudrate;
} }
if (pgm->bitclock == 0) { if (pgm->bitclock == 0) {
avrdude_message(MSG_NOTICE, avrdude_message(MSG_NOTICE,
"%s: defaulting bit clock to 200 kHz\n", "%s: defaulting bit clock to 200 kHz\n", progname);
progname);
pgm->bitclock = 5E-6; // 200 kHz - 5 µs pgm->bitclock = 5E-6; // 200 kHz - 5 µs
} }
@ -289,7 +288,7 @@ static int linuxspi_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
if (p->prog_modes & PM_TPI) { if (p->prog_modes & PM_TPI) {
/* We do not support TPI. This is a dedicated SPI thing */ /* We do not support TPI. This is a dedicated SPI thing */
avrdude_message(MSG_INFO, "%s: error: Programmer " LINUXSPI " does not support TPI\n", progname); avrdude_message(MSG_INFO, "%s: error, programmer " LINUXSPI " does not support TPI\n", progname);
return -1; return -1;
} }
@ -303,7 +302,7 @@ static int linuxspi_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
} while(tries++ < 65); } while(tries++ < 65);
if (ret) if (ret)
avrdude_message(MSG_INFO, "%s: error: AVR device not responding\n", progname); avrdude_message(MSG_INFO, "%s: error, AVR device not responding\n", progname);
return ret; return ret;
} }
@ -317,7 +316,7 @@ static int linuxspi_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
unsigned char cmd[4], res[4]; unsigned char cmd[4], res[4];
if (!p->op[AVR_OP_PGM_ENABLE]) { if (!p->op[AVR_OP_PGM_ENABLE]) {
avrdude_message(MSG_INFO, "%s: error: program enable instruction not defined for part \"%s\"\n", progname, p->desc); avrdude_message(MSG_INFO, "%s: error, program enable instruction not defined for part %s\n", progname, p->desc);
return -1; return -1;
} }
@ -360,7 +359,7 @@ static int linuxspi_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
unsigned char cmd[4], res[4]; unsigned char cmd[4], res[4];
if (!p->op[AVR_OP_CHIP_ERASE]) { if (!p->op[AVR_OP_CHIP_ERASE]) {
avrdude_message(MSG_INFO, "%s: error: chip erase instruction not defined for part \"%s\"\n", progname, p->desc); avrdude_message(MSG_INFO, "%s: error, chip erase instruction not defined for part %s\n", progname, p->desc);
return -1; return -1;
} }