summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2010-03-13 17:28:29 +0000
committerUwe Hermann <uwe@hermann-uwe.de>2010-03-13 17:28:29 +0000
commit439597032eae0f41745d9173805945c5c85475eb (patch)
tree76c0a1816f51012775006aa8c82bdfe78901b5ab
parent645c6df21a9570da7f8ac07fe740a0df3a1d4d1c (diff)
downloadflashrom-439597032eae0f41745d9173805945c5c85475eb.tar.gz
flashrom-439597032eae0f41745d9173805945c5c85475eb.tar.bz2
flashrom-439597032eae0f41745d9173805945c5c85475eb.zip
Various coding style and cosmetic changes
- Fix coding-style, whitespace, and indentation in a few places. - Consistently use the same spelling ("Super I/O") everywhere. Corresponding to flashrom svn r933. - 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>
-rw-r--r--board_enable.c49
-rw-r--r--cli_output.c14
-rw-r--r--dmi.c30
-rw-r--r--flashrom.c7
-rw-r--r--hwaccess.h23
-rw-r--r--internal.c11
-rw-r--r--it87spi.c4
-rw-r--r--serial.c23
8 files changed, 79 insertions, 82 deletions
diff --git a/board_enable.c b/board_enable.c
index 0e89137da..5e57aff1c 100644
--- a/board_enable.c
+++ b/board_enable.c
@@ -79,7 +79,7 @@ static int enable_flash_decode_superio(void)
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 @@ static int enable_flash_decode_superio(void)
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 @@ static int it8705f_write_enable(uint8_t port, const char *name)
* - 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 @@ static int pc87360_gpio_set(uint8_t gpio, int raise)
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_soyo_sy_7vca(const char *name)
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 @@ static int board_asus_a7v8x(const char *name)
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 @@ static int board_asus_a7v8x(const char *name)
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 @@ static int board_asus_a7v8x(const char *name)
* 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 @@ it8712f_gpio_set(unsigned int line, int raise)
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 @@ it8712f_gpio_set(unsigned int line, int raise)
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 @@ int board_flash_enable(const char *vendor, const char *part)
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) {
diff --git a/cli_output.c b/cli_output.c
index 2ced04353..b3d4e0432 100644
--- a/cli_output.c
+++ b/cli_output.c
@@ -27,25 +27,25 @@ int print(int type, const char *fmt, ...)
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;
}
-
diff --git a/dmi.c b/dmi.c
index 30a467036..bb285f400 100644
--- a/dmi.c
+++ b/dmi.c
@@ -31,18 +31,20 @@ enum dmi_strings {
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 @@ const char *dmidecode_command = "dmidecode";
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 @@ static char *get_dmi_string(const char *string_name)
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 @@ static char *get_dmi_string(const char *string_name)
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 @@ void dmi_init(void)
{
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 @@ static int dmi_compare(const char *value, const char *pattern)
{
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 @@ static int dmi_compare(const char *value, const char *pattern)
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 @@ static int dmi_compare(const char *value, const char *pattern)
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;
diff --git a/flashrom.c b/flashrom.c
index 6a9108919..988e0102a 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -664,7 +664,7 @@ int need_erase(uint8_t *have, uint8_t *want, int len, enum write_granularity gra
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 @@ int selfcheck_eraseblocks(struct flashchip *flash)
* 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 @@ int selfcheck_eraseblocks(struct flashchip *flash)
flash->name, k, j);
ret = 1;
}
+ }
}
return ret;
}
@@ -1198,7 +1199,7 @@ void check_chip_supported(struct flashchip *flash)
"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");
}
}
diff --git a/hwaccess.h b/hwaccess.h
index 89469b01a..06817ab49 100644
--- a/hwaccess.h
+++ b/hwaccess.h
@@ -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));
diff --git a/internal.c b/internal.c
index 0afed728b..e2444fd5f 100644
--- a/internal.c
+++ b/internal.c
@@ -105,7 +105,8 @@ int force_boardenable = 0;
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 @@ int internal_init(void)
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\n"
+ "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
diff --git a/it87spi.c b/it87spi.c
index ed72c9006..04022115c 100644
--- a/it87spi.c
+++ b/it87spi.c
@@ -81,7 +81,7 @@ struct superio probe_superio_ite(void)
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 it87spi_init(void)
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) {
diff --git a/serial.c b/serial.c
index 4d49e08eb..37f2549ef 100644
--- a/serial.c
+++ b/serial.c
@@ -105,13 +105,15 @@ fdtype sp_openserport(char *dev, unsigned int baud)
{
#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 @@ fdtype sp_openserport(char *dev, unsigned int baud)
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 @@ fdtype sp_openserport(char *dev, unsigned int baud)
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) {