Michael Niewöhner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/45112 )
Change subject: soc/intel: skl,cnl,icl,jsl,tgl: disable usb over-current pin by default ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/coreboot/+/45112/2/src/soc/intel/cannonlake/fs... File src/soc/intel/cannonlake/fsp_params.c:
https://review.coreboot.org/c/coreboot/+/45112/2/src/soc/intel/cannonlake/fs... PS2, Line 376: params->Usb2OverCurrentPin[i] = config->usb2_ports[i].ocpin;
Why the indirection when we can have a simple if/else […]
There are multiple ways of doing this different. I'm not sure what the "best" way is.
Variant 1 (as Felix suggested):
``` for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) { params->PortUsb20Enable[i] = config->usb2_ports[i].enable; params->Usb3OverCurrentPin[i] = config->usb3_ports[i].enable ? config->usb3_ports[i].ocpin : 0xff; ... ```
Variant 2 (I don't like this)
``` for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) { params->PortUsb20Enable[i] = config->usb2_ports[i].enable; if (config->usb2_ports[i].enable) {
params->Usb3OverCurrentPin[i] = config->usb3_ports[i].enable ? config->usb3_ports[i].ocpin : 0xff; ... ```
Variant 3 (changes logic for the other options, too)
``` memset(params->Usb3OverCurrentPin, 0xff, sizeof(params->Usb3OverCurrentPin)); for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) { if (!config->usb2_ports[i].enable) continue;
params->PortUsb20Enable[i] = 1 params->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin; ... ```