Replace ldata(lfirst(pgm->id)) with pgmid where possible

This commit is contained in:
Stefan Rueger
2023-06-21 18:48:05 +01:00
parent a961284090
commit 80e240b5df
19 changed files with 43 additions and 61 deletions

View File

@@ -333,8 +333,7 @@ static int avr910_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
continue;
}
if (str_eq(extended_param, "help")) {
char *prg = (char *)ldata(lfirst(pgm->id));
msg_error("%s -c %s extended options:\n", progname, prg);
msg_error("%s -c %s extended options:\n", progname, pgmid);
msg_error(" -xdevcode=<arg> Override device code\n");
msg_error(" -xno_blockmode Disable default checking for block transfer capability\n");
msg_error(" -xhelp Show this help menu and exit\n");

View File

@@ -37,7 +37,8 @@ extern char progbuf[]; // Spaces same length as progname
extern int ovsigck; // Override signature check (-F)
extern int verbose; // Verbosity level (-v, -vv, ...)
extern int quell_progress; // Quell progress report -q, reduce effective verbosity level (-qq, -qqq)
extern const char *partdesc; // Part id
extern const char *partdesc; // Part -p string
extern const char *pgmid; // Programmer -c string
int avrdude_message(int msglvl, const char *format, ...);
int avrdude_message2(FILE *fp, int lno, const char *file, const char *func, int msgmode, int msglvl, const char *format, ...);

View File

@@ -378,8 +378,7 @@ buspirate_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
}
if (str_eq(extended_param, "help")) {
char *prg = (char *)ldata(lfirst(pgm->id));
msg_error("%s -c %s extended options:\n", progname, prg);
msg_error("%s -c %s extended options:\n", progname, pgmid);
msg_error(" -xreset=cs,aux,aux2 Override default reset pin\n");
msg_error(" -xspifreq=<0..7> Set binary SPI mode speed\n");
msg_error(" -xrawfreq=<0..3> Set \"raw-wire\" SPI mode speed\n");

View File

@@ -164,11 +164,10 @@ static int dryrun_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
int pm = pgm->prog_modes & p->prog_modes;
if(!pm)
Return("programmer %s and part %s have no common programming mode",
(char *) ldata(lfirst(pgm->id)), p->desc);
Return("programmer %s and part %s have no common programming mode", pgmid, p->desc);
if(pm & (pm-1))
Return("%s and %s share multiple programming modes (%s)",
(char *) ldata(lfirst(pgm->id)), p->desc, avr_prog_modes(pm));
pgmid, p->desc, avr_prog_modes(pm));
*/
return pgm->program_enable(pgm, p);

View File

