Author: hailfinger
Date: Mon Aug 15 21:54:20 2011
New Revision: 1413
URL: http://flashrom.org/trac/flashrom/changeset/1413

Log:
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.

Signed-off-by: Carl-Daniel Hailfinger <[email protected]>
Acked-by: Stefan Tauner <[email protected]>

Modified:
   trunk/board_enable.c
   trunk/buspirate_spi.c
   trunk/chipset_enable.c
   trunk/cli_classic.c
   trunk/dediprog.c
   trunk/dmi.c
   trunk/flashrom.c
   trunk/ft2232_spi.c
   trunk/it85spi.c
   trunk/it87spi.c
   trunk/physmap.c

Modified: trunk/board_enable.c
==============================================================================
--- trunk/board_enable.c        Fri Aug 12 03:19:32 2011        (r1412)
+++ trunk/board_enable.c        Mon Aug 15 21:54:20 2011        (r1413)
@@ -860,7 +860,7 @@
                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 @@
        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 @@
        }
 
        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;
        }
 

Modified: trunk/buspirate_spi.c
==============================================================================
--- trunk/buspirate_spi.c       Fri Aug 12 03:19:32 2011        (r1412)
+++ trunk/buspirate_spi.c       Mon Aug 15 21:54:20 2011        (r1413)
@@ -150,9 +150,11 @@
 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)) {

Modified: trunk/chipset_enable.c
==============================================================================
--- trunk/chipset_enable.c      Fri Aug 12 03:19:32 2011        (r1412)
+++ trunk/chipset_enable.c      Mon Aug 15 21:54:20 2011        (r1413)
@@ -309,8 +309,9 @@
 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 @@
                }
        } else {
                msg_pinfo("AMD Elan SC520 detected, but no BOOTCS. "
-                         "Assuming flash at 4G\n");
+                         "Assuming flash at 4G.\n");
        }
 
        /* 4. Clean up */

Modified: trunk/cli_classic.c
==============================================================================
--- trunk/cli_classic.c Fri Aug 12 03:19:32 2011        (r1412)
+++ trunk/cli_classic.c Mon Aug 15 21:54:20 2011        (r1413)
@@ -104,13 +104,14 @@
        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[] = {

Modified: trunk/dediprog.c
==============================================================================
--- trunk/dediprog.c    Fri Aug 12 03:19:32 2011        (r1412)
+++ trunk/dediprog.c    Mon Aug 15 21:54:20 2011        (r1413)
@@ -496,7 +496,8 @@
 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 @@
 {
        struct usb_device *dev;
        char *voltage;
-       int millivolt = 3500, ret;
+       int millivolt = 3500;
+       int ret;
 
        msg_pspew("%s\n", __func__);
 

Modified: trunk/dmi.c
==============================================================================
--- trunk/dmi.c Fri Aug 12 03:19:32 2011        (r1412)
+++ trunk/dmi.c Mon Aug 15 21:54:20 2011        (r1413)
@@ -196,7 +196,8 @@
  */
 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! */

Modified: trunk/flashrom.c
==============================================================================
--- trunk/flashrom.c    Fri Aug 12 03:19:32 2011        (r1412)
+++ trunk/flashrom.c    Mon Aug 15 21:54:20 2011        (r1413)
@@ -600,8 +600,7 @@
        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 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 @@
  */
 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 @@
 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 @@
  */
 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 @@
                             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_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;

Modified: trunk/ft2232_spi.c
==============================================================================
--- trunk/ft2232_spi.c  Fri Aug 12 03:19:32 2011        (r1412)
+++ trunk/ft2232_spi.c  Mon Aug 15 21:54:20 2011        (r1413)
@@ -252,17 +252,21 @@
                                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 @@
        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)

Modified: trunk/it85spi.c
==============================================================================
--- trunk/it85spi.c     Fri Aug 12 03:19:32 2011        (r1412)
+++ trunk/it85spi.c     Mon Aug 15 21:54:20 2011        (r1413)
@@ -84,15 +84,15 @@
 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 @@
        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);

Modified: trunk/it87spi.c
==============================================================================
--- trunk/it87spi.c     Fri Aug 12 03:19:32 2011        (r1412)
+++ trunk/it87spi.c     Mon Aug 15 21:54:20 2011        (r1413)
@@ -203,7 +203,8 @@
 
 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)

Modified: trunk/physmap.c
==============================================================================
--- trunk/physmap.c     Fri Aug 12 03:19:32 2011        (r1412)
+++ trunk/physmap.c     Mon Aug 15 21:54:20 2011        (r1413)
@@ -76,7 +76,7 @@
 
        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;

_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to