Use uint16_t and friends where appropriate (trivial).
authorUwe Hermann <uwe@hermann-uwe.de>
Wed, 19 Sep 2007 00:03:14 +0000 (00:03 +0000)
committerUwe Hermann <uwe@hermann-uwe.de>
Wed, 19 Sep 2007 00:03:14 +0000 (00:03 +0000)
Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@2783 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1

util/superiotool/Makefile
util/superiotool/fintek.c
util/superiotool/ite.c
util/superiotool/nsc.c
util/superiotool/smsc.c
util/superiotool/superiotool.c
util/superiotool/superiotool.h

index 6e86d01352346445a311b775dca28de0e61563c6..44d0316e5a4d5da69e416aa01add3fc58096f93f 100644 (file)
@@ -24,9 +24,9 @@ CC      = gcc
 INSTALL = /usr/bin/install
 PREFIX  = /usr/local
 
-# TODO: -ansi, -pedantic
+# TODO: -pedantic
 CFLAGS = -O2 -Wall -Werror -Wstrict-prototypes -Wundef -Wstrict-aliasing \
-         -Werror-implicit-function-declaration
+         -Werror-implicit-function-declaration -ansi
 
 OBJS = superiotool.o fintek.o ite.o nsc.o smsc.o
 
index f7baaf6989476c0df7a2da225598772781d8563a..c12954c7f9e330236e60c40fd55b0c5301d11993 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "superiotool.h"
 
-void dump_fintek(unsigned short port, unsigned int did)
+void dump_fintek(uint16_t port, uint16_t did)
 {
        switch (did) {
        case 0x0604:
@@ -89,9 +89,9 @@ void dump_fintek(unsigned short port, unsigned int did)
               regval(port, 0xf6), regval(port, 0xf7), regval(port, 0xf8));
 }
 
