Author: stefanct
Date: Mon Aug 13 10:45:13 2012
New Revision: 1570
URL: http://flashrom.org/trac/flashrom/changeset/1570

Log:
Clean up ICH descriptor code.

 - allows for compilation with -Werror=shadow,
 - use extended line limit to fix the most awful line breaks.

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

Modified:
   trunk/ich_descriptors.c
   trunk/util/ich_descriptors_tool/ich_descriptors_tool.c

Modified: trunk/ich_descriptors.c
==============================================================================
--- trunk/ich_descriptors.c     Sat Aug 11 18:07:08 2012        (r1569)
+++ trunk/ich_descriptors.c     Mon Aug 13 10:45:13 2012        (r1570)
@@ -85,26 +85,16 @@
        msg_pdbg2("\n");
 
        msg_pdbg2("--- Details ---\n");
-       msg_pdbg2("NR          (Number of Regions):                 %5d\n",
-                 cont->NR + 1);
-       msg_pdbg2("FRBA        (Flash Region Base Address):         0x%03x\n",
-                 getFRBA(cont));
-       msg_pdbg2("NC          (Number of Components):              %5d\n",
-                 cont->NC + 1);
-       msg_pdbg2("FCBA        (Flash Component Base Address):      0x%03x\n",
-                 getFCBA(cont));
-       msg_pdbg2("ISL         (ICH/PCH Strap Length):              %5d\n",
-                 cont->ISL);
-       msg_pdbg2("FISBA/FPSBA (Flash ICH/PCH Strap Base Address):  0x%03x\n",
-                 getFISBA(cont));
-       msg_pdbg2("NM          (Number of Masters):                 %5d\n",
-                 cont->NM + 1);
-       msg_pdbg2("FMBA        (Flash Master Base Address):         0x%03x\n",
-                 getFMBA(cont));
-       msg_pdbg2("MSL/PSL     (MCH/PROC Strap Length):             %5d\n",
-                 cont->MSL);
-       msg_pdbg2("FMSBA       (Flash MCH/PROC Strap Base Address): 0x%03x\n",
-                 getFMSBA(cont));
+       msg_pdbg2("NR          (Number of Regions):                 %5d\n",     
cont->NR + 1);
+       msg_pdbg2("FRBA        (Flash Region Base Address):         0x%03x\n",  
getFRBA(cont));
+       msg_pdbg2("NC          (Number of Components):              %5d\n",     
cont->NC + 1);
+       msg_pdbg2("FCBA        (Flash Component Base Address):      0x%03x\n",  
getFCBA(cont));
+       msg_pdbg2("ISL         (ICH/PCH Strap Length):              %5d\n",     
cont->ISL);
+       msg_pdbg2("FISBA/FPSBA (Flash ICH/PCH Strap Base Address):  0x%03x\n",  
getFISBA(cont));
+       msg_pdbg2("NM          (Number of Masters):                 %5d\n",     
cont->NM + 1);
+       msg_pdbg2("FMBA        (Flash Master Base Address):         0x%03x\n",  
getFMBA(cont));
+       msg_pdbg2("MSL/PSL     (MCH/PROC Strap Length):             %5d\n",     
cont->MSL);
+       msg_pdbg2("FMSBA       (Flash MCH/PROC Strap Base Address): 0x%03x\n",  
getFMSBA(cont));
        msg_pdbg2("\n");
 }
 
@@ -520,8 +510,8 @@
 
        msg_pdbg2("Integrated Clocking Configuration used: %d\n",
                  s->cougar.ICC_SEL);
-       msg_pdbg2("PCH Signal CL_RST1# does %sassert when Intel ME performs a "
-                 "reset.\n", s->ibex.MER_CL1 ? "" : "not ");
+       msg_pdbg2("PCH Signal CL_RST1# does %sassert when Intel ME performs a 
reset.\n",
+                 s->ibex.MER_CL1 ? "" : "not ");
        msg_pdbg2("ICC Profile is selected by %s.\n",
                  s->cougar.ICC_PRO_SEL ? "Softstraps" : "BIOS");
        msg_pdbg2("Deep SX is %ssupported on the platform.\n",
@@ -538,8 +528,7 @@
                  s->cougar.IWL_EN ? "en" : "dis");
        msg_pdbg2("Chipset configuration Softstrap 5: %d\n", s->cougar.cs_ss5);
        msg_pdbg2("SMLink1 provides temperature from %s.\n",
-                 s->cougar.SMLINK1_THERM_SEL ?
-                                        "PCH only" : "the CPU, PCH and DIMMs");
+                 s->cougar.SMLINK1_THERM_SEL ? "PCH only" : "the CPU, PCH and 
DIMMs");
        msg_pdbg2("GPIO29 is used as %s.\n", s->cougar.SLP_LAN_GP29_SEL ?
                  "general purpose output" : "SLP_LAN#");
 
