Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/47054 )
Change subject: mb/intel/adlrvp: Replace if-else-if ladder with switch construct ......................................................................
Patch Set 2: Code-Review+2
(1 comment)
https://review.coreboot.org/c/coreboot/+/47054/2/src/mainboard/intel/adlrvp/... File src/mainboard/intel/adlrvp/variants/adlrvp_p/memory.c:
https://review.coreboot.org/c/coreboot/+/47054/2/src/mainboard/intel/adlrvp/... PS2, Line 76: case ADL_P_LP4_1:
Because missing a 'break' (or return, etc.) in switch statements is a common mistake, I like to add […]
I would agree in other cases, but I'd say this case is pretty self-explanatory already. Generally, I only add a comment about falling through when one case executes something and then falls through another case. Here's an example:
/* Ensure magic is not power gated before reading the status */ pci_and_config8(dev, MAGIC_CONTROL_REG, ~POWER_GATE_MAGIC);
enum magic_power_level magic_power = pci_read_config8(dev, MAGIC_STATUS_REG); switch (magic_power) { case NO_MAGIC: printk(BIOS_DEBUG, "Magic is disabled\n"); /* Power off magic to save power */ pci_or_config8(dev, MAGIC_CONTROL_REG, POWER_GATE_MAGIC); /* Intentional fallthrough */ case MINIMUM_MAGIC: /* Ensure advanced magic is off */ pci_and_config8(dev, MAGIC_CONTROL_REG, ~ADVANCED_MAGIC_ENABLE); break; case STANDARD_MAGIC: case MORE_MAGIC: pci_write_config8(dev, MAGIC_POWER_SELECT_REG, magic_power); udelay(400); /* Magic power changes need some time to complete */ /* Only enable advanced magic after power has been configured */ pci_or_config8(dev, MAGIC_CONTROL_REG, ADVANCED_MAGIC_ENABLE); break; default: /* Cannot safely handle too much magic */ die("Requested magic power %u is unsafe\n", magic_power); }
Yes, it might not make much sense, but this magic hardware is programmed using magic sequences.