summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2011-08-15 19:54:20 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2011-08-15 19:54:20 +0000
commit082c8b559cd9f3262c9af58ac2f17f2cc8a09d8b (patch)
treece63847ee6cc1e63289e3f658a5d57ebd35b3619
parent0528b7fefa6daf35365c1dee0d21bc94e8120f78 (diff)
downloadast2050-flashrom-082c8b559cd9f3262c9af58ac2f17f2cc8a09d8b.zip
ast2050-flashrom-082c8b559cd9f3262c9af58ac2f17f2cc8a09d8b.tar.gz
Fixup of r1397
- Mixing uninitialized and initialized local variables leads to confusion. - ft2232_spi error cases should have gotten some error handling, and that's the reason the curly braces were there. - Fixing typos/wording in some places would have been nice given that those places were touched anyway. Corresponding to flashrom svn r1413. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
-rw-r--r--board_enable.c13
-rw-r--r--buspirate_spi.c4
-rw-r--r--chipset_enable.c5
-rw-r--r--cli_classic.c9
-rw-r--r--dediprog.c6
-rw-r--r--dmi.c3
-rw-r--r--flashrom.c22
-rw-r--r--ft2232_spi.c15
-rw-r--r--it85spi.c17
-rw-r--r--it87spi.c3
-rw-r--r--physmap.c2
11 files changed, 59 insertions, 40 deletions
diff --git a/board_enable.c b/board_enable.c
index aba6f38..b362b54 100644
--- a/board_enable.c
+++ b/board_enable.c
@@ -860,7 +860,7 @@ static int nvidia_mcp_gpio_set(int gpio, int raise)
return -1;
}
- /* First, check the ISA bridge */
+ /* Check for the ISA bridge first. */
dev = pci_dev_find_vendorclass(0x10DE, 0x0601);
switch (dev->device_id) {
case 0x0030: /* CK804 */
@@ -1129,8 +1129,8 @@ static int intel_piix4_gpo_set(unsigned int gpo, int raise)
struct pci_dev *dev;
uint32_t tmp, base;
- /* GPPO {0,8,27,28,30} are always available */
- static const uint32_t nonmuxed_gpos = 0x58000101;
+ /* GPO{0,8,27,28,30} are always available. */
+ static const uint32_t nonmuxed_gpos = 0x58000101;
static const struct {unsigned int reg, mask, value; } piix4_gpo[] = {
{0},
@@ -1179,10 +1179,9 @@ static int intel_piix4_gpo_set(unsigned int gpo, int raise)
}
if ((((1 << gpo) & nonmuxed_gpos) == 0) &&
- (pci_read_word(dev, piix4_gpo[gpo].reg)
- & piix4_gpo[gpo].mask) != piix4_gpo[gpo].value) {
- msg_perr("\nERROR: PIIX4 GPO%d not programmed for output.\n",
- gpo);
+ ((pci_read_word(dev, piix4_gpo[gpo].reg) & piix4_gpo[gpo].mask) !=
+ piix4_gpo[gpo].value)) {
+ msg_perr("\nERROR: PIIX4 GPO%d not programmed for output.\n", gpo);
return -1;
}
diff --git a/buspirate_spi.c b/buspirate_spi.c
index 467d271..ff1aac4 100644
--- a/buspirate_spi.c
+++ b/buspirate_spi.c
@@ -150,9 +150,11 @@ static int buspirate_spi_shutdown(void *data)
int buspirate_spi_init(void)
{
unsigned char buf[512];
- int ret = 0, i, spispeed = 0x7;
char *dev = NULL;
char *speed = NULL;
+ int spispeed = 0x7;
+ int ret = 0;
+ int i;
dev = extract_programmer_param("dev");
if (!dev || !strlen(dev)) {
diff --git a/chipset_enable.c b/chipset_enable.c
index b4ec96b..687682a 100644
--- a/chipset_enable.c
+++ b/chipset_enable.c
@@ -309,8 +309,9 @@ static int enable_flash_ich_4e(struct pci_dev *dev, const char *name)
static int enable_flash_ich_dc(struct pci_dev *dev, const char *name)
{
uint32_t fwh_conf;
+ int i, tmp;
char *idsel = NULL;
- int i, tmp, max_decode_fwh_idsel = 0, max_decode_fwh_decode = 0;
+ int max_decode_fwh_idsel = 0, max_decode_fwh_decode = 0;
int contiguous = 1;
idsel = extract_programmer_param("fwh_idsel");
@@ -1035,7 +1036,7 @@ static int get_flashbase_sc520(struct pci_dev *dev, const char *name)
}
} else {
msg_pinfo("AMD Elan SC520 detected, but no BOOTCS. "
- "Assuming flash at 4G\n");
+ "Assuming flash at 4G.\n");
}
/* 4. Clean up */
diff --git a/cli_classic.c b/cli_classic.c
index 22711b0..5d35738 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -104,13 +104,14 @@ int cli_classic(int argc, char *argv[])
struct flashchip flashes[3];
struct flashchip *fill_flash;
const char *name;
- int startchip = 0, chipcount = 0, namelen, opt, option_index = 0;
- int read_it = 0, write_it = 0, erase_it = 0, verify_it = 0;
- int dont_verify_it = 0, list_supported = 0, force = 0;
+ int namelen, opt, i;
+ int startchip = 0, chipcount = 0, option_index = 0, force = 0;
#if CONFIG_PRINT_WIKI == 1
int list_supported_wiki = 0;
#endif
- int operation_specified = 0, i, ret = 0;
+ int read_it = 0, write_it = 0, erase_it = 0, verify_it = 0;
+ int dont_verify_it = 0, list_supported = 0, operation_specified = 0;
+ int ret = 0;
static const char optstring[] = "r:Rw:v:nVEfc:m:l:i:p:Lzh";
static const struct option long_options[] = {
diff --git a/dediprog.c b/dediprog.c
index d752fb4..58eeb44 100644
--- a/dediprog.c
+++ b/dediprog.c
@@ -496,7 +496,8 @@ static int dediprog_command_f(int timeout)
static int parse_voltage(char *voltage)
{
char *tmp = NULL;
- int i, millivolt, fraction = 0;
+ int i;
+ int millivolt = 0, fraction = 0;
if (!voltage || !strlen(voltage)) {
msg_perr("Empty voltage= specified.\n");
@@ -574,7 +575,8 @@ int dediprog_init(void)
{
struct usb_device *dev;
char *voltage;
- int millivolt = 3500, ret;
+ int millivolt = 3500;
+ int ret;
msg_pspew("%s\n", __func__);
diff --git a/dmi.c b/dmi.c
index 4f36245..8f78376 100644
--- a/dmi.c
+++ b/dmi.c
@@ -196,7 +196,8 @@ void dmi_init(void)
*/
static int dmi_compare(const char *value, const char *pattern)
{
- int anchored = 0, patternlen;
+ int anchored = 0;
+ int patternlen;
msg_pspew("matching %s against %s\n", value, pattern);
/* The empty string is part of all strings! */
diff --git a/flashrom.c b/flashrom.c
index 07cfdd9..ad1e042 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -600,8 +600,7 @@ void map_flash_registers(struct flashchip *flash)
size_t size = flash->total_size * 1024;
/* Flash registers live 4 MByte below the flash. */
/* FIXME: This is incorrect for nonstandard flashbase. */
- flash->virtual_registers = (chipaddr)programmer_map_flash_region(
- "flash chip registers", (0xFFFFFFFF - 0x400000 - size + 1), size);
+ flash->virtual_registers = (chipaddr)programmer_map_flash_region("flash chip registers", (0xFFFFFFFF - 0x400000 - size + 1), size);
}
int read_memmapped(struct flashchip *flash, uint8_t *buf, int start, int len)
@@ -753,8 +752,9 @@ int check_erased_range(struct flashchip *flash, int start, int len)
int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len,
const char *message)
{
- int i, ret = 0, failcount = 0;
+ int i;
uint8_t *readbuf = malloc(len);
+ int ret = 0, failcount = 0;
if (!len)
goto out_free;
@@ -832,7 +832,8 @@ out_free:
*/
int need_erase(uint8_t *have, uint8_t *want, int len, enum write_granularity gran)
{
- int result = 0, i, j, limit;
+ int result = 0;
+ int i, j, limit;
switch (gran) {
case write_gran_1bit:
@@ -898,7 +899,8 @@ int need_erase(uint8_t *have, uint8_t *want, int len, enum write_granularity gra
static int get_next_write(uint8_t *have, uint8_t *want, int len,
int *first_start, enum write_granularity gran)
{
- int need_write = 0, rel_start = 0, first_len = 0, i, limit, stride;
+ int need_write = 0, rel_start = 0, first_len = 0;
+ int i, limit, stride;
switch (gran) {
case write_gran_1bit:
@@ -1326,7 +1328,8 @@ out_free:
*/
static int selfcheck_eraseblocks(const struct flashchip *flash)
{
- int i, j, k, ret = 0;
+ int i, j, k;
+ int ret = 0;
for (k = 0; k < NUM_ERASEFUNCTIONS; k++) {
unsigned int done = 0;
@@ -1451,7 +1454,8 @@ static int walk_eraseregions(struct flashchip *flash, int erasefunction,
void *param1, void *param2)
{
int i, j;
- unsigned int start = 0, len;
+ unsigned int start = 0;
+ unsigned int len;
struct block_eraser eraser = flash->block_erasers[erasefunction];
for (i = 0; i < NUM_ERASEREGIONS; i++) {
@@ -1603,8 +1607,10 @@ void list_programmers(const char *delim)
void list_programmers_linebreak(int startcol, int cols, int paren)
{
const char *pname;
- int pnamelen, remaining = 0, firstline = 1, i;
+ int pnamelen;
+ int remaining = 0, firstline = 1;
enum programmer p;
+ int i;
for (p = 0; p < PROGRAMMER_INVALID; p++) {
pname = programmer_table[p].name;
diff --git a/ft2232_spi.c b/ft2232_spi.c
index cb247fa..ef2449a 100644
--- a/ft2232_spi.c
+++ b/ft2232_spi.c
@@ -252,17 +252,21 @@ int ft2232_spi_init(void)
ftdic->error_str);
}
- if (ftdi_usb_reset(ftdic) < 0)
+ if (ftdi_usb_reset(ftdic) < 0) {
msg_perr("Unable to reset FTDI device\n");
+ }
- if (ftdi_set_latency_timer(ftdic, 2) < 0)
+ if (ftdi_set_latency_timer(ftdic, 2) < 0) {
msg_perr("Unable to set latency timer\n");
+ }
- if (ftdi_write_data_set_chunksize(ftdic, 256))
+ if (ftdi_write_data_set_chunksize(ftdic, 256)) {
msg_perr("Unable to set chunk size\n");
+ }
- if (ftdi_set_bitmode(ftdic, 0x00, BITMODE_BITBANG_SPI) < 0)
+ if (ftdi_set_bitmode(ftdic, 0x00, BITMODE_BITBANG_SPI) < 0) {
msg_perr("Unable to set bitmode to SPI\n");
+ }
if (clock_5x) {
msg_pdbg("Disable divide-by-5 front stage\n");
@@ -329,7 +333,8 @@ static int ft2232_spi_send_command(unsigned int writecnt, unsigned int readcnt,
struct ftdi_context *ftdic = &ftdic_context;
static unsigned char *buf = NULL;
/* failed is special. We use bitwise ops, but it is essentially bool. */
- int i = 0, ret = 0, failed = 0, bufsize;
+ int i = 0, ret = 0, failed = 0;
+ int bufsize;
static int oldbufsize = 0;
if (writecnt > 65536 || readcnt > 65536)
diff --git a/it85spi.c b/it85spi.c
index 76e4861..f1ad22b 100644
--- a/it85spi.c
+++ b/it85spi.c
@@ -84,15 +84,15 @@ unsigned char *ce_high, *ce_low;
static int it85xx_scratch_rom_reenter = 0;
/* This function will poll the keyboard status register until either
- * an expected value shows up, or
- * timeout reaches.
+ * an expected value shows up, or the timeout is reached.
+ * timeout is in usec.
*
- * Returns: 0 -- the expected value has shown.
- * 1 -- timeout reached.
+ * Returns: 0 -- the expected value showed up.
+ * 1 -- timeout.
*/
static int wait_for(const unsigned int mask, const unsigned int expected_value,
- const int timeout /* in usec */, const char *error_message,
- const char *function_name, const int lineno)
+ const int timeout, const char * error_message,
+ const char * function_name, const int lineno)
{
int time_passed;
@@ -317,8 +317,9 @@ static int it85xx_spi_send_command(unsigned int writecnt, unsigned int readcnt,
int i;
it85xx_enter_scratch_rom();
- /* exit scratch ROM ONLY when programmer shuts down. Otherwise, the
- * temporary flash state may halt EC. */
+ /* Exit scratch ROM ONLY when programmer shuts down. Otherwise, the
+ * temporary flash state may halt the EC.
+ */
#ifdef LPC_IO
INDIRECT_A1(shm_io_base, (((unsigned long int)ce_high) >> 8) & 0xff);
diff --git a/it87spi.c b/it87spi.c
index c24ba9b..46779ee 100644
--- a/it87spi.c
+++ b/it87spi.c
@@ -203,7 +203,8 @@ static uint16_t it87spi_probe(uint16_t port)
int init_superio_ite(void)
{
- int i, ret = 0;
+ int i;
+ int ret = 0;
for (i = 0; i < superio_count; i++) {
if (superios[i].vendor != SUPERIO_VENDOR_ITE)
diff --git a/physmap.c b/physmap.c
index cbab636..d92015d 100644
--- a/physmap.c
+++ b/physmap.c
@@ -76,7 +76,7 @@ static void *sys_physmap(unsigned long phys_addr, size_t len)
mi.address = phys_addr;
mi.size = len;
- ret = __dpmi_physical_address_mapping (&mi);
+ ret = __dpmi_physical_address_mapping(&mi);
if (ret != 0)
return ERROR_PTR;
OpenPOWER on IntegriCloud