@@ -552,32 +541,32 @@
 
 void prettyprint_ich_descriptor_straps(enum ich_chipset cs, const struct 
ich_descriptors *desc)
 {
-       unsigned int i, max;
+       unsigned int i, max_count;
        msg_pdbg2("=== Softstraps ===\n");
 
        if (sizeof(desc->north.STRPs) / 4 + 1 < desc->content.MSL) {
-               max = sizeof(desc->north.STRPs) / 4 + 1;
-               msg_pdbg2("MSL (%u) is greater than the current maximum of %u "
-                         "entries.\n", desc->content.MSL, max + 1);
-               msg_pdbg2("Only the first %u entries will be printed.\n", max);
+               max_count = sizeof(desc->north.STRPs) / 4 + 1;
+               msg_pdbg2("MSL (%u) is greater than the current maximum of %u 
entries.\n",
+                         desc->content.MSL, max_count + 1);
+               msg_pdbg2("Only the first %u entries will be printed.\n", 
max_count);
        } else
-               max = desc->content.MSL;
+               max_count = desc->content.MSL;
 
-       msg_pdbg2("--- North/MCH/PROC (%d entries) ---\n", max);
-       for (i = 0; i < max; i++)
+       msg_pdbg2("--- North/MCH/PROC (%d entries) ---\n", max_count);
+       for (i = 0; i < max_count; i++)
                msg_pdbg2("STRP%-2d = 0x%08x\n", i, desc->north.STRPs[i]);
        msg_pdbg2("\n");
 
        if (sizeof(desc->south.STRPs) / 4 < desc->content.ISL) {
-               max = sizeof(desc->south.STRPs) / 4;
-               msg_pdbg2("ISL (%u) is greater than the current maximum of %u "
-                         "entries.\n", desc->content.ISL, max);
-               msg_pdbg2("Only the first %u entries will be printed.\n", max);
+               max_count = sizeof(desc->south.STRPs) / 4;
+               msg_pdbg2("ISL (%u) is greater than the current maximum of %u 
entries.\n",
+                         desc->content.ISL, max_count);
+               msg_pdbg2("Only the first %u entries will be printed.\n", 
max_count);
        } else
-               max = desc->content.ISL;
+               max_count = desc->content.ISL;
 
-       msg_pdbg2("--- South/ICH/PCH (%d entries) ---\n", max);
-       for (i = 0; i < max; i++)
+       msg_pdbg2("--- South/ICH/PCH (%d entries) ---\n", max_count);
+       for (i = 0; i < max_count; i++)
                msg_pdbg2("STRP%-2d = 0x%08x\n", i, desc->south.STRPs[i]);
        msg_pdbg2("\n");
 
@@ -608,8 +597,7 @@
        case CHIPSET_ICH_UNKNOWN:
                break;
        default:
-               msg_pdbg2("The meaning of the descriptor straps are unknown "
-                         "yet.\n\n");
+               msg_pdbg2("The meaning of the descriptor straps are unknown 
yet.\n\n");
                break;
        }
 }
@@ -634,8 +622,7 @@
        msg_pdbg2("\n");
 
        msg_pdbg2("VSCC Table: %d entries\n", umap->VTL/2);
