From 9c7c6f7213decfc0d0fee4bbc911a291ee93bcdb Mon Sep 17 00:00:00 2001 From: Lee Leahy Date: Thu, 16 Mar 2017 11:24:09 -0700 Subject: arch/x86: Fix issues with braces detected by checkpatch Fix the following errors and warnings detected by checkpatch.pl: ERROR: open brace '{' following function declarations go on the next line ERROR: that open brace { should be on the previous line ERROR: else should follow close brace '}' WARNING: braces {} are not necessary for any arm of this statement WARNING: braces {} are not necessary for single statement blocks TEST=Build and run on Galileo Gen2 Change-Id: I13d1967757e106c8300a15baed25d920c52a1a95 Signed-off-by: Lee Leahy Reviewed-on: https://review.coreboot.org/18861 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/arch/x86/acpi.c | 14 +++++--------- src/arch/x86/acpigen.c | 22 ++++++++++++---------- src/arch/x86/bootblock_normal.c | 3 ++- src/arch/x86/cpu.c | 24 +++++++----------------- src/arch/x86/exception.c | 28 +++++++++------------------- src/arch/x86/include/arch/bootblock_romcc.h | 3 +-- src/arch/x86/include/arch/io.h | 9 +++------ src/arch/x86/include/arch/smp/mpspec.h | 21 +++++++-------------- src/arch/x86/mpspec.c | 7 ++++--- src/arch/x86/pirq_routing.c | 9 +++------ src/arch/x86/smbios.c | 8 +++----- src/arch/x86/tables.c | 20 ++++++++++---------- 12 files changed, 66 insertions(+), 102 deletions(-) (limited to 'src/arch') diff --git a/src/arch/x86/acpi.c b/src/arch/x86/acpi.c index 703bfa1e9b..4109ec4fae 100644 --- a/src/arch/x86/acpi.c +++ b/src/arch/x86/acpi.c @@ -287,9 +287,8 @@ static void acpi_create_tcpa(acpi_tcpa_t *tcpa) memset((void *)tcpa, 0, sizeof(acpi_tcpa_t)); lasa = get_tcpa_log(&tcpa_log_len); - if (!lasa) { + if (!lasa) return; - } /* Fill out header fields. */ memcpy(header->signature, "TCPA", 4); @@ -354,9 +353,8 @@ void acpi_create_ssdt_generator(acpi_header_t *ssdt, const char *oem_table_id) { struct device *dev; for (dev = all_devices; dev; dev = dev->next) - if (dev->ops && dev->ops->acpi_fill_ssdt_generator) { + if (dev->ops && dev->ops->acpi_fill_ssdt_generator) dev->ops->acpi_fill_ssdt_generator(dev); - } current = (unsigned long) acpigen_get_current(); } @@ -840,11 +838,10 @@ void acpi_create_fadt(acpi_fadt_t *fadt,acpi_facs_t *facs, void *dsdt) fadt->x_dsdt_l = (unsigned long)dsdt; fadt->x_dsdt_h = 0; - if (IS_ENABLED(CONFIG_SYSTEM_TYPE_LAPTOP)) { + if (IS_ENABLED(CONFIG_SYSTEM_TYPE_LAPTOP)) fadt->preferred_pm_profile = PM_MOBILE; - } else { + else fadt->preferred_pm_profile = PM_DESKTOP; - } acpi_fill_fadt(fadt); @@ -953,9 +950,8 @@ unsigned long write_acpi_tables(unsigned long start) acpigen_set_current((char *) current); for (dev = all_devices; dev; dev = dev->next) - if (dev->ops && dev->ops->acpi_inject_dsdt_generator) { + if (dev->ops && dev->ops->acpi_inject_dsdt_generator) dev->ops->acpi_inject_dsdt_generator(dev); - } current = (unsigned long) acpigen_get_current(); memcpy((char *)current, (char *)dsdt_file + sizeof(acpi_header_t), diff --git a/src/arch/x86/acpigen.c b/src/arch/x86/acpigen.c index d3ec05fe3d..7e4775cef3 100644 --- a/src/arch/x86/acpigen.c +++ b/src/arch/x86/acpigen.c @@ -204,9 +204,8 @@ void acpigen_write_name_string(const char *name, const char *string) void acpigen_emit_stream(const char *data, int size) { int i; - for (i = 0; i < size; i++) { + for (i = 0; i < size; i++) acpigen_emit_byte(data[i]); - } } void acpigen_emit_string(const char *string) @@ -238,7 +237,8 @@ void acpigen_write_coreboot_hid(enum coreboot_acpi_ids id) * Check sections 5.3, 18.2.2 and 18.4 of ACPI spec 3.0 for details. */ -static void acpigen_emit_simple_namestring(const char *name) { +static void acpigen_emit_simple_namestring(const char *name) +{ int i; char ud[] = "____"; for (i = 0; i < 4; i++) { @@ -251,13 +251,15 @@ static void acpigen_emit_simple_namestring(const char *name) { } } -static void acpigen_emit_double_namestring(const char *name, int dotpos) { +static void acpigen_emit_double_namestring(const char *name, int dotpos) +{ acpigen_emit_byte(DUAL_NAME_PREFIX); acpigen_emit_simple_namestring(name); acpigen_emit_simple_namestring(&name[dotpos + 1]); } -static void acpigen_emit_multi_namestring(const char *name) { +static void acpigen_emit_multi_namestring(const char *name) +{ int count = 0; unsigned char *pathlen; acpigen_emit_byte(MULTI_NAME_PREFIX); @@ -279,7 +281,8 @@ static void acpigen_emit_multi_namestring(const char *name) { } -void acpigen_emit_namestring(const char *namepath) { +void acpigen_emit_namestring(const char *namepath) +{ int dotcount = 0, i; int dotpos = 0; @@ -311,13 +314,12 @@ void acpigen_emit_namestring(const char *namepath) { i++; } - if (dotcount == 0) { + if (dotcount == 0) acpigen_emit_simple_namestring(namepath); - } else if (dotcount == 1) { + else if (dotcount == 1) acpigen_emit_double_namestring(namepath, dotpos); - } else { + else acpigen_emit_multi_namestring(namepath); - } } void acpigen_write_name(const char *name) diff --git a/src/arch/x86/bootblock_normal.c b/src/arch/x86/bootblock_normal.c index d6aa79a6d5..43d26c9a25 100644 --- a/src/arch/x86/bootblock_normal.c +++ b/src/arch/x86/bootblock_normal.c @@ -16,7 +16,8 @@ #include #include -static const char *get_fallback(const char *stagelist) { +static const char *get_fallback(const char *stagelist) +{ while (*stagelist) stagelist++; return ++stagelist; } diff --git a/src/arch/x86/cpu.c b/src/arch/x86/cpu.c index 1e74d0cd59..e53390f45d 100644 --- a/src/arch/x86/cpu.c +++ b/src/arch/x86/cpu.c @@ -137,9 +137,7 @@ static const char *cpu_vendor_name(int vendor) name = ""; if ((vendor < (ARRAY_SIZE(x86_vendor_name))) && (x86_vendor_name[vendor] != 0)) - { name = x86_vendor_name[vendor]; - } return name; } @@ -154,19 +152,16 @@ static void identify_cpu(struct device *cpu) /* Find the id and vendor_name */ if (!cpu_have_cpuid()) { /* Its a 486 if we can modify the AC flag */ - if (flag_is_changeable_p(X86_EFLAGS_AC)) { + if (flag_is_changeable_p(X86_EFLAGS_AC)) cpu->device = 0x00000400; /* 486 */ - } else { + else cpu->device = 0x00000300; /* 386 */ - } - if ((cpu->device == 0x00000400) && test_cyrix_52div()) { + if ((cpu->device == 0x00000400) && test_cyrix_52div()) memcpy(vendor_name, "CyrixInstead", 13); /* If we ever care we can enable cpuid here */ - } /* Detect NexGen with old hypercode */ - else if (deep_magic_nexgen_probe()) { + else if (deep_magic_nexgen_probe()) memcpy(vendor_name, "NexGenDriven", 13); - } } #endif if (cpu_have_cpuid()) { @@ -189,13 +184,11 @@ static void identify_cpu(struct device *cpu) vendor_name[12] = '\0'; /* Intel-defined flags: level 0x00000001 */ - if (cpuid_level >= 0x00000001) { + if (cpuid_level >= 0x00000001) cpu->device = cpuid_eax(0x00000001); - } - else { + else /* Have CPUID level 0 only unheard of */ cpu->device = 0x00000400; - } } cpu->vendor = X86_VENDOR_UNKNOWN; for (i = 0; i < ARRAY_SIZE(x86_vendors); i++) { @@ -215,9 +208,7 @@ struct cpu_driver *find_cpu_driver(struct device *cpu) id->vendor != X86_VENDOR_INVALID; id++) { if ((cpu->vendor == id->vendor) && (cpu->device == id->device)) - { return driver; - } if (X86_VENDOR_ANY == id->vendor) return driver; } @@ -247,9 +238,8 @@ void cpu_initialize(unsigned int index) printk(BIOS_INFO, "Initializing CPU #%d\n", index); cpu = info->cpu; - if (!cpu) { + if (!cpu) die("CPU: missing CPU device structure"); - } if (cpu->initialized) return; diff --git a/src/arch/x86/exception.c b/src/arch/x86/exception.c index 84328be2c1..1d83a00eb7 100644 --- a/src/arch/x86/exception.c +++ b/src/arch/x86/exception.c @@ -187,8 +187,7 @@ static uint32_t gdb_stub_registers[NUM_REGS]; -static unsigned char exception_to_signal[] = -{ +static unsigned char exception_to_signal[] = { [0] = GDB_SIGFPE, /* divide by zero */ [1] = GDB_SIGTRAP, /* debug exception */ [2] = GDB_SIGSEGV, /* NMI Interrupt */ @@ -342,8 +341,7 @@ static int get_packet(char *buffer) if (checksum != xmitcsum) { stub_putc('-'); /* failed checksum */ stub_flush(); - } - else { + } else { stub_putc('+'); /* successful transfer */ stub_flush(); } @@ -394,9 +392,8 @@ void x86_exception(struct eregs *info) gdb_stub_registers[CS] = info->cs; gdb_stub_registers[PS] = info->eflags; signo = GDB_UNKNOWN; - if (info->vector < ARRAY_SIZE(exception_to_signal)) { + if (info->vector < ARRAY_SIZE(exception_to_signal)) signo = exception_to_signal[info->vector]; - } /* reply to the host that an exception has occurred */ out_buffer[0] = 'S'; @@ -410,9 +407,8 @@ void x86_exception(struct eregs *info) char *ptr; out_buffer[0] = '\0'; out_buffer[1] = '\0'; - if (!get_packet(in_buffer)) { + if (!get_packet(in_buffer)) break; - } switch(in_buffer[0]) { case '?': /* last signal */ out_buffer[0] = 'S'; @@ -438,9 +434,8 @@ void x86_exception(struct eregs *info) (*ptr++ == ',') && parse_ulong(&ptr, &length)) { copy_to_hex(out_buffer, (void *)addr, length); - } else { + } else memcpy(out_buffer, "E01", 4); - } break; case 'M': /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */ @@ -451,26 +446,22 @@ void x86_exception(struct eregs *info) (*(ptr++) == ':')) { copy_from_hex((void *)addr, ptr, length); memcpy(out_buffer, "OK", 3); - } - else { + } else memcpy(out_buffer, "E02", 4); - } break; case 's': case 'c': /* cAA..AA Continue at address AA..AA(optional) */ /* sAA..AA Step one instruction from AA..AA(optional) */ ptr = &in_buffer[1]; - if (parse_ulong(&ptr, &addr)) { + if (parse_ulong(&ptr, &addr)) info->eip = addr; - } /* Clear the trace bit */ info->eflags &= ~(1 << 8); /* Set the trace bit if we are single stepping */ - if (in_buffer[0] == 's') { + if (in_buffer[0] == 's') info->eflags |= (1 << 8); - } return; break; case 'D': @@ -513,8 +504,7 @@ void x86_exception(struct eregs *info) * evident from the looking at the dump */ code = (u8*)((uintptr_t)code & ~0x7); int i; - for (i = 0; i < MDUMP_SIZE; i++) - { + for (i = 0; i < MDUMP_SIZE; i++) { if ( (i & 0x07) == 0 ) printk(BIOS_EMERG, "\n%p:\t", code + i); printk(BIOS_EMERG, "%.2x ", code[i]); diff --git a/src/arch/x86/include/arch/bootblock_romcc.h b/src/arch/x86/include/arch/bootblock_romcc.h index eab8a0dedf..4378d39d0d 100644 --- a/src/arch/x86/include/arch/bootblock_romcc.h +++ b/src/arch/x86/include/arch/bootblock_romcc.h @@ -54,9 +54,8 @@ static void sanitize_cmos(void) if (cmos_default) { int i; cmos_disable_rtc(); - for (i = 14; i < 128; i++) { + for (i = 14; i < 128; i++) cmos_write_inner(cmos_default[i], i); - } cmos_enable_rtc(); } } diff --git a/src/arch/x86/include/arch/io.h b/src/arch/x86/include/arch/io.h index 53c49a1c6d..63359f1464 100644 --- a/src/arch/x86/include/arch/io.h +++ b/src/arch/x86/include/arch/io.h @@ -306,9 +306,8 @@ static inline pci_devfn_t pci_io_locate_device(unsigned pci_id, pci_devfn_t dev) for (; dev <= PCI_DEV(255, 31, 7); dev += PCI_DEV(0,0,1)) { unsigned int id; id = pci_io_read_config32(dev, 0); - if (id == pci_id) { + if (id == pci_id) return dev; - } } return PCI_DEV_INVALID; } @@ -318,9 +317,8 @@ static inline pci_devfn_t pci_locate_device(unsigned pci_id, pci_devfn_t dev) for (; dev <= PCI_DEV(255, 31, 7); dev += PCI_DEV(0,0,1)) { unsigned int id; id = pci_read_config32(dev, 0); - if (id == pci_id) { + if (id == pci_id) return dev; - } } return PCI_DEV_INVALID; } @@ -335,9 +333,8 @@ static inline pci_devfn_t pci_locate_device_on_bus(unsigned pci_id, unsigned bus for (; dev <=last; dev += PCI_DEV(0,0,1)) { unsigned int id; id = pci_read_config32(dev, 0); - if (id == pci_id) { + if (id == pci_id) return dev; - } } return PCI_DEV_INVALID; } diff --git a/src/arch/x86/include/arch/smp/mpspec.h b/src/arch/x86/include/arch/smp/mpspec.h index 28a3e115e4..4123e7432c 100644 --- a/src/arch/x86/include/arch/smp/mpspec.h +++ b/src/arch/x86/include/arch/smp/mpspec.h @@ -39,8 +39,7 @@ #define SMP_FLOATING_TABLE_LEN sizeof(struct intel_mp_floating) -struct intel_mp_floating -{ +struct intel_mp_floating { char mpf_signature[4]; /* "_MP_" */ u32 mpf_physptr; /* Configuration table address */ u8 mpf_length; /* Our length (paragraphs) */ @@ -55,8 +54,7 @@ struct intel_mp_floating u8 mpf_feature5; /* Unused (0) */ } __attribute__((packed)); -struct mp_config_table -{ +struct mp_config_table { char mpc_signature[4]; #define MPC_SIGNATURE "PCMP" u16 mpc_length; /* Size of table */ @@ -81,8 +79,7 @@ struct mp_config_table #define MP_INTSRC 3 #define MP_LINTSRC 4 -struct mpc_config_processor -{ +struct mpc_config_processor { u8 mpc_type; u8 mpc_apicid; /* Local APIC number */ u8 mpc_apicver; /* Its versions */ @@ -97,8 +94,7 @@ struct mpc_config_processor u32 mpc_reserved[2]; } __attribute__((packed)); -struct mpc_config_bus -{ +struct mpc_config_bus { u8 mpc_type; u8 mpc_busid; u8 mpc_bustype[6]; @@ -112,8 +108,7 @@ struct mpc_config_bus #define BUSTYPE_PCI "PCI" #define BUSTYPE_PCMCIA "PCMCIA" -struct mpc_config_ioapic -{ +struct mpc_config_ioapic { u8 mpc_type; u8 mpc_apicid; u8 mpc_apicver; @@ -122,8 +117,7 @@ struct mpc_config_ioapic void *mpc_apicaddr; } __attribute__((packed)); -struct mpc_config_intsrc -{ +struct mpc_config_intsrc { u8 mpc_type; u8 mpc_irqtype; u16 mpc_irqflag; @@ -150,8 +144,7 @@ enum mp_irq_source_types { #define MP_IRQ_TRIGGER_MASK 0xc -struct mpc_config_lintsrc -{ +struct mpc_config_lintsrc { u8 mpc_type; u8 mpc_irqtype; u16 mpc_irqflag; diff --git a/src/arch/x86/mpspec.c b/src/arch/x86/mpspec.c index 5f251e31c9..da2c21ab72 100644 --- a/src/arch/x86/mpspec.c +++ b/src/arch/x86/mpspec.c @@ -63,9 +63,8 @@ static unsigned char smp_compute_checksum(void *v, int len) int i; bytes = v; checksum = 0; - for (i = 0; i < len; i++) { + for (i = 0; i < len; i++) checksum -= bytes[i]; - } return checksum; } @@ -443,7 +442,9 @@ void mptable_add_isa_interrupts(struct mp_config_table *mc, unsigned long bus_is smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0xf, apicid, 0xf); } -void mptable_write_buses(struct mp_config_table *mc, int *max_pci_bus, int *isa_bus) { +void mptable_write_buses(struct mp_config_table *mc, int *max_pci_bus, + int *isa_bus) +{ int dummy, i, highest; char buses[256]; struct device *dev; diff --git a/src/arch/x86/pirq_routing.c b/src/arch/x86/pirq_routing.c index f758dbb572..e534a0656b 100644 --- a/src/arch/x86/pirq_routing.c +++ b/src/arch/x86/pirq_routing.c @@ -100,8 +100,7 @@ static u8 pirq_get_next_free_irq(u8* pirq, u16 bitmap) { int i, link; u8 irq = 0; - for (i = 2; i <= 15; i++) - { + for (i = 2; i <= 15; i++) { /* Can we assign this IRQ ? */ if (!((bitmap >> i) & 1)) continue; @@ -161,13 +160,11 @@ static void pirq_route_irqs(unsigned long addr) } /* yet not routed */ - if (!pirq[link - 1]) - { + if (!pirq[link - 1]) { irq = pirq_get_next_free_irq(pirq, bitmap); if (irq) pirq[link - 1] = irq; - } - else + } else irq = pirq[link - 1]; printk(BIOS_DEBUG, "IRQ: %d\n", irq); diff --git a/src/arch/x86/smbios.c b/src/arch/x86/smbios.c index 864020001e..4b1cb83eab 100644 --- a/src/arch/x86/smbios.c +++ b/src/arch/x86/smbios.c @@ -416,11 +416,10 @@ static int smbios_write_type3(unsigned long *current, int handle) t->bootup_state = SMBIOS_STATE_SAFE; t->power_supply_state = SMBIOS_STATE_SAFE; t->thermal_state = SMBIOS_STATE_SAFE; - if (IS_ENABLED(CONFIG_SYSTEM_TYPE_LAPTOP)) { + if (IS_ENABLED(CONFIG_SYSTEM_TYPE_LAPTOP)) t->_type = SMBIOS_ENCLOSURE_NOTEBOOK; - } else { + else t->_type = SMBIOS_ENCLOSURE_DESKTOP; - } t->security_status = SMBIOS_STATE_SAFE; len = t->length + smbios_string_table_len(t->eos); *current += len; @@ -437,9 +436,8 @@ static int smbios_write_type4(unsigned long *current, int handle) res.eax = res.edx = 0; res.ebx = 0x10000; - if (cpu_have_cpuid()) { + if (cpu_have_cpuid()) res = cpuid(1); - } memset(t, 0, sizeof(struct smbios_type4)); t->type = SMBIOS_PROCESSOR_INFORMATION; diff --git a/src/arch/x86/tables.c b/src/arch/x86/tables.c index edcb71705c..c63bd39ef7 100644 --- a/src/arch/x86/tables.c +++ b/src/arch/x86/tables.c @@ -47,9 +47,9 @@ static unsigned long write_pirq_table(unsigned long rom_table_end) new_high_table_pointer = write_pirq_routing_table(high_table_pointer); // FIXME make pirq table code intelligent enough to know how // much space it's going to need. - if (new_high_table_pointer > (high_table_pointer + MAX_PIRQ_TABLE_SIZE)) { + if (new_high_table_pointer > (high_table_pointer + + MAX_PIRQ_TABLE_SIZE)) printk(BIOS_ERR, "ERROR: Increase PIRQ size.\n"); - } printk(BIOS_DEBUG, "PIRQ table: %ld bytes.\n", new_high_table_pointer - high_table_pointer); } @@ -74,9 +74,9 @@ static unsigned long write_mptable(unsigned long rom_table_end) new_high_table_pointer = write_smp_table(high_table_pointer); // FIXME make mp table code intelligent enough to know how // much space it's going to need. - if (new_high_table_pointer > (high_table_pointer + MAX_MP_TABLE_SIZE)) { + if (new_high_table_pointer > (high_table_pointer + + MAX_MP_TABLE_SIZE)) printk(BIOS_ERR, "ERROR: Increase MP table size.\n"); - } printk(BIOS_DEBUG, "MP table: %ld bytes.\n", new_high_table_pointer - high_table_pointer); @@ -112,9 +112,9 @@ static unsigned long write_acpi_table(unsigned long rom_table_end) rom_table_end = ALIGN(rom_table_end, 16); new_high_table_pointer = write_acpi_tables(high_table_pointer); - if (new_high_table_pointer > ( high_table_pointer + MAX_ACPI_SIZE)) { + if (new_high_table_pointer > ( high_table_pointer + + MAX_ACPI_SIZE)) printk(BIOS_ERR, "ERROR: Increase ACPI size\n"); - } printk(BIOS_DEBUG, "ACPI tables: %ld bytes.\n", new_high_table_pointer - high_table_pointer); @@ -122,9 +122,9 @@ static unsigned long write_acpi_table(unsigned long rom_table_end) /* First we look for the high table RSDP */ while (acpi_start < new_high_table_pointer) { - if (memcmp(((acpi_rsdp_t *)acpi_start)->signature, RSDP_SIG, 8) == 0) { + if (memcmp(((acpi_rsdp_t *)acpi_start)->signature, + RSDP_SIG, 8) == 0) break; - } acpi_start++; } @@ -165,9 +165,9 @@ static unsigned long write_smbios_table(unsigned long rom_table_end) memcpy((void *)rom_table_end, (void *)high_table_pointer, sizeof(struct smbios_entry)); rom_table_end += sizeof(struct smbios_entry); - if (new_high_table_pointer > ( high_table_pointer + MAX_SMBIOS_SIZE)) { + if (new_high_table_pointer > ( high_table_pointer + + MAX_SMBIOS_SIZE)) printk(BIOS_ERR, "ERROR: Increase SMBIOS size\n"); - } printk(BIOS_DEBUG, "SMBIOS tables: %ld bytes.\n", new_high_table_pointer - high_table_pointer); } else { -- cgit v1.2.3