Shiyu Sun has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/40901 )
Change subject: Switch all log prefixed with 'Error:' to '__func__:' ......................................................................
Switch all log prefixed with 'Error:' to '__func__:'
Showing Error is not very informative and switch to function name to make it easy for debug.
Change-Id: If3205d8e453cfcd37f725b4fd135fe1221c913c0 Signed-off-by: Shiyu Sun sshiyu@chromium.org --- M atavia.c M chipset_enable.c M cli_output.c M dediprog.c M digilent_spi.c M dummyflasher.c M flashrom.c M ft2232_spi.c M ichspi.c M it87spi.c M layout.c M libflashrom.c M lspcon_i2c_spi.c M mcp6x_spi.c M mstarddc_spi.c M pcidev.c M pickit2_spi.c M pony_spi.c M rayer_spi.c M sb600spi.c M serprog.c M spi25_statusreg.c 22 files changed, 215 insertions(+), 136 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/01/40901/1
diff --git a/atavia.c b/atavia.c index b407a30..c9dfb4d 100644 --- a/atavia.c +++ b/atavia.c @@ -131,7 +131,8 @@ char *endptr; atavia_offset = (void *)strtoul(arg, &endptr, 0); if (*endptr) { - msg_perr("Error: Invalid offset specified: "%s".\n", arg); + msg_perr("%s: Invalid offset specified: "%s".\n", + __func__, arg); free(arg); return ERROR_FATAL; } diff --git a/chipset_enable.c b/chipset_enable.c index 783bb94..8ebf2c5 100644 --- a/chipset_enable.c +++ b/chipset_enable.c @@ -403,7 +403,7 @@ case CHIPSET_BAYTRAIL: { uint32_t ilb_base = pci_read_long(dev, 0x50) & 0xfffffe00; /* bits 31:9 */ if (ilb_base == 0) { - msg_perr("Error: Invalid ILB_BASE_ADDRESS\n"); + msg_perr("%s: Invalid ILB_BASE_ADDRESS\n", __func__); return ERROR_FATAL; } ilb = rphysmap("BYT IBASE", ilb_base, 512); @@ -427,21 +427,24 @@ char *idsel = extract_programmer_param("fwh_idsel"); if (idsel && strlen(idsel)) { if (!implemented) { - msg_perr("Error: fwh_idsel= specified, but (yet) unsupported on this chipset.\n"); + msg_perr("%s: fwh_idsel= specified, but (yet) unsupported on this chipset.\n", + __func__); goto idsel_garbage_out; } errno = 0; /* Base 16, nothing else makes sense. */ uint64_t fwh_idsel = (uint64_t)strtoull(idsel, NULL, 16); if (errno) { - msg_perr("Error: fwh_idsel= specified, but value could not be converted.\n"); + msg_perr("%s: fwh_idsel= specified, but value could not be converted.\n", + __func__); goto idsel_garbage_out; } uint64_t fwh_mask = 0xffffffff; if (fwh_sel2 > 0) fwh_mask |= (0xffffULL << 32); if (fwh_idsel & ~fwh_mask) { - msg_perr("Error: fwh_idsel= specified, but value had unused bits set.\n"); + msg_perr("%s: fwh_idsel= specified, but value had unused bits set.\n", + __func__); goto idsel_garbage_out; } uint64_t fwh_idsel_old; @@ -460,7 +463,7 @@ fwh_idsel_old, fwh_idsel); /* FIXME: Decode settings are not changed. */ } else if (idsel) { - msg_perr("Error: fwh_idsel= specified, but no value given.\n"); + msg_perr("%s: fwh_idsel= specified, but no value given.\n", __func__); idsel_garbage_out: free(idsel); return ERROR_FATAL; diff --git a/cli_output.c b/cli_output.c index e12446d..d21216f 100644 --- a/cli_output.c +++ b/cli_output.c @@ -49,7 +49,8 @@ return 1; } if ((logfile = fopen(filename, "w")) == NULL) { - msg_gerr("Error: opening log file "%s" failed: %s\n", filename, strerror(errno)); + msg_gerr("%s: opening log file "%s" failed: %s\n", + __func__, filename, strerror(errno)); return 1; } return 0; diff --git a/dediprog.c b/dediprog.c index 175e099..1ea3681 100644 --- a/dediprog.c +++ b/dediprog.c @@ -1075,7 +1075,8 @@ } } if (!spispeeds[i].name) { - msg_perr("Error: Invalid spispeed value: '%s'.\n", spispeed); + msg_perr("%s: Invalid spispeed value: '%s'.\n", + __func__, spispeed); free(spispeed); return 1; } @@ -1095,18 +1096,20 @@ if (id_str) { char prefix0, prefix1; if (sscanf(id_str, "%c%c%d", &prefix0, &prefix1, &id) != 3) { - msg_perr("Error: Could not parse dediprog 'id'.\n"); + msg_perr("%s: Could not parse dediprog 'id'.\n", + __func__); msg_perr("Expected a string like SF012345 or DP012345.\n"); free(id_str); return 1; } if (id < 0 || id >= 0x1000000) { - msg_perr("Error: id %s is out of range!\n", id_str); + msg_perr("%s: id %s is out of range!\n", + __func__, id_str); free(id_str); return 1; } if (!(prefix0 == 'S' && prefix1 == 'F') && !(prefix0 == 'D' && prefix1 == 'P')) { - msg_perr("Error: %s is an invalid id!\n", id_str); + msg_perr("%s: %s is an invalid id!\n", __func__, id_str); free(id_str); return 1; } @@ -1118,22 +1121,25 @@ if (device) { char *dev_suffix; if (id != -1) { - msg_perr("Error: Cannot use 'id' and 'device'.\n"); + msg_perr("%s: Cannot use 'id' and 'device'.\n", + __func__); } errno = 0; usedevice = strtol(device, &dev_suffix, 10); if (errno != 0 || device == dev_suffix) { - msg_perr("Error: Could not convert 'device'.\n"); + msg_perr("%s: Could not convert 'device'.\n", __func__); free(device); return 1; } if (usedevice < 0 || usedevice > INT_MAX) { - msg_perr("Error: Value for 'device' is out of range.\n"); + msg_perr("%s: Value for 'device' is out of range.\n", + __func__); free(device); return 1; } if (strlen(dev_suffix) > 0) { - msg_perr("Error: Garbage following 'device' value.\n"); + msg_perr("%s: Garbage following 'device' value.\n", + __func__); free(device); return 1; } @@ -1147,17 +1153,20 @@ errno = 0; target = strtol(target_str, &target_suffix, 10); if (errno != 0 || target_str == target_suffix) { - msg_perr("Error: Could not convert 'target'.\n"); + msg_perr("%s: Could not convert 'target'.\n", + __func__); free(target_str); return 1; } if (target < 1 || target > 2) { - msg_perr("Error: Value for 'target' is out of range.\n"); + msg_perr("%s: Value for 'target' is out of range.\n", + __func__); free(target_str); return 1; } if (strlen(target_suffix) > 0) { - msg_perr("Error: Garbage following 'target' value.\n"); + msg_perr("%s: Garbage following 'target' value.\n", + __func__); free(target_str); return 1; } diff --git a/digilent_spi.c b/digilent_spi.c index 13a876e..8bae9f7 100644 --- a/digilent_spi.c +++ b/digilent_spi.c @@ -414,7 +414,7 @@ } } if (!spispeeds[i].name) { - msg_perr("Error: Invalid spispeed value: '%s'.\n", p); + msg_perr("%s: Invalid spispeed value: '%s'.\n", __func__, p); free(p); goto close_handle; } diff --git a/dummyflasher.c b/dummyflasher.c index b9f6126..49f0356 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -364,8 +364,9 @@ emu_status = strtoul(status, &endptr, 0); free(status); if (errno != 0 || status == endptr) { - msg_perr("Error: initial status register specified, " - "but the value could not be converted.\n"); + msg_perr("%s: initial status register specified, " + "but the value could not be converted.\n", + __func__); return 1; } msg_pdbg("Initial status register is set to 0x%02x.\n", diff --git a/flashrom.c b/flashrom.c index 4224637..b2d553b 100644 --- a/flashrom.c +++ b/flashrom.c @@ -852,7 +852,7 @@ int ret = 0;
if (start + len > flash->chip->total_size * 1024) { - msg_gerr("Error: %s called with start 0x%x + len 0x%x >" + msg_gerr("%s: called with start 0x%x + len 0x%x >" " total_size 0x%x\n", __func__, start, len, flash->chip->total_size * 1024); ret = -1; @@ -1309,34 +1309,36 @@ const char *filename) { #ifdef __LIBPAYLOAD__ - msg_gerr("Error: No file I/O support in libpayload\n"); + msg_gerr("%s: No file I/O support in libpayload\n", __func__); return 1; #else int ret = 0;
FILE *image; if ((image = fopen(filename, "rb")) == NULL) { - msg_gerr("Error: opening file "%s" failed: %s\n", filename, strerror(errno)); + msg_gerr("%s: opening file "%s" failed: %s\n", + __func__, filename, strerror(errno)); return 1; }
struct stat image_stat; if (fstat(fileno(image), &image_stat) != 0) { - msg_gerr("Error: getting metadata of file "%s" failed: %s\n", filename, strerror(errno)); + msg_gerr("%s: getting metadata of file "%s" failed: %s\n", + __func__, filename, strerror(errno)); ret = 1; goto out; } if (image_stat.st_size != (intmax_t)size) { - msg_gerr("Error: Image size (%jd B) doesn't match the flash chip's size (%lu B)!\n", - (intmax_t)image_stat.st_size, size); + msg_gerr("%s: Image size (%jd B) doesn't match the flash chip's size (%lu B)!\n", + __func__, (intmax_t)image_stat.st_size, size); ret = 1; goto out; }
unsigned long numbytes = fread(buf, 1, size, image); if (numbytes != size) { - msg_gerr("Error: Failed to read complete file. Got %ld bytes, " - "wanted %ld!\n", numbytes, size); + msg_gerr("%s: Failed to read complete file. Got %ld bytes, " + "wanted %ld!\n", __func__, numbytes, size); ret = 1; } out: @@ -1348,7 +1350,7 @@ int write_buf_to_file(const unsigned char *buf, unsigned long size, const char *filename) { #ifdef __LIBPAYLOAD__ - msg_gerr("Error: No file I/O support in libpayload\n"); + msg_gerr("%s: No file I/O support in libpayload\n", __func__); return 1; #else FILE *image; @@ -1359,38 +1361,44 @@ return 1; } if ((image = fopen(filename, "wb")) == NULL) { - msg_gerr("Error: opening file "%s" failed: %s\n", filename, strerror(errno)); + msg_gerr("%s: opening file "%s" failed: %s\n", + __func__, filename, strerror(errno)); return 1; }
unsigned long numbytes = fwrite(buf, 1, size, image); if (numbytes != size) { - msg_gerr("Error: file %s could not be written completely.\n", filename); + msg_gerr("%s: file %s could not be written completely.\n", + __func__, filename); ret = 1; goto out; } if (fflush(image)) { - msg_gerr("Error: flushing file "%s" failed: %s\n", filename, strerror(errno)); + msg_gerr("%s: flushing file "%s" failed: %s\n", + __func__, filename, strerror(errno)); ret = 1; } // Try to fsync() only regular files and if that function is available at all (e.g. not on MinGW). #if defined(_POSIX_FSYNC) && (_POSIX_FSYNC != -1) struct stat image_stat; if (fstat(fileno(image), &image_stat) != 0) { - msg_gerr("Error: getting metadata of file "%s" failed: %s\n", filename, strerror(errno)); + msg_gerr("%s: getting metadata of file "%s" failed: %s\n", + __func__, filename, strerror(errno)); ret = 1; goto out; } if (S_ISREG(image_stat.st_mode)) { if (fsync(fileno(image))) { - msg_gerr("Error: fsyncing file "%s" failed: %s\n", filename, strerror(errno)); + msg_gerr("%s: fsyncing file "%s" failed: %s\n", + __func__, filename, strerror(errno)); ret = 1; } } #endif out: if (fclose(image)) { - msg_gerr("Error: closing file "%s" failed: %s\n", filename, strerror(errno)); + msg_gerr("%s: closing file "%s" failed: %s\n", + __func__, filename, strerror(errno)); ret = 1; } return ret; diff --git a/ft2232_spi.c b/ft2232_spi.c index 9f4c7f0..6f07c05 100644 --- a/ft2232_spi.c +++ b/ft2232_spi.c @@ -283,7 +283,7 @@ * and 0x40 to be driven low to enable output buffers */ pindir = 0xcb; } else { - msg_perr("Error: Invalid device type specified.\n"); + msg_perr("%s: Invalid device type specified.\n", __func__); free(arg); return -1; } @@ -316,7 +316,8 @@ break; } if (channel_count < 0 || strlen(arg) != 1) { - msg_perr("Error: Invalid channel/port/interface specified: "%s".\n", arg); + msg_perr("%s: Invalid channel/port/interface specified: "%s".\n", + __func__, arg); free(arg); return -2; } @@ -329,8 +330,9 @@ char *endptr; temp = strtoul(arg, &endptr, 10); if (*endptr || temp < 2 || temp > 131072 || temp & 0x1) { - msg_perr("Error: Invalid SPI frequency divisor specified: "%s".\n" - "Valid are even values between 2 and 131072.\n", arg); + msg_perr("%s: Invalid SPI frequency divisor specified: "%s".\n" + "Valid are even values between 2 and 131072.\n", + __func__, arg); free(arg); return -2; } @@ -345,9 +347,10 @@ for (unsigned int i = 0; i <= ngpios; i++) { int temp = arg[i] - '0'; if (ngpios == 0 || (ngpios != i && (temp < 0 || temp > 3))) { - msg_perr("Error: Invalid GPIOLs specified: "%s".\n" + msg_perr("%s: Invalid GPIOLs specified: "%s".\n" "Valid values are numbers between 0 and 3. " - "Multiple GPIOLs can be specified.\n", arg); + "Multiple GPIOLs can be specified.\n", + __func__, arg); free(arg); return -2; } else { diff --git a/ichspi.c b/ichspi.c index 12ee126..c993129 100644 --- a/ichspi.c +++ b/ichspi.c @@ -852,7 +852,7 @@ programmer_delay(10); } if (!timeout) { - msg_perr("Error: SCIP never cleared!\n"); + msg_perr("%s: SCIP never cleared!\n", __func__); return 1; }
@@ -969,7 +969,7 @@ programmer_delay(10); } if (!timeout) { - msg_perr("Error: SCIP never cleared!\n"); + msg_perr("%s: SCIP never cleared!\n", __func__); return 1; }
diff --git a/it87spi.c b/it87spi.c index f5955fe..98389bc 100644 --- a/it87spi.c +++ b/it87spi.c @@ -203,9 +203,10 @@ * should only be done if no port between 0x100 and * 0xff8 works due to routing issues. */ - msg_perr("Error: it87spiport specified, but no valid " + msg_perr("%s: it87spiport specified, but no valid " "port specified.\nPort must be a multiple of " - "0x8 and lie between 0x100 and 0xff8.\n"); + "0x8 and lie between 0x100 and 0xff8.\n", + __func__); exit_conf_mode_ite(port); free(param); return 1; diff --git a/layout.c b/layout.c index d80b01f..b39c76f 100644 --- a/layout.c +++ b/layout.c @@ -76,7 +76,8 @@ tstr1 = strtok(tempstr, ":"); tstr2 = strtok(NULL, ":"); if (!tstr1 || !tstr2) { - msg_gerr("Error parsing layout file. Offending string: "%s"\n", tempstr); + msg_gerr("%s: error parsing layout file. Offending string: "%s"\n", + __func__, tempstr); goto _close_ret; } layout->entries[layout->num_entries].start = strtol(tstr1, (char **)NULL, 16); @@ -84,7 +85,8 @@ layout->entries[layout->num_entries].included = 0; layout->entries[layout->num_entries].name = strdup(tempname); if (!layout->entries[layout->num_entries].name) { - msg_gerr("Error adding layout entry: %s\n", strerror(errno)); + msg_gerr("%s: error adding layout entry: %s\n", + __func__, strerror(errno)); goto _close_ret; } layout->num_entries++; @@ -226,8 +228,8 @@ ret = 1; } if (layout->entries[i].start > layout->entries[i].end) { - msg_gerr("Error: Size of the address range of region "%s" is not positive.\n", - layout->entries[i].name); + msg_gerr("%s: Size of the address range of region "%s" is not positive.\n", + __func__, layout->entries[i].name); ret = 1; } } diff --git a/libflashrom.c b/libflashrom.c index 0dec22e..cde2629 100644 --- a/libflashrom.c +++ b/libflashrom.c @@ -281,7 +281,7 @@ break; } if (prog >= PROGRAMMER_INVALID) { - msg_ginfo("Error: Unknown programmer "%s". Valid choices are:\n", prog_name); + msg_ginfo("%s: Unknown programmer "%s". Valid choices are:\n", __func__, prog_name); list_programmers_linebreak(0, 80, 0); return 1; } @@ -531,7 +531,7 @@ l->entries[l->num_entries].name = strndup((const char *)fmap->areas[i].name, FMAP_STRLEN); if (!l->entries[l->num_entries].name) { - msg_gerr("Error adding layout entry: %s\n", strerror(errno)); + msg_gerr("%s: error adding layout entry: %s\n", __func__, strerror(errno)); return 1; } msg_gdbg("fmap %08x - %08x named %s\n", diff --git a/lspcon_i2c_spi.c b/lspcon_i2c_spi.c index 8de2c14..0e01607 100644 --- a/lspcon_i2c_spi.c +++ b/lspcon_i2c_spi.c @@ -154,7 +154,7 @@ } while (!ret && (val & mask) && ++tried < MAX_SPI_WAIT_RETRIES);
if (tried == MAX_SPI_WAIT_RETRIES) { - msg_perr("Error: Time out on sending command.\n"); + msg_perr("%s: Time out on sending command.\n", __func__); return -MAX_SPI_WAIT_RETRIES; }
@@ -179,7 +179,7 @@ } while (!ret && (val & SWSPICTL_ACCESS_TRIGGER) && ++tried < MAX_SPI_WAIT_RETRIES);
if (tried == MAX_SPI_WAIT_RETRIES) { - msg_perr("Error: Time out on waiting ROM free.\n"); + msg_perr("%s: Time out on waiting ROM free.\n", __func__); return -MAX_SPI_WAIT_RETRIES; }
@@ -258,7 +258,8 @@ { unsigned int i; if (writecnt > 16 || readcnt > 16 || writecnt == 0) { - msg_perr("Error: Invalid read/write count for send command.\n"); + msg_perr("%s: Invalid read/write count for send command.\n", + __func__); return SPI_GENERIC_ERROR; }
@@ -402,7 +403,8 @@ static int lspcon_i2c_spi_write_aai(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len) { - msg_perr("Error: AAI write function is not supported.\n"); + msg_perr("%s: AAI write function is not supported.\n", + __func__); return SPI_GENERIC_ERROR; }
@@ -441,17 +443,19 @@ errno = 0; int bus = (int)strtol(bus_str, &bus_suffix, 10); if (errno != 0 || bus_str == bus_suffix) { - msg_perr("Error: Could not convert 'bus'.\n"); + msg_perr("%s: Could not convert 'bus'.\n", __func__); goto get_bus_done; }
if (bus < 0 || bus > 255) { - msg_perr("Error: Value for 'bus' is out of range(0-255).\n"); + msg_perr("%s: Value for 'bus' is out of range(0-255).\n", + __func__); goto get_bus_done; }
if (strlen(bus_suffix) > 0) { - msg_perr("Error: Garbage following 'bus' value.\n"); + msg_perr("%s: Garbage following 'bus' value.\n", + __func__); goto get_bus_done; }
@@ -459,7 +463,7 @@ ret = bus; goto get_bus_done; } else { - msg_perr("Error: Bus number not specified.\n"); + msg_perr("%s: Bus number not specified.\n", __func__); } get_bus_done: if (bus_str) diff --git a/mcp6x_spi.c b/mcp6x_spi.c index b53d07b..c9ac1b5 100644 --- a/mcp6x_spi.c +++ b/mcp6x_spi.c @@ -130,7 +130,8 @@
/* Accessing a NULL pointer BAR is evil. Don't do it. */ if (!mcp6x_spibaraddr && want_spi) { - msg_perr("Error: Chipset is strapped for SPI, but MCP SPI BAR is invalid.\n"); + msg_perr("%s: Chipset is strapped for SPI, but MCP SPI BAR is invalid.\n", + __func__); return 1; } else if (!mcp6x_spibaraddr && !want_spi) { msg_pdbg("MCP SPI is not used.\n"); diff --git a/mstarddc_spi.c b/mstarddc_spi.c index db11157..49fdd95 100644 --- a/mstarddc_spi.c +++ b/mstarddc_spi.c @@ -81,15 +81,17 @@ i2c_address++; } if (i2c_address == NULL || strlen(i2c_address) == 0) { - msg_perr("Error: no address specified.\n" - "Use flashrom -p mstarddc_spi:dev=/dev/device:address.\n"); + msg_perr("%s: no address specified.\n" + "Use flashrom -p mstarddc_spi:dev=/dev/device:address.\n", + __func__); ret = -1; goto out; } mstarddc_addr = strtol(i2c_address, NULL, 16); // FIXME: error handling } else { - msg_perr("Error: no device specified.\n" - "Use flashrom -p mstarddc_spi:dev=/dev/device:address.\n"); + msg_perr("%s: no device specified.\n" + "Use flashrom -p mstarddc_spi:dev=/dev/device:address.\n", + __func__); ret = -1; goto out; } diff --git a/pcidev.c b/pcidev.c index e13b78c..2c3cdfa 100644 --- a/pcidev.c +++ b/pcidev.c @@ -198,7 +198,7 @@ pcidev_bdf = extract_programmer_param("pci"); if (pcidev_bdf != NULL) { if ((msg = pci_filter_parse_slot(&filter, pcidev_bdf))) { - msg_perr("Error: %s\n", msg); + msg_perr("%s: %s\n", __func__, msg); return NULL; } } @@ -237,11 +237,12 @@
/* Only continue if exactly one supported PCI dev has been found. */ if (found == 0) { - msg_perr("Error: No supported PCI device found.\n"); + msg_perr("%s: No supported PCI device found.\n", __func__); return NULL; } else if (found > 1) { - msg_perr("Error: Multiple supported PCI devices found. Use 'flashrom -p xxxx:pci=bb:dd.f'\n" - "to explicitly select the card with the given BDF (PCI bus, device, function).\n"); + msg_perr("%s: Multiple supported PCI devices found. Use 'flashrom -p xxxx:pci=bb:dd.f'\n" + "to explicitly select the card with the given BDF (PCI bus, device, function).\n", + __func__); return NULL; }
diff --git a/pickit2_spi.c b/pickit2_spi.c index 2936ee8..1b5d869 100644 --- a/pickit2_spi.c +++ b/pickit2_spi.c @@ -409,7 +409,7 @@ } } if (spispeeds[i].name == NULL) { - msg_perr("Error: Invalid 'spispeed' value.\n"); + msg_perr("%s: Invalid 'spispeed' value.\n", __func__); free(spispeed); return 1; } diff --git a/pony_spi.c b/pony_spi.c index ed9d326..d113a63 100644 --- a/pony_spi.c +++ b/pony_spi.c @@ -137,8 +137,9 @@ free(arg);
if (!have_device) { - msg_perr("Error: No valid device specified.\n" - "Use flashrom -p pony_spi:dev=/dev/device[,type=name]\n"); + msg_perr("%s: No valid device specified.\n" + "Use flashrom -p pony_spi:dev=/dev/device[,type=name]\n", + __func__); return 1; }
@@ -150,11 +151,11 @@ } else if (arg && !strcasecmp( arg, "ajawe")) { type = TYPE_AJAWE; } else if (arg && !strlen(arg)) { - msg_perr("Error: Missing argument for programmer type.\n"); + msg_perr("%s: Missing argument for programmer type.\n", __func__); free(arg); return 1; } else if (arg){ - msg_perr("Error: Invalid programmer type specified.\n"); + msg_perr("%s: Invalid programmer type specified.\n", __func__); free(arg); return 1; } diff --git a/rayer_spi.c b/rayer_spi.c index 8e869e6..801ac9b 100644 --- a/rayer_spi.c +++ b/rayer_spi.c @@ -184,9 +184,10 @@ * should only be done if no port between 0x100 and * 0xfffc works due to routing issues. */ - msg_perr("Error: iobase= specified, but the I/O base " + msg_perr("%s: iobase= specified, but the I/O base " "given was invalid.\nIt must be a multiple of " - "0x4 and lie between 0x100 and 0xfffc.\n"); + "0x4 and lie between 0x100 and 0xfffc.\n", + __func__); free(arg); return 1; } else { @@ -211,7 +212,8 @@ } } if (prog->type == NULL) { - msg_perr("Error: Invalid device type specified.\n"); + msg_perr("%s: Invalid device type specified.\n" + , __func__); free(arg); return 1; } diff --git a/sb600spi.c b/sb600spi.c index a649253..41c808a 100644 --- a/sb600spi.c +++ b/sb600spi.c @@ -432,7 +432,8 @@ (i == ARRAY_SIZE(spispeeds)) || (amd_gen < CHIPSET_YANGTZE && spispeed_idx > 3) || (amd_gen < CHIPSET_SB89XX && spispeed_idx == 0)) { - msg_perr("Error: Invalid spispeed value: '%s'.\n", spispeed); + msg_perr("%s: Invalid spispeed value: '%s'.\n", + __func__, spispeed); free(spispeed); return 1; } @@ -450,7 +451,8 @@ } if ((strcasecmp(spireadmode, "reserved") == 0) || (i == ARRAY_SIZE(spireadmodes))) { - msg_perr("Error: Invalid spireadmode value: '%s'.\n", spireadmode); + msg_perr("%s: Invalid spireadmode value: '%s'.\n", + __func__, spireadmode); free(spireadmode); return 1; } diff --git a/serprog.c b/serprog.c index 37a9db4..1c269a3 100644 --- a/serprog.c +++ b/serprog.c @@ -91,7 +91,8 @@ msg_pdbg(MSGHEADER "IP %s port %d\n", ip, port); sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (sock < 0) { - msg_perr("Error: serprog cannot open socket: %s\n", strerror(errno)); + msg_perr("%s: serprog cannot open socket: %s\n", + __func__, strerror(errno)); return -1; } hostPtr = gethostbyname(ip); @@ -99,7 +100,7 @@ hostPtr = gethostbyaddr(ip, strlen(ip), AF_INET); if (NULL == hostPtr) { close(sock); - msg_perr("Error: cannot resolve %s\n", ip); + msg_perr("%s: cannot resolve %s\n", __func__, ip); return -1; } } @@ -108,14 +109,16 @@ (void)memcpy(&sp.si.sin_addr, hostPtr->h_addr_list[0], hostPtr->h_length); if (connect(sock, &sp.s, sizeof(sp.si)) < 0) { close(sock); - msg_perr("Error: serprog cannot connect: %s\n", strerror(errno)); + msg_perr("%s: serprog cannot connect: %s\n", + __func__,strerror(errno)); return -1; } /* We are latency limited, and sometimes do write-write-read * * (write-n) - so enable TCP_NODELAY. */ if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(int))) { close(sock); - msg_perr("Error: serprog cannot set socket options: %s\n", strerror(errno)); + msg_perr("%s: serprog cannot set socket options: %s\n", + __func__, strerror(errno)); return -1; } return sock; @@ -185,7 +188,8 @@ } } err_out: - msg_perr("Error: cannot synchronize protocol - check communications and reset device?\n"); + msg_perr("%s: cannot synchronize protocol - check communications and reset device?\n", + __func__); return 1; }
@@ -214,26 +218,31 @@ if (sp_automatic_cmdcheck(command)) return 1; if (serialport_write(&command, 1) != 0) { - msg_perr("Error: cannot write op code: %s\n", strerror(errno)); + msg_perr("%s: cannot write op code: %s\n", + __func__, strerror(errno)); return 1; } if (serialport_write(params, parmlen) != 0) { - msg_perr("Error: cannot write parameters: %s\n", strerror(errno)); + msg_perr("%s: cannot write parameters: %s\n", + __func__, strerror(errno)); return 1; } if (serialport_read(&c, 1) != 0) { - msg_perr("Error: cannot read from device: %s\n", strerror(errno)); + msg_perr("%s: cannot read from device: %s\n", + __func__, strerror(errno)); return 1; } if (c == S_NAK) return 1; if (c != S_ACK) { - msg_perr("Error: invalid response 0x%02X from device (to command 0x%02X)\n", c, command); + msg_perr("%s: invalid response 0x%02X from device (to command 0x%02X)\n", + __func__, c, command); return 1; } if (retlen) { if (serialport_read(retparms, retlen) != 0) { - msg_perr("Error: cannot read return parameters: %s\n", strerror(errno)); + msg_perr("%s: cannot read return parameters: %s\n", + __func__, strerror(errno)); return 1; } } @@ -246,15 +255,18 @@ do { unsigned char c; if (serialport_read(&c, 1) != 0) { - msg_perr("Error: cannot read from device (flushing stream)"); + msg_perr("%s: cannot read from device (flushing stream)\n", + __func__); return 1; } if (c == S_NAK) { - msg_perr("Error: NAK to a stream buffer operation\n"); + msg_perr("%s: NAK to a stream buffer operation\n", + __func__); return 1; } if (c != S_ACK) { - msg_perr("Error: Invalid reply 0x%02X from device\n", c); + msg_perr("%s: Invalid reply 0x%02X from device\n", + __func__, c); return 1; } } while (--sp_streamed_transmit_ops); @@ -271,7 +283,7 @@
sp = malloc(1 + parmlen); if (!sp) { - msg_perr("Error: cannot malloc command buffer\n"); + msg_perr("%s: cannot malloc command buffer\n", __func__); return 1; } sp[0] = cmd; @@ -284,7 +296,7 @@ } } if (serialport_write(sp, 1 + parmlen) != 0) { - msg_perr("Error: cannot write command\n"); + msg_perr("%s: cannot write command\n", __func__); free(sp); return 1; } @@ -368,8 +380,9 @@
#if !IS_WINDOWS if (device && !strlen(device)) { - msg_perr("Error: No device specified.\n" - "Use flashrom -p serprog:dev=/dev/device[:baud]\n"); + msg_perr("%s: No device specified.\n" + "Use flashrom -p serprog:dev=/dev/device[:baud]\n", + __func__); free(device); return 1; } @@ -377,8 +390,9 @@
device = extract_programmer_param("ip"); if (have_device && device) { - msg_perr("Error: Both host and device specified.\n" - "Please use either dev= or ip= but not both.\n"); + msg_perr("%s: Both host and device specified.\n" + "Please use either dev= or ip= but not both.\n", + __func__); free(device); return 1; } @@ -390,8 +404,9 @@ port++; } if (!port || !strlen(port)) { - msg_perr("Error: No port specified.\n" - "Use flashrom -p serprog:ip=ipaddr:port\n"); + msg_perr("%s: No port specified.\n" + "Use flashrom -p serprog:ip=ipaddr:port\n", + __func__); free(device); return 1; } @@ -405,8 +420,9 @@ } } if (device && !strlen(device)) { - msg_perr("Error: No host specified.\n" - "Use flashrom -p serprog:ip=ipaddr:port\n"); + msg_perr("%s: No host specified.\n" + "Use flashrom -p serprog:ip=ipaddr:port\n", + __func__); free(device); return 1; } @@ -415,12 +431,14 @@
if (!have_device) { #if IS_WINDOWS - msg_perr("Error: No device specified.\n" - "Use flashrom -p serprog:dev=comN[:baud]\n"); + msg_perr("%s: No device specified.\n" + "Use flashrom -p serprog:dev=comN[:baud]\n", + __func__); #else - msg_perr("Error: Neither host nor device specified.\n" + msg_perr("%s: Neither host nor device specified.\n" "Use flashrom -p serprog:dev=/dev/device:baud or " - "flashrom -p serprog:ip=ipaddr:port\n"); + "flashrom -p serprog:ip=ipaddr:port\n", + __func__); #endif return 1; } @@ -438,19 +456,21 @@ msg_pdbg(MSGHEADER "Synchronized\n");
if (sp_docommand(S_CMD_Q_IFACE, 0, NULL, 2, &iface)) { - msg_perr("Error: NAK to query interface version\n"); + msg_perr("%s: NAK to query interface version\n", __func__); return 1; }
if (iface != 1) { - msg_perr("Error: Unknown interface version: %d\n", iface); + msg_perr("%s: Unknown interface version: %d\n", + __func__, iface); return 1; }
msg_pdbg(MSGHEADER "Interface version ok.\n");
if (sp_docommand(S_CMD_Q_CMDMAP, 0, NULL, 32, sp_cmdmap)) { - msg_perr("Error: query command map not supported\n"); + msg_perr("%s: query command map not supported\n", + __func__); return 1; }
@@ -476,8 +496,9 @@ uint8_t bt = BUS_SPI; char *spispeed; if (sp_check_commandavail(S_CMD_O_SPIOP) == 0) { - msg_perr("Error: SPI operation not supported while the " - "bustype is SPI\n"); + msg_perr("%s: SPI operation not supported while the " + "bustype is SPI\n", + __func__); return 1; } if (sp_docommand(S_CMD_S_BUSTYPE, 1, &bt, 0, NULL)) @@ -515,7 +536,8 @@ errno = 0; f_spi_req = strtol(spispeed, &f_spi_suffix, 0); if (errno != 0 || spispeed == f_spi_suffix) { - msg_perr("Error: Could not convert 'spispeed'.\n"); + msg_perr("%s: Could not convert 'spispeed'.\n", + __func__); free(spispeed); return 1; } @@ -525,12 +547,14 @@ else if (!strcasecmp(f_spi_suffix, "k")) f_spi_req *= 1000; else { - msg_perr("Error: Garbage following 'spispeed' value.\n"); + msg_perr("%s: Garbage following 'spispeed' value.\n", + __func__); free(spispeed); return 1; } } else if (strlen(f_spi_suffix) > 1) { - msg_perr("Error: Garbage following 'spispeed' value.\n"); + msg_perr("%s: Garbage following 'spispeed' value.\n", + __func__); free(spispeed); return 1; } @@ -560,32 +584,37 @@
if (serprog_buses_supported & BUS_NONSPI) { if (sp_check_commandavail(S_CMD_O_INIT) == 0) { - msg_perr("Error: Initialize operation buffer " - "not supported\n"); + msg_perr("%s: Initialize operation buffer " + "not supported\n", + __func__); return 1; }
if (sp_check_commandavail(S_CMD_O_DELAY) == 0) { - msg_perr("Error: Write to opbuf: " - "delay not supported\n"); + msg_perr("%s: Write to opbuf: " + "delay not supported\n", + __func__); return 1; }
/* S_CMD_O_EXEC availability checked later. */
if (sp_check_commandavail(S_CMD_R_BYTE) == 0) { - msg_perr("Error: Single byte read not supported\n"); + msg_perr("%s: Single byte read not supported\n", + __func__); return 1; } /* This could be translated to single byte reads (if missing), * but now we don't support that. */ if (sp_check_commandavail(S_CMD_R_NBYTES) == 0) { - msg_perr("Error: Read n bytes not supported\n"); + msg_perr("%s: Read n bytes not supported\n", + __func__); return 1; } if (sp_check_commandavail(S_CMD_O_WRITEB) == 0) { - msg_perr("Error: Write to opbuf: " - "write byte not supported\n"); + msg_perr("%s: Write to opbuf: " + "write byte not supported\n", + __func__); return 1; }
@@ -603,8 +632,9 @@ sp_max_write_n); sp_write_n_buf = malloc(sp_max_write_n); if (!sp_write_n_buf) { - msg_perr("Error: cannot allocate memory for " - "Write-n buffer\n"); + msg_perr("%s: cannot allocate memory for " + "Write-n buffer\n", + __func__); return 1; } sp_write_n_bytes = 0; @@ -641,13 +671,15 @@ if (sp_check_commandavail(S_CMD_O_INIT)) { /* This would be inconsistent. */ if (sp_check_commandavail(S_CMD_O_EXEC) == 0) { - msg_perr("Error: Execute operation buffer not " - "supported\n"); + msg_perr("%s: Execute operation buffer not " + "supported\n", + __func__); return 1; }
if (sp_docommand(S_CMD_O_INIT, 0, NULL, 0, NULL)) { - msg_perr("Error: NAK to initialize operation buffer\n"); + msg_perr("%s: NAK to initialize operation buffer\n", + __func__); return 1; }
@@ -662,7 +694,8 @@ if (sp_check_commandavail(S_CMD_S_PIN_STATE)) { uint8_t en = 1; if (sp_docommand(S_CMD_S_PIN_STATE, 1, &en, 0, NULL) != 0) { - msg_perr("Error: could not enable output buffers\n"); + msg_perr("%s: could not enable output buffers\n", + __func__); return 1; } else msg_pdbg(MSGHEADER "Output drivers enabled\n"); @@ -709,11 +742,12 @@ header[5] = (sp_write_n_addr >> 8) & 0xFF; header[6] = (sp_write_n_addr >> 16) & 0xFF; if (serialport_write(header, 7) != 0) { - msg_perr(MSGHEADER "Error: cannot write write-n command\n"); + msg_perr(MSGHEADER "%s: cannot write write-n command\n", + __func__); return 1; } if (serialport_write(sp_write_n_buf, sp_write_n_bytes) != 0) { - msg_perr(MSGHEADER "Error: cannot write write-n data"); + msg_perr(MSGHEADER "%s: cannot write write-n data", __func__); return 1; } sp_streamed_transmit_bytes += 7 + sp_write_n_bytes; @@ -728,12 +762,13 @@ { if ((sp_max_write_n) && (sp_write_n_bytes)) { if (sp_pass_writen() != 0) { - msg_perr("Error: could not transfer write buffer\n"); + msg_perr("%s: could not transfer write buffer\n", + __func__); return 1; } } if (sp_stream_buffer_op(S_CMD_O_EXEC, 0, NULL) != 0) { - msg_perr("Error: could not execute command buffer\n"); + msg_perr("%s: could not execute command buffer\n", __func__); return 1; } msg_pspew(MSGHEADER "Executed operation buffer of %d bytes\n", sp_opbuf_usage); @@ -852,7 +887,7 @@ if (sp_flush_stream() != 0) return 1; if (serialport_read(buf, len) != 0) { - msg_perr(MSGHEADER "Error: cannot read read-n data"); + msg_perr(MSGHEADER "%s: cannot read read-n data", __func__); return 1; } return 0; @@ -904,14 +939,16 @@ msg_pspew("%s, writecnt=%i, readcnt=%i\n", __func__, writecnt, readcnt); if ((sp_opbuf_usage) || (sp_max_write_n && sp_write_n_bytes)) { if (sp_execute_opbuf() != 0) { - msg_perr("Error: could not execute command buffer before sending SPI commands.\n"); + msg_perr("%s: could not execute command buffer before sending SPI commands.\n", + __func__); return 1; } }
parmbuf = malloc(writecnt + 6); if (!parmbuf) { - msg_perr("Error: could not allocate SPI send param buffer.\n"); + msg_perr("%s: could not allocate SPI send param buffer.\n", + __func__); return 1; } parmbuf[0] = (writecnt >> 0) & 0xFF; diff --git a/spi25_statusreg.c b/spi25_statusreg.c index aa574d5..91df8b2 100644 --- a/spi25_statusreg.c +++ b/spi25_statusreg.c @@ -65,7 +65,7 @@ programmer_delay(100 * 1000); while (spi_read_status_register(flash) & SPI_SR_WIP) { if (++i > 490) { - msg_cerr("Error: WIP bit after WRSR never cleared\n"); + msg_cerr("%s: WIP bit after WRSR never cleared\n", __func__); return TIMEOUT_ERROR; } programmer_delay(10 * 1000);
Hello build bot (Jenkins), Edward O'Callaghan,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/40901
to look at the new patch set (#2).
Change subject: Switch all log prefixed with 'Error:' to '__func__:' ......................................................................
Switch all log prefixed with 'Error:' to '__func__:'
Showing Error is not very informative and switch to function name to make it easy for debug.
BUG=b:154285774 BRANCH=none TEST=build success
Change-Id: If3205d8e453cfcd37f725b4fd135fe1221c913c0 Signed-off-by: Shiyu Sun sshiyu@chromium.org --- M atavia.c M chipset_enable.c M cli_output.c M dediprog.c M digilent_spi.c M dummyflasher.c M flashrom.c M ft2232_spi.c M ichspi.c M it87spi.c M layout.c M libflashrom.c M lspcon_i2c_spi.c M mcp6x_spi.c M mstarddc_spi.c M pcidev.c M pickit2_spi.c M pony_spi.c M rayer_spi.c M sb600spi.c M serprog.c M spi25_statusreg.c 22 files changed, 215 insertions(+), 136 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/01/40901/2
Hello build bot (Jenkins), Edward O'Callaghan,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/40901
to look at the new patch set (#3).
Change subject: lspcon_i2c_spi.c: Switch logs with 'Error:' to '__func__:' ......................................................................
lspcon_i2c_spi.c: Switch logs with 'Error:' to '__func__:'
Showing Error is not very informative and switch to function name to make it easy for debug.
BUG=b:154285774 BRANCH=none TEST=build success
Change-Id: If3205d8e453cfcd37f725b4fd135fe1221c913c0 Signed-off-by: Shiyu Sun sshiyu@chromium.org --- M lspcon_i2c_spi.c 1 file changed, 12 insertions(+), 8 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/01/40901/3
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/40901 )
Change subject: lspcon_i2c_spi.c: Switch logs with 'Error:' to '__func__:' ......................................................................
Patch Set 3:
(3 comments)
https://review.coreboot.org/c/flashrom/+/40901/3//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/flashrom/+/40901/3//COMMIT_MSG@7 PS3, Line 7: Switch Prefix with fn name instead of just 'Error:'
https://review.coreboot.org/c/flashrom/+/40901/3//COMMIT_MSG@9 PS3, Line 9: Showing Error is not very informative and switch to function : name to make it easy for debug. Replaces log lines with the prefix formatter '%s: ..' and pass '__func__' to the printers so that errors are prefixed with the function from which they originated.
https://review.coreboot.org/c/flashrom/+/40901/3//COMMIT_MSG@11 PS3, Line 11: remove all this indentation.
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/40901 )
Change subject: lspcon_i2c_spi.c: Switch logs with 'Error:' to '__func__:' ......................................................................
Patch Set 3: Code-Review+1
(2 comments)
https://review.coreboot.org/c/flashrom/+/40901/3//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/flashrom/+/40901/3//COMMIT_MSG@7 PS3, Line 7: Switch
Prefix with fn name instead of just 'Error:'
Or:
Use '__func__' in error messages
https://review.coreboot.org/c/flashrom/+/40901/3//COMMIT_MSG@9 PS3, Line 9: Showing Error is not very informative and switch to function : name to make it easy for debug.
Replaces log lines with the prefix formatter '%s: .. […]
Replace*
Shiyu Sun has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/40901 )
Change subject: lspcon_i2c_spi.c: Switch logs with 'Error:' to '__func__:' ......................................................................
Patch Set 3:
(3 comments)
https://review.coreboot.org/c/flashrom/+/40901/3//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/flashrom/+/40901/3//COMMIT_MSG@7 PS3, Line 7: Switch
Or: […]
Done
https://review.coreboot.org/c/flashrom/+/40901/3//COMMIT_MSG@9 PS3, Line 9: Showing Error is not very informative and switch to function : name to make it easy for debug.
Replace*
Done
https://review.coreboot.org/c/flashrom/+/40901/3//COMMIT_MSG@11 PS3, Line 11:
remove all this indentation.
Done
Hello build bot (Jenkins), Edward O'Callaghan, Angel Pons,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/40901
to look at the new patch set (#4).
Change subject: lspcon_i2c_spi.c: Use '__func__' in error messages of just 'Error:' ......................................................................
lspcon_i2c_spi.c: Use '__func__' in error messages of just 'Error:'
Replace log lines with the prefix formatter '%s: ..' and pass '__func__' to the printers so that errors are prefixed with the function from which they originated.
BUG=b:154285774 BRANCH=none TEST=build success
Change-Id: If3205d8e453cfcd37f725b4fd135fe1221c913c0 Signed-off-by: Shiyu Sun sshiyu@chromium.org --- M lspcon_i2c_spi.c 1 file changed, 12 insertions(+), 8 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/01/40901/4
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/40901 )
Change subject: lspcon_i2c_spi.c: Use '__func__' in error messages of just 'Error:' ......................................................................
Patch Set 5:
(1 comment)
https://review.coreboot.org/c/flashrom/+/40901/5//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/flashrom/+/40901/5//COMMIT_MSG@7 PS5, Line 7: Use '__func__' in error messages of just 'Error:' Again, can you rephrase this to something that makes more sense?
Both Angel and I gave alternatives.
Hello build bot (Jenkins), Edward O'Callaghan, Angel Pons,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/40901
to look at the new patch set (#6).
Change subject: lspcon_i2c_spi.c: Prefix with fn name instead of just 'Error:' ......................................................................
lspcon_i2c_spi.c: Prefix with fn name instead of just 'Error:'
Replace log lines with the prefix formatter '%s: ..' and pass '__func__' to the printers so that errors are prefixed with the function from which they originated.
BUG=b:154285774 BRANCH=none TEST=build success
Change-Id: If3205d8e453cfcd37f725b4fd135fe1221c913c0 Signed-off-by: Shiyu Sun sshiyu@chromium.org --- M lspcon_i2c_spi.c 1 file changed, 12 insertions(+), 8 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/01/40901/6
Shiyu Sun has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/40901 )
Change subject: lspcon_i2c_spi.c: Prefix with fn name instead of just 'Error:' ......................................................................
Patch Set 6:
(1 comment)
Patch Set 5:
(1 comment)
https://review.coreboot.org/c/flashrom/+/40901/5//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/flashrom/+/40901/5//COMMIT_MSG@7 PS5, Line 7: Use '__func__' in error messages of just 'Error:'
Again, can you rephrase this to something that makes more sense? […]
Done
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/40901 )
Change subject: lspcon_i2c_spi.c: Prefix with fn name instead of just 'Error:' ......................................................................
Patch Set 6: Code-Review+2
Edward O'Callaghan has submitted this change. ( https://review.coreboot.org/c/flashrom/+/40901 )
Change subject: lspcon_i2c_spi.c: Prefix with fn name instead of just 'Error:' ......................................................................
lspcon_i2c_spi.c: Prefix with fn name instead of just 'Error:'
Replace log lines with the prefix formatter '%s: ..' and pass '__func__' to the printers so that errors are prefixed with the function from which they originated.
BUG=b:154285774 BRANCH=none TEST=build success
Change-Id: If3205d8e453cfcd37f725b4fd135fe1221c913c0 Signed-off-by: Shiyu Sun sshiyu@chromium.org Reviewed-on: https://review.coreboot.org/c/flashrom/+/40901 Reviewed-by: Edward O'Callaghan quasisec@chromium.org Reviewed-by: Angel Pons th3fanbus@gmail.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M lspcon_i2c_spi.c 1 file changed, 12 insertions(+), 8 deletions(-)
Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, but someone else must approve Edward O'Callaghan: Looks good to me, approved
diff --git a/lspcon_i2c_spi.c b/lspcon_i2c_spi.c index 72ed78a..7b9f1c0 100644 --- a/lspcon_i2c_spi.c +++ b/lspcon_i2c_spi.c @@ -154,7 +154,7 @@ } while (!ret && (val & mask) && ++tried < MAX_SPI_WAIT_RETRIES);
if (tried == MAX_SPI_WAIT_RETRIES) { - msg_perr("Error: Time out on sending command.\n"); + msg_perr("%s: Time out on sending command.\n", __func__); return -MAX_SPI_WAIT_RETRIES; }
@@ -179,7 +179,7 @@ } while (!ret && (val & SWSPICTL_ACCESS_TRIGGER) && ++tried < MAX_SPI_WAIT_RETRIES);
if (tried == MAX_SPI_WAIT_RETRIES) { - msg_perr("Error: Time out on waiting ROM free.\n"); + msg_perr("%s: Time out on waiting ROM free.\n", __func__); return -MAX_SPI_WAIT_RETRIES; }
@@ -258,7 +258,8 @@ { unsigned int i; if (writecnt > 16 || readcnt > 16 || writecnt == 0) { - msg_perr("Error: Invalid read/write count for send command.\n"); + msg_perr("%s: Invalid read/write count for send command.\n", + __func__); return SPI_GENERIC_ERROR; }
@@ -402,7 +403,8 @@ static int lspcon_i2c_spi_write_aai(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len) { - msg_perr("Error: AAI write function is not supported.\n"); + msg_perr("%s: AAI write function is not supported.\n", + __func__); return SPI_GENERIC_ERROR; }
@@ -441,17 +443,19 @@ errno = 0; int bus = (int)strtol(bus_str, &bus_suffix, 10); if (errno != 0 || bus_str == bus_suffix) { - msg_perr("Error: Could not convert 'bus'.\n"); + msg_perr("%s: Could not convert 'bus'.\n", __func__); goto get_bus_done; }
if (bus < 0 || bus > 255) { - msg_perr("Error: Value for 'bus' is out of range(0-255).\n"); + msg_perr("%s: Value for 'bus' is out of range(0-255).\n", + __func__); goto get_bus_done; }
if (strlen(bus_suffix) > 0) { - msg_perr("Error: Garbage following 'bus' value.\n"); + msg_perr("%s: Garbage following 'bus' value.\n", + __func__); goto get_bus_done; }
@@ -459,7 +463,7 @@ ret = bus; goto get_bus_done; } else { - msg_perr("Error: Bus number not specified.\n"); + msg_perr("%s: Bus number not specified.\n", __func__); } get_bus_done: if (bus_str)