Jacob Garber has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/33669
Change subject: tree: Remove unused functions with no prototypes
......................................................................
tree: Remove unused functions with no prototypes
These functions are no longer used, or were never used in the first place.
generate_testpattern() - Introduced in commit eaac68bf8b, never used
list_programmers() - Introduced in commit 552420b0d6, never used
pci_dev_find_filter() - Prototype removed in commit 5c316f9549
erase_chip_jedec() - Usage and prototype removed in commit f52f784bb3
printlock_regspace2_blocks() - Introduced in commit ef3ac8ac17, never used
spi_write_status_enable() - Usage dropped in commit fcbdbbc0d4
Change-Id: I742164670521fea65ffa3808446594848ce63cec
Signed-off-by: Jacob Garber <jgarber1(a)ualberta.ca>
---
M flashrom.c
M internal.c
M jedec.c
M spi25_statusreg.c
4 files changed, 0 insertions(+), 186 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/69/33669/1
diff --git a/flashrom.c b/flashrom.c
index 5b85c14..cb1dca6 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -975,142 +975,6 @@
return first_len;
}
-/* This function generates various test patterns useful for testing controller
- * and chip communication as well as chip behaviour.
- *
- * If a byte can be written multiple times, each time keeping 0-bits at 0
- * and changing 1-bits to 0 if the new value for that bit is 0, the effect
- * is essentially an AND operation. That's also the reason why this function
- * provides the result of AND between various patterns.
- *
- * Below is a list of patterns (and their block length).
- * Pattern 0 is 05 15 25 35 45 55 65 75 85 95 a5 b5 c5 d5 e5 f5 (16 Bytes)
- * Pattern 1 is 0a 1a 2a 3a 4a 5a 6a 7a 8a 9a aa ba ca da ea fa (16 Bytes)
- * Pattern 2 is 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f (16 Bytes)
- * Pattern 3 is a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af (16 Bytes)
- * Pattern 4 is 00 10 20 30 40 50 60 70 80 90 a0 b0 c0 d0 e0 f0 (16 Bytes)
- * Pattern 5 is 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f (16 Bytes)
- * Pattern 6 is 00 (1 Byte)
- * Pattern 7 is ff (1 Byte)
- * Patterns 0-7 have a big-endian block number in the last 2 bytes of each 256
- * byte block.
- *
- * Pattern 8 is 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11... (256 B)
- * Pattern 9 is ff fe fd fc fb fa f9 f8 f7 f6 f5 f4 f3 f2 f1 f0 ef ee... (256 B)
- * Pattern 10 is 00 00 00 01 00 02 00 03 00 04... (128 kB big-endian counter)
- * Pattern 11 is ff ff ff fe ff fd ff fc ff fb... (128 kB big-endian downwards)
- * Pattern 12 is 00 (1 Byte)
- * Pattern 13 is ff (1 Byte)
- * Patterns 8-13 have no block number.
- *
- * Patterns 0-3 are created to detect and efficiently diagnose communication
- * slips like missed bits or bytes and their repetitive nature gives good visual
- * cues to the person inspecting the results. In addition, the following holds:
- * AND Pattern 0/1 == Pattern 4
- * AND Pattern 2/3 == Pattern 5
- * AND Pattern 0/1/2/3 == AND Pattern 4/5 == Pattern 6
- * A weakness of pattern 0-5 is the inability to detect swaps/copies between
- * any two 16-byte blocks except for the last 16-byte block in a 256-byte bloc.
- * They work perfectly for detecting any swaps/aliasing of blocks >= 256 bytes.
- * 0x5 and 0xa were picked because they are 0101 and 1010 binary.
- * Patterns 8-9 are best for detecting swaps/aliasing of blocks < 256 bytes.
- * Besides that, they provide for bit testing of the last two bytes of every
- * 256 byte block which contains the block number for patterns 0-6.
- * Patterns 10-11 are special purpose for detecting subblock aliasing with
- * block sizes >256 bytes (some Dataflash chips etc.)
- * AND Pattern 8/9 == Pattern 12
- * AND Pattern 10/11 == Pattern 12
- * Pattern 13 is the completely erased state.
- * None of the patterns can detect aliasing at boundaries which are a multiple
- * of 16 MBytes (but such chips do not exist anyway for Parallel/LPC/FWH/SPI).
- */
-int generate_testpattern(uint8_t *buf, uint32_t size, int variant)
-{
- int i;
-
- if (!buf) {
- msg_gerr("Invalid buffer!\n");
- return 1;
- }
-
- switch (variant) {
- case 0:
- for (i = 0; i < size; i++)
- buf[i] = (i & 0xf) << 4 | 0x5;
- break;
- case 1:
- for (i = 0; i < size; i++)
- buf[i] = (i & 0xf) << 4 | 0xa;
- break;
- case 2:
- for (i = 0; i < size; i++)
- buf[i] = 0x50 | (i & 0xf);
- break;
- case 3:
- for (i = 0; i < size; i++)
- buf[i] = 0xa0 | (i & 0xf);
- break;
- case 4:
- for (i = 0; i < size; i++)
- buf[i] = (i & 0xf) << 4;
- break;
- case 5:
- for (i = 0; i < size; i++)
- buf[i] = i & 0xf;
- break;
- case 6:
- memset(buf, 0x00, size);
- break;
- case 7:
- memset(buf, 0xff, size);
- break;
- case 8:
- for (i = 0; i < size; i++)
- buf[i] = i & 0xff;
- break;
- case 9:
- for (i = 0; i < size; i++)
- buf[i] = ~(i & 0xff);
- break;
- case 10:
- for (i = 0; i < size % 2; i++) {
- buf[i * 2] = (i >> 8) & 0xff;
- buf[i * 2 + 1] = i & 0xff;
- }
- if (size & 0x1)
- buf[i * 2] = (i >> 8) & 0xff;
- break;
- case 11:
- for (i = 0; i < size % 2; i++) {
- buf[i * 2] = ~((i >> 8) & 0xff);
- buf[i * 2 + 1] = ~(i & 0xff);
- }
- if (size & 0x1)
- buf[i * 2] = ~((i >> 8) & 0xff);
- break;
- case 12:
- memset(buf, 0x00, size);
- break;
- case 13:
- memset(buf, 0xff, size);
- break;
- }
-
- if ((variant >= 0) && (variant <= 7)) {
- /* Write block number in the last two bytes of each 256-byte
- * block, big endian for easier reading of the hexdump.
- * Note that this wraps around for chips larger than 2^24 bytes
- * (16 MB).
- */
- for (i = 0; i < size / 256; i++) {
- buf[i * 256 + 254] = (i >> 8) & 0xff;
- buf[i * 256 + 255] = i & 0xff;
- }
- }
-
- return 0;
-}
-
/* Returns the number of busses commonly supported by the current programmer and flash chip where the latter
* can not be completely accessed due to size/address limits of the programmer. */
unsigned int count_max_decode_exceedings(const struct flashctx *flash)
@@ -2003,18 +1867,6 @@
"mail flashrom(a)flashrom.org, thanks!\n");
}
-/* The way to go if you want a delimited list of programmers */
-void list_programmers(const char *delim)
-{
- enum programmer p;
- for (p = 0; p < PROGRAMMER_INVALID; p++) {
- msg_ginfo("%s", programmer_table[p].name);
- if (p < PROGRAMMER_INVALID - 1)
- msg_ginfo("%s", delim);
- }
- msg_ginfo("\n");
-}
-
void list_programmers_linebreak(int startcol, int cols, int paren)
{
const char *pname;
diff --git a/internal.c b/internal.c
index 2bb437c..12c0ba3 100644
--- a/internal.c
+++ b/internal.c
@@ -21,17 +21,6 @@
#include "programmer.h"
#include "hwaccess.h"
-struct pci_dev *pci_dev_find_filter(struct pci_filter filter)
-{
- struct pci_dev *temp;
-
- for (temp = pacc->devices; temp; temp = temp->next)
- if (pci_filter_match(&filter, temp))
- return temp;
-
- return NULL;
-}
-
struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t devclass)
{
struct pci_dev *temp;
diff --git a/jedec.c b/jedec.c
index 54b7da7..ac1ea0d 100644
--- a/jedec.c
+++ b/jedec.c
@@ -550,14 +550,6 @@
return erase_block_jedec_common(flash, page, size, mask);
}
-int erase_chip_jedec(struct flashctx *flash)
-{
- unsigned int mask;
-
- mask = getaddrmask(flash->chip);
- return erase_chip_jedec_common(flash, mask);
-}
-
struct unlockblock {
unsigned int size;
unsigned int count;
@@ -616,11 +608,6 @@
return 0;
}
-int printlock_regspace2_blocks(const struct flashctx *flash, const struct unlockblock *blocks)
-{
- return regspace2_walk_unlockblocks(flash, blocks, &printlock_regspace2_block);
-}
-
static int printlock_regspace2_uniform(struct flashctx *flash, unsigned long block_size)
{
const unsigned int elems = flash->chip->total_size * 1024 / block_size;
diff --git a/spi25_statusreg.c b/spi25_statusreg.c
index 4cf7023..8cd5a28 100644
--- a/spi25_statusreg.c
+++ b/spi25_statusreg.c
@@ -22,20 +22,6 @@
#include "spi.h"
/* === Generic functions === */
-int spi_write_status_enable(struct flashctx *flash)
-{
- static const unsigned char cmd[JEDEC_EWSR_OUTSIZE] = { JEDEC_EWSR };
- int result;
-
- /* Send EWSR (Enable Write Status Register). */
- result = spi_send_command(flash, sizeof(cmd), JEDEC_EWSR_INSIZE, cmd, NULL);
-
- if (result)
- msg_cerr("%s failed\n", __func__);
-
- return result;
-}
-
static int spi_write_status_register_flag(struct flashctx *flash, int status, const unsigned char enable_opcode)
{
int result;
--
To view, visit https://review.coreboot.org/c/flashrom/+/33669
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I742164670521fea65ffa3808446594848ce63cec
Gerrit-Change-Number: 33669
Gerrit-PatchSet: 1
Gerrit-Owner: Jacob Garber <jgarber1(a)ualberta.ca>
Gerrit-MessageType: newchange
Jacob Garber has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/33654
Change subject: spi25: Make internal functions static
......................................................................
spi25: Make internal functions static
These functions are only used in this file, so they can be made static.
Change-Id: I609971c79860e5697638714cf299ec4a4dcea038
Signed-off-by: Jacob Garber <jgarber1(a)ualberta.ca>
---
M spi25.c
1 file changed, 3 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/54/33654/1
diff --git a/spi25.c b/spi25.c
index fd87dc9..ba9eb0a 100644
--- a/spi25.c
+++ b/spi25.c
@@ -455,19 +455,19 @@
return result ? result : status;
}
-int spi_chip_erase_60(struct flashctx *flash)
+static int spi_chip_erase_60(struct flashctx *flash)
{
/* This usually takes 1-85s, so wait in 1s steps. */
return spi_simple_write_cmd(flash, 0x60, 1000 * 1000);
}
-int spi_chip_erase_62(struct flashctx *flash)
+static int spi_chip_erase_62(struct flashctx *flash)
{
/* This usually takes 2-5s, so wait in 100ms steps. */
return spi_simple_write_cmd(flash, 0x62, 100 * 1000);
}
-int spi_chip_erase_c7(struct flashctx *flash)
+static int spi_chip_erase_c7(struct flashctx *flash)
{
/* This usually takes 1-85s, so wait in 1s steps. */
return spi_simple_write_cmd(flash, 0xc7, 1000 * 1000);
--
To view, visit https://review.coreboot.org/c/flashrom/+/33654
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I609971c79860e5697638714cf299ec4a4dcea038
Gerrit-Change-Number: 33654
Gerrit-PatchSet: 1
Gerrit-Owner: Jacob Garber <jgarber1(a)ualberta.ca>
Gerrit-MessageType: newchange
Jacob Garber has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/33666
Change subject: flashrom: Make internal functions static
......................................................................
flashrom: Make internal functions static
These functions are only used in this file, so they can be made static.
Change-Id: I7b63464bb8b5a25fc004350a188dab6ee5c1a204
Signed-off-by: Jacob Garber <jgarber1(a)ualberta.ca>
---
M flashrom.c
1 file changed, 3 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/66/33666/1
diff --git a/flashrom.c b/flashrom.c
index b47d0a2..ea3d002 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -738,7 +738,7 @@
}
/* start is an offset to the base address of the flash chip */
-int check_erased_range(struct flashctx *flash, unsigned int start,
+static int check_erased_range(struct flashctx *flash, unsigned int start,
unsigned int len)
{
int ret;
@@ -2055,7 +2055,7 @@
}
}
-void print_sysinfo(void)
+static void print_sysinfo(void)
{
#if IS_WINDOWS
SYSTEM_INFO si;
@@ -2235,7 +2235,7 @@
/* FIXME: This function signature needs to be improved once doit() has a better
* function signature.
*/
-int chip_safety_check(const struct flashctx *flash, int force, int read_it, int write_it, int erase_it,
+static int chip_safety_check(const struct flashctx *flash, int force, int read_it, int write_it, int erase_it,
int verify_it)
{
const struct flashchip *chip = flash->chip;
--
To view, visit https://review.coreboot.org/c/flashrom/+/33666
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I7b63464bb8b5a25fc004350a188dab6ee5c1a204
Gerrit-Change-Number: 33666
Gerrit-PatchSet: 1
Gerrit-Owner: Jacob Garber <jgarber1(a)ualberta.ca>
Gerrit-MessageType: newchange
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/25683 )
Change subject: Add support for National Instruments USB-845x devices
......................................................................
Patch Set 17:
(19 comments)
First time I looked through all the code. I know it's
already been lying around for more than a year, sorry
for that.
It looks nearly ready, although I added some serious
comments. Also, there is still a lot of CamelCase. And
generally, we try to follow the coding style of the
Linux kernel. There is a nice tool to help with that
(checkpatch.pl [1]). That is, if you have perl installed.
I don't use it myself, but let me try...
./checkpath.pl --no-tree --max-line-length=112 --file ni845x_spi.c
The first warning is spurious, but the errors should be
checked. And the other warnings might give some nice
hints.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/sc…https://review.coreboot.org/#/c/25683/17/flashrom.8.tmpl
File flashrom.8.tmpl:
https://review.coreboot.org/#/c/25683/17/flashrom.8.tmpl@1144
PS17, Line 1144: 1230A2
Nit, example has only 6 digits.
https://review.coreboot.org/#/c/25683/10/ni845x_spi.c
File ni845x_spi.c:
https://review.coreboot.org/#/c/25683/10/ni845x_spi.c@123
PS10, Line 123: %ld
> int32 is coming from the NI's header where it is defined as a long: […]
Stefan is correct. You shouldn't know what the header file defines. The
header file could change, for instance if NI would issue a 64-bit version
of the library. Please either cast `tmp` to the expected type or use
the `inttypes.h` definitions as Stefan suggested.
https://review.coreboot.org/#/c/25683/17/ni845x_spi.c
File ni845x_spi.c:
https://review.coreboot.org/#/c/25683/17/ni845x_spi.c@43
PS17, Line 43: static char error_string_buffer[1024];
Writing a function around this would probably save a lot lines below
and the buffer could be local. e.g.
void ni845x_report_error(const char *const func, const int32 err)
{
static char buf[1024];
ni845xStatusToString(err, sizeof(buf), buf);
msg_perr("%s failed with: %s (%d)\n", func, buf, (int)err);
}
Callers could use `__func__` to reduce copy-paste errors:
ni845x_report_error(__func__, tmp);
https://review.coreboot.org/#/c/25683/17/ni845x_spi.c@107
PS17, Line 107: * @brief ni845x_spi_open
Nit, adds no information.
https://review.coreboot.org/#/c/25683/17/ni845x_spi.c@109
PS17, Line 109: competition
completion?
https://review.coreboot.org/#/c/25683/17/ni845x_spi.c@134
PS17, Line 134: "USB%d::0x%04X::0x%04X::%08X::RAW",
%d expects an `int`, %X an `unsigned int`. If the pointers you pass
are compatible, is implementation specific.
A generally portable version would be (assuming bus numbers are >= 0):
unsigned int usb_bus, vid, device_pid;
unsigned long int serial_as_number;
sccanf(resource_name, "USB%u::0x%04X::0x%04X::%08lX::RAW",
&usb_bus, &vid, &device_pid, &serial_as_number);
https://review.coreboot.org/#/c/25683/17/ni845x_spi.c@207
PS17, Line 207: IO_voltage_100mV = ((float)IOVoltage_mV / 100.0f);
Doing the calculation as `float` shouldn't make a difference.
https://review.coreboot.org/#/c/25683/17/ni845x_spi.c@219
PS17, Line 219: msg_pwarn
Shouldn't be a warning, msg_pinfo() maybe?
https://review.coreboot.org/#/c/25683/17/ni845x_spi.c@226
PS17, Line 226: if (selected_voltage_100mV == 0) {
This looks odd. I would have expect it to select 1.2V automatically here.
The loop above doesn't look like it's possible to select 1.2V.
https://review.coreboot.org/#/c/25683/17/ni845x_spi.c@266
PS17, Line 266: Set
Get
https://review.coreboot.org/#/c/25683/17/ni845x_spi.c@301
PS17, Line 301: &usb_bus, &vid, &pid, &serial_as_number);
Check return code?
https://review.coreboot.org/#/c/25683/17/ni845x_spi.c@317
PS17, Line 317: ni845xFindDeviceNext(device_find_handle, resource_handle);
Check return code?
https://review.coreboot.org/#/c/25683/17/ni845x_spi.c@342
PS17, Line 342: CS_number = atoi(CS_str);
atoi() isn't a good choice, it would return a valid `0` on any error.
One good pattern is to use strtoul() and check `endptr`, e.g.:
cs_number = strtoul(cs_str, &endptr, 0);
if (!*cs_str || *endptr || cs_number < 0 || 7 < cs_number) {
return 1;
}
In this case, however, as there is only a single digit to parse, this
should be safe too:
cs_number = cs_str[0] - '0';
if (cs_str[1] || cs_number < 0 || 7 < cs_number) {
return 1;
}
https://review.coreboot.org/#/c/25683/17/ni845x_spi.c@345
PS17, Line 345: return 1;
leaking `CS_str`
https://review.coreboot.org/#/c/25683/17/ni845x_spi.c@382
PS17, Line 382: if (serial_number)
Not needed, as `free(NULL);` is valid.
https://review.coreboot.org/#/c/25683/17/ni845x_spi.c@391
PS17, Line 391: atoi
atoi(), see above.
https://review.coreboot.org/#/c/25683/17/ni845x_spi.c@399
PS17, Line 399:
None of the error paths (early `return`s) after opening the device
closes the device. Maybe just call ni845x_spi_shutdown() directly,
in case.
It would be nice to sort the code blocks here: 1. do all the parameter
parsing, 2. open the device and apply the settings. This should also ease
the error path handling.
https://review.coreboot.org/#/c/25683/17/ni845x_spi.c@441
PS17, Line 441: msg_cinfo("FAILED.\n");
Why the second message?
https://review.coreboot.org/#/c/25683/17/ni845x_spi.c@449
PS17, Line 449: (uInt32)
the cast seems unnecessary
--
To view, visit https://review.coreboot.org/c/flashrom/+/25683
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I9477b6f0193bfdf20bbe63421a7fb97b597ec549
Gerrit-Change-Number: 25683
Gerrit-PatchSet: 17
Gerrit-Owner: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: HAOUAS Elyes <ehaouas(a)noos.fr>
Gerrit-CC: Márton Miklós <martonmiklosqdev(a)gmail.com>
Gerrit-CC: Stefan T <stefan.tauner(a)gmx.at>
Gerrit-Comment-Date: Fri, 21 Jun 2019 17:09:24 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Stefan T <stefan.tauner(a)gmx.at>
Comment-In-Reply-To: Márton Miklós <martonmiklosqdev(a)gmail.com>
Gerrit-MessageType: comment