Attention is currently required from: Stefan Reinauer, Edward O'Callaghan, Angel Pons. Xiang Wang has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/49254 )
Change subject: sysfsgpio.c implement spi interface via linux sysfs ......................................................................
Patch Set 3:
(9 comments)
Commit Message:
https://review.coreboot.org/c/flashrom/+/49254/comment/f4b388be_36105b63 PS1, Line 10: some SBC
Which one have you tested this on?
raspberry pi zero w W25Q128.V
File Makefile:
https://review.coreboot.org/c/flashrom/+/49254/comment/9ab8fbb4_3a62ea0b PS1, Line 1: #
Both meson.* and the Makefile needs modifying as well unfortunately.
Done
File sysfsgpio.c:
https://review.coreboot.org/c/flashrom/+/49254/comment/4d35182f_7ff61e51 PS1, Line 36: #define GPIO_DIRECTION "/sys/class/gpio/gpio%d/direction"
The only definition that gets used twice is `GPIO_PATH`. The others are only used once.
Done
https://review.coreboot.org/c/flashrom/+/49254/comment/6c3a4dad_2b187ca9 PS1, Line 38: #define EXIST_PATH(path) (access((path), F_OK) == 0
It's only used twice, so I don't think this provides any benefit. […]
Done
https://review.coreboot.org/c/flashrom/+/49254/comment/66c7c57e_a7f92b35 PS1, Line 42: int pin;
Looks like the code only uses the string representation of `pin`. […]
Remove the pin number of the integer, use a string to record the pin number
https://review.coreboot.org/c/flashrom/+/49254/comment/335ae1bb_7c5e7339 PS1, Line 47: static struct pin_desc pin_cs = { : .name = "cs", : .fd_direction = -1, : .fd_value = -1 : }; : : static struct pin_desc pin_sck = { : .name = "sck", : .fd_direction = -1, : .fd_value = -1 : }; : : static struct pin_desc pin_mosi = { : .name = "mosi", : .fd_direction = -1, : .fd_value = -1 : }; : : static struct pin_desc pin_miso = { : .name = "miso", : .fd_direction = -1, : .fd_value = -1 : };
I would suggest making another struct to hold all pins in a single global variable: […]
Done
https://review.coreboot.org/c/flashrom/+/49254/comment/5ef67f14_379fb3e8 PS1, Line 80: if (ret == (int)strlen(str))
To avoid casting to int, I would test for failure here with `ret < strlen(str)`.
I tried it, and the compilation still reports an error
https://review.coreboot.org/c/flashrom/+/49254/comment/bc71e935_a47b1981 PS1, Line 92: snprintf(s, sizeof(s), "%d", desc->pin);
If you can avoid clobbering the buffer contents with this snprintf call (see suggestion to use a `pi […]
Done
https://review.coreboot.org/c/flashrom/+/49254/comment/361a11d8_e959a707 PS1, Line 209: /* parameter format: pins=cs_pin:sck_pin:mosi_pin:miso_pin */ : char *pins = extract_programmer_param("pins"); : int pins_inited = 0; : do { : struct pin_desc *pins_tab[] = { : &pin_cs, &pin_sck, &pin_mosi, &pin_miso : }; : if (!(pins && strlen(pins))) : break; : char *token = strtok(pins, ":"); : for (unsigned i = 0; i < ARRAY_SIZE(pins_tab); i++) { : long v; : if (!token) : break; : if (atoi_s(token, 1, &v)) : break; : pins_tab[i]->pin = v; : if (export_sysfsgpio(pins_tab[i])) : break; : token = strtok(NULL, ":"); : pins_inited = (i + 1 == ARRAY_SIZE(pins_tab)); : } : } while (0); : if (pins) : free(pins); : if (!pins_inited) : return 1;
I suggest making this its own static fn for param extraction and pass in &pin_desc to fetch out the […]
The pin information can be extracted into the global variable pins. So not need pass parameters