-       for (i = 0; i < umap->VTL/2; i++)
-       {
+       for (i = 0; i < umap->VTL/2; i++) {
                uint32_t jid = umap->vscc_table[i].JID;
                uint32_t vscc = umap->vscc_table[i].VSCC;
                msg_pdbg2("  JID%d  = 0x%08x\n", i, jid);
@@ -651,7 +638,7 @@
 /* len is the length of dump in bytes */
 int read_ich_descriptors_from_dump(const uint32_t *dump, unsigned int len, 
struct ich_descriptors *desc)
 {
-       unsigned int i, max;
+       unsigned int i, max_count;
        uint8_t pch_bug_offset = 0;
 
        if (dump == NULL || desc == NULL)
@@ -708,10 +695,8 @@
                return ICH_RET_OOB;
 
        for (i = 0; i < desc->upper.VTL/2; i++) {
-               desc->upper.vscc_table[i].JID  =
-                                dump[(getVTBA(&desc->upper) >> 2) + i * 2 + 0];
-               desc->upper.vscc_table[i].VSCC =
-                                dump[(getVTBA(&desc->upper) >> 2) + i * 2 + 1];
+               desc->upper.vscc_table[i].JID  = dump[(getVTBA(&desc->upper) >> 
2) + i * 2 + 0];
+               desc->upper.vscc_table[i].VSCC = dump[(getVTBA(&desc->upper) >> 
2) + i * 2 + 1];
        }
 
        /* MCH/PROC (aka. North) straps */
@@ -719,20 +704,18 @@
                return ICH_RET_OOB;
 
        /* limit the range to be written */
-       max = min(sizeof(desc->north.STRPs) / 4, desc->content.MSL);
-       for (i = 0; i < max; i++)
-                       desc->north.STRPs[i] =
-                                     dump[(getFMSBA(&desc->content) >> 2) + i];
+       max_count = min(sizeof(desc->north.STRPs) / 4, desc->content.MSL);
+       for (i = 0; i < max_count; i++)
+               desc->north.STRPs[i] = dump[(getFMSBA(&desc->content) >> 2) + 
i];
 
        /* ICH/PCH (aka. South) straps */
        if (len < getFISBA(&desc->content) + desc->content.ISL * 4)
                return ICH_RET_OOB;
 
        /* limit the range to be written */
-       max = min(sizeof(desc->south.STRPs) / 4, desc->content.ISL);
-       for (i = 0; i < max; i++)
-                       desc->south.STRPs[i] =
-                                     dump[(getFISBA(&desc->content) >> 2) + i];
+       max_count = min(sizeof(desc->south.STRPs) / 4, desc->content.ISL);
+       for (i = 0; i < max_count; i++)
+               desc->south.STRPs[i] = dump[(getFISBA(&desc->content) >> 2) + 
i];
 
        return ICH_RET_OK;
 }
@@ -755,13 +738,12 @@
                size_enc = desc->component.comp2_density;
                break;
        default:
-               msg_perr("Only ICH SPI component index 0 or 1 are supported "
-                        "yet.\n");
+               msg_perr("Only ICH SPI component index 0 or 1 are supported 
yet.\n");
                return 0;
        }
        if (size_enc > 5) {
-               msg_perr("Density of ICH SPI component with index %d is "
-                        "invalid. Encoded density is 0x%x.\n", idx, size_enc);
+               msg_perr("Density of ICH SPI component with index %d is 
invalid. Encoded density is 0x%x.\n",
+                        idx, size_enc);
                return 0;
        }
        return (1 << (19 + size_enc));
@@ -804,8 +786,7 @@
                return ICH_RET_ERR;
        }
 
-       msg_pdbg2("Reading flash descriptors "
-                "mapped by the chipset via FDOC/FDOD...");
+       msg_pdbg2("Reading flash descriptors mapped by the chipset via 
FDOC/FDOD...");
        /* content section */
        desc->content.FLVALSIG  = read_descriptor_reg(0, 0, spibar);
        desc->content.FLMAP0    = read_descriptor_reg(0, 1, spibar);

Modified: trunk/util/ich_descriptors_tool/ich_descriptors_tool.c
==============================================================================
--- trunk/util/ich_descriptors_tool/ich_descriptors_tool.c      Sat Aug 11 
18:07:08 2012        (r1569)
+++ trunk/util/ich_descriptors_tool/ich_descriptors_tool.c      Mon Aug 13 
10:45:13 2012        (r1570)
@@ -40,7 +40,7 @@
 #include <sys/mman.h>
 #endif
 
-static void dump_file(const char *basename, const uint32_t *dump, unsigned int 
len, struct ich_desc_region *reg, unsigned int i)
+static void dump_file(const char *prefix, const uint32_t *dump, unsigned int 
len, struct ich_desc_region *reg, unsigned int i)
 {
        int ret;
        char *fn;
@@ -54,8 +54,7 @@
 
        reg_name = region_names[i];
        if (base > limit) {
-               printf("The %s region is unused and thus not dumped.\n",
-                      reg_name);
+               printf("The %s region is unused and thus not dumped.\n", 
reg_name);
                return;
        }
 
@@ -68,13 +67,13 @@
                return;
        }
 
-       fn = malloc(strlen(basename) + strlen(reg_name) + strlen(".bin") + 2);
+       fn = malloc(strlen(prefix) + strlen(reg_name) + strlen(".bin") + 2);
        if (!fn) {
                fprintf(stderr, "Out of memory!\n");
                exit(1);
        }
-       snprintf(fn, strlen(basename) + strlen(reg_name) + strlen(".bin") + 2,
-                "%s.%s.bin", basename, reg_name);
+       snprintf(fn, strlen(prefix) + strlen(reg_name) + strlen(".bin") + 2,
+                "%s.%s.bin", prefix, reg_name);
        printf("Dumping %u bytes of the %s region from 0x%08x-0x%08x to %s... ",
               file_len, region_names[i], base, limit, fn);
        int fh = open(fn, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
@@ -95,12 +94,12 @@
        close(fh);
 }
 
-void dump_files(const char *n, const uint32_t *buf, unsigned int len, struct 
ich_desc_region *reg)
+void dump_files(const char *name, const uint32_t *buf, unsigned int len, 
struct ich_desc_region *reg)
 {
        unsigned int i;
        printf("=== Dumping region files ===\n");
        for (i = 0; i < 5; i++)
-               dump_file(n, buf, len, reg, i);
+               dump_file(name, buf, len, reg, i);
        printf("\n");
 }
 
@@ -157,8 +156,7 @@
                }
        }
        if (fn == NULL)
-               usage(argv,
-                     "Need a file name of a descriptor image to read from.");
+               usage(argv, "Need the file name of a descriptor image to read 
from.");
 
        fd = open(fn, O_RDONLY);
        if (fd < 0)
@@ -209,8 +207,7 @@
                printf("Image not in descriptor mode.\n");
                exit(1);
        case ICH_RET_OOB:
-               printf("Tried to access a location out of bounds of the image. "
-                      "- Corrupt image?\n");
+               printf("Tried to access a location out of bounds of the image. 
- Corrupt image?\n");
                exit(1);
        default:
                printf("Unhandled return value at %s:%u, please report this.\n",

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

Reply via email to