Author: uwe Date: Sat Mar 13 18:28:29 2010 New Revision: 933 URL: http://flashrom.org/trac/coreboot/changeset/933
Log: Various coding style and cosmetic changes (trivial).
- Fix coding-style, whitespace, and indentation in a few places.
- Consistently use the same spelling ("Super I/O") everywhere.
- Make some flashrom stdout output look a bit nicer.
Signed-off-by: Uwe Hermann uwe@hermann-uwe.de Acked-by: Uwe Hermann uwe@hermann-uwe.de
Modified: trunk/board_enable.c trunk/cli_output.c trunk/dmi.c trunk/flashrom.c trunk/hwaccess.h trunk/internal.c trunk/it87spi.c trunk/serial.c
Modified: trunk/board_enable.c ============================================================================== --- trunk/board_enable.c Sat Mar 13 15:47:48 2010 (r932) +++ trunk/board_enable.c Sat Mar 13 18:28:29 2010 (r933) @@ -79,7 +79,7 @@ break; case SUPERIO_VENDOR_ITE: enter_conf_mode_ite(superio.port); - /* Enable flash mapping. Works for most old ITE style SuperI/O. */ + /* Enable flash mapping. Works for most old ITE style Super I/O. */ tmp = sio_read(superio.port, 0x24); tmp |= 0xfc; sio_write(superio.port, 0x24, tmp); @@ -87,7 +87,7 @@ ret = 0; break; default: - printf_debug("Unhandled SuperI/O type!\n"); + printf_debug("Unhandled Super I/O type!\n"); ret = -1; break; } @@ -226,7 +226,7 @@ * - GIGABYTE GA-7VT600: VIA KT600 + VT8237 + IT8705 * - Shuttle AK38N: VIA KT333CF + VIA VT8235 + ITE IT8705F * - * SIS950 superio probably requires the same flash write enable. + * The SIS950 Super I/O probably requires the same flash write enable. */ static int it8705f_write_enable_2e(const char *name) { @@ -239,36 +239,32 @@ int gpio_bank = gpio / 8; int gpio_pin = gpio % 8; uint16_t baseport; - uint8_t id; - uint8_t val; + uint8_t id, val;
- if (gpio_bank > 4) - { + if (gpio_bank > 4) { fprintf(stderr, "PC87360: Invalid GPIO %d\n", gpio); return -1; }
id = sio_read(0x2E, 0x20); - if (id != 0xE1) - { + if (id != 0xE1) { fprintf(stderr, "PC87360: unexpected ID %02x\n", id); return -1; }
- sio_write(0x2E, 0x07, 0x07); /* select GPIO device */ + sio_write(0x2E, 0x07, 0x07); /* Select GPIO device */ baseport = (sio_read(0x2E, 0x60) << 8) | sio_read(0x2E, 0x61); - if((baseport & 0xFFF0) == 0xFFF0 || baseport == 0) - { + if ((baseport & 0xFFF0) == 0xFFF0 || baseport == 0) { fprintf (stderr, "PC87360: invalid GPIO base address %04x\n", baseport); return -1; } sio_mask (0x2E, 0x30, 0x01, 0x01); /* Enable logical device */ - sio_write(0x2E, 0xF0, gpio_bank*16 + gpio_pin); + sio_write(0x2E, 0xF0, gpio_bank * 16 + gpio_pin); sio_mask (0x2E, 0xF1, 0x01, 0x01); /* Make pin output */
val = INB(baseport + bankbase[gpio_bank]); - if(raise) + if (raise) val |= 1 << gpio_pin; else val &= ~(1 << gpio_pin); @@ -1028,8 +1024,7 @@ static int board_msi_651ml(const char *name) { struct pci_dev *dev; - uint16_t base; - uint16_t temp; + uint16_t base, temp;
dev = pci_dev_find(0x1039, 0x0962); if (!dev) { @@ -1133,7 +1128,7 @@ w836xx_ext_leave(0x2E);
if (id != 0x8701) { - fprintf(stderr, "\nERROR: IT8703F SuperIO not found.\n"); + fprintf(stderr, "\nERROR: IT8703F Super I/O not found.\n"); return -1; }
@@ -1144,7 +1139,7 @@ w836xx_ext_leave(0x2E);
if (!base) { - fprintf(stderr, "\nERROR: Failed to read IT8703F SuperIO GPIO" + fprintf(stderr, "\nERROR: Failed to read IT8703F Super I/O GPIO" " Base.\n"); return -1; } @@ -1161,8 +1156,7 @@ * General routine for raising/dropping GPIO lines on the ITE IT8712F. * There is only some limited checking on the port numbers. */ -static int -it8712f_gpio_set(unsigned int line, int raise) +static int it8712f_gpio_set(unsigned int line, int raise) { unsigned int port; uint16_t id, base; @@ -1186,7 +1180,7 @@ exit_conf_mode_ite(0x2E);
if (id != 0x8712) { - fprintf(stderr, "\nERROR: IT8712F SuperIO not found.\n"); + fprintf(stderr, "\nERROR: IT8712F Super I/O not found.\n"); return -1; }
@@ -1197,7 +1191,7 @@ exit_conf_mode_ite(0x2E);
if (!base) { - fprintf(stderr, "\nERROR: Failed to read IT8712F SuperIO GPIO" + fprintf(stderr, "\nERROR: Failed to read IT8712F Super I/O GPIO" " Base.\n"); return -1; } @@ -1446,20 +1440,19 @@ board = board_match_pci_card_ids();
if (board && board->status == NT) { - if (!force_boardenable) - { + if (!force_boardenable) { printf("WARNING: Your mainboard is %s %s, but the mainboard-specific\n" "code has not been tested, and thus will not not be executed by default.\n" "Depending on your hardware environment, erasing, writing or even probing\n" "can fail without running the board specific code.\n\n" "Please see the man page (section PROGRAMMER SPECIFIC INFO, subsection\n" - ""internal programmer") for details\n", + ""internal programmer") for details.\n", board->vendor_name, board->board_name); board = NULL; - } - else + } else { printf("NOTE: Running an untested board enable procedure.\n" - "Please report success/failure to flashrom@flashrom.org\n"); + "Please report success/failure to flashrom@flashrom.org.\n"); + } }
if (board) {
Modified: trunk/cli_output.c ============================================================================== --- trunk/cli_output.c Sat Mar 13 15:47:48 2010 (r932) +++ trunk/cli_output.c Sat Mar 13 18:28:29 2010 (r933) @@ -27,25 +27,25 @@ va_list ap; int ret; FILE *output_type; - - switch (type) - { + + switch (type) { case MSG_ERROR: output_type = stderr; break; case MSG_BARF: - if (verbose < 2) return 0; + if (verbose < 2) + return 0; case MSG_DEBUG: - if (verbose < 1) return 0; + if (verbose < 1) + return 0; case MSG_INFO: default: output_type = stdout; break; } - + va_start(ap, fmt); ret = vfprintf(output_type, fmt, ap); va_end(ap); return ret; } -
Modified: trunk/dmi.c ============================================================================== --- trunk/dmi.c Sat Mar 13 15:47:48 2010 (r932) +++ trunk/dmi.c Sat Mar 13 18:28:29 2010 (r933) @@ -31,18 +31,20 @@ DMI_BB_MANUFACTURER, DMI_BB_PRODUCT, DMI_BB_VERSION, - DMI_ID_INVALID /* This must always be the last entry */ + DMI_ID_INVALID, /* This must always be the last entry! */ };
-/* The short_id for baseboard starts with "m" as in mainboard to leave - "b" available for BIOS */ +/* + * The short_id for baseboard starts with "m" as in mainboard to leave + * "b" available for BIOS. + */ const char *dmidecode_names[DMI_ID_INVALID] = { "system-manufacturer", "system-product-name", "system-version", "baseboard-manufacturer", "baseboard-product-name", - "baseboard-version" + "baseboard-version", };
#define DMI_COMMAND_LEN_MAX 260 @@ -51,7 +53,7 @@ int has_dmi_support = 0; char *dmistrings[DMI_ID_INVALID];
-/* strings longer than 4096 in DMI are just insane */ +/* Strings longer than 4096 in DMI are just insane. */ #define DMI_MAX_ANSWER_LEN 4096
static char *get_dmi_string(const char *string_name) @@ -59,7 +61,8 @@ FILE *dmidecode_pipe; char *result; char answerbuf[DMI_MAX_ANSWER_LEN]; - char commandline[DMI_COMMAND_LEN_MAX+40]; + char commandline[DMI_COMMAND_LEN_MAX + 40]; + snprintf(commandline, sizeof(commandline), "%s -s %s", dmidecode_command, string_name); dmidecode_pipe = popen(commandline, "r"); @@ -82,7 +85,7 @@ return NULL; }
- /* chomp trailing newline */ + /* Chomp trailing newline. */ if (answerbuf[0] != 0 && answerbuf[strlen(answerbuf) - 1] == '\n') answerbuf[strlen(answerbuf) - 1] = 0; @@ -99,6 +102,7 @@ { int i; char *chassis_type; + has_dmi_support = 1; for (i = 0; i < DMI_ID_INVALID; i++) { dmistrings[i] = get_dmi_string(dmidecode_names[i]); @@ -131,8 +135,9 @@ { int anchored = 0; int patternlen; + printf_debug("matching %s against %s\n", value, pattern); - /* The empty string is part of all strings */ + /* The empty string is part of all strings! */ if (pattern[0] == 0) return 1;
@@ -145,11 +150,11 @@ if (pattern[patternlen - 1] == '$') { int valuelen = strlen(value); patternlen--; - if(patternlen > valuelen) + if (patternlen > valuelen) return 0;
/* full string match: require same length */ - if(anchored && (valuelen != patternlen)) + if (anchored && (valuelen != patternlen)) return 0;
/* start character to make ends match */ @@ -166,11 +171,12 @@ int dmi_match(const char *pattern) { int i; + if (!has_dmi_support) return 0;
- for (i = 0;i < DMI_ID_INVALID; i++) - if(dmi_compare(dmistrings[i], pattern)) + for (i = 0; i < DMI_ID_INVALID; i++) + if (dmi_compare(dmistrings[i], pattern)) return 1;
return 0;
Modified: trunk/flashrom.c ============================================================================== --- trunk/flashrom.c Sat Mar 13 15:47:48 2010 (r932) +++ trunk/flashrom.c Sat Mar 13 18:28:29 2010 (r933) @@ -664,7 +664,7 @@ case write_gran_256bytes: for (j = 0; j < len / 256; j++) { limit = min (256, len - j * 256); - /* Are have and want identical? */ + /* Are 'have' and 'want' identical? */ if (!memcmp(have + j * 256, want + j * 256, limit)) continue; /* have needs to be in erased state. */ @@ -1028,7 +1028,7 @@ * layouts. That would imply "magic" erase functions. The * easiest way to check this is with function pointers. */ - for (j = k + 1; j < NUM_ERASEFUNCTIONS; j++) + for (j = k + 1; j < NUM_ERASEFUNCTIONS; j++) { if (eraser.block_erase == flash->block_erasers[j].block_erase) { msg_gerr("ERROR: Flash chip %s erase function " @@ -1037,6 +1037,7 @@ flash->name, k, j); ret = 1; } + } } return ret; } @@ -1198,7 +1199,7 @@ "this flash part. Please include the flashrom\noutput " "with the additional -V option for all operations you " "tested (-V, -rV,\n-wV, -EV), and mention which " - "mainboard or programmer you tested. Thanks for your " + "mainboard or programmer you tested.\nThanks for your " "help!\n===\n"); } }
Modified: trunk/hwaccess.h ============================================================================== --- trunk/hwaccess.h Sat Mar 13 15:47:48 2010 (r932) +++ trunk/hwaccess.h Sat Mar 13 18:28:29 2010 (r933) @@ -15,8 +15,9 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * + */ + +/* * Header file for hardware access and OS abstraction. Included from flash.h. */
@@ -89,42 +90,36 @@ #endif #include <stdint.h>
-static inline void -outb(uint8_t value, uint16_t port) +static inline void outb(uint8_t value, uint16_t port) { asm volatile ("outb %b0,%w1": :"a" (value), "Nd" (port)); }
-static inline uint8_t -inb(uint16_t port) +static inline uint8_t inb(uint16_t port) { uint8_t value; asm volatile ("inb %w1,%0":"=a" (value):"Nd" (port)); return value; }
-static inline void -outw(uint16_t value, uint16_t port) +static inline void outw(uint16_t value, uint16_t port) { asm volatile ("outw %w0,%w1": :"a" (value), "Nd" (port)); }
-static inline uint16_t -inw(uint16_t port) +static inline uint16_t inw(uint16_t port) { uint16_t value; asm volatile ("inw %w1,%0":"=a" (value):"Nd" (port)); return value; }
-static inline void -outl(uint32_t value, uint16_t port) +static inline void outl(uint32_t value, uint16_t port) { asm volatile ("outl %0,%w1": :"a" (value), "Nd" (port)); }
-static inline uint32_t -inl(uint16_t port) +static inline uint32_t inl(uint16_t port) { uint32_t value; asm volatile ("inl %1,%0":"=a" (value):"Nd" (port));
Modified: trunk/internal.c ============================================================================== --- trunk/internal.c Sat Mar 13 15:47:48 2010 (r932) +++ trunk/internal.c Sat Mar 13 18:28:29 2010 (r933) @@ -105,7 +105,8 @@ void probe_superio(void) { superio = probe_superio_ite(); -#if 0 /* Winbond SuperI/O code is not yet available. */ +#if 0 + /* Winbond Super I/O code is not yet available. */ if (superio.vendor == SUPERIO_VENDOR_NONE) superio = probe_superio_winbond(); #endif @@ -150,17 +151,17 @@ coreboot_init(); dmi_init();
- /* Probe for the SuperI/O chip and fill global struct superio. */ + /* Probe for the Super I/O chip and fill global struct superio. */ probe_superio();
- /* Warn if a laptop is detected */ + /* Warn if a laptop is detected. */ if (is_laptop) printf("========================================================================\n" "WARNING! You seem to be running flashrom on a laptop.\n" "Laptops, notebooks and netbooks are difficult to support and we recommend\n" "to use the vendor flashing utility. The embedded controller (EC) in these\n" - "machines often interacts badly with flashing\n" - "See http://www.flashrom.org/Laptops%5Cn" + "machines often interacts badly with flashing.\n" + "See http://www.flashrom.org/Laptops for details.\n" "========================================================================\n");
/* try to enable it. Failure IS an option, since not all motherboards
Modified: trunk/it87spi.c ============================================================================== --- trunk/it87spi.c Sat Mar 13 15:47:48 2010 (r932) +++ trunk/it87spi.c Sat Mar 13 18:28:29 2010 (r933) @@ -81,7 +81,7 @@ case 0x82: case 0x86: case 0x87: - msg_pinfo("Found ITE SuperI/O, id %04hx\n", + msg_pinfo("Found ITE Super I/O, id %04hx\n", ret.model); return ret; } @@ -170,7 +170,7 @@ int ret;
get_io_perms(); - /* Probe for the SuperI/O chip and fill global struct superio. */ + /* Probe for the Super I/O chip and fill global struct superio. */ probe_superio(); ret = it87spi_common_init(); if (!ret) {
Modified: trunk/serial.c ============================================================================== --- trunk/serial.c Sat Mar 13 15:47:48 2010 (r932) +++ trunk/serial.c Sat Mar 13 18:28:29 2010 (r933) @@ -105,13 +105,15 @@ { #ifdef _WIN32 HANDLE fd; - char* dev2 = dev; - if ((strlen(dev) > 3) && (tolower(dev[0])=='c') && (tolower(dev[1])=='o') && (tolower(dev[2])=='m')) { - dev2 = malloc(strlen(dev)+5); + char *dev2 = dev; + if ((strlen(dev) > 3) && (tolower(dev[0]) == 'c') + && (tolower(dev[1]) == 'o') && (tolower(dev[2]) == 'm')) { + dev2 = malloc(strlen(dev) + 5); strcpy(dev2, "\\.\"); - strcpy(dev2+4, dev); + strcpy(dev2 + 4, dev); } - fd = CreateFile(dev2, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); + fd = CreateFile(dev2, GENERIC_READ | GENERIC_WRITE, 0, NULL, + OPEN_EXISTING, 0, NULL); if (dev2 != dev) free(dev2); if (fd == INVALID_HANDLE_VALUE) { @@ -129,9 +131,9 @@ case 115200: dcb.BaudRate = CBR_115200; break; default: sp_die("Error: Could not set baud rate"); } - dcb.ByteSize=8; - dcb.Parity=NOPARITY; - dcb.StopBits=ONESTOPBIT; + dcb.ByteSize = 8; + dcb.Parity = NOPARITY; + dcb.StopBits = ONESTOPBIT; if (!SetCommState(fd, &dcb)) { sp_die("Error: Could not change serial port configuration"); } @@ -147,9 +149,8 @@ for (i = 0;; i++) { if (sp_baudtable[i].baud == 0) { close(fd); - msg_perr( - "Error: cannot configure for baudrate %d\n", - baud); + msg_perr("Error: cannot configure for baudrate %d\n", + baud); exit(1); } if (sp_baudtable[i].baud == baud) {