-void probe_idregs_fintek(unsigned short port)
+void probe_idregs_fintek(uint16_t port)
 {
-       unsigned int vid, did, success = 0;
+       uint16_t vid, did, success = 0;
 
        /* Enable configuration sequence (Fintek uses this for example)
         * Older ITE chips have the same enable sequence.
index 41f2a9bb3db41b732f72d39505caa61bf673e884..938613efd4d1e51d6d0926275566ad56962f038e 100644 (file)
@@ -187,7 +187,7 @@ const static struct superio_registers reg_table[] = {
        {EOT}
 };
 
-void dump_ite(unsigned short port, unsigned short id)
+void dump_ite(uint16_t port, uint16_t id)
 {
        int i;
 
@@ -211,9 +211,9 @@ void dump_ite(unsigned short port, unsigned short id)
        }
 }
 
-void probe_idregs_ite(unsigned short port)
+void probe_idregs_ite(uint16_t port)
 {
-       unsigned int id, chipver;
+       uint16_t id, chipver;
 
        /* Enable configuration sequence (ITE uses this for newer IT87[012]x)
         * IT871[01] uses 0x87, 0x87 -> fintek detection should handle it
index 0fb2b7463ea9a81b70012ddebb0d499b5e5bcc4a..691ce13967ea1af4e7a6dc9e234a11d13fd1b45b 100644 (file)
@@ -25,7 +25,7 @@ static const char *familyid[] = {
        [0xf1] = "PC8374 (Winbond/NatSemi)"
 };
 
-void dump_ns8374(unsigned short port)
+void dump_ns8374(uint16_t port)
 {
        printf("Enables: 21=%02x, 22=%02x, 23=%02x, 24=%02x, 26=%02x\n",
               regval(port, 0x21), regval(port, 0x22), regval(port, 0x23),
@@ -56,9 +56,9 @@ void dump_ns8374(unsigned short port)
             regval(port, 0xf0));
 }
 
-void probe_idregs_simple(unsigned short port)
+void probe_idregs_simple(uint16_t port)
 {
-       unsigned char id;
+       uint16_t id;
 
        outb(0x20, port);
        if (inb(port) != 0x20) {
index f836b94a99e05f646e22db0a29623e09c5c5897e..7636001bc19f8ee263109249b1fff1e696ca38ff 100644 (file)
@@ -41,7 +41,7 @@ const static struct superio_registers reg_table[] = {
 };
 
 /* Note: The actual SMSC ID is 16 bits, but we must pass 32 bits here. */
-void dump_smsc(uint32_t port, uint32_t id)
+void dump_smsc(uint16_t port, uint16_t id)
 {
        switch (id) {
        case 0x28:
@@ -53,7 +53,7 @@ void dump_smsc(uint32_t port, uint32_t id)
        }
 }
 
-void probe_idregs_smsc(unsigned short port)
+void probe_idregs_smsc(uint16_t port)
 {
        uint16_t id, rev;
 
index 3514b2441598a206882fb2b700203d3480ac8f2d..e95f1baac677c973babe123ccbe5e25a63156e63 100644 (file)
 
 #include "superiotool.h"
 
-unsigned char regval(unsigned short port, unsigned char reg)
+uint8_t regval(uint16_t port, uint8_t reg)
 {
        outb(reg, port);
        return inb(port + 1);
 }
 
-void regwrite(unsigned short port, unsigned char reg, unsigned char val)
+void regwrite(uint16_t port, uint8_t reg, uint8_t val)
 {
        outb(reg, port);
        outb(val, port + 1);
 }
 
 void dump_superio(const char *name, const struct superio_registers reg_table[],
-                 unsigned short port, unsigned short id)
+                 uint16_t port, uint16_t id)
 {
        int i, j, k;
-       signed short *idx;
+       int *idx;
 
        printf("%s ", name);
 
@@ -46,33 +46,32 @@ void dump_superio(const char *name, const struct superio_registers reg_table[],
                if (reg_table[i].superio_id == EOT)
                        break;
 
-               if ((unsigned short)reg_table[i].superio_id != id)
+               if ((uint16_t)reg_table[i].superio_id != id)
                        continue;
 
                printf("%s\n", reg_table[i].name);
 
-               for (j = 0;; j++) {
+               for (j = 0; /* Nothing */; j++) {
                        if (reg_table[i].ldn[j].ldn == EOT)
                                break;
 
                        if (reg_table[i].ldn[j].ldn != NOLDN) {
-                               printf("Switching to LDN 0x%01x\n",
+                               printf("Switching to LDN 0x%02x\n",
                                       reg_table[i].ldn[j].ldn);
-                               regwrite(port, 0x07,
-                                        reg_table[i].ldn[j].ldn);
+                               regwrite(port, 0x07, reg_table[i].ldn[j].ldn);
                        }
 
                        idx = reg_table[i].ldn[j].idx;
 
                        printf("idx ");
-                       for (k = 0;; k++) {
+                       for (k = 0; /* Nothing */; k++) {
                                if (idx[k] == EOT)
                                        break;
                                printf("%02x ", idx[k]);
                        }
 
                        printf("\nval ");
-                       for (k = 0;; k++) {
+                       for (k = 0; /* Nothing */; k++) {
                                if (idx[k] == EOT)
                                        break;
                                printf("%02x ", regval(port, idx[k]));
@@ -80,7 +79,7 @@ void dump_superio(const char *name, const struct superio_registers reg_table[],
 
                        printf("\ndef ");
                        idx = reg_table[i].ldn[j].def;
-                       for (k = 0;; k++) {
+                       for (k = 0; /* Nothing */; k++) {
                                if (idx[k] == EOT)
                                        break;
                                else if (idx[k] == NANA)
index 4986ff167c26ccc312cf30e43d39008cc63d65fc..f4b2a859358244f0f2fa725b88b6c8f1bcdf2e19 100644 (file)
 #define MAXNUMPORTS    (2 + 1)         /* Maximum number of Super I/O ports */
 
 struct superio_registers {
-       /* Yes, superio_id should be unsigned, but EOT has to be negative. */
-       signed short superio_id;
+       int32_t superio_id; /* Signed, as we need EOT. */
        const char name[MAXNAMELEN];
        struct {
-               signed short ldn;
-               signed short idx[IDXSIZE];
-               signed short def[IDXSIZE];
+               int ldn;
+               int idx[IDXSIZE];
+               int def[IDXSIZE];
        } ldn[LDNSIZE];
 };
 
 /* superiotool.c */
-unsigned char regval(unsigned short port, unsigned char reg);
-void regwrite(unsigned short port, unsigned char reg, unsigned char val);
+uint8_t regval(uint16_t port, uint8_t reg);
+void regwrite(uint16_t port, uint8_t reg, uint8_t val);
 void dump_superio(const char *name, const struct superio_registers reg_table[],
-                  unsigned short port, unsigned short id);
-void probe_superio(unsigned short port);
+                  uint16_t port, uint16_t id);
+void probe_superio(uint16_t port);
 
 /* fintek.c */
-void dump_fintek(unsigned short port, unsigned int did);
-void probe_idregs_fintek(unsigned short port);
+void dump_fintek(uint16_t port, uint16_t did);
+void probe_idregs_fintek(uint16_t port);
 
 /* ite.c */
-void dump_ite(unsigned short port, unsigned short id);
-void probe_idregs_ite(unsigned short port);
+void dump_ite(uint16_t port, uint16_t id);
+void probe_idregs_ite(uint16_t port);
 
 /* nsc.c */
-void dump_ns8374(unsigned short port);
-void probe_idregs_simple(unsigned short port);
+void dump_ns8374(uint16_t port);
+void probe_idregs_simple(uint16_t port);
 
 /* smsc.c */
-void dump_smsc(uint32_t port, uint32_t id);
-void probe_idregs_smsc(unsigned short port);
+void dump_smsc(uint16_t port, uint16_t id);
+void probe_idregs_smsc(uint16_t port);
 
 /** Table of which config ports to probe on each Super I/O. */
 const static struct {
-       void (*probe_idregs) (unsigned short port);
-       signed short ports[MAXNUMPORTS]; /* Signed, as we need EOT. */
+       void (*probe_idregs) (uint16_t port);
+       int ports[MAXNUMPORTS]; /* Signed, as we need EOT. */
 } superio_ports_table[] = {
        {probe_idregs_simple,   {0x2e,  0x4e,   EOT}},
        {probe_idregs_fintek,   {0x2e,  0x4e,   EOT}},