@@ -879,7 +879,7 @@ int jtag3_getsync(const PROGRAMMER *pgm, int mode) {
/* XplainedMini boards do not need this, and early revisions had a
* firmware bug where they complained about it. */
if ((pgm->flag & PGM_FL_IS_EDBG) &&
!str_starts(ldata(lfirst(pgm->id)), "xplainedmini")) {
!str_starts(pgmid, "xplainedmini")) {
if (jtag3_edbg_prepare(pgm) < 0) {
return -1;
}
@@ -1583,13 +1583,12 @@ static int jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
}
else if (str_eq(extended_param, "help")) {
char *prg = (char *)ldata(lfirst(pgm->id));
msg_error("%s -c %s extended options:\n", progname, prg);
msg_error("%s -c %s extended options:\n", progname, pgmid);
if (str_eq(pgm->type, "JTAGICE3"))
msg_error(" -xjtagchain=UB,UA,BB,BA Setup the JTAG scan chain order\n");
if (str_eq(prg, "powerdebugger_updi") || str_eq(prg, "pickit4_updi"))
if (str_eq(pgmid, "powerdebugger_updi") || str_eq(pgmid, "pickit4_updi"))
msg_error(" -xhvupdi Enable high-voltage UPDI initialization\n");
if (str_starts(prg, "xplainedmini") && !str_eq(prg, "xplainedmini_tpi")) {
if (str_starts(pgmid, "xplainedmini") && !str_eq(pgmid, "xplainedmini_tpi")) {
msg_error(" -xsuffer Read SUFFER register value\n");
msg_error(" -xsuffer=<arg> Set SUFFER register value\n");
msg_error(" -xvtarg_switch Read on-board target voltage switch state\n");
@@ -1820,7 +1819,7 @@ void jtag3_close(PROGRAMMER * pgm) {
/* XplainedMini boards do not need this, and early revisions had a
* firmware bug where they complained about it. */
if ((pgm->flag & PGM_FL_IS_EDBG) &&
!str_starts(ldata(lfirst(pgm->id)), "xplainedmini")) {
!str_starts(pgmid, "xplainedmini")) {
jtag3_edbg_signoff(pgm);
}

View File

@@ -1216,10 +1216,9 @@ static int jtagmkII_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
const char *ifname;
/* Abort and print error if programmer does not support the target microcontroller */
if ((strncmp(pgm->type, "JTAGMKII_UPDI", strlen("JTAGMKII_UPDI")) == 0 && !(p->prog_modes & PM_UPDI)) ||
(strncmp(ldata(lfirst(pgm->id)), "jtagmkII", strlen("jtagmkII")) == 0 && (p->prog_modes & PM_UPDI))) {
msg_error("programmer %s does not support target %s\n\n",
(char *) ldata(lfirst(pgm->id)), p->desc);
if((str_starts(pgm->type, "JTAGMKII_UPDI") && !(p->prog_modes & PM_UPDI)) ||
(str_starts(pgmid, "jtagmkII") && (p->prog_modes & PM_UPDI))) {
msg_error("programmer %s does not support target %s\n\n", pgmid, p->desc);
return -1;
}
@@ -1289,9 +1288,8 @@ static int jtagmkII_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
AVRMEM *bootmem = avr_locate_mem(p, "boot");
AVRMEM *flashmem = avr_locate_mem(p, "flash");
if (bootmem == NULL || flashmem == NULL) {
if (strncmp(ldata(lfirst(pgm->id)), "jtagmkII", strlen("jtagmkII")) == 0) {
if(str_starts(pgmid, "jtagmkII"))
pmsg_error("cannot locate flash or boot memories in description\n");
}
} else {
if (PDATA(pgm)->fwver < 0x700) {
/* V7+ firmware does not need this anymore */
@@ -1401,8 +1399,7 @@ static int jtagmkII_parseextparms(const PROGRAMMER *pgm, const LISTID extparms)
}
else if (str_eq(extended_param, "help")) {
char *prg = (char *)ldata(lfirst(pgm->id));
msg_error("%s -c %s extended options:\n", progname, prg);
msg_error("%s -c %s extended options:\n", progname, pgmid);
if (str_eq(pgm->type, "JTAGMKII") || str_eq(pgm->type, "DRAGON_JTAG"))
msg_error(" -xjtagchain=UB,UA,BB,BA Setup the JTAG scan chain order\n");
msg_error( " -xhelp Show this help menu and exit\n");

View File

@@ -414,8 +414,7 @@ static int linuxspi_parseextparams(const PROGRAMMER *pgm, const LISTID extparms)
continue;
}
if (str_eq(extended_param, "help")) {
char *prg = (char *)ldata(lfirst(pgm->id));
msg_error("%s -c %s extended options:\n", progname, prg);
msg_error("%s -c %s extended options:\n", progname, pgmid);
msg_error(" -xdisable_no_cs Do not use the SPI_NO_CS bit for the SPI driver\n");
msg_error(" -xhelp Show this help menu and exit\n");
exit(0);

View File

@@ -213,8 +213,8 @@ static PROGRAMMER * pgm;
int verbose; // Verbose output
int quell_progress; // Quell progress report and un-verbose output
int ovsigck; // 1 = override sig check, 0 = don't
const char *partdesc; // Part id
const char *pgmid; // Programmer id
const char *partdesc; // Part -p string
const char *pgmid; // Programmer -c string
/*
* usage message
@@ -1103,8 +1103,7 @@ int main(int argc, char * argv [])
for (LNODEID ln = lfirst(extended_params); ln; ln = lnext(ln)) {
const char *extended_param = ldata(ln);
if (str_eq(extended_param, "help")) {
char *prg = (char *)ldata(lfirst(pgm->id));
msg_error("%s -c %s extended options:\n", progname, prg);
msg_error("%s -c %s extended options:\n", progname, pgmid);
msg_error(" -xhelp Show this help menu and exit\n");
exit(0);
}

View File

@@ -922,8 +922,7 @@ static int micronucleus_parseextparams(const PROGRAMMER *pgm, const LISTID xpara
}
else if (str_eq(param, "help"))
{
char *prg = (char *)ldata(lfirst(pgm->id));
msg_error("%s -c %s extended options:\n", progname, prg);
msg_error("%s -c %s extended options:\n", progname, pgmid);
msg_error(" -xwait Wait for the device to be plugged in if not connected\n");
msg_error(" -xwait=<arg> Wait <arg> [s] for the device to be plugged in if not connected\n");
msg_error(" -xhelp Show this help menu and exit\n");

View File

@@ -1212,8 +1212,7 @@ static int pickit2_parseextparams(const PROGRAMMER *pgm, const LISTID extparms)
continue;
}
if (str_eq(extended_param, "help")) {
char *prg = (char *)ldata(lfirst(pgm->id));
msg_error("%s -c %s extended options:\n", progname, prg);
msg_error("%s -c %s extended options:\n", progname, pgmid);
msg_error(" -xclockrate=<arg> Set the SPI clocking rate in <arg> [Hz]\n");
msg_error(" -xtimeout=<arg> Set the timeout for USB read/write to <arg> [ms]\n");
msg_error(" -xhelp Show this help menu and exit\n");

View File

@@ -944,8 +944,7 @@ static int serialupdi_parseextparms(const PROGRAMMER *pgm, const LISTID extparms
continue;
}
if (str_eq(extended_param, "help")) {
char *prg = (char *)ldata(lfirst(pgm->id));
msg_error("%s -c %s extended options:\n", progname, prg);
msg_error("%s -c %s extended options:\n", progname, pgmid);
msg_error(" -xrtsdtr=low,high Force RTS/DTR lines low or high state during programming\n");
msg_error(" -xhelp Show this help menu and exit\n");
exit(0);

View File

@@ -403,7 +403,7 @@ static int stk500_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
stk500_getparm(pgm, Parm_STK_SW_MINOR, &min);
// MIB510 does not need extparams
if (str_eq(ldata(lfirst(pgm->id)), "mib510"))
if (str_eq(pgmid, "mib510"))
n_extparms = 0;
else if ((maj > 1) || ((maj == 1) && (min > 10)))
n_extparms = 4;
@@ -749,8 +749,7 @@ static int stk500_parseextparms(const PROGRAMMER *pgm, const LISTID extparms)
}
else if (str_eq(extended_param, "help")) {
char *prg = (char *)ldata(lfirst(pgm->id));
msg_error("%s -c %s extended options:\n", progname, prg);
msg_error("%s -c %s extended options:\n", progname, pgmid);
msg_error(" -xattempts=<arg> Specify no. connection retry attempts\n");
if (pgm->extra_features & HAS_VTARG_ADJ) {
msg_error(" -xvtarg Read target supply voltage\n");
@@ -844,7 +843,7 @@ static int stk500_open(PROGRAMMER *pgm, const char *port) {
stk500_drain(pgm, 0);
// MIB510 init
if (str_eq(ldata(lfirst(pgm->id)), "mib510") && mib510_isp(pgm, 1) != 0)
if (str_eq(pgmid, "mib510") && mib510_isp(pgm, 1) != 0)
return -1;
if (stk500_getsync(pgm) < 0)
@@ -857,7 +856,7 @@ static int stk500_open(PROGRAMMER *pgm, const char *port) {
static void stk500_close(PROGRAMMER * pgm)
{
// MIB510 close
if (str_eq(ldata(lfirst(pgm->id)), "mib510"))
if (str_eq(pgmid, "mib510"))
(void)mib510_isp(pgm, 0);
serial_close(&pgm->fd);
@@ -967,7 +966,7 @@ static int set_memtype_a_div(const PROGRAMMER *pgm, const AVRPART *p, const AVRM
if(avr_mem_is_eeprom_type(m)) {
*memtypep = 'E';
// Word addr for bootloaders or Arduino as ISP if part is a "classic" part, byte addr otherwise
*a_divp = ((pgm->prog_modes & PM_SPM) || str_caseeq(ldata(lfirst(pgm->id)), "arduino_as_isp")) \
*a_divp = ((pgm->prog_modes & PM_SPM) || str_caseeq(pgmid, "arduino_as_isp")) \
&& !(p->prog_modes & (PM_UPDI | PM_PDI))? 2: 1;
return 0;
}
@@ -1003,7 +1002,7 @@ static int stk500_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVR
for (; addr < n; addr += block_size) {
// MIB510 uses fixed blocks size of 256 bytes
if (str_eq(ldata(lfirst(pgm->id)), "mib510")) {
if (str_eq(pgmid, "mib510")) {
block_size = 256;
} else {
if (n - addr < page_size)
@@ -1075,7 +1074,7 @@ static int stk500_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVRM
n = addr + n_bytes;
for (; addr < n; addr += block_size) {
// MIB510 uses fixed blocks size of 256 bytes
if (str_eq(ldata(lfirst(pgm->id)), "mib510")) {
if(str_eq(pgmid, "mib510")) {
block_size = 256;
} else {
if (n - addr < page_size)
@@ -1119,7 +1118,7 @@ static int stk500_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVRM
if (stk500_recv(pgm, buf, 1) < 0)
return -1;
if(str_eq(ldata(lfirst(pgm->id)), "mib510")) {
if(str_eq(pgmid, "mib510")) {
if (buf[0] != Resp_STK_INSYNC) {
msg_error("\n");
pmsg_error("protocol expects sync byte 0x%02x but got 0x%02x\n", Resp_STK_INSYNC, buf[0]);

View File

@@ -1932,8 +1932,7 @@ static int stk500v2_parseextparms(const PROGRAMMER *pgm, const LISTID extparms)
}
else if (str_eq(extended_param, "help")) {
char *prg = (char *)ldata(lfirst(pgm->id));
msg_error("%s -c %s extended options:\n", progname, prg);
msg_error("%s -c %s extended options:\n", progname, pgmid);
if (pgm->extra_features & HAS_VTARG_ADJ) {
msg_error(" -xvtarg Read target supply voltage\n");
msg_error(" -xvtarg=<arg> Set target supply voltage\n");
@@ -2046,9 +2045,8 @@ static int stk500v2_jtag3_parseextparms(const PROGRAMMER *pgm, const LISTID extp
}
else if (str_eq(extended_param, "help")) {
char *prg = (char *)ldata(lfirst(pgm->id));
msg_error("%s -c %s extended options:\n", progname, prg);
if (str_starts(prg, "xplainedmini")) {
msg_error("%s -c %s extended options:\n", progname, pgmid);
if(str_starts(pgmid, "xplainedmini")) {
msg_error(" -xsuffer Read SUFFER register value\n");
msg_error(" -xsuffer=<arg> Set SUFFER register value\n");
msg_error(" -xvtarg_switch Read on-board target voltage switch state\n");

View File

@@ -569,8 +569,7 @@ static int teensy_parseextparams(const PROGRAMMER *pgm, const LISTID xparams) {
}
else if (str_eq(param, "help"))
{
char *prg = (char *)ldata(lfirst(pgm->id));
msg_error("%s -c %s extended options:\n", progname, prg);
msg_error("%s -c %s extended options:\n", progname, pgmid);
msg_error(" -xwait Wait for the device to be plugged in if not connected\n");
msg_error(" -xwait=<arg> Wait <arg> [s] for the device to be plugged in if not connected\n");
msg_error(" -xhelp Show this help menu and exit\n");

View File

@@ -895,7 +895,7 @@ static int cmd_erase(const PROGRAMMER *pgm, const AVRPART *p, int argc, char *ar
}
if(rc) {
pmsg_error("(erase) programmer %s failed erasing the chip\n", (char *) ldata(lfirst(pgm->id)));
pmsg_error("(erase) programmer %s failed erasing the chip\n", pgmid);
return -1;
}
@@ -919,7 +919,7 @@ static int cmd_pgerase(const PROGRAMMER *pgm, const AVRPART *p, int argc, char *
return -1;
}
if(!avr_has_paged_access(pgm, mem)) {
pmsg_error("(pgerase) %s memory cannot be paged addressed by %s\n", memtype, (char *) ldata(lfirst(pgm->id)));
pmsg_error("(pgerase) %s memory cannot be paged addressed by %s\n", memtype, pgmid);
return -1;
}

View File

@@ -1757,7 +1757,7 @@ static int ur_readEF(const PROGRAMMER *pgm, const AVRPART *p, uint8_t *buf, uint
int classic = !(p->prog_modes & (PM_UPDI | PM_PDI | PM_aWire));
pmsg_debug("ur_readEF(%s, %s, %s, %p, 0x%06x, %d, %c)\n",
(char *) ldata(lfirst(pgm->id)), p->desc, mchr=='F'? "flash": "eeprom", buf, badd, len, mchr);
pgmid, p->desc, mchr=='F'? "flash": "eeprom", buf, badd, len, mchr);
if(mchr == 'F' && ur.urprotocol && !(ur.urfeatures & UB_READ_FLASH))
Return("bootloader does not have flash read capability");
@@ -2498,7 +2498,7 @@ static int urclock_parseextparms(const PROGRAMMER *pgm, LISTID extparms) {
}
if(help || rc < 0) {
msg_error("%s -c %s extended options:\n", progname, (char *) ldata(lfirst(pgm->id)));
msg_error("%s -c %s extended options:\n", progname, pgmid);
for(size_t i=0; i<sizeof options/sizeof*options; i++) {
msg_error(" -x%s%s%*s%s\n", options[i].name, options[i].assign? "=<arg>": "",
urmax(0, 16-(int) strlen(options[i].name)-(options[i].assign? 6: 0)), "", options[i].help);

View File

@@ -290,8 +290,7 @@ static int usbasp_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
continue;
}
if (str_eq(extended_param, "help")) {
char *prg = (char *)ldata(lfirst(pgm->id));
msg_error("%s -c %s extended options:\n", progname, prg);
msg_error("%s -c %s extended options:\n", progname, pgmid);
msg_error(" -xsection_config Erase configuration section only with -e (TPI only)\n");
msg_error(" -xhelp Show this help menu and exit\n");
exit(0);
@@ -560,7 +559,7 @@ static int usbasp_open(PROGRAMMER *pgm, const char *port) {
vid = pgm->usbvid? pgm->usbvid: USBASP_SHARED_VID;
if (usbOpenDevice(&PDATA(pgm)->usbhandle, vid, pgm->usbvendor, pid, pgm->usbproduct) != 0) {
/* try alternatives */
if(strcasecmp(ldata(lfirst(pgm->id)), "usbasp") == 0) {
if(str_eq(pgmid, "usbasp")) {
/* for id usbasp autodetect some variants */
if(strcasecmp(port, "nibobee") == 0) {
pmsg_error("using -C usbasp -P nibobee is deprecated, use -C nibobee instead\n");

View File

@@ -131,8 +131,7 @@ static int wiring_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
continue;
}
if (str_eq(extended_param, "help")) {
char *prg = (char *)ldata(lfirst(pgm->id));
msg_error("%s -c %s extended options:\n", progname, prg);
msg_error("%s -c %s extended options:\n", progname, pgmid);
msg_error(" -xsnooze=<arg> Wait <arg> [ms] before protocol sync after port open\n");
msg_error(" -xhelp Show this help menu and exit\n");
exit(0);

View File

@@ -1652,8 +1652,7 @@ static int xbee_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
continue;
}
if (str_eq(extended_param, "help")) {
char *prg = (char *)ldata(lfirst(pgm->id));
msg_error("%s -c %s extended options:\n", progname, prg);
msg_error("%s -c %s extended options:\n", progname, pgmid);
msg_error(" -xxbeeresetpin=<1..7> Set XBee pin DIO<1..7> as reset pin\n");
msg_error(" -xhelp Show this help menu and exit\n");
exit(0);