Attention is currently required from: Xiang Wang, Stefan Reinauer, Angel Pons. Edward O'Callaghan 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: Code-Review+1
(8 comments)
Commit Message:
https://review.coreboot.org/c/flashrom/+/49254/comment/b1bf05f4_eecf71e5 PS1, Line 10: some SBC
raspberry pi zero w […]
Include this information in your commit message on a `TEST=` line perhaps?
File sysfsgpio.c:
https://review.coreboot.org/c/flashrom/+/49254/comment/64e2fd6f_d37487a4 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;
The pin information can be extracted into the global variable pins. […]
It looks much better now but I think we can make one more step forwards to keeping more of the functions pure. This helps for unit-tests (which would be ideal if you can add some) but generally helps box down the global state accesses to a limited number of places.
File sysfsgpio.c:
https://review.coreboot.org/c/flashrom/+/49254/comment/29214bde_4d9ed98b PS3, Line 46: pins `g_pins`
https://review.coreboot.org/c/flashrom/+/49254/comment/583cc17f_e72d7d72 PS3, Line 157: p g_
https://review.coreboot.org/c/flashrom/+/49254/comment/2eadaeba_b4fe35ec PS3, Line 184: p g_
https://review.coreboot.org/c/flashrom/+/49254/comment/4ba00f2b_b2d68c0e PS3, Line 204: static int parse_pins(void) `static int parse_pins(struct sysfsgpio_pins *pins)`
https://review.coreboot.org/c/flashrom/+/49254/comment/7f0451ef_2cd72254 PS3, Line 241: ) `parse_pins(&g_pins)`
https://review.coreboot.org/c/flashrom/+/49254/comment/cd11f93e_955efa76 PS3, Line 244: p g_