Changeset 1021


Ignore:
Timestamp:
05/31/10 00:24:40 (20 months ago)
Author:
hailfinger
Message:

Remove unneeded #include statements completely.

unistd.h was only used to get a definition of NULL in all files. Add our
own NULL #define and remove unistd.h from flash.h
stdio.h has no place in flash.h, it should be included only in files
which really need it.
Add #include statements in individual .c files where needed.

Replace a few printf with msg_* to eliminate the need for stdio.h.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@…>
Acked-by: Uwe Hermann <uwe@…>

Location:
trunk
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/82802ab.c

    r991 r1021  
    2727 */ 
    2828 
    29 #include <string.h> 
    30 #include <stdlib.h> 
    3129#include "flash.h" 
    3230#include "chipdrivers.h" 
  • trunk/board_enable.c

    r1015 r1021  
    2626 
    2727#include <string.h> 
    28 #include <fcntl.h> 
    2928#include "flash.h" 
    3029 
     
    108107        id = sio_read(port, 0x20); 
    109108        if (id != 0x44) { 
    110                 fprintf(stderr, "\nERROR: %s: FDC37B787: Wrong ID 0x%02X.\n", 
    111                         name, id); 
     109                msg_perr("\nERROR: %s: FDC37B787: Wrong ID 0x%02X.\n", 
     110                        name, id); 
    112111                OUTB(0xAA, port); /* leave conf mode */ 
    113112                return -1; 
     
    119118        if ((val & 0x1B) != 0x10)       /* output, no invert, GPIO */ 
    120119        { 
    121                 fprintf(stderr, "\nERROR: %s: GPIO50 mode 0x%02X unexpected.\n", 
    122                         name, val); 
     120                msg_perr("\nERROR: %s: GPIO50 mode 0x%02X unexpected.\n", 
     121                        name, val); 
    123122                OUTB(0xAA, port); 
    124123                return -1; 
  • trunk/cbtable.c

    r997 r1021  
    2323 */ 
    2424 
     25#include <unistd.h> 
     26#include <stdio.h> 
    2527#include <stdlib.h> 
    2628#include <sys/types.h> 
  • trunk/chipset_enable.c

    r1016 r1021  
    2828#define _LARGEFILE64_SOURCE 
    2929 
     30#include <unistd.h> 
    3031#include <stdlib.h> 
    3132#include <string.h> 
  • trunk/cli_classic.c

    r1006 r1021  
    2222 */ 
    2323 
     24#include <stdio.h> 
    2425#include <fcntl.h> 
    2526#include <sys/types.h> 
  • trunk/dediprog.c

    r914 r1021  
    1919 
    2020#include <string.h> 
    21 #include <stdlib.h> 
    22 #include <ctype.h> 
    23 #include <sys/types.h> 
    2421#include <usb.h> 
    2522#include "flash.h" 
  • trunk/drkaiser.c

    r911 r1021  
    2020 
    2121#include <stdlib.h> 
    22 #include <string.h> 
    23 #include <sys/types.h> 
    2422#include "flash.h" 
    2523 
  • trunk/flash.h

    r1016 r1021  
    2525#define __FLASH_H__ 1 
    2626 
    27 #include <unistd.h> 
    2827#include <stdint.h> 
    29 #include <stdio.h> 
    3028#include "hwaccess.h" 
    3129#ifdef _WIN32 
     
    3331#undef min 
    3432#undef max 
     33#endif 
     34 
     35#ifndef NULL 
     36#define NULL ((void *) 0) 
    3537#endif 
    3638 
     
    557559extern const char *flashrom_version; 
    558560extern char *chip_to_probe; 
    559 #define printf_debug(x...) { if (verbose) printf(x); } 
    560561void map_flash_registers(struct flashchip *flash); 
    561562int read_memmapped(struct flashchip *flash, uint8_t *buf, int start, int len); 
  • trunk/flashrom.c

    r1013 r1021  
    2222 */ 
    2323 
     24#include <stdio.h> 
    2425#include <fcntl.h> 
    2526#include <sys/types.h> 
  • trunk/hwaccess.c

    r1013 r1021  
    2222#include <string.h> 
    2323#include <stdlib.h> 
     24#include <unistd.h> 
    2425#include <fcntl.h> 
    2526#include <sys/types.h> 
  • trunk/layout.c

    r996 r1021  
    1919 */ 
    2020 
     21#include <stdio.h> 
    2122#include <stdlib.h> 
    2223#include <string.h> 
     
    7475        if ((*walk) == 0 || ((*walk) & 0x3ff) != 0 || (*walk) > size || 
    7576            mb_part_offset > size || mb_vendor_offset > size) { 
    76                 printf("Flash image seems to be a legacy BIOS. Disabling checks.\n"); 
     77                msg_pinfo("Flash image seems to be a legacy BIOS. Disabling checks.\n"); 
    7778                return 0; 
    7879        } 
     
    8283        if (!isprint((unsigned char)*mb_part) || 
    8384            !isprint((unsigned char)*mb_vendor)) { 
    84                 printf("Flash image seems to have garbage in the ID location." 
     85                msg_pinfo("Flash image seems to have garbage in the ID location." 
    8586                       " Disabling checks.\n"); 
    8687                return 0; 
    8788        } 
    8889 
    89         printf_debug("coreboot last image size " 
     90        msg_pdbg("coreboot last image size " 
    9091                     "(not ROM size) is %d bytes.\n", *walk); 
    9192 
    9293        mainboard_part = strdup(mb_part); 
    9394        mainboard_vendor = strdup(mb_vendor); 
    94         printf_debug("Manufacturer: %s\n", mainboard_vendor); 
    95         printf_debug("Mainboard ID: %s\n", mainboard_part); 
     95        msg_pdbg("Manufacturer: %s\n", mainboard_vendor); 
     96        msg_pdbg("Mainboard ID: %s\n", mainboard_part); 
    9697 
    9798        /* 
     
    100101         */ 
    101102        if (!lb_vendor || !lb_part) { 
    102                 printf("Note: If the following flash access fails, " 
     103                msg_pinfo("Note: If the following flash access fails, " 
    103104                       "try -m <vendor>:<mainboard>.\n"); 
    104105                return 0; 
     
    110111        if (!strcasecmp(mainboard_vendor, lb_vendor) && 
    111112            !strcasecmp(mainboard_part, lb_part)) { 
    112                 printf_debug("This firmware image matches this mainboard.\n"); 
     113                msg_pdbg("This firmware image matches this mainboard.\n"); 
    113114        } else { 
    114115                if (force_boardmismatch) { 
    115                         printf("WARNING: This firmware image does not " 
     116                        msg_pinfo("WARNING: This firmware image does not " 
    116117                               "seem to fit to this machine - forcing it.\n"); 
    117118                } else { 
    118                         printf("ERROR: Your firmware image (%s:%s) does not " 
     119                        msg_pinfo("ERROR: Your firmware image (%s:%s) does not " 
    119120                               "appear to\n       be correct for the detected " 
    120121                               "mainboard (%s:%s)\n\nOverride with -p internal:" 
     
    142143 
    143144        if (!romlayout) { 
    144                 fprintf(stderr, "ERROR: Could not open ROM layout (%s).\n", 
     145                msg_gerr("ERROR: Could not open ROM layout (%s).\n", 
    145146                        name); 
    146147                return -1; 
     
    160161                tstr2 = strtok(NULL, ":"); 
    161162                if (!tstr1 || !tstr2) { 
    162                         fprintf(stderr, "Error parsing layout file.\n"); 
     163                        msg_gerr("Error parsing layout file.\n"); 
    163164                        fclose(romlayout); 
    164165                        return 1; 
     
    171172 
    172173        for (i = 0; i < romimages; i++) { 
    173                 printf_debug("romlayout %08x - %08x named %s\n", 
     174                msg_gdbg("romlayout %08x - %08x named %s\n", 
    174175                             rom_entries[i].start, 
    175176                             rom_entries[i].end, rom_entries[i].name); 
     
    188189                return -1; 
    189190 
    190         printf("Looking for \"%s\"... ", name); 
     191        msg_ginfo("Looking for \"%s\"... ", name); 
    191192 
    192193        for (i = 0; i < romimages; i++) { 
    193194                if (!strcmp(rom_entries[i].name, name)) { 
    194195                        rom_entries[i].included = 1; 
    195                         printf("found.\n"); 
     196                        msg_ginfo("found.\n"); 
    196197                        return i; 
    197198                } 
    198199        } 
    199         printf("not found.\n"); // Not found. Error. 
     200        msg_ginfo("not found.\n");      // Not found. Error. 
    200201 
    201202        return -1; 
  • trunk/nic3com.c

    r1013 r1021  
    2222 
    2323#include <stdlib.h> 
    24 #include <string.h> 
    25 #include <sys/types.h> 
    2624#include "flash.h" 
    2725 
  • trunk/nicrealtek.c

    r1013 r1021  
    2222 
    2323#include <stdlib.h> 
    24 #include <string.h> 
    25 #include <sys/types.h> 
    2624#include "flash.h" 
    2725 
  • trunk/physmap.c

    r1013 r1021  
    2121 */ 
    2222 
     23#include <unistd.h> 
     24#include <stdio.h> 
    2325#include <sys/types.h> 
    2426#include <sys/stat.h> 
     
    311313{ 
    312314        char msrfilename[64]; 
    313         memset(msrfilename, 0, 64); 
    314         sprintf(msrfilename, "/dev/cpu/%d/msr", cpu); 
     315        memset(msrfilename, 0, sizeof(msrfilename)); 
     316        snprintf(msrfilename, sizeof(msrfilename), "/dev/cpu/%d/msr", cpu); 
    315317 
    316318        if (fd_msr != -1) { 
     
    394396{ 
    395397        char msrfilename[64]; 
    396         memset(msrfilename, 0, 64); 
    397         sprintf(msrfilename, "/dev/cpu%d", cpu); 
     398        memset(msrfilename, 0, sizeof(msrfilename)); 
     399        snprintf(msrfilename, sizeof(msrfilename), "/dev/cpu%d", cpu); 
    398400 
    399401        if (fd_msr != -1) { 
  • trunk/print.c

    r1013 r1021  
    2020 */ 
    2121 
     22#include <stdio.h> 
    2223#include <string.h> 
    2324#include <stdlib.h> 
  • trunk/programmer.c

    r829 r1021  
    1919 */ 
    2020 
    21 #include <stdlib.h> 
    2221#include "flash.h" 
    2322 
  • trunk/satasii.c

    r911 r1021  
    2222 
    2323#include <stdlib.h> 
    24 #include <string.h> 
    2524#include "flash.h" 
    2625 
  • trunk/sb600spi.c

    r1013 r1021  
    2424#if defined(__i386__) || defined(__x86_64__) 
    2525 
    26 #include <string.h> 
    2726#include "flash.h" 
    2827#include "chipdrivers.h" 
  • trunk/sharplhf00l04.c

    r982 r1021  
    1919 */ 
    2020 
    21 #include <stdlib.h> 
    2221#include "flash.h" 
    2322#include "chipdrivers.h" 
  • trunk/spi.c

    r1016 r1021  
    2323 */ 
    2424 
    25 #include <string.h> 
    2625#include "flash.h" 
    2726#include "flashchips.h" 
  • trunk/sst49lfxxxc.c

    r982 r1021  
    2121 */ 
    2222 
    23 #include <stdlib.h> 
    2423#include "flash.h" 
    2524#include "chipdrivers.h" 
  • trunk/sst_fwhub.c

    r982 r1021  
    2323/* Adapted from the Intel FW hub stuff for 82802ax parts. */ 
    2424 
    25 #include <stdlib.h> 
    26 #include <string.h> 
    2725#include "flash.h" 
    2826#include "chipdrivers.h" 
  • trunk/stm50flw0x0x.c

    r985 r1021  
    2828 */ 
    2929 
    30 #include <string.h> 
    31 #include <stdlib.h> 
    3230#include "flash.h" 
    3331#include "flashchips.h" 
  • trunk/udelay.c

    r992 r1021  
    2020 */ 
    2121 
     22#include <unistd.h> 
    2223#include <sys/time.h> 
    2324#include <stdlib.h> 
     
    6465        int i, tries = 0; 
    6566 
    66         printf("Calibrating delay loop... "); 
     67        msg_pinfo("Calibrating delay loop... "); 
    6768 
    6869recalibrate: 
     
    114115        msg_pdbg("10000 myus = %ld us, ", timeusec); 
    115116 
    116         printf("OK.\n"); 
     117        msg_pinfo("OK.\n"); 
    117118} 
    118119 
  • trunk/wbsio_spi.c

    r1013 r1021  
    2121#if defined(__i386__) || defined(__x86_64__) 
    2222 
    23 #include <string.h> 
    2423#include "flash.h" 
    2524#include "chipdrivers.h" 
Note: See TracChangeset for help on using the changeset viewer.