summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Heymans <arthur@aheymans.xyz>2017-08-28 13:00:24 +0200
committerArthur Heymans <arthur@aheymans.xyz>2017-10-12 08:08:22 +0000
commit0315b6740a7cdc8fef0ae99e3549b810aa11e648 (patch)
tree2da3e26e3de2a12d6173e023fbd6c25bffa7a599
parent6af8aab539cce0bb1841cae7dfb0addbc8321855 (diff)
downloadcoreboot-0315b6740a7cdc8fef0ae99e3549b810aa11e648.tar.xz
sb/amd/sb700/lpc.c: Optimize code flow for less indentation
This changes the code flow so less indentation has to be used. This also changes some lines to limit their length. Change-Id: I50ca99a759a276e9d49327c6ae6c69eeab2a8c90 Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/21234 Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rw-r--r--src/southbridge/amd/sb700/lpc.c146
1 files changed, 74 insertions, 72 deletions
diff --git a/src/southbridge/amd/sb700/lpc.c b/src/southbridge/amd/sb700/lpc.c
index 643a5a1300..a56ccf0465 100644
--- a/src/southbridge/amd/sb700/lpc.c
+++ b/src/southbridge/amd/sb700/lpc.c
@@ -144,83 +144,85 @@ static void sb700_lpc_enable_childrens_resources(device_t dev)
device_t child;
for (child = link->children; child;
child = child->sibling) {
- if (child->enabled
- && (child->path.type == DEVICE_PATH_PNP)) {
- struct resource *res;
- for (res = child->resource_list; res; res = res->next) {
- u32 base, end; /* don't need long long */
- if (!(res->flags & IORESOURCE_IO))
+ if (!(child->enabled
+ && (child->path.type == DEVICE_PATH_PNP)))
+ continue;
+
+ struct resource *res;
+ for (res = child->resource_list; res; res = res->next) {
+ u32 base, end; /* don't need long long */
+ if (!(res->flags & IORESOURCE_IO))
+ continue;
+ base = res->base;
+ end = resource_end(res);
+ printk(BIOS_DEBUG, "sb700 lpc decode:%s,"
+ " base=0x%08x, end=0x%08x\n",
+ dev_path(child), base, end);
+ switch (base) {
+ case 0x60: /* KB */
+ case 0x64: /* MS */
+ reg |= (1 << 29);
+ break;
+ case 0x3f8: /* COM1 */
+ reg |= (1 << 6);
+ break;
+ case 0x2f8: /* COM2 */
+ reg |= (1 << 7);
+ break;
+ case 0x378: /* Parallel 1 */
+ reg |= (1 << 0);
+ reg |= (1 << 1); /* + 0x778 for ECP */
+ break;
+ case 0x3f0: /* FD0 */
+ reg |= (1 << 26);
+ break;
+ case 0x220: /* Audio 0 */
+ reg |= (1 << 8);
+ break;
+ case 0x300: /* Midi 0 */
+ reg |= (1 << 18);
+ break;
+ case 0x400:
+ reg_x |= (1 << 16);
+ break;
+ case 0x480:
+ reg_x |= (1 << 17);
+ break;
+ case 0x500:
+ reg_x |= (1 << 18);
+ break;
+ case 0x580:
+ reg_x |= (1 << 19);
+ break;
+ case 0x4700:
+ reg_x |= (1 << 22);
+ break;
+ case 0xfd60:
+ reg_x |= (1 << 23);
+ break;
+ default:
+ /* only 3 var ; compact them ? */
+ if (var_num >= 3)
continue;
- base = res->base;
- end = resource_end(res);
- printk(BIOS_DEBUG, "sb700 lpc decode:%s, base=0x%08x, end=0x%08x\n",
- dev_path(child), base, end);
- switch (base) {
- case 0x60: /* KB */
- case 0x64: /* MS */
- reg |= (1 << 29);
+ switch (var_num) {
+ case 0:
+ reg_x |= (1 << 2);
+ if ((end - base) < 16)
+ wiosize |= (1 << 0);
break;
- case 0x3f8: /* COM1 */
- reg |= (1 << 6);
+ case 1:
+ reg_x |= (1 << 24);
+ if ((end - base) < 16)
+ wiosize |= (1 << 2);
break;
- case 0x2f8: /* COM2 */
- reg |= (1 << 7);
+ case 2:
+ reg_x |= (1 << 25);
+ reg_x |= (1 << 24);
+ if ((end - base) < 16)
+ wiosize |= (1 << 3);
break;
- case 0x378: /* Parallel 1 */
- reg |= (1 << 0);
- reg |= (1 << 1); /* + 0x778 for ECP */
- break;
- case 0x3f0: /* FD0 */
- reg |= (1 << 26);
- break;
- case 0x220: /* Audio 0 */
- reg |= (1 << 8);
- break;
- case 0x300: /* Midi 0 */
- reg |= (1 << 18);
- break;
- case 0x400:
- reg_x |= (1 << 16);
- break;
- case 0x480:
- reg_x |= (1 << 17);
- break;
- case 0x500:
- reg_x |= (1 << 18);
- break;
- case 0x580:
- reg_x |= (1 << 19);
- break;
- case 0x4700:
- reg_x |= (1 << 22);
- break;
- case 0xfd60:
- reg_x |= (1 << 23);
- break;
- default:
- if (var_num >= 3)
- continue; /* only 3 var ; compact them ? */
- switch (var_num) {
- case 0:
- reg_x |= (1 << 2);
- if ((end - base) < 16)
- wiosize |= (1 << 0);
- break;
- case 1:
- reg_x |= (1 << 24);
- if ((end - base) < 16)
- wiosize |= (1 << 2);
- break;
- case 2:
- reg_x |= (1 << 25);
- reg_x |= (1 << 24);
- if ((end - base) < 16)
- wiosize |= (1 << 3);
- break;
- }
- reg_var[var_num++] =
- base & 0xffff;
}
+ reg_var[var_num++] = base & 0xffff;
}
}
}