All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 00/32] Initial sparse fix series
@ 2012-10-17  0:28 Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 01/32] include/linux/byteorder: import latest endian definitions from linux Kim Phillips
                   ` (35 more replies)
  0 siblings, 36 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

This 32-patch series only begins to address making u-boot source more
'sparseable,' or sparse-clean, ultimately to catch type, address space,
and endianness mismatches and generally improve code quality. E.g., in this
initial dose whose main purpose is to reduce the output volume to workable
levels, a couple of endianness bugs are found and fixed in
of_bus_default_translate() and fdt_get_base_address().  See [PATCH 14/32]
common/fdt_support.c: sparse fixes.

Patch 1 adds endianness attributes to byteorder.h helpers, e.g.,
cpu_to_be32().  This is required for correct operation and
prevents sparse from emitting false-positives.

Patches 2-6 fix issues where u-boot had imported linux header code
and the importer simply force-#defined sparse-specific attributes to
nothing, to allow u-boot to build.

Patches 7-10 are general sparse fixes to common header areas.

Patch 11 is too, which also changes the long-standing u-boot image header
types to __be32, as per u-boot image definition.

Patches 12-14 address further misc. sparse issues in common/.

Patches 15-16 do the same for the net subsystem.

Patches 17-18 do the same for lib/.

Patch 19 for include/fdt.h.

Patches 20-23 for Power Arch's mpc8xxx, 83xx, and 85xx subsystems.

Last but not least, patches 24-32 attempt to clean up various drivers.

Note that there are two libfdt dependencies:

1. commits aa28b89b "libfdt: Add helpers for 64-bit integer properties" and
commit 786ed04 "libfdt: Add support for appending the values to a existing
property", currently sitting in u-boot-fdt/next.  This series is based
on today's mainline u-boot/next with those two patches pre-applied.
    
2. potential upstream dtc change dependencies, due to having to attribute base
device tree header types to __be32 in include/libfdt.  See patch 19/32
"include/fdt.h: sparse fixes".  It is unknown whether such changes would
be welcome to dtc (but there's a way to find out :).

For authors of new patches not willing to sift through the still quite
large sparse output for their board/platform, though interested in what
sparse has to say about their new code, it is recommended to build
with make C=1 after changes such that sparse output will only include
newly built code.

For your convenience, I've pushed the series onto the u-boot-mpc83xx
tree, 'sparsefixes' branch [1].  The branch includes libfdt dependency
#1 mentioned above.

Build-tested in both endians :).  Please help test.

Thanks,

Kim

[1] see http://git.denx.de/u-boot.git/?p=u-boot/u-boot-mpc83xx.git;a=shortlog;h=refs/heads/sparsefixes

Kim Phillips (32):
  include/linux/byteorder: import latest endian definitions from linux
  include/linux/compat.h: fix warning: preprocessor token __iomem
    redefined
  include/linux/unaligned/generic.h: fix warning: preprocessor token
    __force redefined
  include/linux/stddef.h: avoid 'warning: preprocessor token offsetof
    redefined'
  arch/powerpc/include/asm/io.h: fix warning: preprocessor token
    __iomem redefined
  arch/powerpc/lib/bootm.c: fix noinline attribute
  arch/powerpc/lib/extable.c: sparse fix
  arch/powerpc/lib/board.c,*traps.c: sparse fixes
  include/common.h: sparse fix
  include/command.h: sparse fix
  include/image.h: sparse fixes
  common/cmd_*.c: sparse fixes
  common/misc: sparse fixes
  common/fdt_support.c: sparse fixes
  net/: sparse fixes
  drivers/net/: sparse fixes
  lib/zlib: sparse fixes
  lib/vsprintf.c: sparse fixes
  include/fdt.h: sparse fixes
  arch/powerpc/cpu/mpc8xxx/: sparse fixes
  arch/powerpc/cpu/mpc85xx/fdt.c: sparse fixes
  powerpc/mpc85xx: sparse fixes
  powerpc/mpc83xx: sparse fixes
  drivers/block/: sparse fixes
  drivers/gpio/mpc83xx_gpio.c: sparse fixes
  drivers/input/input.c: sparse fix
  drivers/i2c/fsl_i2c.c: sparse fix
  drivers/mmc/mmc.c: sparse fixes
  drivers/mmc/fsl_esdhc.c: sparse fixes
  drivers/mtd/cfi_flash.c: sparse fixes
  drivers/mtd/nand: sparse fixes
  drivers/serial/serial_ns16550.c: sparse fixes

 arch/powerpc/cpu/74xx_7xx/traps.c                  |   6 +-
 arch/powerpc/cpu/mpc512x/traps.c                   |   6 +-
 arch/powerpc/cpu/mpc5xx/traps.c                    |   6 +-
 arch/powerpc/cpu/mpc5xxx/traps.c                   |   6 +-
 arch/powerpc/cpu/mpc8220/traps.c                   |   6 +-
 arch/powerpc/cpu/mpc824x/traps.c                   |   6 +-
 arch/powerpc/cpu/mpc8260/traps.c                   |   6 +-
 arch/powerpc/cpu/mpc83xx/fdt.c                     |   4 +-
 arch/powerpc/cpu/mpc83xx/speed.c                   |   4 +-
 arch/powerpc/cpu/mpc83xx/traps.c                   |   6 +-
 arch/powerpc/cpu/mpc85xx/cpu_init.c                |   2 +-
 arch/powerpc/cpu/mpc85xx/fdt.c                     |  57 +++++----
 arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c      |   2 +-
 arch/powerpc/cpu/mpc85xx/traps.c                   |   6 +-
 arch/powerpc/cpu/mpc86xx/traps.c                   |   6 +-
 arch/powerpc/cpu/mpc8xx/traps.c                    |   6 +-
 arch/powerpc/cpu/mpc8xxx/cpu.c                     |   8 +-
 arch/powerpc/cpu/mpc8xxx/ddr/ctrl_regs.c           |   2 +-
 .../cpu/mpc8xxx/ddr/lc_common_dimm_params.c        |   4 +-
 arch/powerpc/cpu/mpc8xxx/fdt.c                     |   3 +-
 arch/powerpc/cpu/mpc8xxx/fsl_lbc.c                 |   2 +-
 arch/powerpc/cpu/ppc4xx/traps.c                    |   6 +-
 arch/powerpc/include/asm/io.h                      |   1 -
 arch/powerpc/lib/board.c                           |  12 +-
 arch/powerpc/lib/bootm.c                           |   2 +-
 arch/powerpc/lib/extable.c                         |   2 +-
 board/freescale/common/ngpixis.c                   |  10 +-
 board/freescale/mpc8313erdb/mpc8313erdb.c          |  24 ++--
 board/freescale/mpc8568mds/bcsr.c                  |   8 +-
 board/freescale/mpc8569mds/bcsr.c                  |   8 +-
 common/cmd_boot.c                                  |   5 +-
 common/cmd_bootm.c                                 |  27 +++--
 common/cmd_console.c                               |   2 +-
 common/cmd_date.c                                  |   2 +-
 common/cmd_echo.c                                  |   2 +-
 common/cmd_exit.c                                  |   2 +-
 common/cmd_fat.c                                   |   5 +-
 common/cmd_fdt.c                                   |  19 +--
 common/cmd_flash.c                                 |   6 +-
 common/cmd_help.c                                  |   2 +-
 common/cmd_i2c.c                                   |  18 +--
 common/cmd_irq.c                                   |   2 +-
 common/cmd_itest.c                                 |   4 +-
 common/cmd_load.c                                  |  44 +++----
 common/cmd_mdio.c                                  |  20 +--
 common/cmd_mem.c                                   |  25 ++--
 common/cmd_misc.c                                  |   2 +-
 common/cmd_mmc.c                                   |   6 +-
 common/cmd_mp.c                                    |  20 ++-
 common/cmd_mtdparts.c                              |  28 +++--
 common/cmd_nand.c                                  |  17 +--
 common/cmd_net.c                                   |   8 +-
 common/cmd_nvedit.c                                |  23 ++--
 common/cmd_pci.c                                   |  15 ++-
 common/cmd_reginfo.c                               |   3 +-
 common/cmd_sata.c                                  |   4 +-
 common/cmd_setexpr.c                               |   2 +-
 common/cmd_source.c                                |  11 +-
 common/cmd_test.c                                  |   6 +-
 common/cmd_usb.c                                   |  30 ++---
 common/cmd_version.c                               |   2 +-
 common/cmd_ximg.c                                  |  11 +-
 common/command.c                                   |   9 +-
 common/console.c                                   |   2 +-
 common/dlmalloc.c                                  |  36 +++---
 common/fdt_support.c                               |  78 ++++++------
 common/hush.c                                      |  30 ++---
 common/image.c                                     |   8 +-
 common/main.c                                      |   6 +-
 common/update.c                                    |   1 +
 common/usb_storage.c                               |  20 +--
 common/xyzModem.c                                  |   6 +-
 drivers/block/fsl_sata.c                           |  79 ++----------
 drivers/block/fsl_sata.h                           |  12 +-
 drivers/block/sata_sil.c                           |  13 +-
 drivers/gpio/mpc83xx_gpio.c                        |   4 +-
 drivers/i2c/fsl_i2c.c                              |   2 +-
 drivers/input/input.c                              |   2 +-
 drivers/mmc/fsl_esdhc.c                            |   4 +-
 drivers/mmc/mmc.c                                  |  37 +++---
 drivers/mtd/cfi_flash.c                            |  20 +--
 drivers/mtd/nand/nand_base.c                       |   9 +-
 drivers/mtd/nand/nand_ecc.c                        |   1 +
 drivers/net/fm/eth.c                               |   2 +-
 drivers/net/fm/p1023.c                             |   2 +-
 drivers/net/fm/p4080.c                             |   2 +-
 drivers/net/fm/p5020.c                             |   2 +-
 drivers/net/fm/tgec_phy.c                          |  10 +-
 drivers/net/phy/atheros.c                          |   2 +-
 drivers/net/phy/phy.c                              |  19 +--
 drivers/net/phy/vitesse.c                          |   2 +-
 drivers/net/vsc7385.c                              |   1 +
 drivers/qe/qe.h                                    |  34 +++---
 drivers/serial/serial_ns16550.c                    |  12 +-
 include/command.h                                  |   2 +-
 include/common.h                                   |   4 -
 include/fdt.h                                      |  33 ++---
 include/fdt_support.h                              |   4 +-
 include/image.h                                    |  15 +--
 include/libfdt.h                                   |   4 +-
 include/linux/byteorder/big_endian.h               | 135 ++++++++++++++-------
 include/linux/byteorder/little_endian.h            | 133 +++++++++++++-------
 include/linux/byteorder/swab.h                     |   6 +-
 include/linux/compat.h                             |   3 -
 include/linux/stddef.h                             |   2 +
 include/linux/unaligned/generic.h                  |   3 -
 include/net.h                                      |   9 +-
 include/u-boot/zlib.h                              |   2 +-
 lib/libfdt/fdt.c                                   |   2 +-
 lib/libfdt/fdt_ro.c                                |   2 +-
 lib/libfdt/fdt_rw.c                                |   4 +-
 lib/libfdt/fdt_sw.c                                |   4 +-
 lib/libfdt/fdt_wip.c                               |   2 +-
 lib/vsprintf.c                                     |   4 +-
 lib/zlib/adler32.c                                 |   5 +-
 lib/zlib/inffast.c                                 |   5 +-
 lib/zlib/inflate.c                                 |  29 ++---
 lib/zlib/inftrees.c                                |  10 +-
 lib/zlib/zutil.c                                   |  10 +-
 net/arp.c                                          |   6 +-
 net/bootp.c                                        |   6 +-
 net/net.c                                          |   2 +-
 net/ping.h                                         |   3 -
 net/tftp.h                                         |   3 +
 124 files changed, 789 insertions(+), 730 deletions(-)

-- 
1.7.12.3

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 01/32] include/linux/byteorder: import latest endian definitions from linux
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-25 17:37   ` Tom Rini
  2012-10-17  0:28 ` [U-Boot] [PATCH 02/32] include/linux/compat.h: fix warning: preprocessor token __iomem redefined Kim Phillips
                   ` (34 subsequent siblings)
  35 siblings, 1 reply; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

u-boot's byteorder headers did not contain endianness attributions
for use with sparse, causing a lot of false positives.  Import the
kernel's latest definitions, and enable them by including compiler.h
and types.h.  They come with 'const' added for some swab functions, so
fix those up, too:

include/linux/byteorder/big_endian.h:46:2: warning: passing argument 1 of '__swab64p' discards 'const' qualifier from pointer target type [enabled by default]

Also, note: u-boot's historic __BYTE_ORDER definition has been
preserved (for the time being at least).

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 include/linux/byteorder/big_endian.h    | 135 +++++++++++++++++++++-----------
 include/linux/byteorder/little_endian.h | 133 ++++++++++++++++++++-----------
 include/linux/byteorder/swab.h          |   6 +-
 3 files changed, 178 insertions(+), 96 deletions(-)

diff --git a/include/linux/byteorder/big_endian.h b/include/linux/byteorder/big_endian.h
index 19b0c86..aaf7757 100644
--- a/include/linux/byteorder/big_endian.h
+++ b/include/linux/byteorder/big_endian.h
@@ -7,63 +7,104 @@
 #ifndef __BIG_ENDIAN_BITFIELD
 #define __BIG_ENDIAN_BITFIELD
 #endif
-#define	__BYTE_ORDER	__BIG_ENDIAN
+#define __BYTE_ORDER	__BIG_ENDIAN
 
+#include <linux/compiler.h>
+#include <linux/types.h>
 #include <linux/byteorder/swab.h>
 
-#define __constant_htonl(x) ((__u32)(x))
-#define __constant_ntohl(x) ((__u32)(x))
-#define __constant_htons(x) ((__u16)(x))
-#define __constant_ntohs(x) ((__u16)(x))
-#define __constant_cpu_to_le64(x) ___swab64((x))
-#define __constant_le64_to_cpu(x) ___swab64((x))
-#define __constant_cpu_to_le32(x) ___swab32((x))
-#define __constant_le32_to_cpu(x) ___swab32((x))
-#define __constant_cpu_to_le16(x) ___swab16((x))
-#define __constant_le16_to_cpu(x) ___swab16((x))
-#define __constant_cpu_to_be64(x) ((__u64)(x))
-#define __constant_be64_to_cpu(x) ((__u64)(x))
-#define __constant_cpu_to_be32(x) ((__u32)(x))
-#define __constant_be32_to_cpu(x) ((__u32)(x))
-#define __constant_cpu_to_be16(x) ((__u16)(x))
-#define __constant_be16_to_cpu(x) ((__u16)(x))
-#define __cpu_to_le64(x) __swab64((x))
-#define __le64_to_cpu(x) __swab64((x))
-#define __cpu_to_le32(x) __swab32((x))
-#define __le32_to_cpu(x) __swab32((x))
-#define __cpu_to_le16(x) __swab16((x))
-#define __le16_to_cpu(x) __swab16((x))
-#define __cpu_to_be64(x) ((__u64)(x))
-#define __be64_to_cpu(x) ((__u64)(x))
-#define __cpu_to_be32(x) ((__u32)(x))
-#define __be32_to_cpu(x) ((__u32)(x))
-#define __cpu_to_be16(x) ((__u16)(x))
-#define __be16_to_cpu(x) ((__u16)(x))
-#define __cpu_to_le64p(x) __swab64p((x))
-#define __le64_to_cpup(x) __swab64p((x))
-#define __cpu_to_le32p(x) __swab32p((x))
-#define __le32_to_cpup(x) __swab32p((x))
-#define __cpu_to_le16p(x) __swab16p((x))
-#define __le16_to_cpup(x) __swab16p((x))
-#define __cpu_to_be64p(x) (*(__u64*)(x))
-#define __be64_to_cpup(x) (*(__u64*)(x))
-#define __cpu_to_be32p(x) (*(__u32*)(x))
-#define __be32_to_cpup(x) (*(__u32*)(x))
-#define __cpu_to_be16p(x) (*(__u16*)(x))
-#define __be16_to_cpup(x) (*(__u16*)(x))
+#define __constant_htonl(x) ((__force __be32)(__u32)(x))
+#define __constant_ntohl(x) ((__force __u32)(__be32)(x))
+#define __constant_htons(x) ((__force __be16)(__u16)(x))
+#define __constant_ntohs(x) ((__force __u16)(__be16)(x))
+#define __constant_cpu_to_le64(x) ((__force __le64)___constant_swab64((x)))
+#define __constant_le64_to_cpu(x) ___constant_swab64((__force __u64)(__le64)(x))
+#define __constant_cpu_to_le32(x) ((__force __le32)___constant_swab32((x)))
+#define __constant_le32_to_cpu(x) ___constant_swab32((__force __u32)(__le32)(x))
+#define __constant_cpu_to_le16(x) ((__force __le16)___constant_swab16((x)))
+#define __constant_le16_to_cpu(x) ___constant_swab16((__force __u16)(__le16)(x))
+#define __constant_cpu_to_be64(x) ((__force __be64)(__u64)(x))
+#define __constant_be64_to_cpu(x) ((__force __u64)(__be64)(x))
+#define __constant_cpu_to_be32(x) ((__force __be32)(__u32)(x))
+#define __constant_be32_to_cpu(x) ((__force __u32)(__be32)(x))
+#define __constant_cpu_to_be16(x) ((__force __be16)(__u16)(x))
+#define __constant_be16_to_cpu(x) ((__force __u16)(__be16)(x))
+#define __cpu_to_le64(x) ((__force __le64)__swab64((x)))
+#define __le64_to_cpu(x) __swab64((__force __u64)(__le64)(x))
+#define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
+#define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
+#define __cpu_to_le16(x) ((__force __le16)__swab16((x)))
+#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
+#define __cpu_to_be64(x) ((__force __be64)(__u64)(x))
+#define __be64_to_cpu(x) ((__force __u64)(__be64)(x))
+#define __cpu_to_be32(x) ((__force __be32)(__u32)(x))
+#define __be32_to_cpu(x) ((__force __u32)(__be32)(x))
+#define __cpu_to_be16(x) ((__force __be16)(__u16)(x))
+#define __be16_to_cpu(x) ((__force __u16)(__be16)(x))
+
+static inline __le64 __cpu_to_le64p(const __u64 *p)
+{
+	return (__force __le64)__swab64p(p);
+}
+static inline __u64 __le64_to_cpup(const __le64 *p)
+{
+	return __swab64p((__u64 *)p);
+}
+static inline __le32 __cpu_to_le32p(const __u32 *p)
+{
+	return (__force __le32)__swab32p(p);
+}
+static inline __u32 __le32_to_cpup(const __le32 *p)
+{
+	return __swab32p((__u32 *)p);
+}
+static inline __le16 __cpu_to_le16p(const __u16 *p)
+{
+	return (__force __le16)__swab16p(p);
+}
+static inline __u16 __le16_to_cpup(const __le16 *p)
+{
+	return __swab16p((__u16 *)p);
+}
+static inline __be64 __cpu_to_be64p(const __u64 *p)
+{
+	return (__force __be64)*p;
+}
+static inline __u64 __be64_to_cpup(const __be64 *p)
+{
+	return (__force __u64)*p;
+}
+static inline __be32 __cpu_to_be32p(const __u32 *p)
+{
+	return (__force __be32)*p;
+}
+static inline __u32 __be32_to_cpup(const __be32 *p)
+{
+	return (__force __u32)*p;
+}
+static inline __be16 __cpu_to_be16p(const __u16 *p)
+{
+	return (__force __be16)*p;
+}
+static inline __u16 __be16_to_cpup(const __be16 *p)
+{
+	return (__force __u16)*p;
+}
 #define __cpu_to_le64s(x) __swab64s((x))
 #define __le64_to_cpus(x) __swab64s((x))
 #define __cpu_to_le32s(x) __swab32s((x))
 #define __le32_to_cpus(x) __swab32s((x))
 #define __cpu_to_le16s(x) __swab16s((x))
 #define __le16_to_cpus(x) __swab16s((x))
-#define __cpu_to_be64s(x) do {} while (0)
-#define __be64_to_cpus(x) do {} while (0)
-#define __cpu_to_be32s(x) do {} while (0)
-#define __be32_to_cpus(x) do {} while (0)
-#define __cpu_to_be16s(x) do {} while (0)
-#define __be16_to_cpus(x) do {} while (0)
+#define __cpu_to_be64s(x) do { (void)(x); } while (0)
+#define __be64_to_cpus(x) do { (void)(x); } while (0)
+#define __cpu_to_be32s(x) do { (void)(x); } while (0)
+#define __be32_to_cpus(x) do { (void)(x); } while (0)
+#define __cpu_to_be16s(x) do { (void)(x); } while (0)
+#define __be16_to_cpus(x) do { (void)(x); } while (0)
 
+#ifdef __KERNEL__
 #include <linux/byteorder/generic.h>
+#endif
 
 #endif /* _LINUX_BYTEORDER_BIG_ENDIAN_H */
diff --git a/include/linux/byteorder/little_endian.h b/include/linux/byteorder/little_endian.h
index a46f3ec..a4cb3bf 100644
--- a/include/linux/byteorder/little_endian.h
+++ b/include/linux/byteorder/little_endian.h
@@ -9,54 +9,93 @@
 #endif
 #define	__BYTE_ORDER	__LITTLE_ENDIAN
 
+#include <linux/compiler.h>
+#include <linux/types.h>
 #include <linux/byteorder/swab.h>
 
-#define __constant_htonl(x) ___constant_swab32((x))
-#define __constant_ntohl(x) ___constant_swab32((x))
-#define __constant_htons(x) ___constant_swab16((x))
-#define __constant_ntohs(x) ___constant_swab16((x))
-#define __constant_cpu_to_le64(x) ((__u64)(x))
-#define __constant_le64_to_cpu(x) ((__u64)(x))
-#define __constant_cpu_to_le32(x) ((__u32)(x))
-#define __constant_le32_to_cpu(x) ((__u32)(x))
-#define __constant_cpu_to_le16(x) ((__u16)(x))
-#define __constant_le16_to_cpu(x) ((__u16)(x))
-#define __constant_cpu_to_be64(x) ___constant_swab64((x))
-#define __constant_be64_to_cpu(x) ___constant_swab64((x))
-#define __constant_cpu_to_be32(x) ___constant_swab32((x))
-#define __constant_be32_to_cpu(x) ___constant_swab32((x))
-#define __constant_cpu_to_be16(x) ___constant_swab16((x))
-#define __constant_be16_to_cpu(x) ___constant_swab16((x))
-#define __cpu_to_le64(x) ((__u64)(x))
-#define __le64_to_cpu(x) ((__u64)(x))
-#define __cpu_to_le32(x) ((__u32)(x))
-#define __le32_to_cpu(x) ((__u32)(x))
-#define __cpu_to_le16(x) ((__u16)(x))
-#define __le16_to_cpu(x) ((__u16)(x))
-#define __cpu_to_be64(x) __swab64((x))
-#define __be64_to_cpu(x) __swab64((x))
-#define __cpu_to_be32(x) __swab32((x))
-#define __be32_to_cpu(x) __swab32((x))
-#define __cpu_to_be16(x) __swab16((x))
-#define __be16_to_cpu(x) __swab16((x))
-#define __cpu_to_le64p(x) (*(__u64*)(x))
-#define __le64_to_cpup(x) (*(__u64*)(x))
-#define __cpu_to_le32p(x) (*(__u32*)(x))
-#define __le32_to_cpup(x) (*(__u32*)(x))
-#define __cpu_to_le16p(x) (*(__u16*)(x))
-#define __le16_to_cpup(x) (*(__u16*)(x))
-#define __cpu_to_be64p(x) __swab64p((x))
-#define __be64_to_cpup(x) __swab64p((x))
-#define __cpu_to_be32p(x) __swab32p((x))
-#define __be32_to_cpup(x) __swab32p((x))
-#define __cpu_to_be16p(x) __swab16p((x))
-#define __be16_to_cpup(x) __swab16p((x))
-#define __cpu_to_le64s(x) do {} while (0)
-#define __le64_to_cpus(x) do {} while (0)
-#define __cpu_to_le32s(x) do {} while (0)
-#define __le32_to_cpus(x) do {} while (0)
-#define __cpu_to_le16s(x) do {} while (0)
-#define __le16_to_cpus(x) do {} while (0)
+#define __constant_htonl(x) ((__force __be32)___constant_swab32((x)))
+#define __constant_ntohl(x) ___constant_swab32((__force __be32)(x))
+#define __constant_htons(x) ((__force __be16)___constant_swab16((x)))
+#define __constant_ntohs(x) ___constant_swab16((__force __be16)(x))
+#define __constant_cpu_to_le64(x) ((__force __le64)(__u64)(x))
+#define __constant_le64_to_cpu(x) ((__force __u64)(__le64)(x))
+#define __constant_cpu_to_le32(x) ((__force __le32)(__u32)(x))
+#define __constant_le32_to_cpu(x) ((__force __u32)(__le32)(x))
+#define __constant_cpu_to_le16(x) ((__force __le16)(__u16)(x))
+#define __constant_le16_to_cpu(x) ((__force __u16)(__le16)(x))
+#define __constant_cpu_to_be64(x) ((__force __be64)___constant_swab64((x)))
+#define __constant_be64_to_cpu(x) ___constant_swab64((__force __u64)(__be64)(x))
+#define __constant_cpu_to_be32(x) ((__force __be32)___constant_swab32((x)))
+#define __constant_be32_to_cpu(x) ___constant_swab32((__force __u32)(__be32)(x))
+#define __constant_cpu_to_be16(x) ((__force __be16)___constant_swab16((x)))
+#define __constant_be16_to_cpu(x) ___constant_swab16((__force __u16)(__be16)(x))
+#define __cpu_to_le64(x) ((__force __le64)(__u64)(x))
+#define __le64_to_cpu(x) ((__force __u64)(__le64)(x))
+#define __cpu_to_le32(x) ((__force __le32)(__u32)(x))
+#define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
+#define __cpu_to_le16(x) ((__force __le16)(__u16)(x))
+#define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
+#define __cpu_to_be64(x) ((__force __be64)__swab64((x)))
+#define __be64_to_cpu(x) __swab64((__force __u64)(__be64)(x))
+#define __cpu_to_be32(x) ((__force __be32)__swab32((x)))
+#define __be32_to_cpu(x) __swab32((__force __u32)(__be32)(x))
+#define __cpu_to_be16(x) ((__force __be16)__swab16((x)))
+#define __be16_to_cpu(x) __swab16((__force __u16)(__be16)(x))
+
+static inline __le64 __cpu_to_le64p(const __u64 *p)
+{
+	return (__force __le64)*p;
+}
+static inline __u64 __le64_to_cpup(const __le64 *p)
+{
+	return (__force __u64)*p;
+}
+static inline __le32 __cpu_to_le32p(const __u32 *p)
+{
+	return (__force __le32)*p;
+}
+static inline __u32 __le32_to_cpup(const __le32 *p)
+{
+	return (__force __u32)*p;
+}
+static inline __le16 __cpu_to_le16p(const __u16 *p)
+{
+	return (__force __le16)*p;
+}
+static inline __u16 __le16_to_cpup(const __le16 *p)
+{
+	return (__force __u16)*p;
+}
+static inline __be64 __cpu_to_be64p(const __u64 *p)
+{
+	return (__force __be64)__swab64p(p);
+}
+static inline __u64 __be64_to_cpup(const __be64 *p)
+{
+	return __swab64p((__u64 *)p);
+}
+static inline __be32 __cpu_to_be32p(const __u32 *p)
+{
+	return (__force __be32)__swab32p(p);
+}
+static inline __u32 __be32_to_cpup(const __be32 *p)
+{
+	return __swab32p((__u32 *)p);
+}
+static inline __be16 __cpu_to_be16p(const __u16 *p)
+{
+	return (__force __be16)__swab16p(p);
+}
+static inline __u16 __be16_to_cpup(const __be16 *p)
+{
+	return __swab16p((__u16 *)p);
+}
+#define __cpu_to_le64s(x) do { (void)(x); } while (0)
+#define __le64_to_cpus(x) do { (void)(x); } while (0)
+#define __cpu_to_le32s(x) do { (void)(x); } while (0)
+#define __le32_to_cpus(x) do { (void)(x); } while (0)
+#define __cpu_to_le16s(x) do { (void)(x); } while (0)
+#define __le16_to_cpus(x) do { (void)(x); } while (0)
 #define __cpu_to_be64s(x) __swab64s((x))
 #define __be64_to_cpus(x) __swab64s((x))
 #define __cpu_to_be32s(x) __swab32s((x))
@@ -64,6 +103,8 @@
 #define __cpu_to_be16s(x) __swab16s((x))
 #define __be16_to_cpus(x) __swab16s((x))
 
+#ifdef __KERNEL__
 #include <linux/byteorder/generic.h>
+#endif
 
 #endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */
diff --git a/include/linux/byteorder/swab.h b/include/linux/byteorder/swab.h
index b1d570e..bb4a046 100644
--- a/include/linux/byteorder/swab.h
+++ b/include/linux/byteorder/swab.h
@@ -100,7 +100,7 @@ static __inline__ __attribute__((const)) __u16 __fswab16(__u16 x)
 {
 	return __arch__swab16(x);
 }
-static __inline__ __u16 __swab16p(__u16 *x)
+static __inline__ __u16 __swab16p(const __u16 *x)
 {
 	return __arch__swab16p(x);
 }
@@ -113,7 +113,7 @@ static __inline__ __attribute__((const)) __u32 __fswab32(__u32 x)
 {
 	return __arch__swab32(x);
 }
-static __inline__ __u32 __swab32p(__u32 *x)
+static __inline__ __u32 __swab32p(const __u32 *x)
 {
 	return __arch__swab32p(x);
 }
@@ -133,7 +133,7 @@ static __inline__ __attribute__((const)) __u64 __fswab64(__u64 x)
 	return __arch__swab64(x);
 #  endif
 }
-static __inline__ __u64 __swab64p(__u64 *x)
+static __inline__ __u64 __swab64p(const __u64 *x)
 {
 	return __arch__swab64p(x);
 }
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 02/32] include/linux/compat.h: fix warning: preprocessor token __iomem redefined
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 01/32] include/linux/byteorder: import latest endian definitions from linux Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-24 21:31   ` Tom Rini
  2012-10-17  0:28 ` [U-Boot] [PATCH 03/32] include/linux/unaligned/generic.h: fix warning: preprocessor token __force redefined Kim Phillips
                   ` (33 subsequent siblings)
  35 siblings, 1 reply; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

include/linux/compat.h:4:9: warning: preprocessor token __user redefined
include/linux/compiler.h:7:10: this was the original definition
include/linux/compat.h:5:9: warning: preprocessor token __iomem redefined
include/linux/compiler.h:12:10: this was the original definition

fixup __iomem, __user definitions in compat.h code appears to be placed
there as a cover up from a code import from linux when u-boot didn't yet
have a compiler.h, introduced by commit
932394ac43e2e778e664eeb6e456fecd0fae6e59 "Rewrite of NAND code based on
what is in 2.6.12 Linux kernel".

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 include/linux/compat.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/linux/compat.h b/include/linux/compat.h
index 593b07f..e1338bf 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -1,9 +1,6 @@
 #ifndef _LINUX_COMPAT_H_
 #define _LINUX_COMPAT_H_
 
-#define __user
-#define __iomem
-
 #define ndelay(x)	udelay(1)
 
 #define printk	printf
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 03/32] include/linux/unaligned/generic.h: fix warning: preprocessor token __force redefined
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 01/32] include/linux/byteorder: import latest endian definitions from linux Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 02/32] include/linux/compat.h: fix warning: preprocessor token __iomem redefined Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 04/32] include/linux/stddef.h: avoid 'warning: preprocessor token offsetof redefined' Kim Phillips
                   ` (32 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

include/linux/unaligned/generic.h:5:9: warning: preprocessor token __force redefined
include/linux/compiler.h:10:10: this was the original definition

fixup __force definitions in compat.h code appears to be placed
there as a cover up from a code import from linux when u-boot didn't yet
have a compiler.h, introduced by commit
b1b4e89a0f3b75854c39a62cae41bad56d210adf "Add LZO decompressor support".

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 include/linux/unaligned/generic.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/linux/unaligned/generic.h b/include/linux/unaligned/generic.h
index cc688e1..02d97ff 100644
--- a/include/linux/unaligned/generic.h
+++ b/include/linux/unaligned/generic.h
@@ -1,9 +1,6 @@
 #ifndef _LINUX_UNALIGNED_GENERIC_H
 #define _LINUX_UNALIGNED_GENERIC_H
 
-/* define __force to nothing in U-Boot */
-#define __force
-
 /*
  * Cause a link-time error if we try an unaligned access other than
  * 1,2,4 or 8 bytes long
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 04/32] include/linux/stddef.h: avoid 'warning: preprocessor token offsetof redefined'
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (2 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 03/32] include/linux/unaligned/generic.h: fix warning: preprocessor token __force redefined Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 05/32] arch/powerpc/include/asm/io.h: fix warning: preprocessor token __iomem redefined Kim Phillips
                   ` (31 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

hack to avoid:

/opt/gcc-4.6.3-nolibc/powerpc-linux/bin/../lib/gcc/powerpc-linux/4.6.3/include/stddef.h:413:9: warning: preprocessor token offsetof redefined
u-boot/include/linux/stddef.h:20:9: this was the original definition

tried protecting with __KERNEL__, and #including compiler.h first.

Even tried include dir reordering to no avail:

 +++ b/config.mk
 @@ -194,7 +194,11 @@ OBJCFLAGS += --gap-fill=0xff
 gccincdir := $(shell $(CC) -print-file-name=include)

 CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)                \
 -       -D__KERNEL__
 +       -D__KERNEL__  \
 +       -I $(gccincdir) \
 +       -nostdinc
 +
 +#      -isystem $(gccincdir) \

 # Enable garbage collection of un-used sections for SPL
 ifeq ($(CONFIG_SPL_BUILD),y)
 @@ -227,8 +231,7 @@ CPPFLAGS += -I$(OBJTREE)/include2 -I$(OBJTREE)/include
 endif

 CPPFLAGS += -I$(TOPDIR)/include
 -CPPFLAGS += -fno-builtin -ffreestanding -nostdinc      \
 -       -isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
 +CPPFLAGS += -fno-builtin -ffreestanding -pipe $(PLATFORM_CPPFLAGS)

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 include/linux/stddef.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/stddef.h b/include/linux/stddef.h
index 81e34c2..c540f61 100644
--- a/include/linux/stddef.h
+++ b/include/linux/stddef.h
@@ -12,7 +12,9 @@
 #include <linux/types.h>
 #endif
 
+#ifndef __CHECKER__
 #undef offsetof
 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
 
 #endif
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 05/32] arch/powerpc/include/asm/io.h: fix warning: preprocessor token __iomem redefined
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (3 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 04/32] include/linux/stddef.h: avoid 'warning: preprocessor token offsetof redefined' Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 06/32] arch/powerpc/lib/bootm.c: fix noinline attribute Kim Phillips
                   ` (30 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

a fixup __iomem definition in arch code appears to be placed there as a cover
up from a code import from linux when u-boot didn't yet have a compiler.h,
introduced by commit 812711ce6b3a386125dcf0d6a59588e461abbb87 "Implement
__raw_{read,write}[bwl] on all architectures".

git show 812711ce6b3a386125dcf0d6a59588e461abbb87:include/linux/compiler.h
fatal: Path 'include/linux/compiler.h' exists on disk, but not in '812711ce6b3a386125dcf0d6a59588e461abbb87'.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 arch/powerpc/include/asm/io.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index 9e20861..1f12c29 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -127,7 +127,6 @@ static inline void isync(void)
 /*
  * Non ordered and non-swapping "raw" accessors
  */
-#define __iomem
 #define PCI_FIX_ADDR(addr)	(addr)
 
 static inline unsigned char __raw_readb(const volatile void __iomem *addr)
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 06/32] arch/powerpc/lib/bootm.c: fix noinline attribute
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (4 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 05/32] arch/powerpc/include/asm/io.h: fix warning: preprocessor token __iomem redefined Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 07/32] arch/powerpc/lib/extable.c: sparse fix Kim Phillips
                   ` (29 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

including compiler.h in byteorder changes the 'noinline' definition to expand to
__attribute__((noinline)).  This fixes:

bootm.c:329:16: error: attribute '__attribute__': unknown attribute
bootm.c:329:16: error: expected ')' before '__attribute__'
bootm.c:329:25: error: expected identifier or '(' before ')' token

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 arch/powerpc/lib/bootm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/lib/bootm.c b/arch/powerpc/lib/bootm.c
index 53dc4df..ac5bd6d 100644
--- a/arch/powerpc/lib/bootm.c
+++ b/arch/powerpc/lib/bootm.c
@@ -326,7 +326,7 @@ static int boot_body_linux(bootm_headers_t *images)
 	return 0;
 }
 
-__attribute__((noinline))
+noinline
 int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images)
 {
 	int	ret;
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 07/32] arch/powerpc/lib/extable.c: sparse fix
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (5 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 06/32] arch/powerpc/lib/bootm.c: fix noinline attribute Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 08/32] arch/powerpc/lib/board.c, *traps.c: sparse fixes Kim Phillips
                   ` (28 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

extable.c:66:9: warning: symbol 'ex_tab_message' was not declared. Should it be static?

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 arch/powerpc/lib/extable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/lib/extable.c b/arch/powerpc/lib/extable.c
index 7408d5c..7e74a5d 100644
--- a/arch/powerpc/lib/extable.c
+++ b/arch/powerpc/lib/extable.c
@@ -63,7 +63,7 @@ search_one_table(const struct exception_table_entry *first,
 	return 0;
 }
 
-int	ex_tab_message = 1;
+static int ex_tab_message = 1;
 
 unsigned long
 search_exception_table(unsigned long addr)
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 08/32] arch/powerpc/lib/board.c, *traps.c: sparse fixes
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (6 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 07/32] arch/powerpc/lib/extable.c: sparse fix Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-18 16:55   ` Tom Rini
  2012-10-17  0:28 ` [U-Boot] [PATCH 09/32] include/common.h: sparse fix Kim Phillips
                   ` (27 subsequent siblings)
  35 siblings, 1 reply; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

traps.c:*:1: warning: symbol 'print_backtrace' was not declared. Should it be static?
traps.c:66:6: warning: symbol 'show_regs' was not declared. Should it be static?
traps.c:93:1: warning: symbol '_exception' was not declared. Should it be static?
board.c:166:6: warning: symbol '__board_add_ram_info' was not declared. Should it be static?
board.c:174:5: warning: symbol '__board_flash_wp_on' was not declared. Should it be static?
board.c:187:6: warning: symbol '__cpu_secondary_init_r' was not declared. Should it be static?
board.c:265:12: warning: symbol 'init_sequence' was not declared. Should it be static?
board.c:348:5: warning: symbol '__fixup_cpu' was not declared. Should it be static?
board.c:405:53: warning: Using plain integer as NULL pointer

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 arch/powerpc/cpu/74xx_7xx/traps.c |  6 +++---
 arch/powerpc/cpu/mpc512x/traps.c  |  6 +++---
 arch/powerpc/cpu/mpc5xx/traps.c   |  6 +++---
 arch/powerpc/cpu/mpc5xxx/traps.c  |  6 +++---
 arch/powerpc/cpu/mpc8220/traps.c  |  6 +++---
 arch/powerpc/cpu/mpc824x/traps.c  |  6 +++---
 arch/powerpc/cpu/mpc8260/traps.c  |  6 +++---
 arch/powerpc/cpu/mpc83xx/traps.c  |  6 +++---
 arch/powerpc/cpu/mpc85xx/traps.c  |  6 +++---
 arch/powerpc/cpu/mpc86xx/traps.c  |  6 +++---
 arch/powerpc/cpu/mpc8xx/traps.c   |  6 +++---
 arch/powerpc/cpu/ppc4xx/traps.c   |  6 +++---
 arch/powerpc/lib/board.c          | 12 ++++++------
 13 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/arch/powerpc/cpu/74xx_7xx/traps.c b/arch/powerpc/cpu/74xx_7xx/traps.c
index 7ae81eb..4f77202 100644
--- a/arch/powerpc/cpu/74xx_7xx/traps.c
+++ b/arch/powerpc/cpu/74xx_7xx/traps.c
@@ -48,7 +48,7 @@ extern unsigned long search_exception_table(unsigned long);
  * Trap & Exception support
  */
 
-void
+static void
 print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
@@ -69,7 +69,7 @@ print_backtrace(unsigned long *sp)
 	printf("\n");
 }
 
-void
+static void
 show_regs(struct pt_regs * regs)
 {
 	int i;
@@ -100,7 +100,7 @@ show_regs(struct pt_regs * regs)
 }
 
 
-void
+static void
 _exception(int signr, struct pt_regs *regs)
 {
 	show_regs(regs);
diff --git a/arch/powerpc/cpu/mpc512x/traps.c b/arch/powerpc/cpu/mpc512x/traps.c
index 786f4a5..3b84d57 100644
--- a/arch/powerpc/cpu/mpc512x/traps.c
+++ b/arch/powerpc/cpu/mpc512x/traps.c
@@ -47,7 +47,7 @@ extern ulong get_effective_memsize(void);
  * Trap & Exception support
  */
 
-void
+static void
 print_backtrace (unsigned long *sp)
 {
 	int cnt = 0;
@@ -68,7 +68,7 @@ print_backtrace (unsigned long *sp)
 	putc ('\n');
 }
 
-void show_regs (struct pt_regs * regs)
+static void show_regs (struct pt_regs * regs)
 {
 	int i;
 
@@ -94,7 +94,7 @@ void show_regs (struct pt_regs * regs)
 }
 
 
-void
+static void
 _exception (int signr, struct pt_regs *regs)
 {
 	show_regs (regs);
diff --git a/arch/powerpc/cpu/mpc5xx/traps.c b/arch/powerpc/cpu/mpc5xx/traps.c
index e3ce11b..4950b65 100644
--- a/arch/powerpc/cpu/mpc5xx/traps.c
+++ b/arch/powerpc/cpu/mpc5xx/traps.c
@@ -52,7 +52,7 @@ extern unsigned long search_exception_table(unsigned long);
 /*
  * Print stack backtrace
  */
-void print_backtrace(unsigned long *sp)
+static void print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
 	unsigned long i;
@@ -75,7 +75,7 @@ void print_backtrace(unsigned long *sp)
 /*
  * Print current registers
  */
-void show_regs(struct pt_regs * regs)
+static void show_regs(struct pt_regs * regs)
 {
 	int i;
 	printf("NIP: %08lX XER: %08lX LR: %08lX REGS: %p TRAP: %04lx DAR: %08lX\n",
@@ -105,7 +105,7 @@ void show_regs(struct pt_regs * regs)
 /*
  * General exception handler routine
  */
-void _exception(int signr, struct pt_regs *regs)
+static void _exception(int signr, struct pt_regs *regs)
 {
 	show_regs(regs);
 	print_backtrace((unsigned long *)regs->gpr[1]);
diff --git a/arch/powerpc/cpu/mpc5xxx/traps.c b/arch/powerpc/cpu/mpc5xxx/traps.c
index 5972f34..c4d4c0b 100644
--- a/arch/powerpc/cpu/mpc5xxx/traps.c
+++ b/arch/powerpc/cpu/mpc5xxx/traps.c
@@ -49,7 +49,7 @@ extern unsigned long search_exception_table(unsigned long);
  * Trap & Exception support
  */
 
-void
+static void
 print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
@@ -70,7 +70,7 @@ print_backtrace(unsigned long *sp)
 	printf("\n");
 }
 
-void show_regs(struct pt_regs * regs)
+static void show_regs(struct pt_regs * regs)
 {
 	int i;
 
@@ -98,7 +98,7 @@ void show_regs(struct pt_regs * regs)
 }
 
 
-void
+static void
 _exception(int signr, struct pt_regs *regs)
 {
 	show_regs(regs);
diff --git a/arch/powerpc/cpu/mpc8220/traps.c b/arch/powerpc/cpu/mpc8220/traps.c
index 13894c9..d8786c2 100644
--- a/arch/powerpc/cpu/mpc8220/traps.c
+++ b/arch/powerpc/cpu/mpc8220/traps.c
@@ -49,7 +49,7 @@ extern unsigned long search_exception_table (unsigned long);
  * Trap & Exception support
  */
 
-void print_backtrace (unsigned long *sp)
+static void print_backtrace (unsigned long *sp)
 {
 	int cnt = 0;
 	unsigned long i;
@@ -70,7 +70,7 @@ void print_backtrace (unsigned long *sp)
 	printf ("\n");
 }
 
-void show_regs (struct pt_regs *regs)
+static void show_regs (struct pt_regs *regs)
 {
 	int i;
 
@@ -96,7 +96,7 @@ void show_regs (struct pt_regs *regs)
 }
 
 
-void _exception (int signr, struct pt_regs *regs)
+static void _exception (int signr, struct pt_regs *regs)
 {
 	show_regs (regs);
 	print_backtrace ((unsigned long *) regs->gpr[1]);
diff --git a/arch/powerpc/cpu/mpc824x/traps.c b/arch/powerpc/cpu/mpc824x/traps.c
index 163b983..63ab9b9 100644
--- a/arch/powerpc/cpu/mpc824x/traps.c
+++ b/arch/powerpc/cpu/mpc824x/traps.c
@@ -46,7 +46,7 @@ extern unsigned long search_exception_table(unsigned long);
  * Trap & Exception support
  */
 
-void
+static void
 print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
@@ -67,7 +67,7 @@ print_backtrace(unsigned long *sp)
 	printf("\n");
 }
 
-void show_regs(struct pt_regs * regs)
+static void show_regs(struct pt_regs * regs)
 {
 	int i;
 
@@ -95,7 +95,7 @@ void show_regs(struct pt_regs * regs)
 }
 
 
-void
+static void
 _exception(int signr, struct pt_regs *regs)
 {
 	show_regs(regs);
diff --git a/arch/powerpc/cpu/mpc8260/traps.c b/arch/powerpc/cpu/mpc8260/traps.c
index c116cdf..02e287b 100644
--- a/arch/powerpc/cpu/mpc8260/traps.c
+++ b/arch/powerpc/cpu/mpc8260/traps.c
@@ -49,7 +49,7 @@ extern unsigned long search_exception_table(unsigned long);
  * Trap & Exception support
  */
 
-void
+static void
 print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
@@ -70,7 +70,7 @@ print_backtrace(unsigned long *sp)
 	putc ('\n');
 }
 
-void show_regs(struct pt_regs * regs)
+static void show_regs(struct pt_regs * regs)
 {
 	int i;
 
@@ -96,7 +96,7 @@ void show_regs(struct pt_regs * regs)
 }
 
 
-void
+static void
 _exception(int signr, struct pt_regs *regs)
 {
 	show_regs(regs);
diff --git a/arch/powerpc/cpu/mpc83xx/traps.c b/arch/powerpc/cpu/mpc83xx/traps.c
index 9d71b8b..5cefa09 100644
--- a/arch/powerpc/cpu/mpc83xx/traps.c
+++ b/arch/powerpc/cpu/mpc83xx/traps.c
@@ -42,7 +42,7 @@ extern unsigned long search_exception_table(unsigned long);
  * Trap & Exception support
  */
 
-void
+static void
 print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
@@ -63,7 +63,7 @@ print_backtrace(unsigned long *sp)
 	putc ('\n');
 }
 
-void show_regs(struct pt_regs * regs)
+static void show_regs(struct pt_regs * regs)
 {
 	int i;
 
@@ -89,7 +89,7 @@ void show_regs(struct pt_regs * regs)
 }
 
 
-void
+static void
 _exception(int signr, struct pt_regs *regs)
 {
 	show_regs(regs);
diff --git a/arch/powerpc/cpu/mpc85xx/traps.c b/arch/powerpc/cpu/mpc85xx/traps.c
index 7800717..e4bb6af 100644
--- a/arch/powerpc/cpu/mpc85xx/traps.c
+++ b/arch/powerpc/cpu/mpc85xx/traps.c
@@ -82,7 +82,7 @@ extern void do_bedbug_breakpoint(struct pt_regs *);
  * Trap & Exception support
  */
 
-void
+static void
 print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
@@ -103,7 +103,7 @@ print_backtrace(unsigned long *sp)
 	printf("\n");
 }
 
-void show_regs(struct pt_regs * regs)
+static void show_regs(struct pt_regs * regs)
 {
 	int i;
 
@@ -131,7 +131,7 @@ void show_regs(struct pt_regs * regs)
 }
 
 
-void
+static void
 _exception(int signr, struct pt_regs *regs)
 {
 	show_regs(regs);
diff --git a/arch/powerpc/cpu/mpc86xx/traps.c b/arch/powerpc/cpu/mpc86xx/traps.c
index 406403e..83db97c 100644
--- a/arch/powerpc/cpu/mpc86xx/traps.c
+++ b/arch/powerpc/cpu/mpc86xx/traps.c
@@ -52,7 +52,7 @@ extern ulong get_effective_memsize(void);
  * Trap & Exception support
  */
 
-void
+static void
 print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
@@ -74,7 +74,7 @@ print_backtrace(unsigned long *sp)
 	printf("\n");
 }
 
-void
+static void
 show_regs(struct pt_regs *regs)
 {
 	int i;
@@ -103,7 +103,7 @@ show_regs(struct pt_regs *regs)
 }
 
 
-void
+static void
 _exception(int signr, struct pt_regs *regs)
 {
 	show_regs(regs);
diff --git a/arch/powerpc/cpu/mpc8xx/traps.c b/arch/powerpc/cpu/mpc8xx/traps.c
index 343dced..3bc2312 100644
--- a/arch/powerpc/cpu/mpc8xx/traps.c
+++ b/arch/powerpc/cpu/mpc8xx/traps.c
@@ -52,7 +52,7 @@ extern unsigned long search_exception_table(unsigned long);
  * Trap & Exception support
  */
 
-void
+static void
 print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
@@ -73,7 +73,7 @@ print_backtrace(unsigned long *sp)
 	printf("\n");
 }
 
-void show_regs(struct pt_regs * regs)
+static void show_regs(struct pt_regs * regs)
 {
 	int i;
 
@@ -101,7 +101,7 @@ void show_regs(struct pt_regs * regs)
 }
 
 
-void
+static void
 _exception(int signr, struct pt_regs *regs)
 {
 	show_regs(regs);
diff --git a/arch/powerpc/cpu/ppc4xx/traps.c b/arch/powerpc/cpu/ppc4xx/traps.c
index 9baa7a1..1ed8387 100644
--- a/arch/powerpc/cpu/ppc4xx/traps.c
+++ b/arch/powerpc/cpu/ppc4xx/traps.c
@@ -74,7 +74,7 @@ extern void do_bedbug_breakpoint(struct pt_regs *);
  * Trap & Exception support
  */
 
-void
+static void
 print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
@@ -95,7 +95,7 @@ print_backtrace(unsigned long *sp)
 	printf("\n");
 }
 
-void show_regs(struct pt_regs * regs)
+static void show_regs(struct pt_regs * regs)
 {
 	int i;
 
@@ -121,7 +121,7 @@ void show_regs(struct pt_regs * regs)
 }
 
 
-void
+static void
 _exception(int signr, struct pt_regs *regs)
 {
 	show_regs(regs);
diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c
index b860141..42bbff7 100644
--- a/arch/powerpc/lib/board.c
+++ b/arch/powerpc/lib/board.c
@@ -163,7 +163,7 @@ static int init_baudrate(void)
 
 /***********************************************************************/
 
-void __board_add_ram_info(int use_default)
+static void __board_add_ram_info(int use_default)
 {
 	/* please define platform specific board_add_ram_info() */
 }
@@ -171,7 +171,7 @@ void __board_add_ram_info(int use_default)
 void board_add_ram_info(int)
 	__attribute__ ((weak, alias("__board_add_ram_info")));
 
-int __board_flash_wp_on(void)
+static int __board_flash_wp_on(void)
 {
 	/*
 	 * Most flashes can't be detected when write protection is enabled,
@@ -184,7 +184,7 @@ int __board_flash_wp_on(void)
 int board_flash_wp_on(void)
 	__attribute__ ((weak, alias("__board_flash_wp_on")));
 
-void __cpu_secondary_init_r(void)
+static void __cpu_secondary_init_r(void)
 {
 }
 
@@ -262,7 +262,7 @@ static int init_func_watchdog_reset(void)
  * Initialization sequence
  */
 
-init_fnc_t *init_sequence[] = {
+static init_fnc_t *init_sequence[] = {
 #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
 	probecpu,
 #endif
@@ -345,7 +345,7 @@ ulong get_effective_memsize(void)
 #endif
 }
 
-int __fixup_cpu(void)
+static int __fixup_cpu(void)
 {
 	return 0;
 }
@@ -402,7 +402,7 @@ void board_init_f(ulong bootflag)
 
 #ifdef CONFIG_POST
 	post_bootmode_init();
-	post_run(NULL, POST_ROM | post_bootmode_get(0));
+	post_run(NULL, POST_ROM | post_bootmode_get(NULL));
 #endif
 
 	WATCHDOG_RESET();
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 09/32] include/common.h: sparse fix
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (7 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 08/32] arch/powerpc/lib/board.c, *traps.c: sparse fixes Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 10/32] include/command.h: " Kim Phillips
                   ` (26 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

powerpc sparse builds yield:

include/common.h:356:22: error: marked inline, but without a definition

the unknown-reason inlining without a definition is considered obsolete
given it was part of the 2002 initial commit, and no arm version was
'fixed.'

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 include/common.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/include/common.h b/include/common.h
index b23e90b..5e3c5ee 100644
--- a/include/common.h
+++ b/include/common.h
@@ -341,13 +341,9 @@ char	*getenv	     (const char *);
 int	getenv_f     (const char *name, char *buf, unsigned len);
 ulong getenv_ulong(const char *name, int base, ulong default_val);
 int	saveenv	     (void);
-#ifdef CONFIG_PPC		/* ARM version to be fixed! */
-int inline setenv    (const char *, const char *);
-#else
 int	setenv	     (const char *, const char *);
 int setenv_ulong(const char *varname, ulong value);
 int setenv_addr(const char *varname, const void *addr);
-#endif /* CONFIG_PPC */
 #ifdef CONFIG_ARM
 # include <asm/mach-types.h>
 # include <asm/setup.h>
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 10/32] include/command.h: sparse fix
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (8 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 09/32] include/common.h: sparse fix Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-25 16:35   ` Tom Rini
  2012-10-17  0:28 ` [U-Boot] [PATCH 11/32] include/image.h: sparse fixes Kim Phillips
                   ` (25 subsequent siblings)
  35 siblings, 1 reply; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

__u_boot_cmd_* should be declared static, e.g.:

cmd_mem.c:1142:1: warning: symbol '__u_boot_cmd_md' was not declared. Should it be static?
cmd_mem.c:1149:1: warning: symbol '__u_boot_cmd_mm' was not declared. Should it be static?
cmd_mem.c:1156:1: warning: symbol '__u_boot_cmd_nm' was not declared. Should it be static?
cmd_mem.c:1162:1: warning: symbol '__u_boot_cmd_mw' was not declared. Should it be static?
cmd_mem.c:1168:1: warning: symbol '__u_boot_cmd_cp' was not declared. Should it be static?
cmd_mem.c:1174:1: warning: symbol '__u_boot_cmd_cmp' was not declared. Should it be static?
cmd_mem.c:1184:1: warning: symbol '__u_boot_cmd_crc32' was not declared. Should it be static?
cmd_mem.c:1203:1: warning: symbol '__u_boot_cmd_base' was not declared. Should it be static?
cmd_mem.c:1210:1: warning: symbol '__u_boot_cmd_loop' was not declared. Should it be static?
cmd_mem.c:1224:1: warning: symbol '__u_boot_cmd_mtest' was not declared. Should it be static?

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 include/command.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/command.h b/include/command.h
index 1f06aa1..c051158 100644
--- a/include/command.h
+++ b/include/command.h
@@ -174,7 +174,7 @@ int cmd_process(int flag, int argc, char * const argv[],
 	U_BOOT_CMD_MKENT_COMPLETE(name,maxargs,rep,cmd,usage,help,NULL)
 
 #define U_BOOT_CMD_COMPLETE(name,maxargs,rep,cmd,usage,help,comp) \
-	cmd_tbl_t __u_boot_cmd_##name Struct_Section = \
+	static cmd_tbl_t __u_boot_cmd_##name Struct_Section = \
 		U_BOOT_CMD_MKENT_COMPLETE(name,maxargs,rep,cmd,usage,help,comp)
 
 #define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) \
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 11/32] include/image.h: sparse fixes
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (9 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 10/32] include/command.h: " Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 12/32] common/cmd_*.c: " Kim Phillips
                   ` (24 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

include/image.h:378:1: warning: cast to restricted __be32
include/image.h:381:1: warning: cast to restricted __be32
include/image.h:382:1: warning: cast to restricted __be32
include/image.h:383:1: warning: cast to restricted __be32

fix by annotating image header integers big endian.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 include/image.h | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/include/image.h b/include/image.h
index e5f6649..ab27941 100644
--- a/include/image.h
+++ b/include/image.h
@@ -34,6 +34,7 @@
 #define __IMAGE_H__
 
 #include "compiler.h"
+#include <asm/byteorder.h>
 
 #ifdef USE_HOSTCC
 
@@ -183,13 +184,13 @@
  * all data in network byte order (aka natural aka bigendian).
  */
 typedef struct image_header {
-	uint32_t	ih_magic;	/* Image Header Magic Number	*/
-	uint32_t	ih_hcrc;	/* Image Header CRC Checksum	*/
-	uint32_t	ih_time;	/* Image Creation Timestamp	*/
-	uint32_t	ih_size;	/* Image Data Size		*/
-	uint32_t	ih_load;	/* Data	 Load  Address		*/
-	uint32_t	ih_ep;		/* Entry Point Address		*/
-	uint32_t	ih_dcrc;	/* Image Data CRC Checksum	*/
+	__be32		ih_magic;	/* Image Header Magic Number	*/
+	__be32		ih_hcrc;	/* Image Header CRC Checksum	*/
+	__be32		ih_time;	/* Image Creation Timestamp	*/
+	__be32		ih_size;	/* Image Data Size		*/
+	__be32		ih_load;	/* Data	 Load  Address		*/
+	__be32		ih_ep;		/* Entry Point Address		*/
+	__be32		ih_dcrc;	/* Image Data CRC Checksum	*/
 	uint8_t		ih_os;		/* Operating System		*/
 	uint8_t		ih_arch;	/* CPU architecture		*/
 	uint8_t		ih_type;	/* Image Type			*/
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 12/32] common/cmd_*.c: sparse fixes
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (10 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 11/32] include/image.h: sparse fixes Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-24 23:49   ` Tom Rini
  2012-10-17  0:28 ` [U-Boot] [PATCH 13/32] common/misc: " Kim Phillips
                   ` (23 subsequent siblings)
  35 siblings, 1 reply; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

cmd_boot.c:35:15: warning: symbol 'do_go_exec' was not declared. Should it be static?
cmd_boot.c:35:22: error: weak declaration of 'do_go_exec' must be public
cmd_boot.c:40:5: warning: symbol 'do_go' was not declared. Should it be static?
cmd_bootm.c:164:6: warning: symbol '__arch_preboot_os' was not declared. Should it be static?
cmd_bootm.c:477:5: warning: symbol 'do_bootm_subcommand' was not declared. Should it be static?
cmd_bootm.c:1022:1: error: directive in argument list
cmd_bootm.c:1028:1: error: directive in argument list
cmd_bootm.c:1029:1: error: directive in argument list
cmd_bootm.c:1036:1: error: directive in argument list
cmd_bootm.c:1042:1: error: directive in argument list
cmd_bootm.c:1044:1: error: directive in argument list
cmd_bootm.c:1045:1: error: directive in argument list
cmd_bootm.c:1047:1: error: directive in argument list
cmd_bootm.c:1089:5: warning: symbol 'do_iminfo' was not declared. Should it be static?
cmd_bootm.c:1176:5: warning: symbol 'do_imls' was not declared. Should it be static?
cmd_bootm.c:1654:1: error: directive in argument list
cmd_bootm.c:1660:1: error: directive in argument list
cmd_console.c:32:5: warning: symbol 'do_coninfo' was not declared. Should it be s
cmd_date.c:46:5: warning: symbol 'do_date' was not declared. Should it be static?
cmd_echo.c:27:5: warning: symbol 'do_echo' was not declared. Should it be static?
cmd_exit.c:27:5: warning: symbol 'do_exit' was not declared. Should it be static?
cmd_fat.c:97:5: warning: symbol 'do_fat_ls' was not declared. Should it be static?
cmd_fat.c:136:5: warning: symbol 'do_fat_fsinfo' was not declared. Should it be s
cmd_fdt.c:66:5: warning: symbol 'do_fdt' was not declared. Should it be static?
cmd_fdt.c:542:43: warning: incorrect type in assignment (different base types)
cmd_fdt.c:542:43:    expected unsigned int [unsigned] [usertype] <noident>
cmd_fdt.c:542:43:    got restricted __be32 [usertype] <noident>
cmd_fdt.c:679:42: warning: cast to restricted __be32
cmd_fdt.c:820:1: error: directive in argument list
cmd_fdt.c:822:1: error: directive in argument list
cmd_flash.c:292:5: warning: symbol 'do_flinfo' was not declared. Should it be static?
cmd_flash.c:324:5: warning: symbol 'do_flerase' was not declared. Should it be static?
cmd_flash.c:457:5: warning: symbol 'do_protect' was not declared. Should it be st
cmd_help.c:27:5: warning: symbol 'do_help' was not declared. Should it be static?
cmd_i2c.c:136:6: warning: symbol '__def_i2c_init_board' was not declared. Should it be static?
cmd_i2c.c:144:14: warning: symbol '__def_i2c_get_bus_speed' was not declared. Should it be static?
cmd_i2c.c:151:5: warning: symbol '__def_i2c_set_bus_speed' was not declared. Should it be static?
cmd_i2c.c:1322:1: error: directive in argument list
cmd_i2c.c:1324:1: error: directive in argument list
cmd_i2c.c:1326:1: error: directive in argument list
cmd_i2c.c:1328:1: error: directive in argument list
cmd_i2c.c:1337:1: error: directive in argument list
cmd_i2c.c:1339:1: error: directive in argument list
cmd_irq.c:27:5: warning: symbol 'do_interrupts' was not declared. Should it be static?
cmd_itest.c:133:5: warning: symbol 'binary_test' was not declared. Should it be static?
cmd_itest.c:158:5: warning: symbol 'do_itest' was not declared. Should it be stat
cmd_load.c:54:5: warning: symbol 'do_load_serial' was not declared. Should it be static?
cmd_load.c:431:6: warning: symbol 'his_eol' was not declared. Should it be static?
cmd_load.c:432:6: warning: symbol 'his_pad_count' was not declared. Should it be static?
cmd_load.c:433:6: warning: symbol 'his_pad_char' was not declared. Should it be static?
cmd_load.c:434:6: warning: symbol 'his_quote' was not declared. Should it be static?
cmd_load.c:436:5: warning: symbol 'do_load_serial_bin' was not declared. Should it be static?
cmd_load.c:549:6: warning: symbol 'send_pad' was not declared. Should it be static?
cmd_load.c:558:6: warning: symbol 'ktrans' was not declared. Should it be static?
cmd_load.c:568:5: warning: symbol 'chk1' was not declared. Should it be static?
cmd_load.c:578:6: warning: symbol 's1_sendpacket' was not declared. Should it be static?
cmd_load.c:587:6: warning: symbol 'send_ack' was not declared. Should it be static?
cmd_load.c:600:6: warning: symbol 'send_nack' was not declared. Should it be static?
cmd_load.c:614:6: warning: symbol 'os_data_init' was not declared. Should it be static?
cmd_load.c:615:6: warning: symbol 'os_data_char' was not declared. Should it be static?
cmd_load.c:657:6: warning: symbol 'k_data_init' was not declared. Should it be static?
cmd_load.c:663:6: warning: symbol 'k_data_save' was not declared. Should it be static?
cmd_load.c:669:6: warning: symbol 'k_data_restore' was not declared. Should it be static?
cmd_load.c:675:6: warning: symbol 'k_data_char' was not declared. Should it be static?
cmd_load.c:693:6: warning: symbol 'send_parms' was not declared. Should it be static?
cmd_load.c:694:6: warning: symbol 'send_ptr' was not declared. Should it be static?
cmd_load.c:698:6: warning: symbol 'handle_send_packet' was not declared. Should i
cmd_mdio.c:60:5: warning: symbol 'mdio_write_ranges' was not declared. Should it be static?
cmd_mdio.c:82:5: warning: symbol 'mdio_read_ranges' was not declared. Should it be static?
cmd_mdio.c:115:5: warning: symbol 'extract_reg_range' was not declared. Should it be static?
cmd_mdio.c:144:5: warning: symbol 'extract_phy_range' was not declared. Should it
cmd_mem.c:54:5: warning: symbol 'do_mem_md' was not declared. Should it be static?
cmd_mem.c:150:5: warning: symbol 'do_mem_mm' was not declared. Should it be static?
cmd_mem.c:154:5: warning: symbol 'do_mem_nm' was not declared. Should it be static?
cmd_mem.c:159:5: warning: symbol 'do_mem_mw' was not declared. Should it be static?
cmd_mem.c:256:5: warning: symbol 'do_mem_cmp' was not declared. Should it be static?
cmd_mem.c:326:5: warning: symbol 'do_mem_cp' was not declared. Should it be static?
cmd_mem.c:436:5: warning: symbol 'do_mem_base' was not declared. Should it be static?
cmd_mem.c:449:5: warning: symbol 'do_mem_loop' was not declared. Should it be static?
cmd_mem.c:595:5: warning: symbol 'do_mem_mtest' was not declared. Should it be static?
cmd_mem.c:618:26: warning: Using plain integer as NULL pointer
cmd_mem.c:1057:5: warning: symbol 'do_mem_crc' was not declared. Should it be static?
cmd_misc.c:30:5: warning: symbol 'do_sleep' was not declared. Should it be static
cmd_mmc.c:118:5: warning: symbol 'do_mmcinfo' was not declared. Should it be static?
cmd_mmc.c:272:32: warning: Using plain integer as NULL pointer
cmd_mmc.c:150:5: warning: symbol 'do_mmcops' was not declared. Should it be stati
cmd_mp.c:27:1: warning: symbol 'cpu_cmd' was not declared. Should it be static?
cmd_mp.c:85:1: error: directive in argument list
cmd_mp.c:88:1: error: directive in argument list
cmd_mtdparts.c:150:18: warning: symbol 'mtdids' was not declared. Should it be static?
cmd_mtdparts.c:153:18: warning: symbol 'devices' was not declared. Should it be static?
cmd_mtdparts.c:156:19: warning: symbol 'current_mtd_dev' was not declared. Should it be static?
cmd_mtdparts.c:157:4: warning: symbol 'current_mtd_partnum' was not declared. Should it be static?
cmd_mtdparts.c:713:5: warning: symbol 'mtd_device_validate' was not declared. Should it be static?
cmd_mtdparts.c:1045:5: warning: symbol 'mtd_id_parse' was not declared. Should it be static?
cmd_mtdparts.c:1887:5: warning: symbol 'do_chpart' was not declared. Should it be static?
cmd_mtdparts.c:1925:5: warning: symbol 'do_mtdparts' was not declared. Should it be static?
cmd_mtdparts.c:2060:1: error: directive in argument list
cmd_mtdparts.c:2063:1: error: directive in argument list
cmd_mtdparts.c:2066:1: error: directive in argument list
cmd_mtdparts.c:2071:1: error: directive in argument list
cmd_mtdparts.c:2073:1: error: directive in argument list
cmd_nand.c:377:18: error: bad constant expression
cmd_nand.c:431:5: warning: symbol 'do_nand' was not declared. Should it be static?
cmd_nand.c:796:1: error: directive in argument list
cmd_nand.c:801:1: error: directive in argument list
cmd_nand.c:802:1: error: directive in argument list
cmd_nand.c:806:1: error: directive in argument list
cmd_nand.c:819:1: error: directive in argument list
cmd_nand.c:824:1: error: directive in argument list
cmd_nand.c:825:1: error: directive in argument list
cmd_nand.c:831:1: error: directive in argument list
cmd_nand.c:918:5: warning: symbol 'do_nandboot' was not declared. Should it be static?
cmd_net.c:33:5: warning: symbol 'do_bootp' was not declared. Should it be static?
cmd_net.c:107:5: warning: symbol 'do_dhcp' was not declared. Should it be static?
cmd_net.c:120:5: warning: symbol 'do_nfs' was not declared. Should it be static?
cmd_nvedit.c:138:5: warning: symbol 'do_env_print' was not declared. Should it be static?
cmd_nvedit.c:323:5: warning: symbol '_do_env_set' was not declared. Should it be static?
cmd_nvedit.c:435:5: warning: symbol 'do_env_set' was not declared. Should it be static?
cmd_nvedit.c:514:5: warning: symbol 'do_env_edit' was not declared. Should it be static?
cmd_nvedit.c:620:5: warning: symbol 'do_env_save' was not declared. Should it be static?
cmd_nvedit.c:1016:1: error: directive in argument list
cmd_nvedit.c:1018:1: error: directive in argument list
cmd_nvedit.c:1021:1: error: directive in argument list
cmd_nvedit.c:1023:1: error: directive in argument list
cmd_nvedit.c:1024:1: error: directive in argument list
cmd_nvedit.c:1026:1: error: directive in argument list
cmd_nvedit.c:1027:1: error: directive in argument list
cmd_nvedit.c:1029:1: error: directive in argument list
cmd_nvedit.c:1030:1: error: directive in argument list
cmd_nvedit.c:1032:1: error: directive in argument list
cmd_nvedit.c:1034:1: error: directive in argument list
cmd_nvedit.c:1036:1: error: directive in argument list
cmd_nvedit.c:1037:1: error: directive in argument list
cmd_nvedit.c:1039:1: error: directive in argument list
cmd_pci.c:38:17: warning: symbol 'ShortPCIListing' was not declared. Should it be static?
cmd_pci.c:38:22: warning: 'ShortPCIListing' defined but not used [-Wunused-variable]
cmd_pci.c:411:5: warning: symbol 'do_pci' was not declared. Should it be static?
cmd_pci.c:494:1: error: directive in argument list
cmd_pci.c:497:1: error: directive in argument list
cmd_reginfo.c:40:5: warning: symbol 'do_reginfo' was not declared. Should it be static?
cmd_sata.c:31:5: warning: symbol 'sata_curr_device' was not declared. Should it be static?
 note -> ata_piix.c doesn't seem to use 'sata_curr_device'; deleted.
cmd_sata.c:32:18: warning: symbol 'sata_dev_desc' was not declared. Should it be static?
cmd_sata.c:70:5: warning: symbol 'do_sata' was not declared. Should it be static?
cmd_setexpr.c:53:5: warning: symbol 'do_setexpr' was not declared. Should it be static?
cmd_source.c:155:1: warning: symbol 'do_source' was not declared. Should it be static?
cmd_source.c:186:1: error: directive in argument list
cmd_source.c:190:1: error: directive in argument list
cmd_test.c:27:5: warning: symbol 'do_test' was not declared. Should it be static?
cmd_test.c:153:5: warning: symbol 'do_false' was not declared. Should it be static?
cmd_test.c:164:5: warning: symbol 'do_true' was not declared. Should it be static
cmd_usb.c:43:6: warning: symbol 'usb_get_class_desc' was not declared. Should it be static?
cmd_usb.c:69:6: warning: symbol 'usb_display_class_sub' was not declared. Should it be static?
cmd_usb.c:151:6: warning: symbol 'usb_display_string' was not declared. Should it be static?
cmd_usb.c:161:6: warning: symbol 'usb_display_desc' was not declared. Should it be static?
cmd_usb.c:195:6: warning: symbol 'usb_display_conf_desc' was not declared. Should it be static?
cmd_usb.c:210:6: warning: symbol 'usb_display_if_desc' was not declared. Should it be static?
cmd_usb.c:227:6: warning: symbol 'usb_display_ep_desc' was not declared. Should it be static?
cmd_usb.c:252:6: warning: symbol 'usb_display_config' was not declared. Should it be static?
cmd_usb.c:283:6: warning: symbol 'usb_show_tree_graph' was not declared. Should it be static?
cmd_usb.c:343:6: warning: symbol 'usb_show_tree' was not declared. Should it be static?
cmd_usb.c:356:5: warning: symbol 'do_usbboot' was not declared. Should it be static?
cmd_usb.c:366:5: warning: symbol 'do_usb' was not declared. Should it be static?
cmd_version.c:31:5: warning: symbol 'do_version' was not declared. Should it be s
cmd_ximg.c:46:1: warning: symbol 'do_imgextract' was not declared. Should it be static?
cmd_ximg.c:272:1: error: directive in argument list
cmd_ximg.c:276:1: error: directive in argument list

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 common/cmd_boot.c     |  5 +++--
 common/cmd_bootm.c    | 27 ++++++++++++++++-----------
 common/cmd_console.c  |  2 +-
 common/cmd_date.c     |  2 +-
 common/cmd_echo.c     |  2 +-
 common/cmd_exit.c     |  2 +-
 common/cmd_fat.c      |  5 +++--
 common/cmd_fdt.c      | 19 ++++++++++---------
 common/cmd_flash.c    |  6 +++---
 common/cmd_help.c     |  2 +-
 common/cmd_i2c.c      | 18 ++++++++++--------
 common/cmd_irq.c      |  2 +-
 common/cmd_itest.c    |  4 ++--
 common/cmd_load.c     | 44 +++++++++++++++++++++++---------------------
 common/cmd_mdio.c     | 20 ++++++++++----------
 common/cmd_mem.c      | 25 ++++++++++++++-----------
 common/cmd_misc.c     |  2 +-
 common/cmd_mmc.c      |  6 +++---
 common/cmd_mp.c       | 20 +++++++++-----------
 common/cmd_mtdparts.c | 28 ++++++++++++++++------------
 common/cmd_nand.c     | 17 ++++++++++-------
 common/cmd_net.c      |  8 ++++----
 common/cmd_nvedit.c   | 23 ++++++++++++++---------
 common/cmd_pci.c      | 15 +++++++--------
 common/cmd_reginfo.c  |  3 ++-
 common/cmd_sata.c     |  4 ++--
 common/cmd_setexpr.c  |  2 +-
 common/cmd_source.c   | 11 +++++++----
 common/cmd_test.c     |  6 +++---
 common/cmd_usb.c      | 30 +++++++++++++++---------------
 common/cmd_version.c  |  2 +-
 common/cmd_ximg.c     | 11 +++++++----
 32 files changed, 202 insertions(+), 171 deletions(-)

diff --git a/common/cmd_boot.c b/common/cmd_boot.c
index a799b33..ab5a6ed 100644
--- a/common/cmd_boot.c
+++ b/common/cmd_boot.c
@@ -32,12 +32,13 @@
 
 /* Allow ports to override the default behavior */
 __attribute__((weak))
-unsigned long do_go_exec (ulong (*entry)(int, char * const []), int argc, char * const argv[])
+unsigned long do_go_exec (ulong (*entry)(int, char * const []), int argc,
+				 char * const argv[])
 {
 	return entry (argc, argv);
 }
 
-int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong	addr, rc;
 	int     rcode = 0;
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 83fa5d7..92b45b4 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -161,7 +161,7 @@ static boot_os_fn *boot_os[] = {
 bootm_headers_t images;		/* pointers to os/initrd/fdt images */
 
 /* Allow for arch specific config before we boot */
-void __arch_preboot_os(void)
+static void __arch_preboot_os(void)
 {
 	/* please define platform specific arch_preboot_os() */
 }
@@ -474,7 +474,7 @@ static cmd_tbl_t cmd_bootm_sub[] = {
 	U_BOOT_CMD_MKENT(go, 0, 1, (void *)BOOTM_STATE_OS_GO, "", ""),
 };
 
-int do_bootm_subcommand(cmd_tbl_t *cmdtp, int flag, int argc,
+static int do_bootm_subcommand(cmd_tbl_t *cmdtp, int flag, int argc,
 			char * const argv[])
 {
 	int ret = 0;
@@ -1013,9 +1013,7 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
 	return (void *)img_addr;
 }
 
-U_BOOT_CMD(
-	bootm,	CONFIG_SYS_MAXARGS,	1,	do_bootm,
-	"boot application image from memory",
+static char bootm_help_text[] =
 	"[addr [arg ...]]\n    - boot application image stored in memory\n"
 	"\tpassing arguments 'arg ...'; when booting a Linux kernel,\n"
 	"\t'arg' can be the address of an initrd image\n"
@@ -1048,7 +1046,11 @@ U_BOOT_CMD(
 	"\tcmdline - OS specific command line processing/setup\n"
 	"\tbdt     - OS specific bd_t processing\n"
 	"\tprep    - OS specific prep before relocation or go\n"
-	"\tgo      - start OS"
+	"\tgo      - start OS";
+
+U_BOOT_CMD(
+	bootm,	CONFIG_SYS_MAXARGS,	1,	do_bootm,
+	"boot application image from memory", bootm_help_text
 );
 
 /*******************************************************************/
@@ -1084,7 +1086,7 @@ U_BOOT_CMD(
 /* iminfo - print header info for a requested image */
 /*******************************************************************/
 #if defined(CONFIG_CMD_IMI)
-int do_iminfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_iminfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	int	arg;
 	ulong	addr;
@@ -1171,7 +1173,7 @@ U_BOOT_CMD(
 /* imls - list all images found in flash */
 /*******************************************************************/
 #if defined(CONFIG_CMD_IMLS)
-int do_imls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_imls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	flash_info_t *info;
 	int i, j;
@@ -1643,9 +1645,7 @@ static int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return 1;
 }
 
-U_BOOT_CMD(
-	bootz,	CONFIG_SYS_MAXARGS,	1,	do_bootz,
-	"boot Linux zImage image from memory",
+static const char bootz_help_text[] =
 	"[addr [initrd[:size]] [fdt]]\n"
 	"    - boot Linux zImage stored in memory\n"
 	"\tThe argument 'initrd' is optional and specifies the address\n"
@@ -1658,5 +1658,10 @@ U_BOOT_CMD(
 	"\tuse a '-' for the second argument. If you do not pass a third\n"
 	"\ta bd_info struct will be passed instead\n"
 #endif
+	"";
+
+U_BOOT_CMD(
+	bootz,	CONFIG_SYS_MAXARGS,	1,	do_bootz,
+	"boot Linux zImage image from memory", bootz_help_text
 );
 #endif	/* CONFIG_CMD_BOOTZ */
diff --git a/common/cmd_console.c b/common/cmd_console.c
index d8cad6b..07b3d8a 100644
--- a/common/cmd_console.c
+++ b/common/cmd_console.c
@@ -29,7 +29,7 @@
 #include <stdio_dev.h>
 
 extern void _do_coninfo (void);
-int do_coninfo (cmd_tbl_t * cmd, int flag, int argc, char * const argv[])
+static int do_coninfo(cmd_tbl_t * cmd, int flag, int argc, char * const argv[])
 {
 	int l;
 	struct list_head *list = stdio_get_list();
diff --git a/common/cmd_date.c b/common/cmd_date.c
index 335bc05..e645425 100644
--- a/common/cmd_date.c
+++ b/common/cmd_date.c
@@ -43,7 +43,7 @@ static const char * const weekdays[] = {
 
 int mk_date (const char *, struct rtc_time *);
 
-int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	struct rtc_time tm;
 	int rcode = 0;
diff --git a/common/cmd_echo.c b/common/cmd_echo.c
index 1e499fb..52123fe 100644
--- a/common/cmd_echo.c
+++ b/common/cmd_echo.c
@@ -24,7 +24,7 @@
 #include <common.h>
 #include <command.h>
 
-int do_echo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_echo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	int i;
 	int putnl = 1;
diff --git a/common/cmd_exit.c b/common/cmd_exit.c
index f3fc8f5..0f2ee40 100644
--- a/common/cmd_exit.c
+++ b/common/cmd_exit.c
@@ -24,7 +24,7 @@
 #include <common.h>
 #include <command.h>
 
-int do_exit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_exit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	int r;
 
diff --git a/common/cmd_fat.c b/common/cmd_fat.c
index 5a5698b..e6c0437 100644
--- a/common/cmd_fat.c
+++ b/common/cmd_fat.c
@@ -94,7 +94,7 @@ U_BOOT_CMD(
 	"      the load stops on end of file."
 );
 
-int do_fat_ls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_fat_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	char *filename = "/";
 	int ret, dev, part;
@@ -133,7 +133,8 @@ U_BOOT_CMD(
 	"    - list files from 'dev' on 'interface' in a 'directory'"
 );
 
-int do_fat_fsinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_fat_fsinfo(cmd_tbl_t *cmdtp, int flag, int argc,
+			 char * const argv[])
 {
 	int dev, part;
 	block_dev_desc_t *dev_desc;
diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c
index e2225c4..ac5c488 100644
--- a/common/cmd_fdt.c
+++ b/common/cmd_fdt.c
@@ -63,7 +63,7 @@ void set_working_fdt_addr(void *addr)
 /*
  * Flattened Device Tree command, see the help for parameter definitions.
  */
-int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+static int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 {
 	if (argc < 2)
 		return CMD_RET_USAGE;
@@ -539,7 +539,7 @@ static int fdt_parse_prop(char * const *newval, int count, char *data, int *len)
 
 			cp = newp;
 			tmp = simple_strtoul(cp, &newp, 0);
-			*(uint32_t *)data = __cpu_to_be32(tmp);
+			*(__be32 *)data = __cpu_to_be32(tmp);
 			data  += 4;
 			*len += 4;
 
@@ -672,7 +672,7 @@ static void print_data(const void *data, int len)
 	}
 
 	if ((len %4) == 0) {
-		const u32 *p;
+		const __be32 *p;
 
 		printf("<");
 		for (j = 0, p = data; j < len/4; j ++)
@@ -812,11 +812,8 @@ static int fdt_print(const char *pathp, char *prop, int depth)
 }
 
 /********************************************************************/
-
-U_BOOT_CMD(
-	fdt,	255,	0,	do_fdt,
-	"flattened device tree utility commands",
-	    "addr   <addr> [<length>]        - Set the fdt location to <addr>\n"
+static char fdt_help_text[] =
+	"addr   <addr> [<length>]        - Set the fdt location to <addr>\n"
 #ifdef CONFIG_OF_BOARD_SETUP
 	"fdt boardsetup                      - Do board-specific set up\n"
 #endif
@@ -836,5 +833,9 @@ U_BOOT_CMD(
 	"fdt chosen [<start> <end>]          - Add/update the /chosen branch in the tree\n"
 	"                                        <start>/<end> - initrd start/end addr\n"
 	"NOTE: Dereference aliases by omiting the leading '/', "
-		"e.g. fdt print ethernet0."
+		"e.g. fdt print ethernet0.";
+
+U_BOOT_CMD(
+	fdt,	255,	0,	do_fdt,
+	"flattened device tree utility commands", fdt_help_text
 );
diff --git a/common/cmd_flash.c b/common/cmd_flash.c
index e55d366..687eb68 100644
--- a/common/cmd_flash.c
+++ b/common/cmd_flash.c
@@ -289,7 +289,7 @@ flash_fill_sect_ranges (ulong addr_first, ulong addr_last,
 }
 #endif /* CONFIG_SYS_NO_FLASH */
 
-int do_flinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_flinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 #ifndef CONFIG_SYS_NO_FLASH
 	ulong bank;
@@ -321,7 +321,7 @@ int do_flinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return 0;
 }
 
-int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_flerase(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 #ifndef CONFIG_SYS_NO_FLASH
 	flash_info_t *info = NULL;
@@ -454,7 +454,7 @@ int flash_sect_erase (ulong addr_first, ulong addr_last)
 }
 #endif /* CONFIG_SYS_NO_FLASH */
 
-int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_protect(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	int rcode = 0;
 #ifndef CONFIG_SYS_NO_FLASH
diff --git a/common/cmd_help.c b/common/cmd_help.c
index 8c8178e..97af32c 100644
--- a/common/cmd_help.c
+++ b/common/cmd_help.c
@@ -24,7 +24,7 @@
 #include <common.h>
 #include <command.h>
 
-int do_help(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+static int do_help(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 {
 	return _do_help(&__u_boot_cmd_start,
 			&__u_boot_cmd_end - &__u_boot_cmd_start,
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index 795814d..9a184b1 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -133,7 +133,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #define DISP_LINE_LEN	16
 
 /* implement possible board specific board init */
-void __def_i2c_init_board(void)
+static void __def_i2c_init_board(void)
 {
 	return;
 }
@@ -141,14 +141,14 @@ void i2c_init_board(void)
 	__attribute__((weak, alias("__def_i2c_init_board")));
 
 /* TODO: Implement architecture-specific get/set functions */
-unsigned int __def_i2c_get_bus_speed(void)
+static unsigned int __def_i2c_get_bus_speed(void)
 {
 	return CONFIG_SYS_I2C_SPEED;
 }
 unsigned int i2c_get_bus_speed(void)
 	__attribute__((weak, alias("__def_i2c_get_bus_speed")));
 
-int __def_i2c_set_bus_speed(unsigned int speed)
+static int __def_i2c_set_bus_speed(unsigned int speed)
 {
 	if (speed != CONFIG_SYS_I2C_SPEED)
 		return -1;
@@ -1315,10 +1315,7 @@ static int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 }
 
 /***************************************************/
-
-U_BOOT_CMD(
-	i2c, 6, 1, do_i2c,
-	"I2C sub-system",
+static char i2c_help_text[] =
 #if defined(CONFIG_I2C_MUX)
 	"bus [muxtype:muxaddr:muxchannel] - add a new bus reached over muxes\ni2c "
 #endif  /* CONFIG_I2C_MUX */
@@ -1337,7 +1334,12 @@ U_BOOT_CMD(
 #if defined(CONFIG_CMD_SDRAM)
 	"i2c sdram chip - print SDRAM configuration information\n"
 #endif
-	"i2c speed [speed] - show or set I2C bus speed"
+	"i2c speed [speed] - show or set I2C bus speed";
+
+U_BOOT_CMD(
+	i2c, 6, 1, do_i2c,
+	"I2C sub-system",
+	i2c_help_text
 );
 
 #if defined(CONFIG_I2C_MUX)
diff --git a/common/cmd_irq.c b/common/cmd_irq.c
index 9f158ef..70447f1 100644
--- a/common/cmd_irq.c
+++ b/common/cmd_irq.c
@@ -24,7 +24,7 @@
 #include <config.h>
 #include <command.h>
 
-int do_interrupts(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_interrupts(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 
 	if (argc != 2)
diff --git a/common/cmd_itest.c b/common/cmd_itest.c
index d5df758..ec33a93 100644
--- a/common/cmd_itest.c
+++ b/common/cmd_itest.c
@@ -130,7 +130,7 @@ static int arithcomp (char *s, char *t, int op, int w)
 	return (0);
 }
 
-int binary_test (char *op, char *arg1, char *arg2, int w)
+static int binary_test (char *op, char *arg1, char *arg2, int w)
 {
 	int len, i;
 	const op_tbl_t *optp;
@@ -155,7 +155,7 @@ int binary_test (char *op, char *arg1, char *arg2, int w)
 }
 
 /* command line interface to the shell test */
-int do_itest ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] )
+static int do_itest(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	int	value, w;
 
diff --git a/common/cmd_load.c b/common/cmd_load.c
index f4d66de..dd8b7c9 100644
--- a/common/cmd_load.c
+++ b/common/cmd_load.c
@@ -51,7 +51,8 @@ static int do_echo = 1;
 /* -------------------------------------------------------------------- */
 
 #if defined(CONFIG_CMD_LOADS)
-int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc,
+			   char * const argv[])
 {
 	long offset = 0;
 	ulong addr;
@@ -428,12 +429,13 @@ static int k_recv(void);
 static ulong load_serial_bin (ulong offset);
 
 
-char his_eol;        /* character he needs at end of packet */
-int  his_pad_count;  /* number of pad chars he needs */
-char his_pad_char;   /* pad chars he needs */
-char his_quote;      /* quote chars he'll use */
+static char his_eol;        /* character he needs at end of packet */
+static int  his_pad_count;  /* number of pad chars he needs */
+static char his_pad_char;   /* pad chars he needs */
+static char his_quote;      /* quote chars he'll use */
 
-int do_load_serial_bin (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_load_serial_bin (cmd_tbl_t *cmdtp, int flag, int argc,
+			       char * const argv[])
 {
 	ulong offset = 0;
 	ulong addr;
@@ -546,7 +548,7 @@ static ulong load_serial_bin (ulong offset)
 	return offset;
 }
 
-void send_pad (void)
+static void send_pad (void)
 {
 	int count = his_pad_count;
 
@@ -555,7 +557,7 @@ void send_pad (void)
 }
 
 /* converts escaped kermit char to binary char */
-char ktrans (char in)
+static char ktrans (char in)
 {
 	if ((in & 0x60) == 0x40) {
 		return (char) (in & ~0x40);
@@ -565,7 +567,7 @@ char ktrans (char in)
 		return in;
 }
 
-int chk1 (char *buffer)
+static int chk1 (char *buffer)
 {
 	int total = 0;
 
@@ -575,7 +577,7 @@ int chk1 (char *buffer)
 	return (int) ((total + ((total >> 6) & 0x03)) & 0x3f);
 }
 
-void s1_sendpacket (char *packet)
+static void s1_sendpacket (char *packet)
 {
 	send_pad ();
 	while (*packet) {
@@ -584,7 +586,7 @@ void s1_sendpacket (char *packet)
 }
 
 static char a_b[24];
-void send_ack (int n)
+static void send_ack (int n)
 {
 	a_b[0] = START_CHAR;
 	a_b[1] = tochar (3);
@@ -597,7 +599,7 @@ void send_ack (int n)
 	s1_sendpacket (a_b);
 }
 
-void send_nack (int n)
+static void send_nack (int n)
 {
 	a_b[0] = START_CHAR;
 	a_b[1] = tochar (3);
@@ -611,8 +613,8 @@ void send_nack (int n)
 }
 
 
-void (*os_data_init) (void);
-void (*os_data_char) (char new_char);
+static void (*os_data_init) (void);
+static void (*os_data_char) (char new_char);
 static int os_data_state, os_data_state_saved;
 static char *os_data_addr, *os_data_addr_saved;
 static char *bin_start_address;
@@ -654,25 +656,25 @@ static void set_kerm_bin_mode (unsigned long *addr)
 
 /* k_data_* simply handles the kermit escape translations */
 static int k_data_escape, k_data_escape_saved;
-void k_data_init (void)
+static void k_data_init (void)
 {
 	k_data_escape = 0;
 	os_data_init ();
 }
 
-void k_data_save (void)
+static void k_data_save (void)
 {
 	k_data_escape_saved = k_data_escape;
 	os_data_save ();
 }
 
-void k_data_restore (void)
+static void k_data_restore (void)
 {
 	k_data_escape = k_data_escape_saved;
 	os_data_restore ();
 }
 
-void k_data_char (char new_char)
+static void k_data_char (char new_char)
 {
 	if (k_data_escape) {
 		/* last char was escape - translate this character */
@@ -690,12 +692,12 @@ void k_data_char (char new_char)
 }
 
 #define SEND_DATA_SIZE  20
-char send_parms[SEND_DATA_SIZE];
-char *send_ptr;
+static char send_parms[SEND_DATA_SIZE];
+static char *send_ptr;
 
 /* handle_send_packet interprits the protocol info and builds and
    sends an appropriate ack for what we can do */
-void handle_send_packet (int n)
+static void handle_send_packet (int n)
 {
 	int length = 3;
 	int bytes;
diff --git a/common/cmd_mdio.c b/common/cmd_mdio.c
index 77d8df1..ff0063b 100644
--- a/common/cmd_mdio.c
+++ b/common/cmd_mdio.c
@@ -57,9 +57,9 @@ static int extract_range(char *input, int *plo, int *phi)
 	return 0;
 }
 
-int mdio_write_ranges(struct mii_dev *bus, int addrlo,
-			int addrhi, int devadlo, int devadhi,
-			int reglo, int reghi, unsigned short data)
+static int mdio_write_ranges(struct mii_dev *bus, int addrlo,
+			     int addrhi, int devadlo, int devadhi,
+			     int reglo, int reghi, unsigned short data)
 {
 	int addr, devad, reg;
 	int err = 0;
@@ -79,9 +79,9 @@ err_out:
 	return err;
 }
 
-int mdio_read_ranges(struct mii_dev *bus, int addrlo,
-			int addrhi, int devadlo, int devadhi,
-			int reglo, int reghi)
+static int mdio_read_ranges(struct mii_dev *bus, int addrlo,
+			    int addrhi, int devadlo, int devadhi,
+			    int reglo, int reghi)
 {
 	int addr, devad, reg;
 
@@ -112,8 +112,8 @@ int mdio_read_ranges(struct mii_dev *bus, int addrlo,
 }
 
 /* The register will be in the form [a[-b].]x[-y] */
-int extract_reg_range(char *input, int *devadlo, int *devadhi,
-		int *reglo, int *reghi)
+static int extract_reg_range(char *input, int *devadlo, int *devadhi,
+			     int *reglo, int *reghi)
 {
 	char *regstr;
 
@@ -141,8 +141,8 @@ int extract_reg_range(char *input, int *devadlo, int *devadhi,
 	return extract_range(regstr, reglo, reghi);
 }
 
-int extract_phy_range(char *const argv[], int argc, struct mii_dev **bus,
-		int *addrlo, int *addrhi)
+static int extract_phy_range(char *const argv[], int argc, struct mii_dev **bus,
+			     int *addrlo, int *addrhi)
 {
 	struct phy_device *phydev;
 
diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index 18f0a3f..cfaa98c 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -51,7 +51,7 @@ static	ulong	base_address = 0;
  *	md{.b, .w, .l} {addr} {len}
  */
 #define DISP_LINE_LEN	16
-int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_md(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong	addr, length;
 #if defined(CONFIG_HAS_DATAFLASH)
@@ -147,16 +147,16 @@ int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return (rc);
 }
 
-int do_mem_mm ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_mm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	return mod_mem (cmdtp, 1, flag, argc, argv);
 }
-int do_mem_nm ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_nm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	return mod_mem (cmdtp, 0, flag, argc, argv);
 }
 
-int do_mem_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong	addr, writeval, count;
 	int	size;
@@ -253,7 +253,7 @@ int do_mem_mwc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 }
 #endif /* CONFIG_MX_CYCLIC */
 
-int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong	addr1, addr2, count, ngood;
 	int	size;
@@ -323,7 +323,7 @@ int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return rcode;
 }
 
-int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong	addr, dest, count;
 	int	size;
@@ -433,7 +433,8 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return 0;
 }
 
-int do_mem_base (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_base(cmd_tbl_t *cmdtp, int flag, int argc,
+		       char * const argv[])
 {
 	if (argc > 1) {
 		/* Set new base address.
@@ -446,7 +447,8 @@ int do_mem_base (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return 0;
 }
 
-int do_mem_loop (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_loop(cmd_tbl_t *cmdtp, int flag, int argc,
+		       char * const argv[])
 {
 	ulong	addr, length, i;
 	int	size;
@@ -592,7 +594,8 @@ int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until
  * interrupted by ctrl-c or by a failure of one of the sub-tests.
  */
-int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
+		        char * const argv[])
 {
 	vu_long	*addr, *start, *end;
 	ulong	val;
@@ -612,7 +615,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 #if defined(CONFIG_SYS_MEMTEST_SCRATCH)
 	vu_long *dummy = (vu_long*)CONFIG_SYS_MEMTEST_SCRATCH;
 #else
-	vu_long *dummy = 0;	/* yes, this is address 0x0, not NULL */
+	vu_long *dummy = NULL;	/* yes, this is address 0x0, not NULL */
 #endif
 	int	j;
 
@@ -1054,7 +1057,7 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
 
 #ifndef CONFIG_CRC32_VERIFY
 
-int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_crc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong addr, length;
 	ulong crc;
diff --git a/common/cmd_misc.c b/common/cmd_misc.c
index 3b47a0c..5857390 100644
--- a/common/cmd_misc.c
+++ b/common/cmd_misc.c
@@ -27,7 +27,7 @@
 #include <common.h>
 #include <command.h>
 
-int do_sleep (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_sleep (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong start = get_timer(0);
 	ulong delay;
diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index 79a1088..62a1c22 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -115,7 +115,7 @@ static void print_mmcinfo(struct mmc *mmc)
 	printf("Bus Width: %d-bit\n", mmc->bus_width);
 }
 
-int do_mmcinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mmcinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	struct mmc *mmc;
 
@@ -147,7 +147,7 @@ U_BOOT_CMD(
 	"- dislay info of the current MMC device"
 );
 
-int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	enum mmc_state state;
 
@@ -269,7 +269,7 @@ int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			addr = (void *)simple_strtoul(argv[idx], NULL, 16);
 			++idx;
 		} else
-			addr = 0;
+			addr = NULL;
 		blk = simple_strtoul(argv[idx], NULL, 16);
 		cnt = simple_strtoul(argv[idx + 1], NULL, 16);
 
diff --git a/common/cmd_mp.c b/common/cmd_mp.c
index 4b27be4..0de8a5b 100644
--- a/common/cmd_mp.c
+++ b/common/cmd_mp.c
@@ -23,7 +23,7 @@
 #include <common.h>
 #include <command.h>
 
-int
+static int
 cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	unsigned long cpuid;
@@ -61,8 +61,13 @@ cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return 0;
 }
 
+static char cpu_help_text[] =
+	    "<num> reset                 - Reset cpu <num>\n"
+	"cpu <num> status                - Status of cpu <num>\n"
+	"cpu <num> disable               - Disable cpu <num>\n"
+	"cpu <num> release <addr> [args] - Release cpu <num> at <addr> with [args]"
 #ifdef CONFIG_PPC
-#define CPU_ARCH_HELP \
+	"\n"
 	"                         [args] : <pir> <r3> <r6>\n" \
 	"                                   pir - processor id (if writeable)\n" \
 	"                                    r3 - value for gpr 3\n" \
@@ -74,16 +79,9 @@ cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	"     When cpu <num> is released r4 and r5 = 0.\n" \
 	"     r7 will contain the size of the initial mapped area"
 #endif
+	;
 
 U_BOOT_CMD(
 	cpu, CONFIG_SYS_MAXARGS, 1, cpu_cmd,
-	"Multiprocessor CPU boot manipulation and release",
-	    "<num> reset                 - Reset cpu <num>\n"
-	"cpu <num> status                - Status of cpu <num>\n"
-	"cpu <num> disable               - Disable cpu <num>\n"
-	"cpu <num> release <addr> [args] - Release cpu <num> at <addr> with [args]"
-#ifdef CPU_ARCH_HELP
-	"\n"
-	CPU_ARCH_HELP
-#endif
+	"Multiprocessor CPU boot manipulation and release", cpu_help_text
 );
diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c
index 2268829..c057aeb 100644
--- a/common/cmd_mtdparts.c
+++ b/common/cmd_mtdparts.c
@@ -147,14 +147,14 @@ static char last_partition[PARTITION_MAXLEN];
 extern void jffs2_free_cache(struct part_info *part);
 
 /* mtdids mapping list, filled by parse_ids() */
-struct list_head mtdids;
+static struct list_head mtdids;
 
 /* device/partition list, parse_cmdline() parses into here */
-struct list_head devices;
+static struct list_head devices;
 
 /* current active device and partition number */
-struct mtd_device *current_mtd_dev = NULL;
-u8 current_mtd_partnum = 0;
+static struct mtd_device *current_mtd_dev = NULL;
+static u8 current_mtd_partnum = 0;
 
 static struct part_info* mtd_part_info(struct mtd_device *dev, unsigned int part_num);
 
@@ -710,7 +710,7 @@ static int part_parse(const char *const partdef, const char **ret, struct part_i
  * @param size a pointer to the size of the mtd device (output)
  * @return 0 if device is valid, 1 otherwise
  */
-int mtd_device_validate(u8 type, u8 num, u32 *size)
+static int mtd_device_validate(u8 type, u8 num, u32 *size)
 {
 	struct mtd_info *mtd = NULL;
 
@@ -1042,7 +1042,8 @@ static struct mtdids* id_find_by_mtd_id(const char *mtd_id, unsigned int mtd_id_
  * @param dev_num parsed device number (output)
  * @return 0 on success, 1 otherwise
  */
-int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num)
+static int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type,
+			u8 *dev_num)
 {
 	const char *p = id;
 
@@ -1884,7 +1885,7 @@ static struct part_info* mtd_part_info(struct mtd_device *dev, unsigned int part
  * @param argv arguments list
  * @return 0 on success, 1 otherwise
  */
-int do_chpart(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_chpart(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 /* command line only */
 	struct mtd_device *dev;
@@ -1922,7 +1923,8 @@ int do_chpart(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  * @param argv arguments list
  * @return 0 on success, 1 otherwise
  */
-int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc,
+		       char * const argv[])
 {
 	if (argc == 2) {
 		if (strcmp(argv[1], "default") == 0) {
@@ -2046,9 +2048,7 @@ U_BOOT_CMD(
 	"    - change active partition (e.g. part-id = nand0,1)"
 );
 
-U_BOOT_CMD(
-	mtdparts,	6,	0,	do_mtdparts,
-	"define flash/nand partitions",
+static char mtdparts_help_text[] =
 	"\n"
 	"    - list partition table\n"
 	"mtdparts delall\n"
@@ -2090,6 +2090,10 @@ U_BOOT_CMD(
 	"<size>     := standard linux memsize OR '-' to denote all remaining space\n"
 	"<offset>   := partition start offset within the device\n"
 	"<name>     := '(' NAME ')'\n"
-	"<ro-flag>  := when set to 'ro' makes partition read-only (not used, passed to kernel)"
+	"<ro-flag>  := when set to 'ro' makes partition read-only (not used, passed to kernel)";
+
+U_BOOT_CMD(
+	mtdparts,	6,	0,	do_mtdparts,
+	"define flash/nand partitions", mtdparts_help_text
 );
 /***************************************************/
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index e24ed7f..516d709 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -373,8 +373,7 @@ static void nand_print_and_set_info(int idx)
 {
 	nand_info_t *nand = &nand_info[idx];
 	struct nand_chip *chip = nand->priv;
-	const int bufsz = 32;
-	char buf[bufsz];
+	char buf[32];
 
 	printf("Device %d: ", idx);
 	if (chip->numchips > 1)
@@ -429,7 +428,7 @@ static int raw_access(nand_info_t *nand, ulong addr, loff_t off, ulong count,
 	return ret;
 }
 
-int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+static int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 {
 	int i, ret = 0;
 	ulong addr;
@@ -781,9 +780,7 @@ usage:
 	return CMD_RET_USAGE;
 }
 
-U_BOOT_CMD(
-	nand, CONFIG_SYS_MAXARGS, 1, do_nand,
-	"NAND sub-system",
+static char nand_help_text[] =
 	"info - show available NAND devices\n"
 	"nand device [dev] - show or set current device\n"
 	"nand read - addr off|partition size\n"
@@ -829,6 +826,11 @@ U_BOOT_CMD(
 	"nand env.oob set off|partition - set enviromnent offset\n"
 	"nand env.oob get - get environment offset"
 #endif
+	"";
+
+U_BOOT_CMD(
+	nand, CONFIG_SYS_MAXARGS, 1, do_nand,
+	"NAND sub-system", nand_help_text
 );
 
 static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
@@ -913,7 +915,8 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
 	return bootm_maybe_autostart(cmdtp, cmd);
 }
 
-int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+static int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc,
+		       char * const argv[])
 {
 	char *boot_device = NULL;
 	int idx;
diff --git a/common/cmd_net.c b/common/cmd_net.c
index a9ade8b..fb9ef7a 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -30,7 +30,7 @@
 
 static int netboot_common(enum proto_t, cmd_tbl_t *, int, char * const []);
 
-int do_bootp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_bootp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	return netboot_common (BOOTP, cmdtp, argc, argv);
 }
@@ -104,7 +104,7 @@ U_BOOT_CMD(
 #endif
 
 #if defined(CONFIG_CMD_DHCP)
-int do_dhcp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_dhcp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	return netboot_common(DHCP, cmdtp, argc, argv);
 }
@@ -117,7 +117,7 @@ U_BOOT_CMD(
 #endif
 
 #if defined(CONFIG_CMD_NFS)
-int do_nfs (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_nfs (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	return netboot_common(NFS, cmdtp, argc, argv);
 }
@@ -274,7 +274,7 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc,
 }
 
 #if defined(CONFIG_CMD_PING)
-int do_ping (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_ping (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	if (argc < 2)
 		return -1;
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 1f9c674..94cacff 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -136,7 +136,8 @@ static int env_print(char *name)
 	return 0;
 }
 
-int do_env_print (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_env_print(cmd_tbl_t *cmdtp, int flag, int argc,
+			char * const argv[])
 {
 	int i;
 	int rcode = 0;
@@ -325,7 +326,7 @@ int env_check_apply(const char *name, const char *oldval,
  * Set a new environment variable,
  * or replace or delete an existing one.
 */
-int _do_env_set(int flag, int argc, char * const argv[])
+static int _do_env_set(int flag, int argc, char * const argv[])
 {
 	int   i, len;
 	char  *name, *value, *s;
@@ -438,7 +439,7 @@ int setenv_addr(const char *varname, const void *addr)
 }
 
 #ifndef CONFIG_SPL_BUILD
-int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	if (argc < 2)
 		return CMD_RET_USAGE;
@@ -517,7 +518,8 @@ int do_env_ask(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  * Interactively edit an environment variable
  */
 #if defined(CONFIG_CMD_EDITENV)
-int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc,
+		       char * const argv[])
 {
 	char buffer[CONFIG_SYS_CBSIZE];
 	char *init_val;
@@ -625,7 +627,8 @@ ulong getenv_ulong(const char *name, int base, ulong default_val)
 
 #ifndef CONFIG_SPL_BUILD
 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
-int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc,
+		       char * const argv[])
 {
 	printf("Saving Environment to %s...\n", env_name_spec);
 
@@ -1023,9 +1026,7 @@ static int do_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return CMD_RET_USAGE;
 }
 
-U_BOOT_CMD(
-	env, CONFIG_SYS_MAXARGS, 1, do_env,
-	"environment handling commands",
+static char env_help_text[] =
 #if defined(CONFIG_CMD_ASKENV)
 	"ask name [message] [size] - ask for environment variable\nenv "
 #endif
@@ -1050,7 +1051,11 @@ U_BOOT_CMD(
 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
 	"env save - save environment\n"
 #endif
-	"env set [-f] name [arg ...]\n"
+	"env set [-f] name [arg ...]\n";
+
+U_BOOT_CMD(
+	env, CONFIG_SYS_MAXARGS, 1, do_env,
+	"environment handling commands", env_help_text
 );
 
 /*
diff --git a/common/cmd_pci.c b/common/cmd_pci.c
index a1fe519..3b032d8 100644
--- a/common/cmd_pci.c
+++ b/common/cmd_pci.c
@@ -35,8 +35,6 @@
 #include <asm/io.h>
 #include <pci.h>
 
-unsigned char	ShortPCIListing = 1;
-
 /*
  * Follows routines for the output of infos about devices on PCI bus.
  */
@@ -408,7 +406,7 @@ pci_cfg_modify (pci_dev_t bdf, ulong addr, ulong size, ulong value, int incrflag
  *      pci modify[.b, .w, .l] bus.device.function [addr]
  *      pci write[.b, .w, .l] bus.device.function addr value
  */
-int do_pci (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_pci (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong addr = 0, value = 0, size = 0;
 	pci_dev_t bdf = 0;
@@ -485,10 +483,7 @@ int do_pci (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 /***************************************************/
 
-
-U_BOOT_CMD(
-	pci,	5,	1,	do_pci,
-	"list and access PCI Configuration Space",
+static char pci_help_text[] =
 	"[bus] [long]\n"
 	"    - short or long list of PCI devices on bus 'bus'\n"
 #ifdef CONFIG_CMD_PCI_ENUM
@@ -504,5 +499,9 @@ U_BOOT_CMD(
 	"pci modify[.b, .w, .l] b.d.f address\n"
 	"    -  modify, auto increment CFG address\n"
 	"pci write[.b, .w, .l] b.d.f address value\n"
-	"    - write to CFG address"
+	"    - write to CFG address";
+
+U_BOOT_CMD(
+	pci,	5,	1,	do_pci,
+	"list and access PCI Configuration Space", pci_help_text
 );
diff --git a/common/cmd_reginfo.c b/common/cmd_reginfo.c
index 908876c..61371e7 100644
--- a/common/cmd_reginfo.c
+++ b/common/cmd_reginfo.c
@@ -37,7 +37,8 @@ extern void mpc86xx_reginfo(void);
 extern void mpc85xx_reginfo(void);
 #endif
 
-int do_reginfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_reginfo (cmd_tbl_t *cmdtp, int flag, int argc,
+		       char * const argv[])
 {
 #if defined(CONFIG_8xx)
 	volatile immap_t     *immap  = (immap_t *)CONFIG_SYS_IMMR;
diff --git a/common/cmd_sata.c b/common/cmd_sata.c
index 3f98235..b401bd1 100644
--- a/common/cmd_sata.c
+++ b/common/cmd_sata.c
@@ -28,7 +28,7 @@
 #include <part.h>
 #include <sata.h>
 
-int sata_curr_device = -1;
+static int sata_curr_device = -1;
 block_dev_desc_t sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE];
 
 int __sata_initialize(void)
@@ -67,7 +67,7 @@ block_dev_desc_t *sata_get_dev(int dev)
 }
 #endif
 
-int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	int rc = 0;
 
diff --git a/common/cmd_setexpr.c b/common/cmd_setexpr.c
index 1b3edb7..7b140de 100644
--- a/common/cmd_setexpr.c
+++ b/common/cmd_setexpr.c
@@ -50,7 +50,7 @@ static ulong get_arg(char *s, int w)
 	}
 }
 
-int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong a, b;
 	char buf[16];
diff --git a/common/cmd_source.c b/common/cmd_source.c
index c4cde98..7780c71 100644
--- a/common/cmd_source.c
+++ b/common/cmd_source.c
@@ -151,7 +151,7 @@ source (ulong addr, const char *fit_uname)
 
 /**************************************************/
 #if defined(CONFIG_CMD_SOURCE)
-int
+static int
 do_source (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong addr;
@@ -177,9 +177,7 @@ do_source (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return rcode;
 }
 
-U_BOOT_CMD(
-	source, 2, 0,	do_source,
-	"run script from memory",
+static char source_help_text[] =
 	"[addr]\n"
 	"\t- run script starting at addr\n"
 	"\t- A valid image header must be present"
@@ -188,5 +186,10 @@ U_BOOT_CMD(
 	"For FIT format uImage addr must include subimage\n"
 	"unit name in the form of addr:<subimg_uname>"
 #endif
+	"";
+
+U_BOOT_CMD(
+	source, 2, 0,	do_source,
+	"run script from memory", source_help_text
 );
 #endif
diff --git a/common/cmd_test.c b/common/cmd_test.c
index 6da06b9..d4ec186 100644
--- a/common/cmd_test.c
+++ b/common/cmd_test.c
@@ -24,7 +24,7 @@
 #include <common.h>
 #include <command.h>
 
-int do_test(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_test(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	char * const *ap;
 	int left, adv, expr, last_expr, neg, last_cmp;
@@ -150,7 +150,7 @@ U_BOOT_CMD(
 	"[args..]"
 );
 
-int do_false(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_false(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	return 1;
 }
@@ -161,7 +161,7 @@ U_BOOT_CMD(
 	NULL
 );
 
-int do_true(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_true(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	return 0;
 }
diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index c128455..8ad0b23 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -40,7 +40,7 @@ static int usb_ether_curr_dev = -1; /* current ethernet device */
 #endif
 
 /* some display routines (info command) */
-char *usb_get_class_desc(unsigned char dclass)
+static char *usb_get_class_desc(unsigned char dclass)
 {
 	switch (dclass) {
 	case USB_CLASS_PER_INTERFACE:
@@ -66,8 +66,8 @@ char *usb_get_class_desc(unsigned char dclass)
 	}
 }
 
-void usb_display_class_sub(unsigned char dclass, unsigned char subclass,
-			   unsigned char proto)
+static void usb_display_class_sub(unsigned char dclass, unsigned char subclass,
+				  unsigned char proto)
 {
 	switch (dclass) {
 	case USB_CLASS_PER_INTERFACE:
@@ -148,7 +148,7 @@ void usb_display_class_sub(unsigned char dclass, unsigned char subclass,
 	}
 }
 
-void usb_display_string(struct usb_device *dev, int index)
+static void usb_display_string(struct usb_device *dev, int index)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(char, buffer, 256);
 
@@ -158,7 +158,7 @@ void usb_display_string(struct usb_device *dev, int index)
 	}
 }
 
-void usb_display_desc(struct usb_device *dev)
+static void usb_display_desc(struct usb_device *dev)
 {
 	if (dev->descriptor.bDescriptorType == USB_DT_DEVICE) {
 		printf("%d: %s,  USB Revision %x.%x\n", dev->devnum,
@@ -192,8 +192,8 @@ void usb_display_desc(struct usb_device *dev)
 
 }
 
-void usb_display_conf_desc(struct usb_configuration_descriptor *config,
-			   struct usb_device *dev)
+static void usb_display_conf_desc(struct usb_configuration_descriptor *config,
+				  struct usb_device *dev)
 {
 	printf("   Configuration: %d\n", config->bConfigurationValue);
 	printf("   - Interfaces: %d %s%s%dmA\n", config->bNumInterfaces,
@@ -207,8 +207,8 @@ void usb_display_conf_desc(struct usb_configuration_descriptor *config,
 	}
 }
 
-void usb_display_if_desc(struct usb_interface_descriptor *ifdesc,
-			 struct usb_device *dev)
+static void usb_display_if_desc(struct usb_interface_descriptor *ifdesc,
+				struct usb_device *dev)
 {
 	printf("     Interface: %d\n", ifdesc->bInterfaceNumber);
 	printf("     - Alternate Setting %d, Endpoints: %d\n",
@@ -224,7 +224,7 @@ void usb_display_if_desc(struct usb_interface_descriptor *ifdesc,
 	}
 }
 
-void usb_display_ep_desc(struct usb_endpoint_descriptor *epdesc)
+static void usb_display_ep_desc(struct usb_endpoint_descriptor *epdesc)
 {
 	printf("     - Endpoint %d %s ", epdesc->bEndpointAddress & 0xf,
 		(epdesc->bEndpointAddress & 0x80) ? "In" : "Out");
@@ -249,7 +249,7 @@ void usb_display_ep_desc(struct usb_endpoint_descriptor *epdesc)
 }
 
 /* main routine to diasplay the configs, interfaces and endpoints */
-void usb_display_config(struct usb_device *dev)
+static void usb_display_config(struct usb_device *dev)
 {
 	struct usb_config *config;
 	struct usb_interface *ifdesc;
@@ -280,7 +280,7 @@ static inline char *portspeed(int speed)
 }
 
 /* shows the device tree recursively */
-void usb_show_tree_graph(struct usb_device *dev, char *pre)
+static void usb_show_tree_graph(struct usb_device *dev, char *pre)
 {
 	int i, index;
 	int has_child, last_child;
@@ -340,7 +340,7 @@ void usb_show_tree_graph(struct usb_device *dev, char *pre)
 }
 
 /* main routine for the tree command */
-void usb_show_tree(struct usb_device *dev)
+static void usb_show_tree(struct usb_device *dev)
 {
 	char preamble[32];
 
@@ -353,7 +353,7 @@ void usb_show_tree(struct usb_device *dev)
  * usb boot command intepreter. Derived from diskboot
  */
 #ifdef CONFIG_USB_STORAGE
-int do_usbboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_usbboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	return common_diskboot(cmdtp, "usb", argc, argv);
 }
@@ -363,7 +363,7 @@ int do_usbboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 /******************************************************************************
  * usb command intepreter
  */
-int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 
 	int i;
diff --git a/common/cmd_version.c b/common/cmd_version.c
index e4b2ac1..ab4c560 100644
--- a/common/cmd_version.c
+++ b/common/cmd_version.c
@@ -28,7 +28,7 @@
 
 const char __weak version_string[] = U_BOOT_VERSION_STRING;
 
-int do_version(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_version(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	printf("\n%s\n", version_string);
 #ifdef CC_VERSION_STRING
diff --git a/common/cmd_ximg.c b/common/cmd_ximg.c
index 0414589..9ef6048 100644
--- a/common/cmd_ximg.c
+++ b/common/cmd_ximg.c
@@ -42,7 +42,7 @@
 #define CONFIG_SYS_XIMG_LEN	0x800000
 #endif
 
-int
+static int
 do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong		addr = load_addr;
@@ -264,9 +264,7 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 	return 0;
 }
 
-U_BOOT_CMD(
-	imxtract, 4, 1, do_imgextract,
-	"extract a part of a multi-image",
+static char imgextract_help_text[] =
 	"addr part [dest]\n"
 	"    - extract <part> from legacy image at <addr> and copy to <dest>"
 #if defined(CONFIG_FIT)
@@ -274,4 +272,9 @@ U_BOOT_CMD(
 	"addr uname [dest]\n"
 	"    - extract <uname> subimage from FIT image at <addr> and copy to <dest>"
 #endif
+	"";
+
+U_BOOT_CMD(
+	imxtract, 4, 1, do_imgextract,
+	"extract a part of a multi-image", imgextract_help_text
 );
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 13/32] common/misc: sparse fixes
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (11 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 12/32] common/cmd_*.c: " Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-25 17:32   ` Tom Rini
  2012-10-17  0:28 ` [U-Boot] [PATCH 14/32] common/fdt_support.c: " Kim Phillips
                   ` (22 subsequent siblings)
  35 siblings, 1 reply; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

command.c:44:38: error: bad constant expression
console.c:537:18: warning: symbol 'search_device' was not declared. Should it be static?
dlmalloc.c:1468:2: warning: Using plain integer as NULL pointer
dlmalloc.c:1468:5: warning: Using plain integer as NULL pointer
dlmalloc.c:2176:12: warning: Using plain integer as NULL pointer
dlmalloc.c:2179:31: warning: Using plain integer as NULL pointer
dlmalloc.c:2382:14: warning: Using plain integer as NULL pointer
dlmalloc.c:2436:14: warning: Using plain integer as NULL pointer
dlmalloc.c:2582:31: warning: Using plain integer as NULL pointer
dlmalloc.c:2585:17: warning: Using plain integer as NULL pointer
dlmalloc.c:2646:14: warning: Using plain integer as NULL pointer
dlmalloc.c:2659:19: warning: Using plain integer as NULL pointer
dlmalloc.c:2692:19: warning: Using plain integer as NULL pointer
dlmalloc.c:2707:19: warning: Using plain integer as NULL pointer
dlmalloc.c:2708:14: warning: Using plain integer as NULL pointer
dlmalloc.c:2786:31: warning: Using plain integer as NULL pointer
dlmalloc.c:2801:12: warning: Using plain integer as NULL pointer
dlmalloc.c:2801:22: warning: Using plain integer as NULL pointer
dlmalloc.c:2926:27: warning: Using plain integer as NULL pointer
dlmalloc.c:2928:14: warning: Using plain integer as NULL pointer
dlmalloc.c:2929:12: warning: Using plain integer as NULL pointer
dlmalloc.c:3075:14: warning: Using plain integer as NULL pointer
hush.c:292:14: warning: symbol 'last_return_code' was not declared. Should it be static?
hush.c:293:5: warning: symbol 'nesting_level' was not declared. Should it be static?
hush.c:2175:20: warning: Using plain integer as NULL pointer
hush.c:2175:34: warning: Using plain integer as NULL pointer
hush.c:2210:41: warning: Using plain integer as NULL pointer
hush.c:2216:45: warning: Using plain integer as NULL pointer
hush.c:2249:25: warning: Using plain integer as NULL pointer
hush.c:2332:13: warning: symbol 'new_pipe' was not declared. Should it be static?
hush.c:2390:5: warning: symbol 'reserved_word' was not declared. Should it be static?
hush.c:2927:5: warning: symbol 'parse_stream' was not declared. Should it be static?
hush.c:3127:6: warning: symbol 'mapset' was not declared. Should it be static?
hush.c:3133:6: warning: symbol 'update_ifs_map' was not declared. Should it be static?
hush.c:3161:5: warning: symbol 'parse_stream_outer' was not declared. Should it be static?
hush.c:3295:34: warning: Using plain integer as NULL pointer
hush.c:3631:5: warning: symbol 'do_showvar' was not declared. Should it be static
image.c:1282:29: warning: Using plain integer as NULL pointer
image.c:1315:41: warning: Using plain integer as NULL pointer
image.c:1330:25: warning: Using plain integer as NULL pointer
image.c:1706:25: warning: Using plain integer as NULL pointer
main.c:510:10: warning: symbol 'hist_num' was not declared. Should it be static?
main.c:512:5: warning: symbol 'hist_list' was not declared. Should it be static?
main.c:513:6: warning: symbol 'hist_lines' was not declared. Should it be static?
usb_storage.c:195:6: warning: symbol 'usb_show_progress' was not declared. Should it be static?
usb_storage.c:440:48: warning: Using plain integer as NULL pointer
usb_storage.c:503:5: warning: symbol 'usb_stor_BBB_comdat' was not declared. Should it be static?
usb_storage.c:551:5: warning: symbol 'usb_stor_CB_comdat' was not declared. Should it be static?
usb_storage.c:629:55: warning: Using plain integer as NULL pointer
usb_storage.c:620:5: warning: symbol 'usb_stor_CBI_get_status' was not declared. Should it be static?
usb_storage.c:675:43: warning: Using plain integer as NULL pointer
usb_storage.c:668:5: warning: symbol 'usb_stor_BBB_clear_endpt_stall' was not declared. Should it be static?
usb_storage.c:679:5: warning: symbol 'usb_stor_BBB_transport' was not declared. Should it be static?
usb_storage.c:801:5: warning: symbol 'usb_stor_CB_transport' was not declared. Sh
xyzModem.c:104:1: warning: symbol 'CYGACC_COMM_IF_GETC_TIMEOUT' was not declared. Should it be static?
xyzModem.c:122:1: warning: symbol 'CYGACC_COMM_IF_PUTC' was not declared. Should it be static?
xyzModem.c:169:1: warning: symbol 'parse_num' was not declared. Should it be stat

note: hush.c's nesting_level deleted because not used.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 common/command.c     |  9 ++++++++-
 common/console.c     |  2 +-
 common/dlmalloc.c    | 36 ++++++++++++++++++------------------
 common/hush.c        | 30 +++++++++++++++---------------
 common/image.c       |  8 ++++----
 common/main.c        |  6 +++---
 common/usb_storage.c | 20 ++++++++++----------
 common/xyzModem.c    |  6 +++---
 8 files changed, 62 insertions(+), 55 deletions(-)

diff --git a/common/command.c b/common/command.c
index aa0fb0a..c866ac4 100644
--- a/common/command.c
+++ b/common/command.c
@@ -40,8 +40,15 @@ int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
 	int i;
 	int rcode = 0;
 
+	if (cmd_items > CONFIG_SYS_MAXARGS) {
+		printf("%s: cmd_items %d exceeds hardcoded limit %d."
+		       " Recompile with higher CONFIG_SYS_MAXARGS?\n",
+		       __FUNCTION__, cmd_items, CONFIG_SYS_MAXARGS);
+               return -1;
+	}
+
 	if (argc == 1) {	/*show list of commands */
-		cmd_tbl_t *cmd_array[cmd_items];
+		cmd_tbl_t *cmd_array[CONFIG_SYS_MAXARGS];
 		int i, j, swaps;
 
 		/* Make array of commands from .uboot_cmd section */
diff --git a/common/console.c b/common/console.c
index 1177f7d..c780ce8 100644
--- a/common/console.c
+++ b/common/console.c
@@ -534,7 +534,7 @@ inline void dbg(const char *fmt, ...)
 
 /** U-Boot INIT FUNCTIONS *************************************************/
 
-struct stdio_dev *search_device(int flags, const char *name)
+static struct stdio_dev *search_device(int flags, const char *name)
 {
 	struct stdio_dev *dev;
 
diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index 1d7e527..b2f0a1a 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -1465,7 +1465,7 @@ typedef struct malloc_chunk* mbinptr;
 #define IAV(i)  bin_at(i), bin_at(i)
 
 static mbinptr av_[NAV * 2 + 2] = {
- 0, 0,
+ NULL, NULL,
  IAV(0),   IAV(1),   IAV(2),   IAV(3),   IAV(4),   IAV(5),   IAV(6),   IAV(7),
  IAV(8),   IAV(9),   IAV(10),  IAV(11),  IAV(12),  IAV(13),  IAV(14),  IAV(15),
  IAV(16),  IAV(17),  IAV(18),  IAV(19),  IAV(20),  IAV(21),  IAV(22),  IAV(23),
@@ -2173,10 +2173,10 @@ Void_t* mALLOc(bytes) size_t bytes;
   /* check if mem_malloc_init() was run */
   if ((mem_malloc_start == 0) && (mem_malloc_end == 0)) {
     /* not initialized yet */
-    return 0;
+    return NULL;
   }
 
-  if ((long)bytes < 0) return 0;
+  if ((long)bytes < 0) return NULL;
 
   nb = request2size(bytes);  /* padded request size; */
 
@@ -2379,7 +2379,7 @@ Void_t* mALLOc(bytes) size_t bytes;
     /* Try to extend */
     malloc_extend_top(nb);
     if ( (remainder_size = chunksize(top) - nb) < (long)MINSIZE)
-      return 0; /* propagate failure */
+      return NULL; /* propagate failure */
   }
 
   victim = top;
@@ -2433,7 +2433,7 @@ void fREe(mem) Void_t* mem;
   mchunkptr fwd;       /* misc temp for linking */
   int       islr;      /* track whether merging with last_remainder */
 
-  if (mem == 0)                              /* free(0) has no effect */
+  if (mem == NULL)                              /* free(0) has no effect */
     return;
 
   p = mem2chunk(mem);
@@ -2579,10 +2579,10 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
   if (bytes == 0) { fREe(oldmem); return 0; }
 #endif
 
-  if ((long)bytes < 0) return 0;
+  if ((long)bytes < 0) return NULL;
 
   /* realloc of null is supposed to be same as malloc */
-  if (oldmem == 0) return mALLOc(bytes);
+  if (oldmem == NULL) return mALLOc(bytes);
 
   newp    = oldp    = mem2chunk(oldmem);
   newsize = oldsize = chunksize(oldp);
@@ -2643,7 +2643,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
     }
     else
     {
-      next = 0;
+      next = NULL;
       nextsize = 0;
     }
 
@@ -2656,7 +2656,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
 
       /* try forward + backward first to save a later consolidation */
 
-      if (next != 0)
+      if (next != NULL)
       {
 	/* into top */
 	if (next == top)
@@ -2689,7 +2689,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
       }
 
       /* backward only */
-      if (prev != 0 && (long)(prevsize + newsize) >= (long)nb)
+      if (prev != NULL && (long)(prevsize + newsize) >= (long)nb)
       {
 	unlink(prev, bck, fwd);
 	newp = prev;
@@ -2704,8 +2704,8 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
 
     newmem = mALLOc (bytes);
 
-    if (newmem == 0)  /* propagate failure */
-      return 0;
+    if (newmem == NULL)  /* propagate failure */
+      return NULL;
 
     /* Avoid copy if newp is next chunk after oldp. */
     /* (This can only happen when new chunk is sbrk'ed.) */
@@ -2783,7 +2783,7 @@ Void_t* mEMALIGn(alignment, bytes) size_t alignment; size_t bytes;
   mchunkptr remainder;        /* spare room at end to split off */
   long      remainder_size;   /* its size */
 
-  if ((long)bytes < 0) return 0;
+  if ((long)bytes < 0) return NULL;
 
   /* If need less alignment than we give anyway, just relay to malloc */
 
@@ -2798,7 +2798,7 @@ Void_t* mEMALIGn(alignment, bytes) size_t alignment; size_t bytes;
   nb = request2size(bytes);
   m  = (char*)(mALLOc(nb + alignment + MINSIZE));
 
-  if (m == 0) return 0; /* propagate failure */
+  if (m == NULL) return NULL; /* propagate failure */
 
   p = mem2chunk(m);
 
@@ -2923,10 +2923,10 @@ Void_t* cALLOc(n, elem_size) size_t n; size_t elem_size;
 #endif
   Void_t* mem = mALLOc (sz);
 
-  if ((long)n < 0) return 0;
+  if ((long)n < 0) return NULL;
 
-  if (mem == 0)
-    return 0;
+  if (mem == NULL)
+    return NULL;
   else
   {
     p = mem2chunk(mem);
@@ -3072,7 +3072,7 @@ size_t malloc_usable_size(mem) Void_t* mem;
 #endif
 {
   mchunkptr p;
-  if (mem == 0)
+  if (mem == NULL)
     return 0;
   else
   {
diff --git a/common/hush.c b/common/hush.c
index 4c84c2f..68d5f43 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -289,8 +289,7 @@ struct variables {
 char **global_argv;
 unsigned int global_argc;
 #endif
-unsigned int last_return_code;
-int nesting_level;
+static unsigned int last_return_code;
 #ifndef __U_BOOT__
 extern char **environ; /* This is in <unistd.h>, but protected with __USE_GNU */
 #endif
@@ -2172,7 +2171,7 @@ int set_local_var(const char *s, int flg_export)
 	 * NAME=VALUE format.  So the first order of business is to
 	 * split 's' on the '=' into 'name' and 'value' */
 	value = strchr(name, '=');
-	if (value==0 && ++value==0) {
+	if (value==NULL && ++value==NULL) {
 		free(name);
 		return -1;
 	}
@@ -2207,13 +2206,13 @@ int set_local_var(const char *s, int flg_export)
 			result = -1;
 		} else {
 			cur->name = strdup(name);
-			if(cur->name == 0) {
+			if(cur->name == NULL) {
 				free(cur);
 				result = -1;
 			} else {
 				struct variables *bottom = top_vars;
 				cur->value = strdup(value);
-				cur->next = 0;
+				cur->next = NULL;
 				cur->flg_export = flg_export;
 				cur->flg_read_only = 0;
 				while(bottom->next) bottom=bottom->next;
@@ -2246,7 +2245,7 @@ void unset_local_var(const char *name)
 			if(strcmp(cur->name, name)==0)
 				break;
 		}
-		if(cur!=0) {
+		if(cur!=NULL) {
 			struct variables *next = top_vars;
 			if(cur->flg_read_only) {
 				error_msg("%s: readonly variable", name);
@@ -2329,7 +2328,7 @@ static int setup_redirect(struct p_context *ctx, int fd, redir_type style,
 }
 #endif
 
-struct pipe *new_pipe(void) {
+static struct pipe *new_pipe(void) {
 	struct pipe *pi;
 	pi = xmalloc(sizeof(struct pipe));
 	pi->num_progs = 0;
@@ -2387,7 +2386,7 @@ static struct reserved_combo reserved_list[] = {
 };
 #define NRES (sizeof(reserved_list)/sizeof(struct reserved_combo))
 
-int reserved_word(o_string *dest, struct p_context *ctx)
+static int reserved_word(o_string *dest, struct p_context *ctx)
 {
 	struct reserved_combo *r;
 	for (r=reserved_list;
@@ -2924,8 +2923,8 @@ int parse_string(o_string *dest, struct p_context *ctx, const char *src)
 #endif
 
 /* return code is 0 for normal exit, 1 for syntax error */
-int parse_stream(o_string *dest, struct p_context *ctx,
-	struct in_str *input, int end_trigger)
+static int parse_stream(o_string *dest, struct p_context *ctx,
+			struct in_str *input, int end_trigger)
 {
 	unsigned int ch, m;
 #ifndef __U_BOOT__
@@ -3124,13 +3123,13 @@ int parse_stream(o_string *dest, struct p_context *ctx,
 	return 0;
 }
 
-void mapset(const unsigned char *set, int code)
+static void mapset(const unsigned char *set, int code)
 {
 	const unsigned char *s;
 	for (s=set; *s; s++) map[*s] = code;
 }
 
-void update_ifs_map(void)
+static void update_ifs_map(void)
 {
 	/* char *ifs and char map[256] are both globals. */
 	ifs = (uchar *)getenv("IFS");
@@ -3158,7 +3157,7 @@ void update_ifs_map(void)
 
 /* most recursion does not come through here, the exeception is
  * from builtin_source() */
-int parse_stream_outer(struct in_str *inp, int flag)
+static int parse_stream_outer(struct in_str *inp, int flag)
 {
 
 	struct p_context ctx;
@@ -3292,7 +3291,7 @@ int u_boot_hush_start(void)
 		top_vars = malloc(sizeof(struct variables));
 		top_vars->name = "HUSH_VERSION";
 		top_vars->value = "0.01";
-		top_vars->next = 0;
+		top_vars->next = NULL;
 		top_vars->flg_export = 0;
 		top_vars->flg_read_only = 1;
 #ifdef CONFIG_NEEDS_MANUAL_RELOC
@@ -3628,7 +3627,8 @@ static char * make_string(char ** inp)
 }
 
 #ifdef __U_BOOT__
-int do_showvar (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_showvar (cmd_tbl_t *cmdtp, int flag, int argc,
+		       char * const argv[])
 {
 	int i, k;
 	int rcode = 0;
diff --git a/common/image.c b/common/image.c
index f084d2b..8b5c0d5 100644
--- a/common/image.c
+++ b/common/image.c
@@ -1279,7 +1279,7 @@ void boot_fdt_add_mem_rsv_regions(struct lmb *lmb, void *fdt_blob)
 int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size)
 {
 	void	*fdt_blob = *of_flat_tree;
-	void	*of_start = 0;
+	void	*of_start = NULL;
 	char	*fdt_high;
 	ulong	of_len = 0;
 	int	err;
@@ -1312,7 +1312,7 @@ int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size)
 			of_start =
 			    (void *)(ulong) lmb_alloc_base(lmb, of_len, 0x1000,
 							   (ulong)desired_addr);
-			if (of_start == 0) {
+			if (of_start == NULL) {
 				puts("Failed using fdt_high value for Device Tree");
 				goto error;
 			}
@@ -1327,7 +1327,7 @@ int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size)
 						   + getenv_bootm_low());
 	}
 
-	if (of_start == 0) {
+	if (of_start == NULL) {
 		puts("device tree - allocation error\n");
 		goto error;
 	}
@@ -1703,7 +1703,7 @@ int boot_get_fdt(int flag, int argc, char * const argv[],
 	return 0;
 
 error:
-	*of_flat_tree = 0;
+	*of_flat_tree = NULL;
 	*of_size = 0;
 	return 1;
 }
diff --git a/common/main.c b/common/main.c
index 9507cec..0fd62e4 100644
--- a/common/main.c
+++ b/common/main.c
@@ -508,10 +508,10 @@ void reset_cmd_timeout(void)
 static int hist_max = 0;
 static int hist_add_idx = 0;
 static int hist_cur = -1;
-unsigned hist_num = 0;
+static unsigned hist_num = 0;
 
-char* hist_list[HIST_MAX];
-char hist_lines[HIST_MAX][HIST_SIZE + 1];	 /* Save room for NULL */
+static char* hist_list[HIST_MAX];
+static char hist_lines[HIST_MAX][HIST_SIZE + 1];	/* Save room for NULL */
 
 #define add_idx_minus_one() ((hist_add_idx == 0) ? hist_max : hist_add_idx-1)
 
diff --git a/common/usb_storage.c b/common/usb_storage.c
index 950451e..8382006 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -192,7 +192,7 @@ block_dev_desc_t *usb_stor_get_dev(int index)
 }
 #endif
 
-void usb_show_progress(void)
+static void usb_show_progress(void)
 {
 	debug(".");
 }
@@ -437,7 +437,7 @@ static int usb_stor_BBB_reset(struct us_data *us)
 	result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev, 0),
 				 US_BBB_RESET,
 				 USB_TYPE_CLASS | USB_RECIP_INTERFACE,
-				 0, us->ifnum, 0, 0, USB_CNTL_TIMEOUT * 5);
+				 0, us->ifnum, NULL, 0, USB_CNTL_TIMEOUT * 5);
 
 	if ((result < 0) && (us->pusb_dev->status & USB_ST_STALLED)) {
 		USB_STOR_PRINTF("RESET:stall\n");
@@ -500,7 +500,7 @@ static int usb_stor_CB_reset(struct us_data *us)
  * Set up the command for a BBB device. Note that the actual SCSI
  * command is copied into cbw.CBWCDB.
  */
-int usb_stor_BBB_comdat(ccb *srb, struct us_data *us)
+static int usb_stor_BBB_comdat(ccb *srb, struct us_data *us)
 {
 	int result;
 	int actlen;
@@ -548,7 +548,7 @@ int usb_stor_BBB_comdat(ccb *srb, struct us_data *us)
 /* FIXME: we also need a CBI_command which sets up the completion
  * interrupt, and waits for it
  */
-int usb_stor_CB_comdat(ccb *srb, struct us_data *us)
+static int usb_stor_CB_comdat(ccb *srb, struct us_data *us)
 {
 	int result = 0;
 	int dir_in, retry;
@@ -617,7 +617,7 @@ int usb_stor_CB_comdat(ccb *srb, struct us_data *us)
 }
 
 
-int usb_stor_CBI_get_status(ccb *srb, struct us_data *us)
+static int usb_stor_CBI_get_status(ccb *srb, struct us_data *us)
 {
 	int timeout;
 
@@ -626,7 +626,7 @@ int usb_stor_CBI_get_status(ccb *srb, struct us_data *us)
 			(void *) &us->ip_data, us->irqmaxp, us->irqinterval);
 	timeout = 1000;
 	while (timeout--) {
-		if ((volatile int *) us->ip_wanted == 0)
+		if ((volatile int *) us->ip_wanted == NULL)
 			break;
 		mdelay(10);
 	}
@@ -665,18 +665,18 @@ int usb_stor_CBI_get_status(ccb *srb, struct us_data *us)
 #define USB_TRANSPORT_NOT_READY_RETRY 10
 
 /* clear a stall on an endpoint - special for BBB devices */
-int usb_stor_BBB_clear_endpt_stall(struct us_data *us, __u8 endpt)
+static int usb_stor_BBB_clear_endpt_stall(struct us_data *us, __u8 endpt)
 {
 	int result;
 
 	/* ENDPOINT_HALT = 0, so set value to 0 */
 	result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev, 0),
 				USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT,
-				0, endpt, 0, 0, USB_CNTL_TIMEOUT * 5);
+				0, endpt, NULL, 0, USB_CNTL_TIMEOUT * 5);
 	return result;
 }
 
-int usb_stor_BBB_transport(ccb *srb, struct us_data *us)
+static int usb_stor_BBB_transport(ccb *srb, struct us_data *us)
 {
 	int result, retry;
 	int dir_in;
@@ -798,7 +798,7 @@ again:
 	return result;
 }
 
-int usb_stor_CB_transport(ccb *srb, struct us_data *us)
+static int usb_stor_CB_transport(ccb *srb, struct us_data *us)
 {
 	int result, status;
 	ccb *psrb;
diff --git a/common/xyzModem.c b/common/xyzModem.c
index a1f955b..f30b002 100644
--- a/common/xyzModem.c
+++ b/common/xyzModem.c
@@ -100,7 +100,7 @@ static struct
 
 #ifndef REDBOOT			/*SB */
 typedef int cyg_int32;
-int
+static int
 CYGACC_COMM_IF_GETC_TIMEOUT (char chan, char *c)
 {
 #define DELAY 20
@@ -118,7 +118,7 @@ CYGACC_COMM_IF_GETC_TIMEOUT (char chan, char *c)
   return 0;
 }
 
-void
+static void
 CYGACC_COMM_IF_PUTC (char x, char y)
 {
   putc (y);
@@ -165,7 +165,7 @@ _tolower (char c)
 }
 
 /* Parse (scan) a number */
-bool
+static bool
 parse_num (char *s, unsigned long *val, char **es, char *delim)
 {
   bool first = true;
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 14/32] common/fdt_support.c: sparse fixes
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (12 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 13/32] common/misc: " Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 15/32] net/: " Kim Phillips
                   ` (21 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

trivial:

fdt_support.c:89:64: warning: Using plain integer as NULL pointer
fdt_support.c:325:65: warning: Using plain integer as NULL pointer
fdt_support.c:352:65: warning: Using plain integer as NULL pointer

For the following bad constant expression, We hardcode the max. number of
memory banks to four for the foreseeable future, and add an error with
instructions on what to do once it's exceeded:

fdt_support.c:397:22: error: bad constant expression

For the rest below, sparse found a couple of wrong endian conversions
in of_bus_default_translate() and fdt_get_base_address(), but
otherwise the rest is mostly annotation fixes:

fdt_support.c:64:24: warning: cast to restricted __be32
fdt_support.c:192:21: warning: incorrect type in assignment (different base types)
fdt_support.c:192:21:    expected unsigned int [unsigned] [usertype] tmp
fdt_support.c:192:21:    got restricted __be32 [usertype] <noident>
fdt_support.c:201:21: warning: incorrect type in assignment (different base types)
fdt_support.c:201:21:    expected unsigned int [unsigned] [addressable] [usertype] tmp
fdt_support.c:201:21:    got restricted __be32 [usertype] <noident>
fdt_support.c:304:13: warning: incorrect type in assignment (different base types)
fdt_support.c:304:13:    expected unsigned int [unsigned] [usertype] val
fdt_support.c:304:13:    got restricted __be32 [usertype] <noident>
fdt_support.c:333:13: warning: incorrect type in assignment (different base types)
fdt_support.c:333:13:    expected unsigned int [unsigned] [usertype] val
fdt_support.c:333:13:    got restricted __be32 [usertype] <noident>
fdt_support.c:359:13: warning: incorrect type in assignment (different base types)
fdt_support.c:359:13:    expected unsigned int [unsigned] [usertype] val
fdt_support.c:359:13:    got restricted __be32 [usertype] <noident>
fdt_support.c:373:21: warning: cast to restricted __be32
fdt_support.c:963:48: warning: incorrect type in argument 1 (different base types)
fdt_support.c:963:48:    expected restricted __be32 const [usertype] *p
fdt_support.c:963:48:    got unsigned int [usertype] *<noident>
fdt_support.c:971:48: warning: incorrect type in argument 1 (different base types)
fdt_support.c:971:48:    expected restricted __be32 const [usertype] *p
fdt_support.c:971:48:    got unsigned int [usertype] *<noident>
fdt_support.c:984:29: warning: incorrect type in argument 1 (different base types)
fdt_support.c:984:29:    expected restricted __be32 const [usertype] *cell
fdt_support.c:984:29:    got unsigned int [usertype] *addr
fdt_support.c:996:32: warning: incorrect type in argument 1 (different base types)
fdt_support.c:996:32:    expected restricted __be32 const [usertype] *cell
fdt_support.c:996:32:    got unsigned int [usertype] *addr
fdt_support.c:1041:41: warning: incorrect type in argument 1 (different base types)
fdt_support.c:1041:41:    expected restricted __be32 const [usertype] *cell
fdt_support.c:1041:41:    got unsigned int [usertype] *addr
fdt_support.c:1053:41: warning: incorrect type in argument 2 (different base types)
fdt_support.c:1053:41:    expected restricted __be32 const [usertype] *range
fdt_support.c:1053:41:    got unsigned int const [usertype] *[assigned] ranges
fdt_support.c:1064:53: warning: incorrect type in argument 2 (different base types)
fdt_support.c:1064:53:    expected restricted __be32 const [usertype] *addr
fdt_support.c:1064:53:    got unsigned int [usertype] *addr
fdt_support.c:1110:50: warning: incorrect type in argument 2 (different base types)
fdt_support.c:1110:50:    expected restricted __be32 const [usertype] *addr
fdt_support.c:1110:50:    got unsigned int *<noident>
fdt_support.c:1121:49: warning: incorrect type in argument 1 (different base types)
fdt_support.c:1121:49:    expected restricted __be32 const [usertype] *cell
fdt_support.c:1121:49:    got unsigned int *<noident>
fdt_support.c:1147:60: warning: incorrect type in argument 2 (different base types)
fdt_support.c:1147:60:    expected restricted __be32 const [usertype] *addr
fdt_support.c:1147:60:    got unsigned int *<noident>
fdt_support.c:1081:5: warning: symbol '__of_translate_address' was not declared. Should it be static?
fdt_support.c:1154:5: error: symbol 'fdt_translate_address' redeclared with different type (originally declared at include/fdt_support.h:95) - incompatible argument 3 (different base types)
fdt_support.c: In function 'fdt_node_offset_by_compat_reg':
fdt_support.c:1173:17: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]

See also linux kernel commit 0131d897 "of/address: use proper
endianess in get_flags".

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 arch/powerpc/cpu/mpc85xx/fdt.c |  2 +-
 common/fdt_support.c           | 78 +++++++++++++++++++++++-------------------
 include/fdt_support.h          |  2 +-
 3 files changed, 45 insertions(+), 37 deletions(-)

diff --git a/arch/powerpc/cpu/mpc85xx/fdt.c b/arch/powerpc/cpu/mpc85xx/fdt.c
index a0a9b4c..e57d69c 100644
--- a/arch/powerpc/cpu/mpc85xx/fdt.c
+++ b/arch/powerpc/cpu/mpc85xx/fdt.c
@@ -761,7 +761,7 @@ int ft_verify_fdt(void *fdt)
 #ifdef CONFIG_SYS_LBC_ADDR
 	off = fdt_node_offset_by_compatible(fdt, -1, "fsl,elbc");
 	if (off > 0) {
-		const u32 *reg = fdt_getprop(fdt, off, "reg", NULL);
+		const __be32 *reg = fdt_getprop(fdt, off, "reg", NULL);
 		if (reg) {
 			uint64_t uaddr = CCSR_VIRT_TO_PHYS(CONFIG_SYS_LBC_ADDR);
 
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 963ea90..f1c3dfb 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -52,7 +52,7 @@ DECLARE_GLOBAL_DATA_PTR;
 u32 fdt_getprop_u32_default(const void *fdt, const char *path,
 				const char *prop, const u32 dflt)
 {
-	const u32 *val;
+	const __be32 *val;
 	int off;
 
 	off = fdt_path_offset(fdt, path);
@@ -86,7 +86,7 @@ int fdt_find_and_setprop(void *fdt, const char *node, const char *prop,
 	if (nodeoff < 0)
 		return nodeoff;
 
-	if ((!create) && (fdt_get_property(fdt, nodeoff, prop, 0) == NULL))
+	if ((!create) && (fdt_get_property(fdt, nodeoff, prop, NULL) == NULL))
 		return 0; /* create flag not set; so exit quietly */
 
 	return fdt_setprop(fdt, nodeoff, prop, val, len);
@@ -150,7 +150,7 @@ int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end, int force)
 {
 	int   nodeoffset;
 	int   err, j, total;
-	u32   tmp;
+	__be32   tmp;
 	const char *path;
 	uint64_t addr, size;
 
@@ -301,8 +301,8 @@ void do_fixup_by_path(void *fdt, const char *path, const char *prop,
 void do_fixup_by_path_u32(void *fdt, const char *path, const char *prop,
 			  u32 val, int create)
 {
-	val = cpu_to_fdt32(val);
-	do_fixup_by_path(fdt, path, prop, &val, sizeof(val), create);
+	__be32 tmp = cpu_to_fdt32(val);
+	do_fixup_by_path(fdt, path, prop, &tmp, sizeof(tmp), create);
 }
 
 void do_fixup_by_prop(void *fdt,
@@ -320,7 +320,7 @@ void do_fixup_by_prop(void *fdt,
 #endif
 	off = fdt_node_offset_by_prop_value(fdt, -1, pname, pval, plen);
 	while (off != -FDT_ERR_NOTFOUND) {
-		if (create || (fdt_get_property(fdt, off, prop, 0) != NULL))
+		if (create || (fdt_get_property(fdt, off, prop, NULL) != NULL))
 			fdt_setprop(fdt, off, prop, val, len);
 		off = fdt_node_offset_by_prop_value(fdt, off, pname, pval, plen);
 	}
@@ -330,8 +330,8 @@ void do_fixup_by_prop_u32(void *fdt,
 			  const char *pname, const void *pval, int plen,
 			  const char *prop, u32 val, int create)
 {
-	val = cpu_to_fdt32(val);
-	do_fixup_by_prop(fdt, pname, pval, plen, prop, &val, 4, create);
+	__be32 tmp = cpu_to_fdt32(val);
+	do_fixup_by_prop(fdt, pname, pval, plen, prop, &tmp, 4, create);
 }
 
 void do_fixup_by_compat(void *fdt, const char *compat,
@@ -347,7 +347,7 @@ void do_fixup_by_compat(void *fdt, const char *compat,
 #endif
 	off = fdt_node_offset_by_compatible(fdt, -1, compat);
 	while (off != -FDT_ERR_NOTFOUND) {
-		if (create || (fdt_get_property(fdt, off, prop, 0) != NULL))
+		if (create || (fdt_get_property(fdt, off, prop, NULL) != NULL))
 			fdt_setprop(fdt, off, prop, val, len);
 		off = fdt_node_offset_by_compatible(fdt, off, compat);
 	}
@@ -356,8 +356,8 @@ void do_fixup_by_compat(void *fdt, const char *compat,
 void do_fixup_by_compat_u32(void *fdt, const char *compat,
 			    const char *prop, u32 val, int create)
 {
-	val = cpu_to_fdt32(val);
-	do_fixup_by_compat(fdt, compat, prop, &val, 4, create);
+	__be32 tmp = cpu_to_fdt32(val);
+	do_fixup_by_compat(fdt, compat, prop, &tmp, 4, create);
 }
 
 /*
@@ -367,7 +367,7 @@ void do_fixup_by_compat_u32(void *fdt, const char *compat,
  */
 static int get_cells_len(void *blob, char *nr_cells_name)
 {
-	const u32 *cell;
+	const __be32 *cell;
 
 	cell = fdt_getprop(blob, 0, nr_cells_name, NULL);
 	if (cell && fdt32_to_cpu(*cell) == 2)
@@ -388,13 +388,21 @@ static void write_cell(u8 *addr, u64 val, int size)
 	}
 }
 
+#define MEMORY_BANKS_MAX 4
 int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks)
 {
 	int err, nodeoffset;
 	int addr_cell_len, size_cell_len, len;
-	u8 tmp[banks * 16]; /* Up to 64-bit address + 64-bit size */
+	u8 tmp[MEMORY_BANKS_MAX * 16]; /* Up to 64-bit address + 64-bit size */
 	int bank;
 
+	if (banks > MEMORY_BANKS_MAX) {
+		printf("%s: num banks %d exceeds hardcoded limit %d."
+		       " Recompile with higher MEMORY_BANKS_MAX?\n",
+		       __FUNCTION__, banks, MEMORY_BANKS_MAX);
+		return -1;
+	}
+
 	err = fdt_check_header(blob);
 	if (err < 0) {
 		printf("%s: %s\n", __FUNCTION__, fdt_strerror(err));
@@ -921,7 +929,7 @@ static inline u64 of_read_number(const __be32 *cell, int size)
 
 /* Debug utility */
 #ifdef DEBUG
-static void of_dump_addr(const char *s, const u32 *addr, int na)
+static void of_dump_addr(const char *s, const __be32 *addr, int na)
 {
 	printf("%s", s);
 	while(na--)
@@ -929,7 +937,7 @@ static void of_dump_addr(const char *s, const u32 *addr, int na)
 	printf("\n");
 }
 #else
-static void of_dump_addr(const char *s, const u32 *addr, int na) { }
+static void of_dump_addr(const char *s, const __be32 *addr, int na) { }
 #endif
 
 /* Callbacks for bus specific translators */
@@ -938,21 +946,21 @@ struct of_bus {
 	const char	*addresses;
 	void		(*count_cells)(void *blob, int parentoffset,
 				int *addrc, int *sizec);
-	u64		(*map)(u32 *addr, const u32 *range,
+	u64		(*map)(__be32 *addr, const __be32 *range,
 				int na, int ns, int pna);
-	int		(*translate)(u32 *addr, u64 offset, int na);
+	int		(*translate)(__be32 *addr, u64 offset, int na);
 };
 
 /* Default translator (generic bus) */
 static void of_bus_default_count_cells(void *blob, int parentoffset,
 					int *addrc, int *sizec)
 {
-	const u32 *prop;
+	const __be32 *prop;
 
 	if (addrc) {
 		prop = fdt_getprop(blob, parentoffset, "#address-cells", NULL);
 		if (prop)
-			*addrc = be32_to_cpup((u32 *)prop);
+			*addrc = be32_to_cpup(prop);
 		else
 			*addrc = 2;
 	}
@@ -960,13 +968,13 @@ static void of_bus_default_count_cells(void *blob, int parentoffset,
 	if (sizec) {
 		prop = fdt_getprop(blob, parentoffset, "#size-cells", NULL);
 		if (prop)
-			*sizec = be32_to_cpup((u32 *)prop);
+			*sizec = be32_to_cpup(prop);
 		else
 			*sizec = 1;
 	}
 }
 
-static u64 of_bus_default_map(u32 *addr, const u32 *range,
+static u64 of_bus_default_map(__be32 *addr, const __be32 *range,
 		int na, int ns, int pna)
 {
 	u64 cp, s, da;
@@ -983,14 +991,14 @@ static u64 of_bus_default_map(u32 *addr, const u32 *range,
 	return da - cp;
 }
 
-static int of_bus_default_translate(u32 *addr, u64 offset, int na)
+static int of_bus_default_translate(__be32 *addr, u64 offset, int na)
 {
 	u64 a = of_read_number(addr, na);
 	memset(addr, 0, na * 4);
 	a += offset;
 	if (na > 1)
-		addr[na - 2] = a >> 32;
-	addr[na - 1] = a & 0xffffffffu;
+		addr[na - 2] = cpu_to_be32(a >> 32);
+	addr[na - 1] = cpu_to_be32(a & 0xffffffffu);
 
 	return 0;
 }
@@ -1008,10 +1016,10 @@ static struct of_bus of_busses[] = {
 };
 
 static int of_translate_one(void * blob, int parent, struct of_bus *bus,
-			    struct of_bus *pbus, u32 *addr,
+			    struct of_bus *pbus, __be32 *addr,
 			    int na, int ns, int pna, const char *rprop)
 {
-	const u32 *ranges;
+	const __be32 *ranges;
 	int rlen;
 	int rone;
 	u64 offset = OF_BAD_ADDR;
@@ -1028,7 +1036,7 @@ static int of_translate_one(void * blob, int parent, struct of_bus *bus,
 	 * to translate addresses that aren't supposed to be translated in
 	 * the first place. --BenH.
 	 */
-	ranges = (u32 *)fdt_getprop(blob, parent, rprop, &rlen);
+	ranges = fdt_getprop(blob, parent, rprop, &rlen);
 	if (ranges == NULL || rlen == 0) {
 		offset = of_read_number(addr, na);
 		memset(addr, 0, pna * 4);
@@ -1070,12 +1078,12 @@ static int of_translate_one(void * blob, int parent, struct of_bus *bus,
  * that can be mapped to a cpu physical address). This is not really specified
  * that way, but this is traditionally the way IBM at least do things
  */
-u64 __of_translate_address(void *blob, int node_offset, const u32 *in_addr,
-			   const char *rprop)
+static u64 __of_translate_address(void *blob, int node_offset, const __be32 *in_addr,
+				  const char *rprop)
 {
 	int parent;
 	struct of_bus *bus, *pbus;
-	u32 addr[OF_MAX_ADDR_CELLS];
+	__be32 addr[OF_MAX_ADDR_CELLS];
 	int na, ns, pna, pns;
 	u64 result = OF_BAD_ADDR;
 
@@ -1143,7 +1151,7 @@ u64 __of_translate_address(void *blob, int node_offset, const u32 *in_addr,
 	return result;
 }
 
-u64 fdt_translate_address(void *blob, int node_offset, const u32 *in_addr)
+u64 fdt_translate_address(void *blob, int node_offset, const __be32 *in_addr)
 {
 	return __of_translate_address(blob, node_offset, in_addr, "ranges");
 }
@@ -1162,7 +1170,7 @@ int fdt_node_offset_by_compat_reg(void *blob, const char *compat,
 {
 	int len, off = fdt_node_offset_by_compatible(blob, -1, compat);
 	while (off != -FDT_ERR_NOTFOUND) {
-		u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", &len);
+		const __be32 *reg = fdt_getprop(blob, off, "reg", &len);
 		if (reg) {
 			if (compat_off == fdt_translate_address(blob, off, reg))
 				return off;
@@ -1356,7 +1364,7 @@ err_size:
 int fdt_verify_alias_address(void *fdt, int anode, const char *alias, u64 addr)
 {
 	const char *path;
-	const u32 *reg;
+	const __be32 *reg;
 	int node, len;
 	u64 dt_addr;
 
@@ -1398,11 +1406,11 @@ u64 fdt_get_base_address(void *fdt, int node)
 {
 	int size;
 	u32 naddr;
-	const u32 *prop;
+	const __be32 *prop;
 
 	prop = fdt_getprop(fdt, node, "#address-cells", &size);
 	if (prop && size == 4)
-		naddr = *prop;
+		naddr = be32_to_cpup(prop);
 	else
 		naddr = 2;
 
diff --git a/include/fdt_support.h b/include/fdt_support.h
index 4b9f84a..2e18d82 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -92,7 +92,7 @@ int fdt_fixup_nor_flash_size(void *blob);
 
 void fdt_fixup_mtdparts(void *fdt, void *node_info, int node_info_size);
 void fdt_del_node_and_alias(void *blob, const char *alias);
-u64 fdt_translate_address(void *blob, int node_offset, const u32 *in_addr);
+u64 fdt_translate_address(void *blob, int node_offset, const __be32 *in_addr);
 int fdt_node_offset_by_compat_reg(void *blob, const char *compat,
 					phys_addr_t compat_off);
 int fdt_alloc_phandle(void *blob);
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 15/32] net/: sparse fixes
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (13 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 14/32] common/fdt_support.c: " Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 16/32] drivers/net/: " Kim Phillips
                   ` (20 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

bootp.c:44:14: warning: symbol 'dhcp_state' was not declared. Should it be static?
bootp.c:45:15: warning: symbol 'dhcp_leasetime' was not declared. Should it be static?
bootp.c:46:10: warning: symbol 'NetDHCPServerIP' was not declared. Should it be static?
arp.c:30:17: warning: symbol 'NetArpWaitReplyIP' was not declared. Should it be static?
arp.c:37:16: warning: symbol 'NetArpTxPacket' was not declared. Should it be static?
arp.c:38:17: warning: symbol 'NetArpPacketBuf' was not declared. Should it be static?
atheros.c:33:19: warning: symbol 'AR8021_driver' was not declared. Should it be static?
net.c:183:7: warning: symbol 'PktBuf' was not declared. Should it be static?
net.c:159:21: warning: symbol 'net_state' was not declared. Should it be static?
ping.c:73:6: warning: symbol 'ping_start' was not declared. Should it be static?
ping.c:82:13: warning: symbol 'ping_receive' was not declared. Should it be static?
tftp.c:53:7: warning: symbol 'TftpRRQTimeoutMSecs' was not declared. Should it be static?
tftp.c:54:5: warning: symbol 'TftpRRQTimeoutCountMax' was not declared. Should it be static?
eth.c:125:19: warning: symbol 'eth_current' was not declared. Should it be static?

Note: in the ping.c fix, commit a36b12f95a29647a06b5459198684fc142482020
"net: Move PING out of net.c" mistakenly carried the ifdef CMD_PING
clause from when it was necessary to avoid warnings when it was embedded
in net.c.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 common/update.c           | 1 +
 drivers/net/phy/atheros.c | 2 +-
 include/net.h             | 9 +++++----
 net/arp.c                 | 6 +++---
 net/bootp.c               | 6 +++---
 net/net.c                 | 2 +-
 net/ping.h                | 3 ---
 net/tftp.h                | 3 +++
 8 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/common/update.c b/common/update.c
index 5b1a064..94d6a82 100644
--- a/common/update.c
+++ b/common/update.c
@@ -37,6 +37,7 @@
 #include <command.h>
 #include <flash.h>
 #include <net.h>
+#include <net/tftp.h>
 #include <malloc.h>
 
 /* env variable holding the location of the update file */
diff --git a/drivers/net/phy/atheros.c b/drivers/net/phy/atheros.c
index 798473d..9b3808b 100644
--- a/drivers/net/phy/atheros.c
+++ b/drivers/net/phy/atheros.c
@@ -30,7 +30,7 @@ static int ar8021_config(struct phy_device *phydev)
 	return 0;
 }
 
-struct phy_driver AR8021_driver =  {
+static struct phy_driver AR8021_driver =  {
 	.name = "AR8021",
 	.uid = 0x4dd040,
 	.mask = 0xfffff0,
diff --git a/include/net.h b/include/net.h
index 3539336..970d4d1 100644
--- a/include/net.h
+++ b/include/net.h
@@ -102,12 +102,13 @@ extern int eth_register(struct eth_device* dev);/* Register network device */
 extern int eth_unregister(struct eth_device *dev);/* Remove network device */
 extern void eth_try_another(int first_restart);	/* Change the device */
 extern void eth_set_current(void);		/* set nterface to ethcur var */
+
 /* get the current device MAC */
+extern struct eth_device *eth_current;
+
 static inline __attribute__((always_inline))
 struct eth_device *eth_get_dev(void)
 {
-	extern struct eth_device *eth_current;
-
 	return eth_current;
 }
 extern struct eth_device *eth_get_dev_by_name(const char *devname);
@@ -517,10 +518,10 @@ enum net_loop_state {
 	NETLOOP_SUCCESS,
 	NETLOOP_FAIL
 };
+extern enum net_loop_state net_state;
+
 static inline void net_set_state(enum net_loop_state state)
 {
-	extern enum net_loop_state net_state;
-
 	debug_cond(DEBUG_INT_STATE, "--- NetState set to %d\n", state);
 	net_state = state;
 }
diff --git a/net/arp.c b/net/arp.c
index 8e1d2ed..20c6b2d 100644
--- a/net/arp.c
+++ b/net/arp.c
@@ -27,15 +27,15 @@
 #endif
 
 IPaddr_t	NetArpWaitPacketIP;
-IPaddr_t	NetArpWaitReplyIP;
+static IPaddr_t	NetArpWaitReplyIP;
 /* MAC address of waiting packet's destination */
 uchar	       *NetArpWaitPacketMAC;
 int		NetArpWaitTxPacketSize;
 ulong		NetArpWaitTimerStart;
 int		NetArpWaitTry;
 
-uchar	       *NetArpTxPacket;	/* THE ARP transmit packet */
-uchar		NetArpPacketBuf[PKTSIZE_ALIGN + PKTALIGN];
+static uchar   *NetArpTxPacket;	/* THE ARP transmit packet */
+static uchar	NetArpPacketBuf[PKTSIZE_ALIGN + PKTALIGN];
 
 void ArpInit(void)
 {
diff --git a/net/bootp.c b/net/bootp.c
index cd5c5dd..4300f1c 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -41,9 +41,9 @@ ulong		BootpID;
 int		BootpTry;
 
 #if defined(CONFIG_CMD_DHCP)
-dhcp_state_t dhcp_state = INIT;
-unsigned long dhcp_leasetime;
-IPaddr_t NetDHCPServerIP;
+static dhcp_state_t dhcp_state = INIT;
+static unsigned long dhcp_leasetime;
+static IPaddr_t NetDHCPServerIP;
 static void DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
 			unsigned len);
 
diff --git a/net/net.c b/net/net.c
index 569fec4..82c4cc9 100644
--- a/net/net.c
+++ b/net/net.c
@@ -180,7 +180,7 @@ IPaddr_t	NetNtpServerIP;
 int		NetTimeOffset;
 #endif
 
-uchar PktBuf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN];
+static uchar PktBuf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN];
 
 /* Receive packet */
 uchar *NetRxPackets[PKTBUFSRX];
diff --git a/net/ping.h b/net/ping.h
index fd8d8d9..8c71be4 100644
--- a/net/ping.h
+++ b/net/ping.h
@@ -8,8 +8,6 @@
  *	Copyright 2000-2002 Wolfgang Denk, wd at denx.de
  */
 
-#if defined(CONFIG_CMD_PING)
-
 #ifndef __PING_H__
 #define __PING_H__
 
@@ -31,4 +29,3 @@ void ping_start(void);
 void ping_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len);
 
 #endif /* __PING_H__ */
-#endif
diff --git a/net/tftp.h b/net/tftp.h
index 18e4c9c..2b686e3 100644
--- a/net/tftp.h
+++ b/net/tftp.h
@@ -22,6 +22,9 @@ void TftpStart(enum proto_t protocol);	/* Begin TFTP get/put */
 extern void TftpStartServer(void);	/* Wait for incoming TFTP put */
 #endif
 
+extern ulong TftpRRQTimeoutMSecs;
+extern int TftpRRQTimeoutCountMax;
+
 /**********************************************************************/
 
 #endif /* __TFTP_H__ */
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 16/32] drivers/net/: sparse fixes
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (14 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 15/32] net/: " Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 17/32] lib/zlib: " Kim Phillips
                   ` (19 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

phy.c:46:5: warning: symbol 'genphy_config_advert' was not declared. Should it be static?
phy.c:121:5: warning: symbol 'genphy_setup_forced' was not declared. Should it be static?
phy.c:468:5: warning: symbol 'phy_probe' was not declared. Should it be static?
phy.c:491:19: warning: symbol 'get_phy_driver' was not declared. Should it be static?
phy.c:508:19: warning: symbol 'phy_device_create' was not declared. Should it be static?
phy.c:552:5: warning: symbol 'get_phy_id' was not declared. Should it be static?
phy.c:584:19: warning: symbol 'get_phy_device' was not declared. Should it be sta
vitesse.c:126:5: warning: symbol 'vsc8601_config' was not declared. Should it be static?
vsc7385.c:33:5: warning: symbol 'vsc7385_upload_firmware' was not declared. Should it be static?
tgec_phy.c:33:5: warning: symbol 'tgec_mdio_write' was not declared. Should it be static?
tgec_phy.c:75:5: warning: symbol 'tgec_mdio_read' was not declared. Should it be static?
tgec_phy.c:117:5: warning: symbol 'tgec_mdio_reset' was not declared. Should it be static?
eth.c:48:6: warning: symbol 'dtsec_configure_serdes' was not declared. Should it be static?
p4080.c:26:5: warning: symbol 'port_to_devdisr' was not declared. Should it be static?

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 drivers/net/fm/eth.c      |  2 +-
 drivers/net/fm/p1023.c    |  2 +-
 drivers/net/fm/p4080.c    |  2 +-
 drivers/net/fm/p5020.c    |  2 +-
 drivers/net/fm/tgec_phy.c | 10 +++++-----
 drivers/net/phy/phy.c     | 19 ++++++++++---------
 drivers/net/phy/vitesse.c |  2 +-
 drivers/net/vsc7385.c     |  1 +
 8 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/drivers/net/fm/eth.c b/drivers/net/fm/eth.c
index 2b616ad..3560990 100644
--- a/drivers/net/fm/eth.c
+++ b/drivers/net/fm/eth.c
@@ -45,7 +45,7 @@ static int num_controllers;
 			TBICR_FULL_DUPLEX | TBICR_SPEED1_SET)
 
 /* Configure the TBI for SGMII operation */
-void dtsec_configure_serdes(struct fm_eth *priv)
+static void dtsec_configure_serdes(struct fm_eth *priv)
 {
 	struct dtsec *regs = priv->mac->base;
 	struct tsec_mii_mng *phyregs = priv->mac->phyregs;
diff --git a/drivers/net/fm/p1023.c b/drivers/net/fm/p1023.c
index 9765da5..387d2a3 100644
--- a/drivers/net/fm/p1023.c
+++ b/drivers/net/fm/p1023.c
@@ -23,7 +23,7 @@
 #include <asm/immap_85xx.h>
 #include <asm/fsl_serdes.h>
 
-u32 port_to_devdisr[] = {
+static u32 port_to_devdisr[] = {
 	[FM1_DTSEC1] = MPC85xx_DEVDISR_TSEC1,
 	[FM1_DTSEC2] = MPC85xx_DEVDISR_TSEC2,
 };
diff --git a/drivers/net/fm/p4080.c b/drivers/net/fm/p4080.c
index 9dc6049..b04fd0f 100644
--- a/drivers/net/fm/p4080.c
+++ b/drivers/net/fm/p4080.c
@@ -23,7 +23,7 @@
 #include <asm/immap_85xx.h>
 #include <asm/fsl_serdes.h>
 
-u32 port_to_devdisr[] = {
+static u32 port_to_devdisr[] = {
 	[FM1_DTSEC1] = FSL_CORENET_DEVDISR2_DTSEC1_1,
 	[FM1_DTSEC2] = FSL_CORENET_DEVDISR2_DTSEC1_2,
 	[FM1_DTSEC3] = FSL_CORENET_DEVDISR2_DTSEC1_3,
diff --git a/drivers/net/fm/p5020.c b/drivers/net/fm/p5020.c
index a7a6e43..5391044 100644
--- a/drivers/net/fm/p5020.c
+++ b/drivers/net/fm/p5020.c
@@ -23,7 +23,7 @@
 #include <asm/immap_85xx.h>
 #include <asm/fsl_serdes.h>
 
-u32 port_to_devdisr[] = {
+static u32 port_to_devdisr[] = {
 	[FM1_DTSEC1] = FSL_CORENET_DEVDISR2_DTSEC1_1,
 	[FM1_DTSEC2] = FSL_CORENET_DEVDISR2_DTSEC1_2,
 	[FM1_DTSEC3] = FSL_CORENET_DEVDISR2_DTSEC1_3,
diff --git a/drivers/net/fm/tgec_phy.c b/drivers/net/fm/tgec_phy.c
index 2d349ad..2be69d7 100644
--- a/drivers/net/fm/tgec_phy.c
+++ b/drivers/net/fm/tgec_phy.c
@@ -30,8 +30,8 @@
  * until the write is done before it returns.  All PHY configuration has to be
  * done through the TSEC1 MIIM regs
  */
-int tgec_mdio_write(struct mii_dev *bus, int port_addr, int dev_addr,
-			int regnum, u16 value)
+static int tgec_mdio_write(struct mii_dev *bus, int port_addr, int dev_addr,
+			   int regnum, u16 value)
 {
 	u32 mdio_ctl;
 	u32 stat_val;
@@ -72,8 +72,8 @@ int tgec_mdio_write(struct mii_dev *bus, int port_addr, int dev_addr,
  * Clears miimcom first.  All PHY configuration has to be done through the
  * TSEC1 MIIM regs
  */
-int tgec_mdio_read(struct mii_dev *bus, int port_addr, int dev_addr,
-			int regnum)
+static int tgec_mdio_read(struct mii_dev *bus, int port_addr, int dev_addr,
+			  int regnum)
 {
 	u32 mdio_ctl;
 	u32 stat_val;
@@ -114,7 +114,7 @@ int tgec_mdio_read(struct mii_dev *bus, int port_addr, int dev_addr,
 	return in_be32(&regs->mdio_data) & 0xffff;
 }
 
-int tgec_mdio_reset(struct mii_dev *bus)
+static int tgec_mdio_reset(struct mii_dev *bus)
 {
 	return 0;
 }
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index baef60f..1ffa791 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -43,7 +43,7 @@
  *   what is supported.  Returns < 0 on error, 0 if the PHY's advertisement
  *   hasn't changed, and > 0 if it has changed.
  */
-int genphy_config_advert(struct phy_device *phydev)
+static int genphy_config_advert(struct phy_device *phydev)
 {
 	u32 advertise;
 	int oldadv, adv;
@@ -118,7 +118,7 @@ int genphy_config_advert(struct phy_device *phydev)
  * Description: Configures MII_BMCR to force speed/duplex
  *   to the values in phydev. Assumes that the values are valid.
  */
-int genphy_setup_forced(struct phy_device *phydev)
+static int genphy_setup_forced(struct phy_device *phydev)
 {
 	int err;
 	int ctl = 0;
@@ -465,7 +465,7 @@ int phy_register(struct phy_driver *drv)
 	return 0;
 }
 
-int phy_probe(struct phy_device *phydev)
+static int phy_probe(struct phy_device *phydev)
 {
 	int err = 0;
 
@@ -488,7 +488,7 @@ static struct phy_driver *generic_for_interface(phy_interface_t interface)
 	return &genphy_driver;
 }
 
-struct phy_driver *get_phy_driver(struct phy_device *phydev,
+static struct phy_driver *get_phy_driver(struct phy_device *phydev,
 				phy_interface_t interface)
 {
 	struct list_head *entry;
@@ -505,8 +505,9 @@ struct phy_driver *get_phy_driver(struct phy_device *phydev,
 	return generic_for_interface(interface);
 }
 
-struct phy_device *phy_device_create(struct mii_dev *bus, int addr, int phy_id,
-					phy_interface_t interface)
+static struct phy_device *phy_device_create(struct mii_dev *bus, int addr,
+					    int phy_id,
+					    phy_interface_t interface)
 {
 	struct phy_device *dev;
 
@@ -549,7 +550,7 @@ struct phy_device *phy_device_create(struct mii_dev *bus, int addr, int phy_id,
  * Description: Reads the ID registers of the PHY at @addr on the
  *   @bus, stores it in @phy_id and returns zero on success.
  */
-int get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id)
+static int get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id)
 {
 	int phy_reg;
 
@@ -581,8 +582,8 @@ int get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id)
  * Description: Reads the ID registers of the PHY at @addr on the
  *   @bus, then allocates and returns the phy_device to represent it.
  */
-struct phy_device *get_phy_device(struct mii_dev *bus, int addr,
-				phy_interface_t interface)
+static struct phy_device *get_phy_device(struct mii_dev *bus, int addr,
+					 phy_interface_t interface)
 {
 	u32 phy_id = 0x1fffffff;
 	int i;
diff --git a/drivers/net/phy/vitesse.c b/drivers/net/phy/vitesse.c
index 0a0f40d..6c5cb99 100644
--- a/drivers/net/phy/vitesse.c
+++ b/drivers/net/phy/vitesse.c
@@ -123,7 +123,7 @@ static int cis8204_config(struct phy_device *phydev)
 }
 
 /* Vitesse VSC8601 */
-int vsc8601_config(struct phy_device *phydev)
+static int vsc8601_config(struct phy_device *phydev)
 {
 	/* Configure some basic stuff */
 #ifdef CONFIG_SYS_VSC8601_SKEWFIX
diff --git a/drivers/net/vsc7385.c b/drivers/net/vsc7385.c
index ada42c4..a5110e5 100644
--- a/drivers/net/vsc7385.c
+++ b/drivers/net/vsc7385.c
@@ -16,6 +16,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/errno.h>
+#include "vsc7385.h"
 
 /*
  * Upload a Vitesse VSC7385 firmware image to the hardware
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 17/32] lib/zlib: sparse fixes
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (15 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 16/32] drivers/net/: " Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 18/32] lib/vsprintf.c: " Kim Phillips
                   ` (18 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

define Z_NULL to (void *)0 include/u-boot/zlib.h to get rid of most of
the NULL pointer warnings.

inflate.c:942:1: warning: non-ANSI definition of function 'inflateEnd'
inflate.c:9:1: warning: non-ANSI definition of function 'inflateReset'
inflate.c:12:17: warning: Using plain integer as NULL pointer
inflate.c:12:42: warning: Using plain integer as NULL pointer
inflate.c:15:17: warning: Using plain integer as NULL pointer
inflate.c:21:19: warning: Using plain integer as NULL pointer
inflate.c:35:1: warning: non-ANSI definition of function 'inflateInit2_'
inflate.c:38:20: warning: Using plain integer as NULL pointer
inflate.c:41:17: warning: Using plain integer as NULL pointer
inflate.c:42:17: warning: Using plain integer as NULL pointer
inflate.c:50:18: warning: Using plain integer as NULL pointer
inflate.c:65:23: warning: Using plain integer as NULL pointer
inflate.c:69:21: warning: Using plain integer as NULL pointer
inflate.c:78:1: warning: non-ANSI definition of function 'inflateInit_'
inflate.c:86:1: warning: non-ANSI definition of function 'fixedtables'
inflate.c:108:26: warning: Using plain integer as NULL pointer
inflate.c:109:1: warning: non-ANSI definition of function 'updatewindow'
inflate.c:112:30: warning: Using plain integer as NULL pointer
inflate.c:339:1: warning: non-ANSI definition of function 'inflate'
inflate.c:349:17: warning: Using plain integer as NULL pointer
inflate.c:349:42: warning: Using plain integer as NULL pointer
inflate.c:350:27: warning: Using plain integer as NULL pointer
inflate.c:369:42: warning: Using plain integer as NULL pointer
inflate.c:376:32: warning: Using plain integer as NULL pointer
inflate.c:401:54: warning: Using plain integer as NULL pointer
inflate.c:419:32: warning: Using plain integer as NULL pointer
inflate.c:426:32: warning: Using plain integer as NULL pointer
inflate.c:433:32: warning: Using plain integer as NULL pointer
inflate.c:444:36: warning: Using plain integer as NULL pointer
inflate.c:449:37: warning: Using plain integer as NULL pointer
inflate.c:450:38: warning: Using plain integer as NULL pointer
inflate.c:457:40: warning: Using plain integer as NULL pointer
inflate.c:458:47: warning: Using plain integer as NULL pointer
inflate.c:480:40: warning: Using plain integer as NULL pointer
inflate.c:481:50: warning: Using plain integer as NULL pointer
inflate.c:491:37: warning: Using plain integer as NULL pointer
inflate.c:492:37: warning: Using plain integer as NULL pointer
inflate.c:501:40: warning: Using plain integer as NULL pointer
inflate.c:502:53: warning: Using plain integer as NULL pointer
inflate.c:512:37: warning: Using plain integer as NULL pointer
inflate.c:513:40: warning: Using plain integer as NULL pointer
inflate.c:525:32: warning: Using plain integer as NULL pointer
inflate.c:529:52: warning: Using plain integer as NULL pointer
inflate.c:543:54: warning: Using plain integer as NULL pointer
inflate.c:932:17: warning: Using plain integer as NULL pointer
inflate.c:932:42: warning: Using plain integer as NULL pointer
inflate.c:935:26: warning: Using plain integer as NULL pointer
inflate.c:940:19: warning: Using plain integer as NULL pointer
adler32.c:58:5: warning: non-ANSI definition of function 'adler32'
adler32.c:81:16: warning: Using plain integer as NULL pointer
zutil.c:53:9: warning: non-ANSI definition of function 'zcalloc'
zutil.c:64:9: warning: non-ANSI definition of function 'zcfree'
inffast.c:70:1: warning: non-ANSI definition of function 'inflate_fast'
inftrees.c:33:1: warning: non-ANSI definition of function 'inflate_table'

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 include/u-boot/zlib.h |  2 +-
 lib/zlib/adler32.c    |  5 +----
 lib/zlib/inffast.c    |  5 ++---
 lib/zlib/inflate.c    | 29 ++++++++---------------------
 lib/zlib/inftrees.c   | 10 +++-------
 lib/zlib/zutil.c      | 10 ++--------
 6 files changed, 17 insertions(+), 44 deletions(-)

diff --git a/include/u-boot/zlib.h b/include/u-boot/zlib.h
index b611fe7..e23ceb5 100644
--- a/include/u-boot/zlib.h
+++ b/include/u-boot/zlib.h
@@ -505,7 +505,7 @@ typedef gz_header FAR *gz_headerp;
 #define Z_DEFLATED   8
 /* The deflate compression method (the only one supported in this version) */
 
-#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
+#define Z_NULL  (void *)0  /* for initializing zalloc, zfree, opaque */
 
                         /* basic functions */
 
diff --git a/lib/zlib/adler32.c b/lib/zlib/adler32.c
index dc9480d..b468441 100644
--- a/lib/zlib/adler32.c
+++ b/lib/zlib/adler32.c
@@ -54,10 +54,7 @@
 #endif
 
 /* ========================================================================= */
-uLong ZEXPORT adler32(adler, buf, len)
-    uLong adler;
-    const Bytef *buf;
-    uInt len;
+uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
 {
     unsigned long sum2;
     unsigned n;
diff --git a/lib/zlib/inffast.c b/lib/zlib/inffast.c
index 38f2f90..0700e04 100644
--- a/lib/zlib/inffast.c
+++ b/lib/zlib/inffast.c
@@ -66,9 +66,8 @@
       requires strm->avail_out >= 258 for each loop to avoid checking for
       output space.
  */
-void inflate_fast(strm, start)
-z_streamp strm;
-unsigned start;         /* inflate()'s starting value for strm->avail_out */
+void inflate_fast(z_streamp strm, unsigned start)
+/* start: inflate()'s starting value for strm->avail_out */
 {
     struct inflate_state FAR *state;
     unsigned char FAR *in;      /* local strm->next_in */
diff --git a/lib/zlib/inflate.c b/lib/zlib/inflate.c
index 1eef609..6411c47 100644
--- a/lib/zlib/inflate.c
+++ b/lib/zlib/inflate.c
@@ -5,8 +5,7 @@
 local void fixedtables OF((struct inflate_state FAR *state));
 local int updatewindow OF((z_streamp strm, unsigned out));
 
-int ZEXPORT inflateReset(strm)
-z_streamp strm;
+int ZEXPORT inflateReset(z_streamp strm)
 {
     struct inflate_state FAR *state;
 
@@ -31,11 +30,8 @@ z_streamp strm;
     return Z_OK;
 }
 
-int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
-z_streamp strm;
-int windowBits;
-const char *version;
-int stream_size;
+int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, const char *version,
+			  int stream_size)
 {
     struct inflate_state FAR *state;
 
@@ -74,16 +70,12 @@ int stream_size;
     return inflateReset(strm);
 }
 
-int ZEXPORT inflateInit_(strm, version, stream_size)
-z_streamp strm;
-const char *version;
-int stream_size;
+int ZEXPORT inflateInit_(z_streamp strm, const char *version, int stream_size)
 {
     return inflateInit2_(strm, DEF_WBITS, version, stream_size);
 }
 
-local void fixedtables(state)
-struct inflate_state FAR *state;
+local void fixedtables(struct inflate_state FAR *state)
 {
     state->lencode = lenfix;
     state->lenbits = 9;
@@ -105,9 +97,7 @@ struct inflate_state FAR *state;
    output will fall in the output data, making match copies simpler and faster.
    The advantage may be dependent on the size of the processor's data caches.
  */
-local int updatewindow(strm, out)
-z_streamp strm;
-unsigned out;
+local int updatewindow(z_streamp strm, unsigned out)
 {
     struct inflate_state FAR *state;
     unsigned copy, dist;
@@ -335,9 +325,7 @@ unsigned out;
    when flush is set to Z_FINISH, inflate() cannot return Z_OK.  Instead it
    will return Z_BUF_ERROR if it has not reached the end of the stream.
  */
-int ZEXPORT inflate(strm, flush)
-z_streamp strm;
-int flush;
+int ZEXPORT inflate(z_streamp strm, int flush)
 {
     struct inflate_state FAR *state;
     unsigned char FAR *next;    /* next input */
@@ -938,8 +926,7 @@ int flush;
     return ret;
 }
 
-int ZEXPORT inflateEnd(strm)
-z_streamp strm;
+int ZEXPORT inflateEnd(z_streamp strm)
 {
     struct inflate_state FAR *state;
     if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
diff --git a/lib/zlib/inftrees.c b/lib/zlib/inftrees.c
index c6d4c03..7474a52 100644
--- a/lib/zlib/inftrees.c
+++ b/lib/zlib/inftrees.c
@@ -29,13 +29,9 @@
    table index bits.  It will differ if the request is greater than the
    longest code or if it is less than the shortest code.
  */
-int inflate_table(type, lens, codes, table, bits, work)
-codetype type;
-unsigned short FAR *lens;
-unsigned codes;
-code FAR * FAR *table;
-unsigned FAR *bits;
-unsigned short FAR *work;
+int inflate_table(codetype type, unsigned short FAR *lens, unsigned codes,
+		  code FAR * FAR *table, unsigned FAR *bits,
+		  unsigned short FAR *work)
 {
     unsigned len;               /* a code's length in bits */
     unsigned sym;               /* index of code symbols */
diff --git a/lib/zlib/zutil.c b/lib/zlib/zutil.c
index 65f9554..ba5742d 100644
--- a/lib/zlib/zutil.c
+++ b/lib/zlib/zutil.c
@@ -49,10 +49,7 @@ extern voidp    calloc OF((uInt items, uInt size));
 extern void     free   OF((voidpf ptr));
 #endif
 
-voidpf zcalloc (opaque, items, size)
-	voidpf opaque;
-	unsigned items;
-	unsigned size;
+voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
 {
 	if (opaque)
 		items += size - size; /* make compiler happy */
@@ -60,10 +57,7 @@ voidpf zcalloc (opaque, items, size)
 		(voidpf)calloc(items, size);
 }
 
-void  zcfree (opaque, ptr, nb)
-	voidpf opaque;
-	voidpf ptr;
-	unsigned nb;
+void  zcfree (voidpf opaque, voidpf ptr, unsigned nb)
 {
 	free(ptr);
 	if (opaque)
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 18/32] lib/vsprintf.c: sparse fixes
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (16 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 17/32] lib/zlib: " Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 19/32] include/fdt.h: " Kim Phillips
                   ` (17 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

vsprintf.c:31:12: warning: symbol 'hex_asc' was not declared. Should it be static?
vsprintf.c:398:18: warning: Using plain integer as NULL pointer

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 lib/vsprintf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index d762763..7215531 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -28,7 +28,7 @@
 /* some reluctance to put this into a new limits.h, so it is here */
 #define INT_MAX		((int)(~0U>>1))
 
-const char hex_asc[] = "0123456789abcdef";
+static const char hex_asc[] = "0123456789abcdef";
 #define hex_asc_lo(x)   hex_asc[((x) & 0x0f)]
 #define hex_asc_hi(x)   hex_asc[((x) & 0xf0) >> 4]
 
@@ -395,7 +395,7 @@ static char *string(char *buf, char *end, char *s, int field_width,
 {
 	int len, i;
 
-	if (s == 0)
+	if (s == NULL)
 		s = "<NULL>";
 
 	len = strnlen(s, precision);
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 19/32] include/fdt.h: sparse fixes
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (17 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 18/32] lib/vsprintf.c: " Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 20/32] arch/powerpc/cpu/mpc8xxx/: " Kim Phillips
                   ` (16 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

fix endianness warnings such as these:

cmd_fdt.c:479:29: warning: cast to restricted __be32
cmd_fdt.c:482:41: warning: cast to restricted __be32
cmd_fdt.c:486:29: warning: cast to restricted __be32
cmd_fdt.c:489:41: warning: cast to restricted __be32
cmd_fdt.c:776:41: warning: cast to restricted __be32
cmd_fdt.c:777:36: warning: cast to restricted __be32
cmd_fdt.c:101:35: warning: cast to restricted __be32
cmd_fdt.c:104:46: warning: cast to restricted __be32
cmd_fdt.c:154:31: warning: cast to restricted __be32
cmd_fdt.c:157:35: warning: cast to restricted __be32
cmd_fdt.c:160:46: warning: cast to restricted __be32
cmd_fdt.c:331:31: warning: cast to restricted __be32
cmd_fdt.c:332:46: warning: cast to restricted __be32
cmd_fdt.c:333:53: warning: cast to restricted __be32
cmd_fdt.c:334:24: warning: cast to restricted __be32
cmd_fdt.c:336:24: warning: cast to restricted __be32
cmd_fdt.c:338:24: warning: cast to restricted __be32
cmd_fdt.c:340:24: warning: cast to restricted __be32
cmd_fdt.c:343:24: warning: cast to restricted __be32
cmd_fdt.c:346:33: warning: cast to restricted __be32
cmd_fdt.c:349:33: warning: cast to restricted __be32
cmd_fdt.c:352:33: warning: cast to restricted __be32
include/libfdt.h:169:1: warning: incorrect type in assignment (different base types)
include/libfdt.h:169:1:    expected unsigned int [unsigned] [usertype] boot_cpuid_phys
include/libfdt.h:169:1:    got restricted __be32 [usertype] <noident>

by annotating fdt header integers big endian.

Also address the following problems for files in lib/libfdt/:

fdt.c:108:15: warning: cast to restricted __be32
fdt.c:128:27: warning: cast to restricted __be32
fdt_ro.c:341:16: warning: cast to restricted __be32
fdt_rw.c:374:17: warning: incorrect type in assignment (different base types)
fdt_rw.c:374:17:    expected unsigned int [unsigned] [usertype] <noident>
fdt_rw.c:374:17:    got restricted __be32 [usertype] <noident>
include/libfdt.h:1156:13: warning: incorrect type in assignment (different base types)
include/libfdt.h:1156:13:    expected unsigned int [unsigned] [usertype] val
include/libfdt.h:1156:13:    got restricted __be32 [usertype] <noident>
fdt_sw.c:164:13: warning: incorrect type in assignment (different base types)
fdt_sw.c:164:13:    expected unsigned int [unsigned] [usertype] <noident>
fdt_sw.c:164:13:    got restricted __be32 [usertype] <noident>
fdt_sw.c:227:14: warning: incorrect type in assignment (different base types)
fdt_sw.c:227:14:    expected unsigned int [unsigned] [usertype] <noident>
fdt_sw.c:227:14:    got restricted __be32 [usertype] <noident>
fdt_wip.c:84:20: warning: incorrect type in assignment (different base types)
fdt_wip.c:84:20:    expected unsigned int [unsigned] [usertype] <noident>
fdt_wip.c:84:20:    got restricted __be32 [usertype] <noident>

the changes in include/fdt_support.h fix these problems in
arch/powerpc/cpu/mpc8xxx/fdt.c:

fdt.c:57:6: warning: symbol 'ft_fixup_num_cores' was not declared. Should it be static?
fdt.c:331:6: warning: symbol 'ft_srio_setup' was not declared. Should it be static?

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 include/fdt.h         | 33 +++++++++++++++++----------------
 include/fdt_support.h |  2 ++
 include/libfdt.h      |  4 ++--
 lib/libfdt/fdt.c      |  2 +-
 lib/libfdt/fdt_ro.c   |  2 +-
 lib/libfdt/fdt_rw.c   |  4 ++--
 lib/libfdt/fdt_sw.c   |  4 ++--
 lib/libfdt/fdt_wip.c  |  2 +-
 8 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/include/fdt.h b/include/fdt.h
index c51212e..1b7f044 100644
--- a/include/fdt.h
+++ b/include/fdt.h
@@ -2,40 +2,41 @@
 #define _FDT_H
 
 #ifndef __ASSEMBLY__
+#include <asm/byteorder.h>
 
 struct fdt_header {
-	uint32_t magic;			 /* magic word FDT_MAGIC */
-	uint32_t totalsize;		 /* total size of DT block */
-	uint32_t off_dt_struct;		 /* offset to structure */
-	uint32_t off_dt_strings;	 /* offset to strings */
-	uint32_t off_mem_rsvmap;	 /* offset to memory reserve map */
-	uint32_t version;		 /* format version */
-	uint32_t last_comp_version;	 /* last compatible version */
+	__be32 magic;			 /* magic word FDT_MAGIC */
+	__be32 totalsize;		 /* total size of DT block */
+	__be32 off_dt_struct;		 /* offset to structure */
+	__be32 off_dt_strings;	 /* offset to strings */
+	__be32 off_mem_rsvmap;	 /* offset to memory reserve map */
+	__be32 version;		 /* format version */
+	__be32 last_comp_version;	 /* last compatible version */
 
 	/* version 2 fields below */
-	uint32_t boot_cpuid_phys;	 /* Which physical CPU id we're
+	__be32 boot_cpuid_phys;	 /* Which physical CPU id we're
 					    booting on */
 	/* version 3 fields below */
-	uint32_t size_dt_strings;	 /* size of the strings block */
+	__be32 size_dt_strings;	 /* size of the strings block */
 
 	/* version 17 fields below */
-	uint32_t size_dt_struct;	 /* size of the structure block */
+	__be32 size_dt_struct;	 /* size of the structure block */
 };
 
 struct fdt_reserve_entry {
-	uint64_t address;
-	uint64_t size;
+	__be64 address;
+	__be64 size;
 };
 
 struct fdt_node_header {
-	uint32_t tag;
+	__be32 tag;
 	char name[0];
 };
 
 struct fdt_property {
-	uint32_t tag;
-	uint32_t len;
-	uint32_t nameoff;
+	__be32 tag;
+	__be32 len;
+	__be32 nameoff;
 	char data[0];
 };
 
diff --git a/include/fdt_support.h b/include/fdt_support.h
index 2e18d82..399b73f 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -81,7 +81,9 @@ int fdt_pci_dma_ranges(void *blob, int phb_off, struct pci_controller *hose);
 #ifdef CONFIG_OF_BOARD_SETUP
 void ft_board_setup(void *blob, bd_t *bd);
 void ft_cpu_setup(void *blob, bd_t *bd);
+void ft_fixup_num_cores(void *blob);
 void ft_pci_setup(void *blob, bd_t *bd);
+void ft_srio_setup(void *blob);
 #endif
 
 void set_working_fdt_addr(void *addr);
diff --git a/include/libfdt.h b/include/libfdt.h
index 4589c5f..ab98d23 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -1153,8 +1153,8 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,
 				  uint32_t val)
 {
-	val = cpu_to_fdt32(val);
-	return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val));
+	__be32 tmp = cpu_to_fdt32(val);
+	return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
diff --git a/lib/libfdt/fdt.c b/lib/libfdt/fdt.c
index 4157b21..5a82c60 100644
--- a/lib/libfdt/fdt.c
+++ b/lib/libfdt/fdt.c
@@ -96,7 +96,7 @@ const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)
 
 uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
 {
-	const uint32_t *tagp, *lenp;
+	const __be32 *tagp, *lenp;
 	uint32_t tag;
 	int offset = startoffset;
 	const char *p;
diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
index 1933010..4e3d87a 100644
--- a/lib/libfdt/fdt_ro.c
+++ b/lib/libfdt/fdt_ro.c
@@ -326,7 +326,7 @@ const void *fdt_getprop(const void *fdt, int nodeoffset,
 
 uint32_t fdt_get_phandle(const void *fdt, int nodeoffset)
 {
-	const uint32_t *php;
+	const __be32 *php;
 	int len;
 
 	/* FIXME: This is a bit sub-optimal, since we potentially scan
diff --git a/lib/libfdt/fdt_rw.c b/lib/libfdt/fdt_rw.c
index 5ed23d6..688b817 100644
--- a/lib/libfdt/fdt_rw.c
+++ b/lib/libfdt/fdt_rw.c
@@ -343,7 +343,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
 	int nodelen;
 	int err;
 	uint32_t tag;
-	uint32_t *endtag;
+	__be32 *endtag;
 
 	FDT_RW_CHECK_HEADER(fdt);
 
@@ -370,7 +370,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
 	nh->tag = cpu_to_fdt32(FDT_BEGIN_NODE);
 	memset(nh->name, 0, FDT_TAGALIGN(namelen+1));
 	memcpy(nh->name, name, namelen);
-	endtag = (uint32_t *)((char *)nh + nodelen - FDT_TAGSIZE);
+	endtag = (__be32 *)((char *)nh + nodelen - FDT_TAGSIZE);
 	*endtag = cpu_to_fdt32(FDT_END_NODE);
 
 	return offset;
diff --git a/lib/libfdt/fdt_sw.c b/lib/libfdt/fdt_sw.c
index 55ebebf..5ce91ba 100644
--- a/lib/libfdt/fdt_sw.c
+++ b/lib/libfdt/fdt_sw.c
@@ -153,7 +153,7 @@ int fdt_begin_node(void *fdt, const char *name)
 
 int fdt_end_node(void *fdt)
 {
-	uint32_t *en;
+	__be32 *en;
 
 	FDT_SW_CHECK_HEADER(fdt);
 
@@ -213,7 +213,7 @@ int fdt_property(void *fdt, const char *name, const void *val, int len)
 int fdt_finish(void *fdt)
 {
 	char *p = (char *)fdt;
-	uint32_t *end;
+	__be32 *end;
 	int oldstroffset, newstroffset;
 	uint32_t tag;
 	int offset, nextoffset;
diff --git a/lib/libfdt/fdt_wip.c b/lib/libfdt/fdt_wip.c
index e373677..dc1e14c 100644
--- a/lib/libfdt/fdt_wip.c
+++ b/lib/libfdt/fdt_wip.c
@@ -78,7 +78,7 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
 
 static void _fdt_nop_region(void *start, int len)
 {
-	uint32_t *p;
+	__be32 *p;
 
 	for (p = start; (char *)p < ((char *)start + len); p++)
 		*p = cpu_to_fdt32(FDT_NOP);
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 20/32] arch/powerpc/cpu/mpc8xxx/: sparse fixes
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (18 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 19/32] include/fdt.h: " Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 21/32] arch/powerpc/cpu/mpc85xx/fdt.c: " Kim Phillips
                   ` (15 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

ctrl_regs.c:31:5: warning: symbol 'fsl_ddr_get_version' was not declared. Should it be static?
cpu.c:135:14: warning: non-ANSI function declaration of function 'cpu_mask'
cpu.c:154:18: warning: non-ANSI function declaration of function 'cpu_numcores'
cpu.c:37:17: warning: symbol 'cpu_type_list' was not declared. Should it be static?
cpu.c:117:17: warning: symbol 'cpu_type_unknown' was not declared. Should it be static?
fsl_lbc.c:14:6: warning: symbol '__lbc_sdram_init' was not declared. Should it be static?

and:

lc_common_dimm_params.c:15:1: warning: symbol 'compute_cas_latency_ddr3' was not declared. Should it be static?

making it static produces the following compiler warning:

lc_common_dimm_params.c:15:1: warning: 'compute_cas_latency_ddr3' defined but not used [-Wunused-function]

so we protect it with the preprocessor.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 arch/powerpc/cpu/mpc8xxx/cpu.c                       | 8 ++++----
 arch/powerpc/cpu/mpc8xxx/ddr/ctrl_regs.c             | 2 +-
 arch/powerpc/cpu/mpc8xxx/ddr/lc_common_dimm_params.c | 4 +++-
 arch/powerpc/cpu/mpc8xxx/fsl_lbc.c                   | 2 +-
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/cpu/mpc8xxx/cpu.c b/arch/powerpc/cpu/mpc8xxx/cpu.c
index 78a8f92..acd1b64 100644
--- a/arch/powerpc/cpu/mpc8xxx/cpu.c
+++ b/arch/powerpc/cpu/mpc8xxx/cpu.c
@@ -34,7 +34,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-struct cpu_type cpu_type_list [] = {
+static struct cpu_type cpu_type_list [] = {
 #if defined(CONFIG_MPC85xx)
 	CPU_TYPE_ENTRY(8533, 8533, 1),
 	CPU_TYPE_ENTRY(8535, 8535, 1),
@@ -114,7 +114,7 @@ u32 compute_ppc_cpumask(void)
 #define compute_ppc_cpumask()	1
 #endif /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */
 
-struct cpu_type cpu_type_unknown = CPU_TYPE_ENTRY(Unknown, Unknown, 0);
+static struct cpu_type cpu_type_unknown = CPU_TYPE_ENTRY(Unknown, Unknown, 0);
 
 struct cpu_type *identify_cpu(u32 ver)
 {
@@ -132,7 +132,7 @@ struct cpu_type *identify_cpu(u32 ver)
 /*
  * Return a 32-bit mask indicating which cores are present on this SOC.
  */
-u32 cpu_mask()
+u32 cpu_mask(void)
 {
 	ccsr_pic_t __iomem *pic = (void *)CONFIG_SYS_MPC8xxx_PIC_ADDR;
 	struct cpu_type *cpu = gd->cpu;
@@ -151,7 +151,7 @@ u32 cpu_mask()
 /*
  * Return the number of cores on this SOC.
  */
-int cpu_numcores() {
+int cpu_numcores(void) {
 	struct cpu_type *cpu = gd->cpu;
 
 	/*
diff --git a/arch/powerpc/cpu/mpc8xxx/ddr/ctrl_regs.c b/arch/powerpc/cpu/mpc8xxx/ddr/ctrl_regs.c
index 2592873..0e77408 100644
--- a/arch/powerpc/cpu/mpc8xxx/ddr/ctrl_regs.c
+++ b/arch/powerpc/cpu/mpc8xxx/ddr/ctrl_regs.c
@@ -28,7 +28,7 @@
 	#error "Undefined _DDR_ADDR"
 #endif
 
-u32 fsl_ddr_get_version(void)
+static u32 fsl_ddr_get_version(void)
 {
 	ccsr_ddr_t *ddr;
 	u32 ver_major_minor_errata;
diff --git a/arch/powerpc/cpu/mpc8xxx/ddr/lc_common_dimm_params.c b/arch/powerpc/cpu/mpc8xxx/ddr/lc_common_dimm_params.c
index 03a784c..400b0d7 100644
--- a/arch/powerpc/cpu/mpc8xxx/ddr/lc_common_dimm_params.c
+++ b/arch/powerpc/cpu/mpc8xxx/ddr/lc_common_dimm_params.c
@@ -11,7 +11,8 @@
 
 #include "ddr.h"
 
-unsigned int
+#if defined(CONFIG_FSL_DDR3)
+static unsigned int
 compute_cas_latency_ddr3(const dimm_params_t *dimm_params,
 			 common_timing_params_t *outpdimm,
 			 unsigned int number_of_dimms)
@@ -65,6 +66,7 @@ compute_cas_latency_ddr3(const dimm_params_t *dimm_params,
 
 	return 0;
 }
+#endif
 
 /*
  * compute_lowest_common_dimm_parameters()
diff --git a/arch/powerpc/cpu/mpc8xxx/fsl_lbc.c b/arch/powerpc/cpu/mpc8xxx/fsl_lbc.c
index 023ac9a..c1fe579 100644
--- a/arch/powerpc/cpu/mpc8xxx/fsl_lbc.c
+++ b/arch/powerpc/cpu/mpc8xxx/fsl_lbc.c
@@ -11,7 +11,7 @@
 
 #ifdef CONFIG_MPC85xx
 /* Boards should provide their own version of this if they use lbc sdram */
-void __lbc_sdram_init(void)
+static void __lbc_sdram_init(void)
 {
 	/* Do nothing */
 }
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 21/32] arch/powerpc/cpu/mpc85xx/fdt.c: sparse fixes
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (19 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 20/32] arch/powerpc/cpu/mpc8xxx/: " Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 22/32] powerpc/mpc85xx: " Kim Phillips
                   ` (14 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

this is mostly about using the proper __be32 type for 32-bit device
tree property content variables.

includes uncasting fdt_getprop() callsites, enforcing callsite code to
use __be32 (identified by casting a 32-bit entity).  This allows sparse
to continue to find endianness type mismatches at the callsite.

__be-ifying QE/FMAN firmware struct entries enables sparse to detect
a couple of endian bugs when handling firmware length.  It is assumed
QE/FMAN firmware is defined big-endian.

fdt.c:62:29: warning: incorrect type in assignment (different base types)
fdt.c:62:29:    expected unsigned long long [unsigned] [usertype] val
fdt.c:62:29:    got restricted __be64 [usertype] <noident>
fdt.c:65:65: warning: Using plain integer as NULL pointer
fdt.c:47:6: warning: symbol 'ft_fixup_cpu' was not declared. Should it be static?
fdt.c:57:65: warning: Using plain integer as NULL pointer
fdt.c:112:29: warning: incorrect type in argument 1 (different address spaces)
fdt.c:112:29:    expected unsigned int const volatile [noderef] <asn:2>*addr
fdt.c:112:29:    got unsigned int *<noident>
fdt.c:182:64: warning: Using plain integer as NULL pointer
fdt.c:244:72: warning: Using plain integer as NULL pointer
fdt.c:259:73: warning: Using plain integer as NULL pointer
fdt.c:275:83: warning: Using plain integer as NULL pointer
fdt.c:289:5: warning: symbol 'fdt_fixup_phy_connection' was not declared. Should it be static?
fdt.c:324:73: warning: Using plain integer as NULL pointer
fdt.c:349:6: warning: symbol 'fdt_add_enet_stashing' was not declared. Should it be static?
fdt.c:428:6: warning: symbol 'fdt_fixup_fman_firmware' was not declared. Should it be static?
fdt.c:580:65: warning: Using plain integer as NULL pointer
fdt.c:484:52: warning: incorrect type in argument 2 (different base types)
fdt.c:484:52:    expected int [signed] add_len
fdt.c:484:52:    got restricted __be32 [usertype] length
fdt.c:516:78: warning: incorrect type in argument 5 (different base types)
fdt.c:516:78:    expected int [signed] len
fdt.c:516:78:    got restricted __be32 [usertype] length
fdt.c:582:21: warning: incorrect type in assignment (different base types)
fdt.c:582:21:    expected int [signed] val
fdt.c:582:21:    got restricted __be32 [usertype] <noident>

ft_verify_fdt is a weak symbol, so this still gets emitted:

fdt.c:708:5: warning: symbol 'ft_verify_fdt' was not declared. Should it be static?

perhaps we should stop using weak symbols.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 arch/powerpc/cpu/mpc85xx/fdt.c | 55 +++++++++++++++++++++++-------------------
 arch/powerpc/cpu/mpc8xxx/fdt.c |  3 ++-
 drivers/qe/qe.h                | 34 +++++++++++++-------------
 3 files changed, 49 insertions(+), 43 deletions(-)

diff --git a/arch/powerpc/cpu/mpc85xx/fdt.c b/arch/powerpc/cpu/mpc85xx/fdt.c
index e57d69c..0013e42 100644
--- a/arch/powerpc/cpu/mpc85xx/fdt.c
+++ b/arch/powerpc/cpu/mpc85xx/fdt.c
@@ -44,7 +44,7 @@ extern void ft_srio_setup(void *blob);
 #ifdef CONFIG_MP
 #include "mp.h"
 
-void ft_fixup_cpu(void *blob, u64 memory_limit)
+static void ft_fixup_cpu(void *blob, u64 memory_limit)
 {
 	int off;
 	ulong spin_tbl_addr = get_spin_phys_addr();
@@ -54,13 +54,15 @@ void ft_fixup_cpu(void *blob, u64 memory_limit)
 
 	off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
 	while (off != -FDT_ERR_NOTFOUND) {
-		u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", 0);
+		const __be32 *reg = fdt_getprop(blob, off, "reg", NULL);
 
 		if (reg) {
-			u32 phys_cpu_id = thread_to_core(*reg);
-			u64 val = phys_cpu_id * SIZE_BOOT_ENTRY + spin_tbl_addr;
-			val = cpu_to_fdt64(val);
-			if (*reg == id) {
+			u32 phys_cpu_id = thread_to_core(fdt32_to_cpu(*reg));
+			__be64 val;
+
+			val = cpu_to_fdt64(phys_cpu_id * SIZE_BOOT_ENTRY +
+					   spin_tbl_addr);
+			if (fdt32_to_cpu(*reg) == id) {
 				fdt_setprop_string(blob, off, "status",
 								"okay");
 			} else {
@@ -106,7 +108,7 @@ void ft_fixup_cpu(void *blob, u64 memory_limit)
 static inline void ft_fixup_l3cache(void *blob, int off)
 {
 	u32 line_size, num_ways, size, num_sets;
-	cpc_corenet_t *cpc = (void *)CONFIG_SYS_FSL_CPC_ADDR;
+	cpc_corenet_t __iomem *cpc = (void __iomem *)CONFIG_SYS_FSL_CPC_ADDR;
 	u32 cfg0 = in_be32(&cpc->cpccfg0);
 
 	size = CPC_CFG0_SZ_K(cfg0) * 1024 * CONFIG_SYS_NUM_CPC;
@@ -163,7 +165,7 @@ static inline u32 l2cache_size(void)
 static inline void ft_fixup_l2cache(void *blob)
 {
 	int len, off;
-	u32 *ph;
+	const __be32 *ph;
 	struct cpu_type *cpu = identify_cpu(SVR_SOC_VER(get_svr()));
 
 	const u32 line_size = 32;
@@ -177,14 +179,14 @@ static inline void ft_fixup_l2cache(void *blob)
 		return;
 	}
 
-	ph = (u32 *)fdt_getprop(blob, off, "next-level-cache", 0);
+	ph = fdt_getprop(blob, off, "next-level-cache", NULL);
 
 	if (ph == NULL) {
 		debug("no next-level-cache property\n");
 		return ;
 	}
 
-	off = fdt_node_offset_by_phandle(blob, *ph);
+	off = fdt_node_offset_by_phandle(blob, fdt32_to_cpu(*ph));
 	if (off < 0) {
 		printf("%s: %s\n", __func__, fdt_strerror(off));
 		return ;
@@ -224,7 +226,7 @@ static inline void ft_fixup_l2cache(void *blob)
 static inline void ft_fixup_l2cache(void *blob)
 {
 	int off, l2_off, l3_off = -1;
-	u32 *ph;
+	const __be32 *ph;
 	u32 l2cfg0 = mfspr(SPRN_L2CFG0);
 	u32 size, line_size, num_ways, num_sets;
 	int has_l2 = 1;
@@ -241,14 +243,14 @@ static inline void ft_fixup_l2cache(void *blob)
 	off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
 
 	while (off != -FDT_ERR_NOTFOUND) {
-		ph = (u32 *)fdt_getprop(blob, off, "next-level-cache", 0);
+		ph = fdt_getprop(blob, off, "next-level-cache", NULL);
 
 		if (ph == NULL) {
 			debug("no next-level-cache property\n");
 			goto next;
 		}
 
-		l2_off = fdt_node_offset_by_phandle(blob, *ph);
+		l2_off = fdt_node_offset_by_phandle(blob, fdt32_to_cpu(*ph));
 		if (l2_off < 0) {
 			printf("%s: %s\n", __func__, fdt_strerror(off));
 			goto next;
@@ -256,7 +258,7 @@ static inline void ft_fixup_l2cache(void *blob)
 
 		if (has_l2) {
 #ifdef CONFIG_SYS_CACHE_STASHING
-			u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", 0);
+			u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", NULL);
 			if (reg)
 				fdt_setprop_cell(blob, l2_off, "cache-stash-id",
 					 (*reg * 2) + 32 + 1);
@@ -272,13 +274,14 @@ static inline void ft_fixup_l2cache(void *blob)
 		}
 
 		if (l3_off < 0) {
-			ph = (u32 *)fdt_getprop(blob, l2_off, "next-level-cache", 0);
+			ph = fdt_getprop(blob, l2_off, "next-level-cache",
+					 NULL);
 
 			if (ph == NULL) {
 				debug("no next-level-cache property\n");
 				goto next;
 			}
-			l3_off = *ph;
+			l3_off = fdt32_to_cpu(*ph);
 		}
 next:
 		off = fdt_node_offset_by_prop_value(blob, off,
@@ -321,7 +324,7 @@ static inline void ft_fixup_cache(void *blob)
 
 #ifdef CONFIG_SYS_CACHE_STASHING
 		{
-			u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", 0);
+			u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", NULL);
 			if (reg)
 				fdt_setprop_cell(blob, off, "cache-stash-id",
 					 (*reg * 2) + 32 + 0);
@@ -346,7 +349,7 @@ static inline void ft_fixup_cache(void *blob)
 }
 
 
-void fdt_add_enet_stashing(void *fdt)
+static void fdt_add_enet_stashing(void *fdt)
 {
 	do_fixup_by_compat(fdt, "gianfar", "bd-stash", NULL, 0, 1);
 
@@ -425,13 +428,13 @@ static void ft_fixup_qe_snum(void *blob)
  * be able to parse the binary data to determine any attributes it needs.
  */
 #ifdef CONFIG_SYS_DPAA_FMAN
-void fdt_fixup_fman_firmware(void *blob)
+static void fdt_fixup_fman_firmware(void *blob)
 {
 	int rc, fmnode, fwnode = -1;
 	uint32_t phandle;
 	struct qe_firmware *fmanfw;
 	const struct qe_header *hdr;
-	unsigned int length;
+	unsigned int length, fw_length;
 	uint32_t crc;
 	const char *p;
 
@@ -471,14 +474,16 @@ void fdt_fixup_fman_firmware(void *blob)
 	}
 
 	length -= sizeof(u32);	/* Subtract the size of the CRC */
-	crc = be32_to_cpu(*(u32 *)((void *)fmanfw + length));
+	crc = be32_to_cpu(*(__be32 *)((void *)fmanfw + length));
 	if (crc != crc32_no_comp(0, (void *)fmanfw, length)) {
 		printf("Fman firmware@%p has invalid CRC\n", fmanfw);
 		return;
 	}
 
+	fw_length = be32_to_cpu(fmanfw->header.length);
+
 	/* Increase the size of the fdt to make room for the node. */
-	rc = fdt_increase_size(blob, fmanfw->header.length);
+	rc = fdt_increase_size(blob, fw_length);
 	if (rc < 0) {
 		printf("Unable to make room for Fman firmware: %s\n",
 			fdt_strerror(rc));
@@ -510,7 +515,7 @@ void fdt_fixup_fman_firmware(void *blob)
 		       fdt_strerror(rc));
 		return;
 	}
-	rc = fdt_setprop(blob, fwnode, "fsl,firmware", fmanfw, fmanfw->header.length);
+	rc = fdt_setprop(blob, fwnode, "fsl,firmware", fmanfw, fw_length);
 	if (rc < 0) {
 		char s[64];
 		fdt_get_path(blob, fwnode, s, sizeof(s));
@@ -559,7 +564,7 @@ static void fdt_fixup_usb(void *fdt)
 void ft_cpu_setup(void *blob, bd_t *bd)
 {
 	int off;
-	int val;
+	__be32 val;
 	sys_info_t sysinfo;
 
 	/* delete crypto node if not on an E-processor */
@@ -577,7 +582,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)
 	get_sys_info(&sysinfo);
 	off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
 	while (off != -FDT_ERR_NOTFOUND) {
-		u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", 0);
+		u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", NULL);
 		val = cpu_to_fdt32(sysinfo.freqProcessor[*reg]);
 		fdt_setprop(blob, off, "clock-frequency", &val, 4);
 		off = fdt_node_offset_by_prop_value(blob, off, "device_type",
diff --git a/arch/powerpc/cpu/mpc8xxx/fdt.c b/arch/powerpc/cpu/mpc8xxx/fdt.c
index 32ab050..af2545d 100644
--- a/arch/powerpc/cpu/mpc8xxx/fdt.c
+++ b/arch/powerpc/cpu/mpc8xxx/fdt.c
@@ -27,6 +27,7 @@
 #include <libfdt.h>
 #include <fdt_support.h>
 #include <asm/mp.h>
+#include <asm/fsl_enet.h>
 #include <asm/fsl_serdes.h>
 #include <phy.h>
 #include <hwconfig.h>
@@ -61,7 +62,7 @@ void ft_fixup_num_cores(void *blob) {
 
 	off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
 	while (off != -FDT_ERR_NOTFOUND) {
-		u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", 0);
+		u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", NULL);
 		u32 phys_cpu_id = thread_to_core(*reg);
 
 		if (!is_core_valid(phys_cpu_id) || is_core_disabled(phys_cpu_id)) {
diff --git a/drivers/qe/qe.h b/drivers/qe/qe.h
index faad43c..3914fab 100644
--- a/drivers/qe/qe.h
+++ b/drivers/qe/qe.h
@@ -242,7 +242,7 @@ typedef enum qe_clock {
  */
 struct qe_firmware {
 	struct qe_header {
-		u32 length;	/* Length of the entire structure, in bytes */
+		__be32 length;	/* Length of the entire structure, in bytes */
 		u8 magic[3];	/* Set to { 'Q', 'E', 'F' } */
 		u8 version;	/* Version of this layout. First ver is '1' */
 	} header;
@@ -250,26 +250,26 @@ struct qe_firmware {
 	u8 split;		/* 0 = shared I-RAM, 1 = split I-RAM */
 	u8 count;		/* Number of microcode[] structures */
 	struct {
-		u16 model;	/* The SOC model  */
+		__be16 model;	/* The SOC model  */
 		u8 major;	/* The SOC revision major */
 		u8 minor;	/* The SOC revision minor */
 	} __attribute__ ((packed)) soc;
 	u8 padding[4];		/* Reserved, for alignment */
-	u64 extended_modes;	/* Extended modes */
-	u32 vtraps[8];		/* Virtual trap addresses */
+	__be64 extended_modes;	/* Extended modes */
+	__be32 vtraps[8];	/* Virtual trap addresses */
 	u8 reserved[4];		/* Reserved, for future expansion */
 	struct qe_microcode {
-		u8 id[32];	/* Null-terminated identifier */
-		u32 traps[16];	/* Trap addresses, 0 == ignore */
-		u32 eccr;	/* The value for the ECCR register */
-		u32 iram_offset;/* Offset into I-RAM for the code */
-		u32 count;	/* Number of 32-bit words of the code */
-		u32 code_offset;/* Offset of the actual microcode */
-		u8 major;	/* The microcode version major */
-		u8 minor;	/* The microcode version minor */
-		u8 revision;	/* The microcode version revision */
-		u8 padding;	/* Reserved, for alignment */
-		u8 reserved[4];	/* Reserved, for future expansion */
+		u8 id[32];		/* Null-terminated identifier */
+		__be32 traps[16];	/* Trap addresses, 0 == ignore */
+		__be32 eccr;		/* The value for the ECCR register */
+		__be32 iram_offset;	/* Offset into I-RAM for the code */
+		__be32 count;		/* Number of 32-bit words of the code */
+		__be32 code_offset;	/* Offset of the actual microcode */
+		u8 major;		/* The microcode version major */
+		u8 minor;		/* The microcode version minor */
+		u8 revision;		/* The microcode version revision */
+		u8 padding;		/* Reserved, for alignment */
+		u8 reserved[4];		/* Reserved, for future expansion */
 	} __attribute__ ((packed)) microcode[1];
 	/* All microcode binaries should be located here */
 	/* CRC32 should be located here, after the microcode binaries */
@@ -277,8 +277,8 @@ struct qe_firmware {
 
 struct qe_firmware_info {
 	char id[64];		/* Firmware name */
-	u32 vtraps[8];		/* Virtual trap addresses */
-	u64 extended_modes;	/* Extended modes */
+	__be32 vtraps[8];		/* Virtual trap addresses */
+	__be64 extended_modes;	/* Extended modes */
 };
 
 void qe_config_iopin(u8 port, u8 pin, int dir, int open_drain, int assign);
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 22/32] powerpc/mpc85xx: sparse fixes
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (20 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 21/32] arch/powerpc/cpu/mpc85xx/fdt.c: " Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 23/32] powerpc/mpc83xx: " Kim Phillips
                   ` (13 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

fsl_corenet_serdes.c:485:6: warning: symbol '__soc_serdes_init' was not declared. Should it be static?
cpu_init.c:185:6: warning: symbol 'invalidate_cpc' was not declared. Should it be static?
bcsr.c:28:27: warning: non-ANSI function declaration of function 'enable_8568mds_duart'
bcsr.c:39:33: warning: non-ANSI function declaration of function 'enable_8568mds_flash_write'
bcsr.c:46:34: warning: non-ANSI function declaration of function 'disable_8568mds_flash_write'
bcsr.c:53:29: warning: non-ANSI function declaration of function 'enable_8568mds_qe_mdio'
bcsr.c:28:33: warning: non-ANSI function declaration of function 'enable_8569mds_flash_write'
bcsr.c:33:34: warning: non-ANSI function declaration of function 'disable_8569mds_flash_write'
bcsr.c:38:28: warning: non-ANSI function declaration of function 'enable_8569mds_qe_uec'
bcsr.c:63:47: warning: non-ANSI function declaration of function 'disable_8569mds_brd_eeprom_write_protect'
ngpixis.c:245:1: error: directive in argument list
ngpixis.c:247:1: error: directive in argument list

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 arch/powerpc/cpu/mpc85xx/cpu_init.c           |  2 +-
 arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c |  2 +-
 board/freescale/common/ngpixis.c              | 10 ++++++----
 board/freescale/mpc8568mds/bcsr.c             |  8 ++++----
 board/freescale/mpc8569mds/bcsr.c             |  8 ++++----
 5 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/arch/powerpc/cpu/mpc85xx/cpu_init.c b/arch/powerpc/cpu/mpc85xx/cpu_init.c
index afb5671..fac20db 100644
--- a/arch/powerpc/cpu/mpc85xx/cpu_init.c
+++ b/arch/powerpc/cpu/mpc85xx/cpu_init.c
@@ -182,7 +182,7 @@ static void enable_cpc(void)
 	printf("Corenet Platform Cache: %d KB enabled\n", size);
 }
 
-void invalidate_cpc(void)
+static void invalidate_cpc(void)
 {
 	int i;
 	cpc_corenet_t *cpc = (cpc_corenet_t *)CONFIG_SYS_FSL_CPC_ADDR;
diff --git a/arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c b/arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c
index 2a68060..0df6b54 100644
--- a/arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c
+++ b/arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c
@@ -482,7 +482,7 @@ static void wait_for_rstdone(unsigned int bank)
 }
 
 
-void __soc_serdes_init(void)
+static void __soc_serdes_init(void)
 {
 	/* Allow for SoC-specific initialization in <SOC>_serdes.c  */
 };
diff --git a/board/freescale/common/ngpixis.c b/board/freescale/common/ngpixis.c
index 276ae3c..5f8421a 100644
--- a/board/freescale/common/ngpixis.c
+++ b/board/freescale/common/ngpixis.c
@@ -237,13 +237,15 @@ int pixis_reset_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return 0;
 }
 
-U_BOOT_CMD(
-	pixis_reset, CONFIG_SYS_MAXARGS, 1, pixis_reset_cmd,
-	"Reset the board using the FPGA sequencer",
+static char pixis_help_text[] =
 	"- hard reset to default bank\n"
 	"pixis_reset altbank - reset to alternate bank\n"
 #ifdef DEBUG
 	"pixis_reset dump - display the PIXIS registers\n"
 #endif
-	"pixis_reset sysclk <SYSCLK_freq> - reset with SYSCLK frequency(KHz)\n"
+	"pixis_reset sysclk <SYSCLK_freq> - reset with SYSCLK frequency(KHz)\n";
+
+U_BOOT_CMD(
+	pixis_reset, CONFIG_SYS_MAXARGS, 1, pixis_reset_cmd,
+	"Reset the board using the FPGA sequencer", pixis_help_text
 	);
diff --git a/board/freescale/mpc8568mds/bcsr.c b/board/freescale/mpc8568mds/bcsr.c
index 30676e1..2a172cc 100644
--- a/board/freescale/mpc8568mds/bcsr.c
+++ b/board/freescale/mpc8568mds/bcsr.c
@@ -25,7 +25,7 @@
 
 #include "bcsr.h"
 
-void enable_8568mds_duart()
+void enable_8568mds_duart(void)
 {
 	volatile uint* duart_mux	= (uint *)(CONFIG_SYS_CCSRBAR + 0xe0060);
 	volatile uint* devices		= (uint *)(CONFIG_SYS_CCSRBAR + 0xe0070);
@@ -36,21 +36,21 @@ void enable_8568mds_duart()
 	bcsr[5] |= 0x01;		/* Enable Duart in BCSR*/
 }
 
-void enable_8568mds_flash_write()
+void enable_8568mds_flash_write(void)
 {
 	volatile u8 *bcsr = (u8 *)(CONFIG_SYS_BCSR);
 
 	bcsr[9] |= 0x01;
 }
 
-void disable_8568mds_flash_write()
+void disable_8568mds_flash_write(void)
 {
 	volatile u8 *bcsr = (u8 *)(CONFIG_SYS_BCSR);
 
 	bcsr[9] &= ~(0x01);
 }
 
-void enable_8568mds_qe_mdio()
+void enable_8568mds_qe_mdio(void)
 {
 	u8 *bcsr = (u8 *)(CONFIG_SYS_BCSR);
 
diff --git a/board/freescale/mpc8569mds/bcsr.c b/board/freescale/mpc8569mds/bcsr.c
index b688e5c..37d0c5f 100644
--- a/board/freescale/mpc8569mds/bcsr.c
+++ b/board/freescale/mpc8569mds/bcsr.c
@@ -25,17 +25,17 @@
 
 #include "bcsr.h"
 
-void enable_8569mds_flash_write()
+void enable_8569mds_flash_write(void)
 {
 	setbits_8((u8 *)(CONFIG_SYS_BCSR_BASE + 17), BCSR17_FLASH_nWP);
 }
 
-void disable_8569mds_flash_write()
+void disable_8569mds_flash_write(void)
 {
 	clrbits_8((u8 *)(CONFIG_SYS_BCSR_BASE + 17), BCSR17_FLASH_nWP);
 }
 
-void enable_8569mds_qe_uec()
+void enable_8569mds_qe_uec(void)
 {
 #if defined(CONFIG_SYS_UCC_RGMII_MODE)
 	setbits_8((u8 *)(CONFIG_SYS_BCSR_BASE + 7),
@@ -60,7 +60,7 @@ void enable_8569mds_qe_uec()
 #endif
 }
 
-void disable_8569mds_brd_eeprom_write_protect()
+void disable_8569mds_brd_eeprom_write_protect(void)
 {
 	clrbits_8((u8 *)(CONFIG_SYS_BCSR_BASE + 7), BCSR7_BRD_WRT_PROTECT);
 }
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 23/32] powerpc/mpc83xx: sparse fixes
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (21 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 22/32] powerpc/mpc85xx: " Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 24/32] drivers/block/: " Kim Phillips
                   ` (12 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

fdt.c:91:78: warning: Using plain integer as NULL pointer
fdt.c:103:78: warning: Using plain integer as NULL pointer
speed.c:55:11: warning: symbol 'corecnf_tab' was not declared. Should it be static?
speed.c:519:5: warning: symbol 'do_clocks' was not declared. Should it be static?
mpc8313erdb.c:73:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:74:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:75:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:76:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:79:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:80:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:81:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:82:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:85:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:86:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:87:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:88:17: warning: obsolete struct initializer, use C99 syntax

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 arch/powerpc/cpu/mpc83xx/fdt.c            |  4 ++--
 arch/powerpc/cpu/mpc83xx/speed.c          |  4 ++--
 board/freescale/mpc8313erdb/mpc8313erdb.c | 24 ++++++++++++------------
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/arch/powerpc/cpu/mpc83xx/fdt.c b/arch/powerpc/cpu/mpc83xx/fdt.c
index 028c8f0..6cb096a 100644
--- a/arch/powerpc/cpu/mpc83xx/fdt.c
+++ b/arch/powerpc/cpu/mpc83xx/fdt.c
@@ -88,7 +88,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)
 				u32 tmp[] = { 32, 0x8, 33, 0x8, 34, 0x8 };
 
 				path = fdt_path_offset(blob, prop);
-				prop = fdt_getprop(blob, path, "interrupts", 0);
+				prop = fdt_getprop(blob, path, "interrupts", NULL);
 				if (prop)
 					fdt_setprop(blob, path, "interrupts",
 						    &tmp, sizeof(tmp));
@@ -100,7 +100,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)
 				u32 tmp[] = { 35, 0x8, 36, 0x8, 37, 0x8 };
 
 				path = fdt_path_offset(blob, prop);
-				prop = fdt_getprop(blob, path, "interrupts", 0);
+				prop = fdt_getprop(blob, path, "interrupts", NULL);
 				if (prop)
 					fdt_setprop(blob, path, "interrupts",
 						    &tmp, sizeof(tmp));
diff --git a/arch/powerpc/cpu/mpc83xx/speed.c b/arch/powerpc/cpu/mpc83xx/speed.c
index f78099d..195f5b4 100644
--- a/arch/powerpc/cpu/mpc83xx/speed.c
+++ b/arch/powerpc/cpu/mpc83xx/speed.c
@@ -52,7 +52,7 @@ typedef struct {
 	mult_t vco_divider;
 } corecnf_t;
 
-corecnf_t corecnf_tab[] = {
+static corecnf_t corecnf_tab[] = {
 	{_byp, _byp},		/* 0x00 */
 	{_byp, _byp},		/* 0x01 */
 	{_byp, _byp},		/* 0x02 */
@@ -516,7 +516,7 @@ ulong get_ddr_freq(ulong dummy)
 	return gd->mem_clk;
 }
 
-int do_clocks (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+static int do_clocks(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 {
 	char buf[32];
 
diff --git a/board/freescale/mpc8313erdb/mpc8313erdb.c b/board/freescale/mpc8313erdb/mpc8313erdb.c
index 730ec4e..1071803 100644
--- a/board/freescale/mpc8313erdb/mpc8313erdb.c
+++ b/board/freescale/mpc8313erdb/mpc8313erdb.c
@@ -70,22 +70,22 @@ int checkboard(void)
 #ifndef CONFIG_NAND_SPL
 static struct pci_region pci_regions[] = {
 	{
-		bus_start: CONFIG_SYS_PCI1_MEM_BASE,
-		phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
-		size: CONFIG_SYS_PCI1_MEM_SIZE,
-		flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
+		.bus_start = CONFIG_SYS_PCI1_MEM_BASE,
+		.phys_start = CONFIG_SYS_PCI1_MEM_PHYS,
+		.size = CONFIG_SYS_PCI1_MEM_SIZE,
+		.flags = PCI_REGION_MEM | PCI_REGION_PREFETCH
 	},
 	{
-		bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
-		phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
-		size: CONFIG_SYS_PCI1_MMIO_SIZE,
-		flags: PCI_REGION_MEM
+		.bus_start = CONFIG_SYS_PCI1_MMIO_BASE,
+		.phys_start = CONFIG_SYS_PCI1_MMIO_PHYS,
+		.size = CONFIG_SYS_PCI1_MMIO_SIZE,
+		.flags = PCI_REGION_MEM
 	},
 	{
-		bus_start: CONFIG_SYS_PCI1_IO_BASE,
-		phys_start: CONFIG_SYS_PCI1_IO_PHYS,
-		size: CONFIG_SYS_PCI1_IO_SIZE,
-		flags: PCI_REGION_IO
+		.bus_start = CONFIG_SYS_PCI1_IO_BASE,
+		.phys_start = CONFIG_SYS_PCI1_IO_PHYS,
+		.size = CONFIG_SYS_PCI1_IO_SIZE,
+		.flags = PCI_REGION_IO
 	}
 };
 
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 24/32] drivers/block/: sparse fixes
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (22 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 23/32] powerpc/mpc83xx: " Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 25/32] drivers/gpio/mpc83xx_gpio.c: " Kim Phillips
                   ` (11 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

sata_sil.c:371:7: warning: symbol 'sil_sata_rw_lba28' was not declared. Should it be static?
sata_sil.c:399:7: warning: symbol 'sil_sata_rw_lba48' was not declared. Should it be static?
sata_sil.c:429:6: warning: symbol 'sil_sata_cmd_flush_cache' was not declared. Should it be static?
sata_sil.c:441:6: warning: symbol 'sil_sata_cmd_flush_cache_ext' was not declared. Should it be static?
sata_sil.c:489:7: warning: symbol 'sata_read' was not declared. Should it be static?
sata_sil.c:505:7: warning: symbol 'sata_write' was not declared. Should it be static?
sata_sil.c:526:5: warning: symbol 'init_sata' was not declared. Should it be static?
sata_sil.c:588:5: warning: symbol 'scan_sata' was not declared. Should it be static?
fsl_sata.c:59:6: warning: symbol 'dprint_buffer' was not declared. Should it be static?
fsl_sata.c:187:42: warning: incorrect type in assignment (different base types)
fsl_sata.c:187:42:    expected unsigned int [unsigned] [usertype] cda
fsl_sata.c:187:42:    got restricted __le32 [usertype] <noident>
fsl_sata.c:291:6: warning: symbol 'fsl_sata_hardware_reset' was not declared. Should it be static?
fsl_sata.c:418:27: warning: incorrect type in assignment (different base types)
fsl_sata.c:418:27:    expected unsigned int [unsigned] [usertype] dba
fsl_sata.c:418:27:    got restricted __le32 [usertype] <noident>
fsl_sata.c:424:41: warning: incorrect type in assignment (different base types)
fsl_sata.c:424:41:    expected unsigned int [unsigned] [usertype] ext_c_ddc
fsl_sata.c:424:41:    got restricted __le32 [usertype] <noident>
fsl_sata.c:431:41: warning: incorrect type in assignment (different base types)
fsl_sata.c:431:41:    expected unsigned int [unsigned] [usertype] ext_c_ddc
fsl_sata.c:431:41:    got restricted __le32 [usertype] <noident>
fsl_sata.c:442:22: warning: incorrect type in assignment (different base types)
fsl_sata.c:442:22:    expected unsigned int [unsigned] [usertype] cda
fsl_sata.c:442:22:    got restricted __le32 [usertype] <noident>
fsl_sata.c:446:31: warning: incorrect type in assignment (different base types)
fsl_sata.c:446:31:    expected unsigned int [unsigned] [usertype] prde_fis_len
fsl_sata.c:446:31:    got restricted __le32 [usertype] <noident>
fsl_sata.c:448:22: warning: incorrect type in assignment (different base types)
fsl_sata.c:448:22:    expected unsigned int [unsigned] [usertype] ttl
fsl_sata.c:448:22:    got restricted __le32 [usertype] <noident>
fsl_sata.c:460:28: warning: incorrect type in assignment (different base types)
fsl_sata.c:460:28:    expected unsigned int [unsigned] [usertype] attribute
fsl_sata.c:460:28:    got restricted __le32 [usertype] <noident>
fsl_sata.c:623:6: warning: symbol 'fsl_sata_flush_cache' was not declared. Should it be static?
fsl_sata.c:667:5: warning: symbol 'fsl_sata_rw_ncq_cmd' was not declared. Should it be static?
fsl_sata.c:710:6: warning: symbol 'fsl_sata_flush_cache_ext' was not declared. Should it be static?
fsl_sata.c:725:6: warning: symbol 'fsl_sata_software_reset' was not declared. Should it be static?
fsl_sata.c:760:5: warning: symbol 'ata_low_level_rw_lba48' was not declared. Should it be static?
fsl_sata.c:795:5: warning: symbol 'ata_low_level_rw_lba28' was not declared. Should it be static?

the following compiler warnings show up after fixing the above, so
remove those three functions:

fsl_sata.c:59:13: warning: 'dprint_buffer' defined but not used [-Wunused-function]
fsl_sata.c:291:13: warning: 'fsl_sata_hardware_reset' defined but not used [-Wunused-function]
fsl_sata.c:726:13: warning: 'fsl_sata_software_reset' defined but not used [-Wunused-function]

Other than that, the following are fixed by __iomem annotation:

fsl_sata.c:84:39: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:84:39:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:84:39:    got unsigned int volatile *addr
fsl_sata.c:172:26: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:172:26:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:172:26:    got unsigned int *<noident>
fsl_sata.c:175:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:175:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:175:19:    got unsigned int *<noident>
fsl_sata.c:181:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:181:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:181:19:    got unsigned int *<noident>
fsl_sata.c:184:26: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:184:26:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:184:26:    got unsigned int *<noident>
fsl_sata.c:186:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:186:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:186:19:    got unsigned int *<noident>
fsl_sata.c:189:26: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:189:26:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:189:26:    got unsigned int *<noident>
fsl_sata.c:191:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:191:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:191:19:    got unsigned int *<noident>
fsl_sata.c:194:26: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:194:26:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:194:26:    got unsigned int *<noident>
fsl_sata.c:195:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:195:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:195:19:    got unsigned int *<noident>
fsl_sata.c:198:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:198:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:198:19:    got unsigned int *<noident>
fsl_sata.c:201:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:201:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:201:19:    got unsigned int *<noident>
fsl_sata.c:204:26: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:204:26:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:204:26:    got unsigned int *<noident>
fsl_sata.c:205:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:205:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:205:19:    got unsigned int *<noident>
fsl_sata.c:208:26: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:208:26:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:208:26:    got unsigned int *<noident>
fsl_sata.c:209:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:209:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:209:19:    got unsigned int *<noident>
fsl_sata.c:212:26: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:212:26:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:212:26:    got unsigned int *<noident>
fsl_sata.c:213:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:213:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:213:19:    got unsigned int *<noident>
fsl_sata.c:216:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:216:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:216:19:    got unsigned int *<noident>
fsl_sata.c:219:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:219:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:219:19:    got unsigned int *<noident>
fsl_sata.c:222:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:222:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:222:19:    got unsigned int *<noident>
fsl_sata.c:225:26: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:225:26:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:225:26:    got unsigned int *<noident>
fsl_sata.c:227:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:227:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:227:19:    got unsigned int *<noident>
fsl_sata.c:242:26: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:242:26:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:242:26:    got unsigned int *<noident>
fsl_sata.c:256:32: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:256:32:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:256:32:    got unsigned int *<noident>
fsl_sata.c:262:26: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:262:26:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:262:26:    got unsigned int *<noident>
fsl_sata.c:274:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:274:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:274:53:    got unsigned int *<noident>
fsl_sata.c:275:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:275:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:275:53:    got unsigned int *<noident>
fsl_sata.c:276:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:276:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:276:53:    got unsigned int *<noident>
fsl_sata.c:277:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:277:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:277:53:    got unsigned int *<noident>
fsl_sata.c:278:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:278:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:278:53:    got unsigned int *<noident>
fsl_sata.c:279:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:279:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:279:53:    got unsigned int *<noident>
fsl_sata.c:280:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:280:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:280:53:    got unsigned int *<noident>
fsl_sata.c:281:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:281:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:281:53:    got unsigned int *<noident>
fsl_sata.c:282:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:282:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:282:53:    got unsigned int *<noident>
fsl_sata.c:283:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:283:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:283:53:    got unsigned int *<noident>
fsl_sata.c:284:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:284:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:284:53:    got unsigned int *<noident>
fsl_sata.c:285:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:285:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:285:53:    got unsigned int *<noident>
fsl_sata.c:286:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:286:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:286:53:    got unsigned int *<noident>
fsl_sata.c:287:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:287:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:287:53:    got unsigned int *<noident>
fsl_sata.c:288:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:288:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:288:53:    got unsigned int *<noident>
fsl_sata.c:289:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:289:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:289:53:    got unsigned int *<noident>
fsl_sata.c:290:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:290:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:290:53:    got unsigned int *<noident>
fsl_sata.c:291:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:291:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:291:53:    got unsigned int *<noident>
fsl_sata.c:292:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:292:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:292:53:    got unsigned int *<noident>
fsl_sata.c:293:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:293:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:293:53:    got unsigned int *<noident>
fsl_sata.c:294:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:294:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:294:53:    got unsigned int *<noident>
fsl_sata.c:295:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:295:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:295:53:    got unsigned int *<noident>
fsl_sata.c:296:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:296:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:296:53:    got unsigned int *<noident>
fsl_sata.c:297:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:297:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:297:53:    got unsigned int *<noident>
fsl_sata.c:298:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:298:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:298:53:    got unsigned int *<noident>

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 drivers/block/fsl_sata.c | 79 ++++++------------------------------------------
 drivers/block/fsl_sata.h | 12 ++++----
 drivers/block/sata_sil.c | 13 ++++----
 3 files changed, 23 insertions(+), 81 deletions(-)

diff --git a/drivers/block/fsl_sata.c b/drivers/block/fsl_sata.c
index fda3389..7e2a22a 100644
--- a/drivers/block/fsl_sata.c
+++ b/drivers/block/fsl_sata.c
@@ -56,25 +56,6 @@ static inline void sdelay(unsigned long sec)
 		mdelay(1000);
 }
 
-void dprint_buffer(unsigned char *buf, int len)
-{
-	int i, j;
-
-	i = 0;
-	j = 0;
-	printf("\n\r");
-
-	for (i = 0; i < len; i++) {
-		printf("%02x ", *buf++);
-		j++;
-		if (j == 16) {
-			printf("\n\r");
-			j = 0;
-		}
-	}
-	printf("\n\r");
-}
-
 static void fsl_sata_dump_sfis(struct sata_fis_d2h *s)
 {
 	printf("Status FIS dump:\n\r");
@@ -94,7 +75,7 @@ static void fsl_sata_dump_sfis(struct sata_fis_d2h *s)
 	printf("sector_count_exp:	%02x\n\r", s->sector_count_exp);
 }
 
-static int ata_wait_register(volatile unsigned *addr, u32 mask,
+static int ata_wait_register(unsigned __iomem *addr, u32 mask,
 			 u32 val, u32 timeout_msec)
 {
 	int i;
@@ -112,7 +93,7 @@ int init_sata(int dev)
 	cmd_hdr_tbl_t *cmd_hdr;
 	u32 cda;
 	u32 val32;
-	fsl_sata_reg_t *reg;
+	fsl_sata_reg_t __iomem *reg;
 	u32 sig;
 	int i;
 	fsl_sata_t *sata;
@@ -287,42 +268,7 @@ int init_sata(int dev)
 	return 0;
 }
 
-/* Hardware reset, like Power-on and COMRESET */
-void fsl_sata_hardware_reset(u32 reg_base)
-{
-	fsl_sata_reg_t *reg = (fsl_sata_reg_t *)reg_base;
-	u32 scontrol;
-
-	/* Disable the SATA interface and put PHY offline */
-	scontrol = in_le32(&reg->scontrol);
-	scontrol = (scontrol & 0x0f0) | 0x304;
-	out_le32(&reg->scontrol, scontrol);
-
-	/* No speed strict */
-	scontrol = in_le32(&reg->scontrol);
-	scontrol = scontrol & ~0x0f0;
-	out_le32(&reg->scontrol, scontrol);
-
-	/* Issue PHY wake/reset, Hardware_reset_asserted */
-	scontrol = in_le32(&reg->scontrol);
-	scontrol = (scontrol & 0x0f0) | 0x301;
-	out_le32(&reg->scontrol, scontrol);
-
-	mdelay(100);
-
-	/* Resume PHY, COMRESET negated, the device initialize hardware
-	 * and execute diagnostics, send good status-signature to host,
-	 * which is D2H register FIS, and then the device enter idle state.
-	 */
-	scontrol = in_le32(&reg->scontrol);
-	scontrol = (scontrol & 0x0f0) | 0x300;
-	out_le32(&reg->scontrol, scontrol);
-
-	mdelay(100);
-	return;
-}
-
-static void fsl_sata_dump_regs(fsl_sata_reg_t *reg)
+static void fsl_sata_dump_regs(fsl_sata_reg_t __iomem *reg)
 {
 	printf("\n\rSATA:           %08x\n\r", (u32)reg);
 	printf("CQR:            %08x\n\r", in_le32(&reg->cqr));
@@ -363,7 +309,7 @@ static int fsl_ata_exec_ata_cmd(struct fsl_sata *sata, struct sata_fis_h2d *cfis
 	u32 prde_count;
 	u32 val32;
 	u32 ttl;
-	fsl_sata_reg_t *reg = sata->reg_base;
+	fsl_sata_reg_t __iomem *reg = sata->reg_base;
 	int i;
 
 	/* Check xfer length */
@@ -620,7 +566,7 @@ static u32 fsl_sata_rw_cmd(int dev, u32 start, u32 blkcnt, u8 *buffer, int is_wr
 	return blkcnt;
 }
 
-void fsl_sata_flush_cache(int dev)
+static void fsl_sata_flush_cache(int dev)
 {
 	fsl_sata_t *sata = (fsl_sata_t *)sata_dev_desc[dev].priv;
 	struct sata_fis_h2d h2d, *cfis = &h2d;
@@ -664,7 +610,8 @@ static u32 fsl_sata_rw_cmd_ext(int dev, u32 start, u32 blkcnt, u8 *buffer, int i
 	return blkcnt;
 }
 
-u32 fsl_sata_rw_ncq_cmd(int dev, u32 start, u32 blkcnt, u8 *buffer, int is_write)
+static u32 fsl_sata_rw_ncq_cmd(int dev, u32 start, u32 blkcnt, u8 *buffer,
+			       int is_write)
 {
 	fsl_sata_t *sata = (fsl_sata_t *)sata_dev_desc[dev].priv;
 	struct sata_fis_h2d h2d, *cfis = &h2d;
@@ -707,7 +654,7 @@ u32 fsl_sata_rw_ncq_cmd(int dev, u32 start, u32 blkcnt, u8 *buffer, int is_write
 	return blkcnt;
 }
 
-void fsl_sata_flush_cache_ext(int dev)
+static void fsl_sata_flush_cache_ext(int dev)
 {
 	fsl_sata_t *sata = (fsl_sata_t *)sata_dev_desc[dev].priv;
 	struct sata_fis_h2d h2d, *cfis = &h2d;
@@ -721,12 +668,6 @@ void fsl_sata_flush_cache_ext(int dev)
 	fsl_sata_exec_cmd(sata, cfis, CMD_ATA, 0, NULL, 0);
 }
 
-/* Software reset, set SRST of the Device Control register */
-void fsl_sata_software_reset(int dev)
-{
-	return;
-}
-
 static void fsl_sata_init_wcache(int dev, u16 *id)
 {
 	fsl_sata_t *sata = (fsl_sata_t *)sata_dev_desc[dev].priv;
@@ -757,7 +698,7 @@ static int fsl_sata_get_flush_ext(int dev)
 	return sata->flush_ext;
 }
 
-u32 ata_low_level_rw_lba48(int dev, u32 blknr, lbaint_t blkcnt,
+static u32 ata_low_level_rw_lba48(int dev, u32 blknr, lbaint_t blkcnt,
 		const void *buffer, int is_write)
 {
 	u32 start, blks;
@@ -792,7 +733,7 @@ u32 ata_low_level_rw_lba48(int dev, u32 blknr, lbaint_t blkcnt,
 	return blkcnt;
 }
 
-u32 ata_low_level_rw_lba28(int dev, u32 blknr, u32 blkcnt, const void *buffer,
+static u32 ata_low_level_rw_lba28(int dev, u32 blknr, u32 blkcnt, const void *buffer,
 		int is_write)
 {
 	u32 start, blks;
diff --git a/drivers/block/fsl_sata.h b/drivers/block/fsl_sata.h
index cecff68..58cd2a4 100644
--- a/drivers/block/fsl_sata.h
+++ b/drivers/block/fsl_sata.h
@@ -176,10 +176,10 @@ typedef struct fsl_sata_reg {
 * Command Header Entry
 */
 typedef struct cmd_hdr_entry {
-	u32 cda;		/* Command Descriptor Address, 4 bytes aligned */
-	u32 prde_fis_len;	/* Number of PRD entries and FIS length */
-	u32 ttl;		/* Total transfer length */
-	u32 attribute;		/* the attribute of command */
+	__le32 cda;		/* Command Descriptor Address, 4 bytes aligned */
+	__le32 prde_fis_len;	/* Number of PRD entries and FIS length */
+	__le32 ttl;		/* Total transfer length */
+	__le32 attribute;	/* the attribute of command */
 } __attribute__ ((packed)) cmd_hdr_entry_t;
 
 #define SATA_HC_CMD_HDR_ENTRY_SIZE	sizeof(struct cmd_hdr_entry)
@@ -230,10 +230,10 @@ typedef struct cmd_hdr_tbl {
 * PRD entry - Physical Region Descriptor entry
 */
 typedef struct prd_entry {
-	u32 dba;	/* Data base address, 4 bytes aligned */
+	__le32 dba;	/* Data base address, 4 bytes aligned */
 	u32 res1;
 	u32 res2;
-	u32 ext_c_ddc;	/* Indirect PRD flags, snoop and data word count */
+	__le32 ext_c_ddc;	/* Indirect PRD flags, snoop and data word count */
 } __attribute__ ((packed)) prd_entry_t;
 
 #define SATA_HC_CMD_DESC_PRD_SIZE	sizeof(struct prd_entry)
diff --git a/drivers/block/sata_sil.c b/drivers/block/sata_sil.c
index 245b872..b70f04d 100644
--- a/drivers/block/sata_sil.c
+++ b/drivers/block/sata_sil.c
@@ -27,6 +27,7 @@
 #include <fis.h>
 #include <sata.h>
 #include <libata.h>
+#include <sata.h>
 #include "sata_sil.h"
 
 /* Convert sectorsize to wordsize */
@@ -369,8 +370,8 @@ static ulong sil_sata_rw_cmd_ext(int dev, ulong start, ulong blkcnt,
 	return blkcnt;
 }
 
-ulong sil_sata_rw_lba28(int dev, ulong blknr, lbaint_t blkcnt,
-		const void *buffer, int is_write)
+static ulong sil_sata_rw_lba28(int dev, ulong blknr, lbaint_t blkcnt,
+			       const void *buffer, int is_write)
 {
 	ulong start, blks, max_blks;
 	u8 *addr;
@@ -397,8 +398,8 @@ ulong sil_sata_rw_lba28(int dev, ulong blknr, lbaint_t blkcnt,
 	return blkcnt;
 }
 
-ulong sil_sata_rw_lba48(int dev, ulong blknr, lbaint_t blkcnt,
-		const void *buffer, int is_write)
+static ulong sil_sata_rw_lba48(int dev, ulong blknr, lbaint_t blkcnt,
+			       const void *buffer, int is_write)
 {
 	ulong start, blks, max_blks;
 	u8 *addr;
@@ -427,7 +428,7 @@ ulong sil_sata_rw_lba48(int dev, ulong blknr, lbaint_t blkcnt,
 	return blkcnt;
 }
 
-void sil_sata_cmd_flush_cache(int dev)
+static void sil_sata_cmd_flush_cache(int dev)
 {
 	struct sil_cmd_block cmdb, *pcmd = &cmdb;
 
@@ -439,7 +440,7 @@ void sil_sata_cmd_flush_cache(int dev)
 	sil_exec_cmd(dev, pcmd, 0);
 }
 
-void sil_sata_cmd_flush_cache_ext(int dev)
+static void sil_sata_cmd_flush_cache_ext(int dev)
 {
 	struct sil_cmd_block cmdb, *pcmd = &cmdb;
 
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 25/32] drivers/gpio/mpc83xx_gpio.c: sparse fixes
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (23 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 24/32] drivers/block/: " Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 26/32] drivers/input/input.c: sparse fix Kim Phillips
                   ` (10 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

mpc83xx_gpio.c:166:26: warning: non-ANSI function declaration of function 'mpc83xx_gpio_init_f'
mpc83xx_gpio.c:190:26: warning: non-ANSI function declaration of function 'mpc83xx_gpio_init_r'

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 drivers/gpio/mpc83xx_gpio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/mpc83xx_gpio.c b/drivers/gpio/mpc83xx_gpio.c
index a9afcb2..e167852 100644
--- a/drivers/gpio/mpc83xx_gpio.c
+++ b/drivers/gpio/mpc83xx_gpio.c
@@ -163,7 +163,7 @@ int gpio_set_value(unsigned gpio, int value)
 }
 
 /* Configure GPIO registers early */
-void mpc83xx_gpio_init_f()
+void mpc83xx_gpio_init_f(void)
 {
 	immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
 
@@ -187,7 +187,7 @@ void mpc83xx_gpio_init_f()
 }
 
 /* Initialize GPIO soft-copies */
-void mpc83xx_gpio_init_r()
+void mpc83xx_gpio_init_r(void)
 {
 #if MPC83XX_GPIO_CTRLRS >= 1
 	gpio_output_value[0] = CONFIG_MPC83XX_GPIO_0_INIT_VALUE;
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 26/32] drivers/input/input.c: sparse fix
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (24 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 25/32] drivers/gpio/mpc83xx_gpio.c: " Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 27/32] drivers/i2c/fsl_i2c.c: " Kim Phillips
                   ` (9 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

input.c:97:5: warning: symbol 'input_queue_ascii' was not declared. Should it be

TODO: fix:

input.c:236:18: error: bad constant expression
input.c:344:17: error: bad constant expression

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 drivers/input/input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index 5b2b4b0..5a4c76d 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -94,7 +94,7 @@ static unsigned char kbd_ctrl_xlate[] = {
 };
 
 
-int input_queue_ascii(struct input_config *config, int ch)
+static int input_queue_ascii(struct input_config *config, int ch)
 {
 	if (config->fifo_in + 1 == INPUT_BUFFER_LEN) {
 		if (!config->fifo_out)
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 27/32] drivers/i2c/fsl_i2c.c: sparse fix
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (25 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 26/32] drivers/input/input.c: sparse fix Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  3:57   ` Heiko Schocher
  2012-10-26  3:29   ` [U-Boot] [U-Boot,27/32] " Tom Rini
  2012-10-17  0:28 ` [U-Boot] [PATCH 28/32] drivers/mmc/mmc.c: sparse fixes Kim Phillips
                   ` (8 subsequent siblings)
  35 siblings, 2 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

fsl_i2c.c:217:14: warning: symbol 'get_i2c_clock' was not declared. Should it be static?

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 drivers/i2c/fsl_i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c
index 5b017a9..3cb232f 100644
--- a/drivers/i2c/fsl_i2c.c
+++ b/drivers/i2c/fsl_i2c.c
@@ -214,7 +214,7 @@ static unsigned int set_i2c_bus_speed(const struct fsl_i2c *dev,
 	return speed;
 }
 
-unsigned int get_i2c_clock(int bus)
+static unsigned int get_i2c_clock(int bus)
 {
 	if (bus)
 		return gd->i2c2_clk;	/* I2C2 clock */
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 28/32] drivers/mmc/mmc.c: sparse fixes
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (26 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 27/32] drivers/i2c/fsl_i2c.c: " Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 29/32] drivers/mmc/fsl_esdhc.c: " Kim Phillips
                   ` (7 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

mmc.c:137:5: warning: symbol 'mmc_send_cmd' was not declared. Should it be static?
mmc.c:203:5: warning: symbol 'mmc_send_status' was not declared. Should it be static?
mmc.c:247:5: warning: symbol 'mmc_set_blocklen' was not declared. Should it be static?
mmc.c:440:5: warning: symbol 'mmc_read_blocks' was not declared. Should it be static?
mmc.c:510:5: warning: symbol 'mmc_go_idle' was not declared. Should it be static?
mmc.c:532:1: warning: symbol 'sd_send_op_cond' was not declared. Should it be static?
mmc.c:597:5: warning: symbol 'mmc_send_op_cond' was not declared. Should it be static?
mmc.c:661:5: warning: symbol 'mmc_send_ext_csd' was not declared. Should it be static?
mmc.c:683:5: warning: symbol 'mmc_switch' was not declared. Should it be static?
mmc.c:705:5: warning: symbol 'mmc_change_freq' was not declared. Should it be static?
mmc.c:775:5: warning: symbol 'sd_switch' was not declared. Should it be static?
mmc.c:796:5: warning: symbol 'sd_change_freq' was not declared. Should it be static?
mmc.c:935:6: warning: symbol 'mmc_set_ios' was not declared. Should it be static?
mmc.c:953:6: warning: symbol 'mmc_set_bus_width' was not declared. Should it be static?
mmc.c:1108:26: warning: dubious: !x & y
mmc.c:960:5: warning: symbol 'mmc_startup' was not declared. Should it be static?
mmc.c:1243:5: warning: symbol 'mmc_send_if_cond' was not declared. Should it be s

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 drivers/mmc/mmc.c | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index a60cfe1..b1b6a07 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -134,7 +134,8 @@ static inline void mmc_bounce_buffer_stop(struct mmc_data *backup,
 					struct mmc_data *orig) { }
 #endif
 
-int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
+static int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
+			struct mmc_data *data)
 {
 	struct mmc_data backup;
 	int ret;
@@ -200,7 +201,7 @@ int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
 	return ret;
 }
 
-int mmc_send_status(struct mmc *mmc, int timeout)
+static int mmc_send_status(struct mmc *mmc, int timeout)
 {
 	struct mmc_cmd cmd;
 	int err, retries = 5;
@@ -244,7 +245,7 @@ int mmc_send_status(struct mmc *mmc, int timeout)
 	return 0;
 }
 
-int mmc_set_blocklen(struct mmc *mmc, int len)
+static int mmc_set_blocklen(struct mmc *mmc, int len)
 {
 	struct mmc_cmd cmd;
 
@@ -437,7 +438,8 @@ mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const void*src)
 	return blkcnt;
 }
 
-int mmc_read_blocks(struct mmc *mmc, void *dst, ulong start, lbaint_t blkcnt)
+static int mmc_read_blocks(struct mmc *mmc, void *dst, ulong start,
+			   lbaint_t blkcnt)
 {
 	struct mmc_cmd cmd;
 	struct mmc_data data;
@@ -507,7 +509,7 @@ static ulong mmc_bread(int dev_num, ulong start, lbaint_t blkcnt, void *dst)
 	return blkcnt;
 }
 
-int mmc_go_idle(struct mmc* mmc)
+static int mmc_go_idle(struct mmc* mmc)
 {
 	struct mmc_cmd cmd;
 	int err;
@@ -528,8 +530,7 @@ int mmc_go_idle(struct mmc* mmc)
 	return 0;
 }
 
-int
-sd_send_op_cond(struct mmc *mmc)
+static int sd_send_op_cond(struct mmc *mmc)
 {
 	int timeout = 1000;
 	int err;
@@ -594,7 +595,7 @@ sd_send_op_cond(struct mmc *mmc)
 	return 0;
 }
 
-int mmc_send_op_cond(struct mmc *mmc)
+static int mmc_send_op_cond(struct mmc *mmc)
 {
 	int timeout = 10000;
 	struct mmc_cmd cmd;
@@ -658,7 +659,7 @@ int mmc_send_op_cond(struct mmc *mmc)
 }
 
 
-int mmc_send_ext_csd(struct mmc *mmc, u8 *ext_csd)
+static int mmc_send_ext_csd(struct mmc *mmc, u8 *ext_csd)
 {
 	struct mmc_cmd cmd;
 	struct mmc_data data;
@@ -680,7 +681,7 @@ int mmc_send_ext_csd(struct mmc *mmc, u8 *ext_csd)
 }
 
 
-int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
+static int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
 {
 	struct mmc_cmd cmd;
 	int timeout = 1000;
@@ -702,7 +703,7 @@ int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
 
 }
 
-int mmc_change_freq(struct mmc *mmc)
+static int mmc_change_freq(struct mmc *mmc)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(u8, ext_csd, 512);
 	char cardtype;
@@ -772,7 +773,7 @@ int mmc_getcd(struct mmc *mmc)
 	return cd;
 }
 
-int sd_switch(struct mmc *mmc, int mode, int group, u8 value, u8 *resp)
+static int sd_switch(struct mmc *mmc, int mode, int group, u8 value, u8 *resp)
 {
 	struct mmc_cmd cmd;
 	struct mmc_data data;
@@ -793,7 +794,7 @@ int sd_switch(struct mmc *mmc, int mode, int group, u8 value, u8 *resp)
 }
 
 
-int sd_change_freq(struct mmc *mmc)
+static int sd_change_freq(struct mmc *mmc)
 {
 	int err;
 	struct mmc_cmd cmd;
@@ -932,7 +933,7 @@ static const int multipliers[] = {
 	80,
 };
 
-void mmc_set_ios(struct mmc *mmc)
+static void mmc_set_ios(struct mmc *mmc)
 {
 	mmc->set_ios(mmc);
 }
@@ -950,14 +951,14 @@ void mmc_set_clock(struct mmc *mmc, uint clock)
 	mmc_set_ios(mmc);
 }
 
-void mmc_set_bus_width(struct mmc *mmc, uint width)
+static void mmc_set_bus_width(struct mmc *mmc, uint width)
 {
 	mmc->bus_width = width;
 
 	mmc_set_ios(mmc);
 }
 
-int mmc_startup(struct mmc *mmc)
+static int mmc_startup(struct mmc *mmc)
 {
 	int err, width;
 	uint mult, freq;
@@ -1105,7 +1106,7 @@ int mmc_startup(struct mmc *mmc)
 	if (!IS_SD(mmc) && (mmc->version >= MMC_VERSION_4)) {
 		/* check  ext_csd version and capacity */
 		err = mmc_send_ext_csd(mmc, ext_csd);
-		if (!err & (ext_csd[EXT_CSD_REV] >= 2)) {
+		if (!err && (ext_csd[EXT_CSD_REV] >= 2)) {
 			/*
 			 * According to the JEDEC Standard, the value of
 			 * ext_csd's capacity is valid if the value is more
@@ -1240,7 +1241,7 @@ int mmc_startup(struct mmc *mmc)
 	return 0;
 }
 
-int mmc_send_if_cond(struct mmc *mmc)
+static int mmc_send_if_cond(struct mmc *mmc)
 {
 	struct mmc_cmd cmd;
 	int err;
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 29/32] drivers/mmc/fsl_esdhc.c: sparse fixes
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (27 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 28/32] drivers/mmc/mmc.c: sparse fixes Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 30/32] drivers/mtd/cfi_flash.c: " Kim Phillips
                   ` (6 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

fsl_esdhc.c:71:6: warning: symbol 'esdhc_xfertyp' was not declared. Should it be static?
fsl_esdhc.c:413:6: warning: symbol 'set_sysctl' was not declared. Should it be st

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 drivers/mmc/fsl_esdhc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index 3f8d30d..301dd8c 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -68,7 +68,7 @@ struct fsl_esdhc {
 };
 
 /* Return the XFERTYP flags for a given command and data packet */
-uint esdhc_xfertyp(struct mmc_cmd *cmd, struct mmc_data *data)
+static uint esdhc_xfertyp(struct mmc_cmd *cmd, struct mmc_data *data)
 {
 	uint xfertyp = 0;
 
@@ -410,7 +410,7 @@ esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
 	return 0;
 }
 
-void set_sysctl(struct mmc *mmc, uint clock)
+static void set_sysctl(struct mmc *mmc, uint clock)
 {
 	int sdhc_clk = gd->sdhc_clk;
 	int div, pre_div;
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 30/32] drivers/mtd/cfi_flash.c: sparse fixes
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (28 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 29/32] drivers/mmc/fsl_esdhc.c: " Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-17  0:28 ` [U-Boot] [PATCH 31/32] drivers/mtd/nand: " Kim Phillips
                   ` (5 subsequent siblings)
  35 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

cfi_flash.c:756:43: warning: Using plain integer as NULL pointer
cfi_flash.c:1150:52: warning: cast to non-scalar
cfi_flash.c:1433:46: warning: cast truncates bits from constant value (890089 becomes 89)
cfi_flash.c:1490:61: warning: cast truncates bits from constant value (1f001f becomes 1f)
cfi_flash.c:1508:61: warning: cast truncates bits from constant value (10001 becomes 1)
cfi_flash.c:1738:63: warning: cast truncates bits from constant value (10001 becomes 1)
cfi_flash.c:1857:6: warning: symbol '__flash_cmd_reset' was not declared. Should it be static?

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 drivers/mtd/cfi_flash.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 43140f3..8a90f32 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -753,7 +753,7 @@ static void flash_add_byte (flash_info_t * info, cfiword_t * cword, uchar c)
 static flash_sect_t find_sector (flash_info_t * info, ulong addr)
 {
 	static flash_sect_t saved_sector = 0; /* previously found sector */
-	static flash_info_t *saved_info = 0; /* previously used flash bank */
+	static flash_info_t *saved_info = NULL; /* previously used flash bank */
 	flash_sect_t sector = saved_sector;
 
 	if ((info != saved_info) || (sector >= info->sector_count))
@@ -1147,8 +1147,9 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
 			}
 
 			if (use_flash_status_poll(info)) {
-				cfiword_t cword = (cfiword_t)0xffffffffffffffffULL;
+				cfiword_t cword;
 				void *dest;
+				cword.ll = 0xffffffffffffffffULL;
 				dest = flash_map(info, sect, 0);
 				st = flash_status_poll(info, &cword, dest,
 						       info->erase_blk_tout, "erase");
@@ -1430,8 +1431,8 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
 
 static int cfi_protect_bugfix(flash_info_t *info, long sector, int prot)
 {
-	if ((info->manufacturer_id == (uchar)INTEL_MANUFACT) &&
-		(info->device_id == NUMONYX_256MBIT)) {
+	if (info->manufacturer_id == ((INTEL_MANUFACT & FLASH_VENDMASK) >> 16)
+	    && info->device_id == NUMONYX_256MBIT) {
 		/*
 		 * see errata called
 		 * "Numonyx Axcell P33/P30 Specification Update" :)
@@ -1487,7 +1488,8 @@ int flash_real_protect (flash_info_t * info, long sector, int prot)
 		case CFI_CMDSET_AMD_EXTENDED:
 		case CFI_CMDSET_AMD_STANDARD:
 			/* U-Boot only checks the first byte */
-			if (info->manufacturer_id == (uchar)ATM_MANUFACT) {
+			if (info->manufacturer_id ==
+			    ((ATM_MANUFACT & FLASH_VENDMASK) >> 16)) {
 				if (prot) {
 					flash_unlock_seq (info, 0);
 					flash_write_cmd (info, 0,
@@ -1505,7 +1507,8 @@ int flash_real_protect (flash_info_t * info, long sector, int prot)
 							0, ATM_CMD_UNLOCK_SECT);
 				}
 			}
-			if (info->manufacturer_id == (uchar)AMD_MANUFACT) {
+			if (info->manufacturer_id ==
+			    ((AMD_MANUFACT & FLASH_VENDMASK) >> 16)) {
 				int flag = disable_interrupts();
 				int lock_flag;
 
@@ -1735,7 +1738,8 @@ static int cmdset_amd_init(flash_info_t *info, struct cfi_qry *qry)
 	flash_write_cmd(info, 0, info->cfi_offset, FLASH_CMD_CFI);
 
 #ifdef CONFIG_SYS_FLASH_PROTECTION
-	if (info->ext_addr && info->manufacturer_id == (uchar)AMD_MANUFACT) {
+	if (info->ext_addr && info->manufacturer_id ==
+	    ((AMD_MANUFACT & FLASH_VENDMASK) >> 16)) {
 		ushort spus;
 
 		/* read sector protect/unprotect scheme */
@@ -1854,7 +1858,7 @@ static void flash_read_cfi (flash_info_t *info, void *buf,
 		p[i] = flash_read_uchar(info, start + i);
 }
 
-void __flash_cmd_reset(flash_info_t *info)
+static void __flash_cmd_reset(flash_info_t *info)
 {
 	/*
 	 * We do not yet know what kind of commandset to use, so we issue
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 31/32] drivers/mtd/nand: sparse fixes
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (29 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 30/32] drivers/mtd/cfi_flash.c: " Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-22 19:18   ` Scott Wood
  2012-10-17  0:28 ` [U-Boot] [PATCH 32/32] drivers/serial/serial_ns16550.c: " Kim Phillips
                   ` (4 subsequent siblings)
  35 siblings, 1 reply; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

nand_ecc.c:82:5: warning: symbol 'nand_calculate_ecc' was not declared. Should it be static?
nand_ecc.c:155:5: warning: symbol 'nand_correct_data' was not declared. Should it be static?
nand_base.c:2854:1: error: directive in argument list
nand_base.c:2856:1: error: directive in argument list

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 drivers/mtd/nand/nand_base.c | 9 +++++----
 drivers/mtd/nand/nand_ecc.c  | 1 +
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 71f5027..110cebd 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2849,12 +2849,13 @@ ident_done:
 
 	/* TODO onfi flash name */
 	MTDDEBUG (MTD_DEBUG_LEVEL0, "NAND device: Manufacturer ID:"
-		" 0x%02x, Chip ID: 0x%02x (%s %s)\n", *maf_id, *dev_id,
-		nand_manuf_ids[maf_idx].name,
+		" 0x%02x, Chip ID: 0x%02x (%s", *maf_id, *dev_id,
+		nand_manuf_ids[maf_idx].name);
 #ifdef CONFIG_SYS_NAND_ONFI_DETECTION
-		chip->onfi_version ? chip->onfi_params.model : type->name);
+	MTDDEBUG (MTD_DEBUG_LEVEL0, " %s)\n", chip->onfi_version ?
+		  chip->onfi_params.model : type->name);
 #else
-		type->name);
+	MTDDEBUG (MTD_DEBUG_LEVEL0, " %s)\n", type->name);
 #endif
 
 	return type;
diff --git a/drivers/mtd/nand/nand_ecc.c b/drivers/mtd/nand/nand_ecc.c
index 81f0e08..097cf62 100644
--- a/drivers/mtd/nand/nand_ecc.c
+++ b/drivers/mtd/nand/nand_ecc.c
@@ -39,6 +39,7 @@
 
 #include <asm/errno.h>
 #include <linux/mtd/mtd.h>
+#include <linux/mtd/nand_ecc.h>
 
 /* The PPC4xx NDFC uses Smart Media (SMC) bytes order */
 #ifdef CONFIG_NAND_NDFC
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 32/32] drivers/serial/serial_ns16550.c: sparse fixes
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (30 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 31/32] drivers/mtd/nand: " Kim Phillips
@ 2012-10-17  0:28 ` Kim Phillips
  2012-10-26  3:30   ` [U-Boot] [U-Boot, " Tom Rini
  2012-10-18  0:19 ` [U-Boot] [PATCH 00/32] Initial sparse fix series Jerry Van Baren
                   ` (3 subsequent siblings)
  35 siblings, 1 reply; 133+ messages in thread
From: Kim Phillips @ 2012-10-17  0:28 UTC (permalink / raw)
  To: u-boot

serial_ns16550.c:222:1: warning: symbol 'eserial1_init' was not declared. Should it be static?
serial_ns16550.c:222:1: warning: symbol 'eserial1_setbrg' was not declared. Should it be static?
serial_ns16550.c:222:1: warning: symbol 'eserial1_getc' was not declared. Should it be static?
serial_ns16550.c:222:1: warning: symbol 'eserial1_tstc' was not declared. Should it be static?
serial_ns16550.c:222:1: warning: symbol 'eserial1_putc' was not declared. Should it be static?
serial_ns16550.c:222:1: warning: symbol 'eserial1_puts' was not declared. Should it be static?
serial_ns16550.c:225:1: warning: symbol 'eserial2_init' was not declared. Should it be static?
serial_ns16550.c:225:1: warning: symbol 'eserial2_setbrg' was not declared. Should it be static?
serial_ns16550.c:225:1: warning: symbol 'eserial2_getc' was not declared. Should it be static?
serial_ns16550.c:225:1: warning: symbol 'eserial2_tstc' was not declared. Should it be static?
serial_ns16550.c:225:1: warning: symbol 'eserial2_putc' was not declared. Should it be static?
serial_ns16550.c:225:1: warning: symbol 'eserial2_puts' was not declared. Should it be static?
serial_ns16550.c:228:1: warning: symbol 'eserial3_init' was not declared. Should it be static?
serial_ns16550.c:228:1: warning: symbol 'eserial3_setbrg' was not declared. Should it be static?
serial_ns16550.c:228:1: warning: symbol 'eserial3_getc' was not declared. Should it be static?
serial_ns16550.c:228:1: warning: symbol 'eserial3_tstc' was not declared. Should it be static?
serial_ns16550.c:228:1: warning: symbol 'eserial3_putc' was not declared. Should it be static?
serial_ns16550.c:228:1: warning: symbol 'eserial3_puts' was not declared. Should it be static?
serial_ns16550.c:231:1: warning: symbol 'eserial4_init' was not declared. Should it be static?
serial_ns16550.c:231:1: warning: symbol 'eserial4_setbrg' was not declared. Should it be static?
serial_ns16550.c:231:1: warning: symbol 'eserial4_getc' was not declared. Should it be static?
serial_ns16550.c:231:1: warning: symbol 'eserial4_tstc' was not declared. Should it be static?
serial_ns16550.c:231:1: warning: symbol 'eserial4_putc' was not declared. Should it be static?
serial_ns16550.c:231:1: warning: symbol 'eserial4_puts' was not declared. Should it be static?

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 drivers/serial/serial_ns16550.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index b5d1248..4176e25 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -78,20 +78,20 @@ static NS16550_t serial_ports[4] = {
 
 /* Multi serial device functions */
 #define DECLARE_ESERIAL_FUNCTIONS(port) \
-    int  eserial##port##_init (void) {\
+    static int  eserial##port##_init (void) {\
 	int clock_divisor; \
 	clock_divisor = calc_divisor(serial_ports[port-1]); \
 	NS16550_init(serial_ports[port-1], clock_divisor); \
 	return(0);}\
-    void eserial##port##_setbrg (void) {\
+    static void eserial##port##_setbrg (void) {\
 	serial_setbrg_dev(port);}\
-    int  eserial##port##_getc (void) {\
+    static int  eserial##port##_getc (void) {\
 	return serial_getc_dev(port);}\
-    int  eserial##port##_tstc (void) {\
+    static int  eserial##port##_tstc (void) {\
 	return serial_tstc_dev(port);}\
-    void eserial##port##_putc (const char c) {\
+    static void eserial##port##_putc (const char c) {\
 	serial_putc_dev(port, c);}\
-    void eserial##port##_puts (const char *s) {\
+    static void eserial##port##_puts (const char *s) {\
 	serial_puts_dev(port, s);}
 
 /* Serial device descriptor */
-- 
1.7.12.3

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 27/32] drivers/i2c/fsl_i2c.c: sparse fix
  2012-10-17  0:28 ` [U-Boot] [PATCH 27/32] drivers/i2c/fsl_i2c.c: " Kim Phillips
@ 2012-10-17  3:57   ` Heiko Schocher
  2012-10-26  3:29   ` [U-Boot] [U-Boot,27/32] " Tom Rini
  1 sibling, 0 replies; 133+ messages in thread
From: Heiko Schocher @ 2012-10-17  3:57 UTC (permalink / raw)
  To: u-boot

Helo Kim,

On 17.10.2012 02:28, Kim Phillips wrote:
> fsl_i2c.c:217:14: warning: symbol 'get_i2c_clock' was not declared. Should it be static?
>
> Signed-off-by: Kim Phillips<kim.phillips@freescale.com>
> ---
>   drivers/i2c/fsl_i2c.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Acked-by: Heiko Schocher <hs@denx.de>

Thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 00/32] Initial sparse fix series
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (31 preceding siblings ...)
  2012-10-17  0:28 ` [U-Boot] [PATCH 32/32] drivers/serial/serial_ns16550.c: " Kim Phillips
@ 2012-10-18  0:19 ` Jerry Van Baren
  2012-10-18 12:11   ` David Gibson
  2012-10-18 16:53 ` [U-Boot] [PATCH 00/32] Initial sparse fix series Tom Rini
                   ` (2 subsequent siblings)
  35 siblings, 1 reply; 133+ messages in thread
From: Jerry Van Baren @ 2012-10-18  0:19 UTC (permalink / raw)
  To: u-boot

Hi David, Jon,

Kim Phillips created a series of patches to change variable declarations
that are big endian to be __be32/__be64.  Since the device tree is
defined to be big endian, he created a patch to mark the appropriate
libfdt entities as __be*.

On 10/16/2012 08:28 PM, Kim Phillips wrote:
> This 32-patch series only begins to address making u-boot source more
> 'sparseable,' or sparse-clean, ultimately to catch type, address space,
> and endianness mismatches and generally improve code quality. E.g., in this
> initial dose whose main purpose is to reduce the output volume to workable
> levels, a couple of endianness bugs are found and fixed in
> of_bus_default_translate() and fdt_get_base_address().  See [PATCH 14/32]
> common/fdt_support.c: sparse fixes.

Upside: This is very good for identifying endian errors early.
Downside: It could break/complicate non-linux uses of libfdt.

What are your thoughts on this quest?

[snip]

> Note that there are two libfdt dependencies:

[snipped #1, u-boot-fdt dependency, NBD]

> 2. potential upstream dtc change dependencies, due to having to attribute base
> device tree header types to __be32 in include/libfdt.  See patch 19/32
> "include/fdt.h: sparse fixes".  It is unknown whether such changes would
> be welcome to dtc (but there's a way to find out :).

[snip]

> Build-tested in both endians :).  Please help test.
> 
> Thanks,
> 
> Kim

Below is the actual patch for reference (it was in a separate email).
The impact in terms of changed lines is pretty small.  I'm not sure how
this impacts non-linux / non-gcc systems since the sparse checker comes
from a linux background and uses gcc extensions.

Possibly this could be handled a definition:

#ifndef _LINUX_TYPES_H
typedef uint32_t __be32
typedef uint64_t __be64
#endif

>  include/fdt.h         | 33 +++++++++++++++++----------------
>  include/fdt_support.h |  2 ++
>  include/libfdt.h      |  4 ++--
>  lib/libfdt/fdt.c      |  2 +-
>  lib/libfdt/fdt_ro.c   |  2 +-
>  lib/libfdt/fdt_rw.c   |  4 ++--
>  lib/libfdt/fdt_sw.c   |  4 ++--
>  lib/libfdt/fdt_wip.c  |  2 +-
>  8 files changed, 28 insertions(+), 25 deletions(-)
> 
> diff --git a/include/fdt.h b/include/fdt.h
> index c51212e..1b7f044 100644
> --- a/include/fdt.h
> +++ b/include/fdt.h
> @@ -2,40 +2,41 @@
>  #define _FDT_H
>  
>  #ifndef __ASSEMBLY__
> +#include <asm/byteorder.h>
>  
>  struct fdt_header {
> -	uint32_t magic;			 /* magic word FDT_MAGIC */
> -	uint32_t totalsize;		 /* total size of DT block */
> -	uint32_t off_dt_struct;		 /* offset to structure */
> -	uint32_t off_dt_strings;	 /* offset to strings */
> -	uint32_t off_mem_rsvmap;	 /* offset to memory reserve map */
> -	uint32_t version;		 /* format version */
> -	uint32_t last_comp_version;	 /* last compatible version */
> +	__be32 magic;			 /* magic word FDT_MAGIC */
> +	__be32 totalsize;		 /* total size of DT block */
> +	__be32 off_dt_struct;		 /* offset to structure */
> +	__be32 off_dt_strings;	 /* offset to strings */
> +	__be32 off_mem_rsvmap;	 /* offset to memory reserve map */
> +	__be32 version;		 /* format version */
> +	__be32 last_comp_version;	 /* last compatible version */
>  
>  	/* version 2 fields below */
> -	uint32_t boot_cpuid_phys;	 /* Which physical CPU id we're
> +	__be32 boot_cpuid_phys;	 /* Which physical CPU id we're
>  					    booting on */
>  	/* version 3 fields below */
> -	uint32_t size_dt_strings;	 /* size of the strings block */
> +	__be32 size_dt_strings;	 /* size of the strings block */
>  
>  	/* version 17 fields below */
> -	uint32_t size_dt_struct;	 /* size of the structure block */
> +	__be32 size_dt_struct;	 /* size of the structure block */
>  };
>  
>  struct fdt_reserve_entry {
> -	uint64_t address;
> -	uint64_t size;
> +	__be64 address;
> +	__be64 size;
>  };
>  
>  struct fdt_node_header {
> -	uint32_t tag;
> +	__be32 tag;
>  	char name[0];
>  };
>  
>  struct fdt_property {
> -	uint32_t tag;
> -	uint32_t len;
> -	uint32_t nameoff;
> +	__be32 tag;
> +	__be32 len;
> +	__be32 nameoff;
>  	char data[0];
>  };
>  
> diff --git a/include/fdt_support.h b/include/fdt_support.h
> index 2e18d82..399b73f 100644
> --- a/include/fdt_support.h
> +++ b/include/fdt_support.h
> @@ -81,7 +81,9 @@ int fdt_pci_dma_ranges(void *blob, int phb_off, struct pci_controller *hose);
>  #ifdef CONFIG_OF_BOARD_SETUP
>  void ft_board_setup(void *blob, bd_t *bd);
>  void ft_cpu_setup(void *blob, bd_t *bd);
> +void ft_fixup_num_cores(void *blob);
>  void ft_pci_setup(void *blob, bd_t *bd);
> +void ft_srio_setup(void *blob);
>  #endif
>  
>  void set_working_fdt_addr(void *addr);
> diff --git a/include/libfdt.h b/include/libfdt.h
> index 4589c5f..ab98d23 100644
> --- a/include/libfdt.h
> +++ b/include/libfdt.h
> @@ -1153,8 +1153,8 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
>  static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,
>  				  uint32_t val)
>  {
> -	val = cpu_to_fdt32(val);
> -	return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val));
> +	__be32 tmp = cpu_to_fdt32(val);
> +	return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
>  }
>  
>  /**
> diff --git a/lib/libfdt/fdt.c b/lib/libfdt/fdt.c
> index 4157b21..5a82c60 100644
> --- a/lib/libfdt/fdt.c
> +++ b/lib/libfdt/fdt.c
> @@ -96,7 +96,7 @@ const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)
>  
>  uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
>  {
> -	const uint32_t *tagp, *lenp;
> +	const __be32 *tagp, *lenp;
>  	uint32_t tag;
>  	int offset = startoffset;
>  	const char *p;
> diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
> index 1933010..4e3d87a 100644
> --- a/lib/libfdt/fdt_ro.c
> +++ b/lib/libfdt/fdt_ro.c
> @@ -326,7 +326,7 @@ const void *fdt_getprop(const void *fdt, int nodeoffset,
>  
>  uint32_t fdt_get_phandle(const void *fdt, int nodeoffset)
>  {
> -	const uint32_t *php;
> +	const __be32 *php;
>  	int len;
>  
>  	/* FIXME: This is a bit sub-optimal, since we potentially scan
> diff --git a/lib/libfdt/fdt_rw.c b/lib/libfdt/fdt_rw.c
> index 5ed23d6..688b817 100644
> --- a/lib/libfdt/fdt_rw.c
> +++ b/lib/libfdt/fdt_rw.c
> @@ -343,7 +343,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
>  	int nodelen;
>  	int err;
>  	uint32_t tag;
> -	uint32_t *endtag;
> +	__be32 *endtag;
>  
>  	FDT_RW_CHECK_HEADER(fdt);
>  
> @@ -370,7 +370,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
>  	nh->tag = cpu_to_fdt32(FDT_BEGIN_NODE);
>  	memset(nh->name, 0, FDT_TAGALIGN(namelen+1));
>  	memcpy(nh->name, name, namelen);
> -	endtag = (uint32_t *)((char *)nh + nodelen - FDT_TAGSIZE);
> +	endtag = (__be32 *)((char *)nh + nodelen - FDT_TAGSIZE);
>  	*endtag = cpu_to_fdt32(FDT_END_NODE);
>  
>  	return offset;
> diff --git a/lib/libfdt/fdt_sw.c b/lib/libfdt/fdt_sw.c
> index 55ebebf..5ce91ba 100644
> --- a/lib/libfdt/fdt_sw.c
> +++ b/lib/libfdt/fdt_sw.c
> @@ -153,7 +153,7 @@ int fdt_begin_node(void *fdt, const char *name)
>  
>  int fdt_end_node(void *fdt)
>  {
> -	uint32_t *en;
> +	__be32 *en;
>  
>  	FDT_SW_CHECK_HEADER(fdt);
>  
> @@ -213,7 +213,7 @@ int fdt_property(void *fdt, const char *name, const void *val, int len)
>  int fdt_finish(void *fdt)
>  {
>  	char *p = (char *)fdt;
> -	uint32_t *end;
> +	__be32 *end;
>  	int oldstroffset, newstroffset;
>  	uint32_t tag;
>  	int offset, nextoffset;
> diff --git a/lib/libfdt/fdt_wip.c b/lib/libfdt/fdt_wip.c
> index e373677..dc1e14c 100644
> --- a/lib/libfdt/fdt_wip.c
> +++ b/lib/libfdt/fdt_wip.c
> @@ -78,7 +78,7 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
>  
>  static void _fdt_nop_region(void *start, int len)
>  {
> -	uint32_t *p;
> +	__be32 *p;
>  
>  	for (p = start; (char *)p < ((char *)start + len); p++)
>  		*p = cpu_to_fdt32(FDT_NOP);

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 00/32] Initial sparse fix series
  2012-10-18  0:19 ` [U-Boot] [PATCH 00/32] Initial sparse fix series Jerry Van Baren
@ 2012-10-18 12:11   ` David Gibson
  2012-10-18 22:30     ` Kim Phillips
  0 siblings, 1 reply; 133+ messages in thread
From: David Gibson @ 2012-10-18 12:11 UTC (permalink / raw)
  To: u-boot

On Wed, Oct 17, 2012 at 08:19:23PM -0400, Jerry Van Baren wrote:
> Hi David, Jon,
> 
> Kim Phillips created a series of patches to change variable declarations
> that are big endian to be __be32/__be64.  Since the device tree is
> defined to be big endian, he created a patch to mark the appropriate
> libfdt entities as __be*.

So, in general I approve the idea of having endian annotations.
Obviously we do need to make sure it doesn't break things.

> On 10/16/2012 08:28 PM, Kim Phillips wrote:
> > This 32-patch series only begins to address making u-boot source more
> > 'sparseable,' or sparse-clean, ultimately to catch type, address space,
> > and endianness mismatches and generally improve code quality. E.g., in this
> > initial dose whose main purpose is to reduce the output volume to workable
> > levels, a couple of endianness bugs are found and fixed in
> > of_bus_default_translate() and fdt_get_base_address().  See [PATCH 14/32]
> > common/fdt_support.c: sparse fixes.
> 
> Upside: This is very good for identifying endian errors early.
> Downside: It could break/complicate non-linux uses of libfdt.

This shouldn't be an inherent problem - we can always have the default
behaviour be that be32 etc. are #defined to be uint32_t, and we only
turn on "real" annotations when we have the right setup.

It does complicate things a bit, but I think it should be manageable.

I'd much prefer to see this done against the upstream dtc/libfdt, of
course, rather than the u-boot copy.

> What are your thoughts on this quest?
> 
> [snip]
> 
> > Note that there are two libfdt dependencies:
> 
> [snipped #1, u-boot-fdt dependency, NBD]
> 
> > 2. potential upstream dtc change dependencies, due to having to attribute base
> > device tree header types to __be32 in include/libfdt.  See patch 19/32
> > "include/fdt.h: sparse fixes".  It is unknown whether such changes would
> > be welcome to dtc (but there's a way to find out :).
> 
> [snip]
> 
> > Build-tested in both endians :).  Please help test.
> > 
> > Thanks,
> > 
> > Kim
> 
> Below is the actual patch for reference (it was in a separate email).
> The impact in terms of changed lines is pretty small.  I'm not sure how
> this impacts non-linux / non-gcc systems since the sparse checker comes
> from a linux background and uses gcc extensions.
> 
> Possibly this could be handled a definition:
> 
> #ifndef _LINUX_TYPES_H
> typedef uint32_t __be32
> typedef uint64_t __be64
> #endif

Yes, something along those lines would be appropriate, although I
think that condition isn't right.

> >  include/fdt.h         | 33 +++++++++++++++++----------------
> >  include/fdt_support.h |  2 ++
> >  include/libfdt.h      |  4 ++--
> >  lib/libfdt/fdt.c      |  2 +-
> >  lib/libfdt/fdt_ro.c   |  2 +-
> >  lib/libfdt/fdt_rw.c   |  4 ++--
> >  lib/libfdt/fdt_sw.c   |  4 ++--
> >  lib/libfdt/fdt_wip.c  |  2 +-
> >  8 files changed, 28 insertions(+), 25 deletions(-)
> > 
> > diff --git a/include/fdt.h b/include/fdt.h
> > index c51212e..1b7f044 100644
> > --- a/include/fdt.h
> > +++ b/include/fdt.h
> > @@ -2,40 +2,41 @@
> >  #define _FDT_H
> >  
> >  #ifndef __ASSEMBLY__
> > +#include <asm/byteorder.h>

This change, however, is not acceptable.  libfdt is supposed to
compile in a wide range of environments (such as bootloaders and
firmwares) which may be very different from a typical Unix userland
environment.  As such all the headers are built to have minimal
dependencies on external libraries.  The byteorder headers are, alas,
horribly non-portable even amongst otherwise similar Unix systems, so
right out for libfdt.

In fact, the way this is supposed to work is that the *only* external
header directly included by the fdt headers is libfdt_env.h.  It is
supplied by the surrounding build environment and is responsible for
providing the minimal things that libfdt does require.  Roughly
speaking that's: stdint like types, some byteswap functions and a some
string.h prototypes - exactly what's required should be better
documented than it currently is.  libfdt_env.h can do this either by
including appropriate pre-existing headers from the environment, or by
directly defining the required things, whichever makes sense.  The
libfdt_env.h which is shipped with libfdt is essentially just an
example, for use in the environment of "POSIX like userspace".

Anyway, I think the right way to handle this is to decide on a name
like __FDT_ANNOTATIONS__ or something.  In fdt.h we have

#ifndef __FDT_ANNOTATIONS__
typedef uint32_t fdt32_t;
/* etc */
#endif

And libfdt is reworked to use these fdt32_t and so forth types.  Then,
by default everything should compile fine, but with no extra checking.
Environments which have sparse or a similar checker available can
#define __FDT_ANNOTATIONS__ from their version of libfdt_env.h in
which case they would also be required to define the annotated integer
types as necessary for their checker.

For convenience on Linux systems we can have the "default"
libfdt_env.h shipped with libfdt go either way depending on SPARSE,
LINUX_TYPES or whatever suitable pre-existing preprocessor tags we can
locate.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 00/32] Initial sparse fix series
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (32 preceding siblings ...)
  2012-10-18  0:19 ` [U-Boot] [PATCH 00/32] Initial sparse fix series Jerry Van Baren
@ 2012-10-18 16:53 ` Tom Rini
  2012-10-24 21:21   ` Tom Rini
  2012-10-25 17:46 ` Tom Rini
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
  35 siblings, 1 reply; 133+ messages in thread
From: Tom Rini @ 2012-10-18 16:53 UTC (permalink / raw)
  To: u-boot

On Tue, Oct 16, 2012 at 07:28:16PM -0500, Kim Phillips wrote:

> This 32-patch series only begins to address making u-boot source more
> 'sparseable,' or sparse-clean, ultimately to catch type, address space,
> and endianness mismatches and generally improve code quality. E.g., in this
> initial dose whose main purpose is to reduce the output volume to workable
> levels, a couple of endianness bugs are found and fixed in
> of_bus_default_translate() and fdt_get_base_address().  See [PATCH 14/32]
> common/fdt_support.c: sparse fixes.
> 
> Patch 1 adds endianness attributes to byteorder.h helpers, e.g.,
> cpu_to_be32().  This is required for correct operation and
> prevents sparse from emitting false-positives.
> 
> Patches 2-6 fix issues where u-boot had imported linux header code
> and the importer simply force-#defined sparse-specific attributes to
> nothing, to allow u-boot to build.
> 
> Patches 7-10 are general sparse fixes to common header areas.
> 
> Patch 11 is too, which also changes the long-standing u-boot image header
> types to __be32, as per u-boot image definition.
> 
> Patches 12-14 address further misc. sparse issues in common/.
> 
> Patches 15-16 do the same for the net subsystem.
> 
> Patches 17-18 do the same for lib/.
> 
> Patch 19 for include/fdt.h.
> 
> Patches 20-23 for Power Arch's mpc8xxx, 83xx, and 85xx subsystems.

I've assigned in patchwork some of these patches to the area custodians,
once reviewed please hand them back to me.  For the rest of the series,
I'm giving things a read and review.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121018/a8c6ff24/attachment.pgp>

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 08/32] arch/powerpc/lib/board.c, *traps.c: sparse fixes
  2012-10-17  0:28 ` [U-Boot] [PATCH 08/32] arch/powerpc/lib/board.c, *traps.c: sparse fixes Kim Phillips
@ 2012-10-18 16:55   ` Tom Rini
  0 siblings, 0 replies; 133+ messages in thread
From: Tom Rini @ 2012-10-18 16:55 UTC (permalink / raw)
  To: u-boot

On Tue, Oct 16, 2012 at 07:28:24PM -0500, Kim Phillips wrote:

> traps.c:*:1: warning: symbol 'print_backtrace' was not declared. Should it be static?
> traps.c:66:6: warning: symbol 'show_regs' was not declared. Should it be static?
> traps.c:93:1: warning: symbol '_exception' was not declared. Should it be static?
> board.c:166:6: warning: symbol '__board_add_ram_info' was not declared. Should it be static?
> board.c:174:5: warning: symbol '__board_flash_wp_on' was not declared. Should it be static?
> board.c:187:6: warning: symbol '__cpu_secondary_init_r' was not declared. Should it be static?
> board.c:265:12: warning: symbol 'init_sequence' was not declared. Should it be static?
> board.c:348:5: warning: symbol '__fixup_cpu' was not declared. Should it be static?
> board.c:405:53: warning: Using plain integer as NULL pointer
> 
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
> ---
>  arch/powerpc/cpu/74xx_7xx/traps.c |  6 +++---
>  arch/powerpc/cpu/mpc512x/traps.c  |  6 +++---
>  arch/powerpc/cpu/mpc5xx/traps.c   |  6 +++---
>  arch/powerpc/cpu/mpc5xxx/traps.c  |  6 +++---
>  arch/powerpc/cpu/mpc8220/traps.c  |  6 +++---
>  arch/powerpc/cpu/mpc824x/traps.c  |  6 +++---
>  arch/powerpc/cpu/mpc8260/traps.c  |  6 +++---
>  arch/powerpc/cpu/mpc83xx/traps.c  |  6 +++---
>  arch/powerpc/cpu/mpc85xx/traps.c  |  6 +++---
>  arch/powerpc/cpu/mpc86xx/traps.c  |  6 +++---
>  arch/powerpc/cpu/mpc8xx/traps.c   |  6 +++---
>  arch/powerpc/cpu/ppc4xx/traps.c   |  6 +++---
>  arch/powerpc/lib/board.c          | 12 ++++++------
>  13 files changed, 42 insertions(+), 42 deletions(-)
> 
> diff --git a/arch/powerpc/cpu/74xx_7xx/traps.c b/arch/powerpc/cpu/74xx_7xx/traps.c
> index 7ae81eb..4f77202 100644
> --- a/arch/powerpc/cpu/74xx_7xx/traps.c
> +++ b/arch/powerpc/cpu/74xx_7xx/traps.c
> @@ -48,7 +48,7 @@ extern unsigned long search_exception_table(unsigned long);
>   * Trap & Exception support
>   */
>  
> -void
> +static void
>  print_backtrace(unsigned long *sp)

This isn't the right form, can you fix these kind of checkpatch warnings
while you're in here?  A full fix of the files would be nice, but not
required.  And I'll just assume the rest of the series finds similar
issues, thanks.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121018/b3bbaf33/attachment.pgp>

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 00/32] Initial sparse fix series
  2012-10-18 12:11   ` David Gibson
@ 2012-10-18 22:30     ` Kim Phillips
  2012-10-19  0:43       ` David Gibson
  0 siblings, 1 reply; 133+ messages in thread
From: Kim Phillips @ 2012-10-18 22:30 UTC (permalink / raw)
  To: u-boot

On Thu, 18 Oct 2012 23:11:12 +1100
David Gibson <david@gibson.dropbear.id.au> wrote:

> On Wed, Oct 17, 2012 at 08:19:23PM -0400, Jerry Van Baren wrote:
> > Hi David, Jon,
> > 
> > Kim Phillips created a series of patches to change variable declarations
> > that are big endian to be __be32/__be64.  Since the device tree is
> > defined to be big endian, he created a patch to mark the appropriate
> > libfdt entities as __be*.
> 
> So, in general I approve the idea of having endian annotations.
> Obviously we do need to make sure it doesn't break things.

cool.

> > On 10/16/2012 08:28 PM, Kim Phillips wrote:
> > > This 32-patch series only begins to address making u-boot source more
> > > 'sparseable,' or sparse-clean, ultimately to catch type, address space,
> > > and endianness mismatches and generally improve code quality. E.g., in this
> > > initial dose whose main purpose is to reduce the output volume to workable
> > > levels, a couple of endianness bugs are found and fixed in
> > > of_bus_default_translate() and fdt_get_base_address().  See [PATCH 14/32]
> > > common/fdt_support.c: sparse fixes.
> > 
> > Upside: This is very good for identifying endian errors early.
> > Downside: It could break/complicate non-linux uses of libfdt.
> 
> This shouldn't be an inherent problem - we can always have the default
> behaviour be that be32 etc. are #defined to be uint32_t, and we only
> turn on "real" annotations when we have the right setup.
> 
> It does complicate things a bit, but I think it should be manageable.
> 
> I'd much prefer to see this done against the upstream dtc/libfdt, of
> course, rather than the u-boot copy.

understood.

> > What are your thoughts on this quest?
> > 
> > [snip]
> > 
> > > Note that there are two libfdt dependencies:
> > 
> > [snipped #1, u-boot-fdt dependency, NBD]
> > 
> > > 2. potential upstream dtc change dependencies, due to having to attribute base
> > > device tree header types to __be32 in include/libfdt.  See patch 19/32
> > > "include/fdt.h: sparse fixes".  It is unknown whether such changes would
> > > be welcome to dtc (but there's a way to find out :).
> > 
> > [snip]
> > 
> > > Build-tested in both endians :).  Please help test.
> > > 
> > > Thanks,
> > > 
> > > Kim
> > 
> > Below is the actual patch for reference (it was in a separate email).
> > The impact in terms of changed lines is pretty small.  I'm not sure how
> > this impacts non-linux / non-gcc systems since the sparse checker comes
> > from a linux background and uses gcc extensions.
> > 
> > Possibly this could be handled a definition:
> > 
> > #ifndef _LINUX_TYPES_H
> > typedef uint32_t __be32
> > typedef uint64_t __be64
> > #endif
> 
> Yes, something along those lines would be appropriate, although I
> think that condition isn't right.

right, we don't want all uint32_t's to be one endian, we just want
fdt32 types to have big endian annotation when being checked by a
checker such as sparse.

> > >  include/fdt.h         | 33 +++++++++++++++++----------------
> > >  include/fdt_support.h |  2 ++
> > >  include/libfdt.h      |  4 ++--
> > >  lib/libfdt/fdt.c      |  2 +-
> > >  lib/libfdt/fdt_ro.c   |  2 +-
> > >  lib/libfdt/fdt_rw.c   |  4 ++--
> > >  lib/libfdt/fdt_sw.c   |  4 ++--
> > >  lib/libfdt/fdt_wip.c  |  2 +-
> > >  8 files changed, 28 insertions(+), 25 deletions(-)
> > > 
> > > diff --git a/include/fdt.h b/include/fdt.h
> > > index c51212e..1b7f044 100644
> > > --- a/include/fdt.h
> > > +++ b/include/fdt.h
> > > @@ -2,40 +2,41 @@
> > >  #define _FDT_H
> > >  
> > >  #ifndef __ASSEMBLY__
> > > +#include <asm/byteorder.h>
> 
> This change, however, is not acceptable.  libfdt is supposed to
> compile in a wide range of environments (such as bootloaders and
> firmwares) which may be very different from a typical Unix userland
> environment.  As such all the headers are built to have minimal
> dependencies on external libraries.  The byteorder headers are, alas,
> horribly non-portable even amongst otherwise similar Unix systems, so
> right out for libfdt.
> 
> In fact, the way this is supposed to work is that the *only* external
> header directly included by the fdt headers is libfdt_env.h.  It is
> supplied by the surrounding build environment and is responsible for
> providing the minimal things that libfdt does require.  Roughly
> speaking that's: stdint like types, some byteswap functions and a some
> string.h prototypes - exactly what's required should be better
> documented than it currently is.  libfdt_env.h can do this either by
> including appropriate pre-existing headers from the environment, or by
> directly defining the required things, whichever makes sense.  The
> libfdt_env.h which is shipped with libfdt is essentially just an
> example, for use in the environment of "POSIX like userspace".
> 
> Anyway, I think the right way to handle this is to decide on a name
> like __FDT_ANNOTATIONS__ or something.

this is named __CHECKER__ in linux and u-boot.  Ifdef __CHECKER__,
then the code is being parsed by a checker.

>  In fdt.h we have
> 
> #ifndef __FDT_ANNOTATIONS__
> typedef uint32_t fdt32_t;
> /* etc */
> #endif
> 
> And libfdt is reworked to use these fdt32_t and so forth types.  Then,
> by default everything should compile fine, but with no extra checking.
> Environments which have sparse or a similar checker available can
> #define __FDT_ANNOTATIONS__ from their version of libfdt_env.h in
> which case they would also be required to define the annotated integer
> types as necessary for their checker.
> 
> For convenience on Linux systems we can have the "default"
> libfdt_env.h shipped with libfdt go either way depending on SPARSE,
> LINUX_TYPES or whatever suitable pre-existing preprocessor tags we can
> locate.

understood, that's how I envisaged things going too.

Let me see what I can do.

Kim

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 00/32] Initial sparse fix series
  2012-10-18 22:30     ` Kim Phillips
@ 2012-10-19  0:43       ` David Gibson
  2012-10-30 21:57           ` [U-Boot] " Kim Phillips
  0 siblings, 1 reply; 133+ messages in thread
From: David Gibson @ 2012-10-19  0:43 UTC (permalink / raw)
  To: u-boot

On Thu, Oct 18, 2012 at 05:30:22PM -0500, Kim Phillips wrote:
> On Thu, 18 Oct 2012 23:11:12 +1100
> David Gibson <david@gibson.dropbear.id.au> wrote:
> 
> > On Wed, Oct 17, 2012 at 08:19:23PM -0400, Jerry Van Baren wrote:
> > > Hi David, Jon,
> > > 
> > > Kim Phillips created a series of patches to change variable declarations
> > > that are big endian to be __be32/__be64.  Since the device tree is
> > > defined to be big endian, he created a patch to mark the appropriate
> > > libfdt entities as __be*.
> > 
> > So, in general I approve the idea of having endian annotations.
> > Obviously we do need to make sure it doesn't break things.
> 
> cool.
> 
> > > On 10/16/2012 08:28 PM, Kim Phillips wrote:
> > > > This 32-patch series only begins to address making u-boot source more
> > > > 'sparseable,' or sparse-clean, ultimately to catch type, address space,
> > > > and endianness mismatches and generally improve code quality. E.g., in this
> > > > initial dose whose main purpose is to reduce the output volume to workable
> > > > levels, a couple of endianness bugs are found and fixed in
> > > > of_bus_default_translate() and fdt_get_base_address().  See [PATCH 14/32]
> > > > common/fdt_support.c: sparse fixes.
> > > 
> > > Upside: This is very good for identifying endian errors early.
> > > Downside: It could break/complicate non-linux uses of libfdt.
> > 
> > This shouldn't be an inherent problem - we can always have the default
> > behaviour be that be32 etc. are #defined to be uint32_t, and we only
> > turn on "real" annotations when we have the right setup.
> > 
> > It does complicate things a bit, but I think it should be manageable.
> > 
> > I'd much prefer to see this done against the upstream dtc/libfdt, of
> > course, rather than the u-boot copy.
> 
> understood.
> 
> > > What are your thoughts on this quest?
> > > 
> > > [snip]
> > > 
> > > > Note that there are two libfdt dependencies:
> > > 
> > > [snipped #1, u-boot-fdt dependency, NBD]
> > > 
> > > > 2. potential upstream dtc change dependencies, due to having to attribute base
> > > > device tree header types to __be32 in include/libfdt.  See patch 19/32
> > > > "include/fdt.h: sparse fixes".  It is unknown whether such changes would
> > > > be welcome to dtc (but there's a way to find out :).
> > > 
> > > [snip]
> > > 
> > > > Build-tested in both endians :).  Please help test.
> > > > 
> > > > Thanks,
> > > > 
> > > > Kim
> > > 
> > > Below is the actual patch for reference (it was in a separate email).
> > > The impact in terms of changed lines is pretty small.  I'm not sure how
> > > this impacts non-linux / non-gcc systems since the sparse checker comes
> > > from a linux background and uses gcc extensions.
> > > 
> > > Possibly this could be handled a definition:
> > > 
> > > #ifndef _LINUX_TYPES_H
> > > typedef uint32_t __be32
> > > typedef uint64_t __be64
> > > #endif
> > 
> > Yes, something along those lines would be appropriate, although I
> > think that condition isn't right.
> 
> right, we don't want all uint32_t's to be one endian, we just want
> fdt32 types to have big endian annotation when being checked by a
> checker such as sparse.

Right.

> > > >  include/fdt.h         | 33 +++++++++++++++++----------------
> > > >  include/fdt_support.h |  2 ++
> > > >  include/libfdt.h      |  4 ++--
> > > >  lib/libfdt/fdt.c      |  2 +-
> > > >  lib/libfdt/fdt_ro.c   |  2 +-
> > > >  lib/libfdt/fdt_rw.c   |  4 ++--
> > > >  lib/libfdt/fdt_sw.c   |  4 ++--
> > > >  lib/libfdt/fdt_wip.c  |  2 +-
> > > >  8 files changed, 28 insertions(+), 25 deletions(-)
> > > > 
> > > > diff --git a/include/fdt.h b/include/fdt.h
> > > > index c51212e..1b7f044 100644
> > > > --- a/include/fdt.h
> > > > +++ b/include/fdt.h
> > > > @@ -2,40 +2,41 @@
> > > >  #define _FDT_H
> > > >  
> > > >  #ifndef __ASSEMBLY__
> > > > +#include <asm/byteorder.h>
> > 
> > This change, however, is not acceptable.  libfdt is supposed to
> > compile in a wide range of environments (such as bootloaders and
> > firmwares) which may be very different from a typical Unix userland
> > environment.  As such all the headers are built to have minimal
> > dependencies on external libraries.  The byteorder headers are, alas,
> > horribly non-portable even amongst otherwise similar Unix systems, so
> > right out for libfdt.
> > 
> > In fact, the way this is supposed to work is that the *only* external
> > header directly included by the fdt headers is libfdt_env.h.  It is
> > supplied by the surrounding build environment and is responsible for
> > providing the minimal things that libfdt does require.  Roughly
> > speaking that's: stdint like types, some byteswap functions and a some
> > string.h prototypes - exactly what's required should be better
> > documented than it currently is.  libfdt_env.h can do this either by
> > including appropriate pre-existing headers from the environment, or by
> > directly defining the required things, whichever makes sense.  The
> > libfdt_env.h which is shipped with libfdt is essentially just an
> > example, for use in the environment of "POSIX like userspace".
> > 
> > Anyway, I think the right way to handle this is to decide on a name
> > like __FDT_ANNOTATIONS__ or something.
> 
> this is named __CHECKER__ in linux and u-boot.  Ifdef __CHECKER__,
> then the code is being parsed by a checker.

Ok, that name works for me.

> >  In fdt.h we have
> > 
> > #ifndef __FDT_ANNOTATIONS__
> > typedef uint32_t fdt32_t;
> > /* etc */
> > #endif
> > 
> > And libfdt is reworked to use these fdt32_t and so forth types.  Then,
> > by default everything should compile fine, but with no extra checking.
> > Environments which have sparse or a similar checker available can
> > #define __FDT_ANNOTATIONS__ from their version of libfdt_env.h in
> > which case they would also be required to define the annotated integer
> > types as necessary for their checker.
> > 
> > For convenience on Linux systems we can have the "default"
> > libfdt_env.h shipped with libfdt go either way depending on SPARSE,
> > LINUX_TYPES or whatever suitable pre-existing preprocessor tags we can
> > locate.
> 
> understood, that's how I envisaged things going too.
> 
> Let me see what I can do.

Sounds good.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 31/32] drivers/mtd/nand: sparse fixes
  2012-10-17  0:28 ` [U-Boot] [PATCH 31/32] drivers/mtd/nand: " Kim Phillips
@ 2012-10-22 19:18   ` Scott Wood
  0 siblings, 0 replies; 133+ messages in thread
From: Scott Wood @ 2012-10-22 19:18 UTC (permalink / raw)
  To: u-boot

On 10/16/2012 07:28:47 PM, Kim Phillips wrote:
> nand_ecc.c:82:5: warning: symbol 'nand_calculate_ecc' was not  
> declared. Should it be static?
> nand_ecc.c:155:5: warning: symbol 'nand_correct_data' was not  
> declared. Should it be static?
> nand_base.c:2854:1: error: directive in argument list
> nand_base.c:2856:1: error: directive in argument list
> 
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
> ---
>  drivers/mtd/nand/nand_base.c | 9 +++++----
>  drivers/mtd/nand/nand_ecc.c  | 1 +
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_base.c  
> b/drivers/mtd/nand/nand_base.c
> index 71f5027..110cebd 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -2849,12 +2849,13 @@ ident_done:
> 
>  	/* TODO onfi flash name */
>  	MTDDEBUG (MTD_DEBUG_LEVEL0, "NAND device: Manufacturer ID:"
> -		" 0x%02x, Chip ID: 0x%02x (%s %s)\n", *maf_id, *dev_id,
> -		nand_manuf_ids[maf_idx].name,
> +		" 0x%02x, Chip ID: 0x%02x (%s", *maf_id, *dev_id,
> +		nand_manuf_ids[maf_idx].name);
>  #ifdef CONFIG_SYS_NAND_ONFI_DETECTION
> -		chip->onfi_version ? chip->onfi_params.model :  
> type->name);
> +	MTDDEBUG (MTD_DEBUG_LEVEL0, " %s)\n", chip->onfi_version ?
> +		  chip->onfi_params.model : type->name);
>  #else
> -		type->name);
> +	MTDDEBUG (MTD_DEBUG_LEVEL0, " %s)\n", type->name);
>  #endif

I didn't know preprocessor directives inside an argument list were  
banned...

In any case how about something like:

	const char *name = type->name;

#ifdef CONFIG_SYS_NAND_ONFI_DETECTION
	if (chip->onfi_version)
		name = chip->onfi_params.model;
#endif

	MTDDEBUG(..., name);

-Scott

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 00/32] Initial sparse fix series
  2012-10-18 16:53 ` [U-Boot] [PATCH 00/32] Initial sparse fix series Tom Rini
@ 2012-10-24 21:21   ` Tom Rini
  2012-10-24 22:47     ` Kim Phillips
  0 siblings, 1 reply; 133+ messages in thread
From: Tom Rini @ 2012-10-24 21:21 UTC (permalink / raw)
  To: u-boot

On Thu, Oct 18, 2012 at 09:53:36AM -0700, Tom Rini wrote:
> On Tue, Oct 16, 2012 at 07:28:16PM -0500, Kim Phillips wrote:
> 
> > This 32-patch series only begins to address making u-boot source more
> > 'sparseable,' or sparse-clean, ultimately to catch type, address space,
> > and endianness mismatches and generally improve code quality. E.g., in this
> > initial dose whose main purpose is to reduce the output volume to workable
> > levels, a couple of endianness bugs are found and fixed in
> > of_bus_default_translate() and fdt_get_base_address().  See [PATCH 14/32]
> > common/fdt_support.c: sparse fixes.
> > 
> > Patch 1 adds endianness attributes to byteorder.h helpers, e.g.,
> > cpu_to_be32().  This is required for correct operation and
> > prevents sparse from emitting false-positives.
> > 
> > Patches 2-6 fix issues where u-boot had imported linux header code
> > and the importer simply force-#defined sparse-specific attributes to
> > nothing, to allow u-boot to build.
> > 
> > Patches 7-10 are general sparse fixes to common header areas.
> > 
> > Patch 11 is too, which also changes the long-standing u-boot image header
> > types to __be32, as per u-boot image definition.
> > 
> > Patches 12-14 address further misc. sparse issues in common/.
> > 
> > Patches 15-16 do the same for the net subsystem.
> > 
> > Patches 17-18 do the same for lib/.
> > 
> > Patch 19 for include/fdt.h.
> > 
> > Patches 20-23 for Power Arch's mpc8xxx, 83xx, and 85xx subsystems.
> 
> I've assigned in patchwork some of these patches to the area custodians,
> once reviewed please hand them back to me.  For the rest of the series,
> I'm giving things a read and review.

To this end I'm preparing to merge some of these patches today.
However, even cutting out a number of patches with changes requested
already I'm seeing various failures on MAKEALL --arch arm.  I'll let you
know at what point I stop taking the patches in and what the error is.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121024/270d4c4a/attachment.pgp>

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 02/32] include/linux/compat.h: fix warning: preprocessor token __iomem redefined
  2012-10-17  0:28 ` [U-Boot] [PATCH 02/32] include/linux/compat.h: fix warning: preprocessor token __iomem redefined Kim Phillips
@ 2012-10-24 21:31   ` Tom Rini
  0 siblings, 0 replies; 133+ messages in thread
From: Tom Rini @ 2012-10-24 21:31 UTC (permalink / raw)
  To: u-boot

On Tue, Oct 16, 2012 at 07:28:18PM -0500, Kim Phillips wrote:

> include/linux/compat.h:4:9: warning: preprocessor token __user redefined
> include/linux/compiler.h:7:10: this was the original definition
> include/linux/compat.h:5:9: warning: preprocessor token __iomem redefined
> include/linux/compiler.h:12:10: this was the original definition
> 
> fixup __iomem, __user definitions in compat.h code appears to be placed
> there as a cover up from a code import from linux when u-boot didn't yet
> have a compiler.h, introduced by commit
> 932394ac43e2e778e664eeb6e456fecd0fae6e59 "Rewrite of NAND code based on
> what is in 2.6.12 Linux kernel".
> 
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>

include/linux/mtd/mtd-api.h now blows up on a number of omap3 boards
with:
In file included from .../u-boot/u-boot/include/linux/mtd/mtd.h:12:0,
from mtdcore.c:10: .../u-boot/include/linux/mtd/mtd-abi.h:22:23:
error: expected ':', ',', ';', '}' or '__attribute__' before '*' token

I can get past this locally by adding <linux/compiler.h> to the file
in question.

-- 
Tom

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 00/32] Initial sparse fix series
  2012-10-24 21:21   ` Tom Rini
@ 2012-10-24 22:47     ` Kim Phillips
  0 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-24 22:47 UTC (permalink / raw)
  To: u-boot

On Wed, 24 Oct 2012 14:21:20 -0700
Tom Rini <trini@ti.com> wrote:

> On Thu, Oct 18, 2012 at 09:53:36AM -0700, Tom Rini wrote:
> > On Tue, Oct 16, 2012 at 07:28:16PM -0500, Kim Phillips wrote:
> > 
> > > This 32-patch series only begins to address making u-boot source more
> > > 'sparseable,' or sparse-clean, ultimately to catch type, address space,
> > > and endianness mismatches and generally improve code quality. E.g., in this
> > > initial dose whose main purpose is to reduce the output volume to workable
> > > levels, a couple of endianness bugs are found and fixed in
> > > of_bus_default_translate() and fdt_get_base_address().  See [PATCH 14/32]
> > > common/fdt_support.c: sparse fixes.
> > > 
> > > Patch 1 adds endianness attributes to byteorder.h helpers, e.g.,
> > > cpu_to_be32().  This is required for correct operation and
> > > prevents sparse from emitting false-positives.
> > > 
> > > Patches 2-6 fix issues where u-boot had imported linux header code
> > > and the importer simply force-#defined sparse-specific attributes to
> > > nothing, to allow u-boot to build.
> > > 
> > > Patches 7-10 are general sparse fixes to common header areas.
> > > 
> > > Patch 11 is too, which also changes the long-standing u-boot image header
> > > types to __be32, as per u-boot image definition.
> > > 
> > > Patches 12-14 address further misc. sparse issues in common/.
> > > 
> > > Patches 15-16 do the same for the net subsystem.
> > > 
> > > Patches 17-18 do the same for lib/.
> > > 
> > > Patch 19 for include/fdt.h.
> > > 
> > > Patches 20-23 for Power Arch's mpc8xxx, 83xx, and 85xx subsystems.
> > 
> > I've assigned in patchwork some of these patches to the area custodians,
> > once reviewed please hand them back to me.  For the rest of the series,
> > I'm giving things a read and review.
> 
> To this end I'm preparing to merge some of these patches today.
> However, even cutting out a number of patches with changes requested
> already I'm seeing various failures on MAKEALL --arch arm.  I'll let you
> know at what point I stop taking the patches in and what the error is.

I was going to resubmit the whole series after I'd re-done the
libfdt ones to suit the dtc and the kernel libfdt copies, but
patches 1 through 6 are the most important.  Whether I tangled
things up in my rebases, sure, there might be issues; I just wanted
to partition by importance and subsystem, so the subsystem
maintainers can ack/apply freely (as one did).

I will definitely re-submit 14 and 19, and run checkpatch over any
others you don't end up applying.  I'm just caught up doing other
stuff right now...

Kim

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 12/32] common/cmd_*.c: sparse fixes
  2012-10-17  0:28 ` [U-Boot] [PATCH 12/32] common/cmd_*.c: " Kim Phillips
@ 2012-10-24 23:49   ` Tom Rini
  0 siblings, 0 replies; 133+ messages in thread
From: Tom Rini @ 2012-10-24 23:49 UTC (permalink / raw)
  To: u-boot

On Tue, Oct 16, 2012 at 07:28:28PM -0500, Kim Phillips wrote:

[snip]
> cmd_mtdparts.c:157:4: warning: symbol 'current_mtd_partnum' was not declared. Should it be static?
[snip]
>  /* current active device and partition number */
> -struct mtd_device *current_mtd_dev = NULL;
> -u8 current_mtd_partnum = 0;
> +static struct mtd_device *current_mtd_dev = NULL;
> +static u8 current_mtd_partnum = 0;

This is wrong, cmd_jffs.c also uses current_mtd_partnum and has an
extern in the C file for it :(

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121024/567dbbce/attachment.pgp>

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 10/32] include/command.h: sparse fix
  2012-10-17  0:28 ` [U-Boot] [PATCH 10/32] include/command.h: " Kim Phillips
@ 2012-10-25 16:35   ` Tom Rini
  0 siblings, 0 replies; 133+ messages in thread
From: Tom Rini @ 2012-10-25 16:35 UTC (permalink / raw)
  To: u-boot

On Tue, Oct 16, 2012 at 07:28:26PM -0500, Kim Phillips wrote:

> __u_boot_cmd_* should be declared static, e.g.:
> 
> cmd_mem.c:1142:1: warning: symbol '__u_boot_cmd_md' was not declared. Should it be static?
> cmd_mem.c:1149:1: warning: symbol '__u_boot_cmd_mm' was not declared. Should it be static?
> cmd_mem.c:1156:1: warning: symbol '__u_boot_cmd_nm' was not declared. Should it be static?
> cmd_mem.c:1162:1: warning: symbol '__u_boot_cmd_mw' was not declared. Should it be static?
> cmd_mem.c:1168:1: warning: symbol '__u_boot_cmd_cp' was not declared. Should it be static?
> cmd_mem.c:1174:1: warning: symbol '__u_boot_cmd_cmp' was not declared. Should it be static?
> cmd_mem.c:1184:1: warning: symbol '__u_boot_cmd_crc32' was not declared. Should it be static?
> cmd_mem.c:1203:1: warning: symbol '__u_boot_cmd_base' was not declared. Should it be static?
> cmd_mem.c:1210:1: warning: symbol '__u_boot_cmd_loop' was not declared. Should it be static?
> cmd_mem.c:1224:1: warning: symbol '__u_boot_cmd_mtest' was not declared. Should it be static?
> 
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
> ---
>  include/command.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/command.h b/include/command.h
> index 1f06aa1..c051158 100644
> --- a/include/command.h
> +++ b/include/command.h
> @@ -174,7 +174,7 @@ int cmd_process(int flag, int argc, char * const argv[],
>  	U_BOOT_CMD_MKENT_COMPLETE(name,maxargs,rep,cmd,usage,help,NULL)
>  
>  #define U_BOOT_CMD_COMPLETE(name,maxargs,rep,cmd,usage,help,comp) \
> -	cmd_tbl_t __u_boot_cmd_##name Struct_Section = \
> +	static cmd_tbl_t __u_boot_cmd_##name Struct_Section = \
>  		U_BOOT_CMD_MKENT_COMPLETE(name,maxargs,rep,cmd,usage,help,comp)
>  
>  #define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) \

I tried porting this change to the LG-arrays that are now in master and
that resulted in no commands being available.  Please re-do and test
against master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121025/ab8da0e0/attachment.pgp>

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 13/32] common/misc: sparse fixes
  2012-10-17  0:28 ` [U-Boot] [PATCH 13/32] common/misc: " Kim Phillips
@ 2012-10-25 17:32   ` Tom Rini
  0 siblings, 0 replies; 133+ messages in thread
From: Tom Rini @ 2012-10-25 17:32 UTC (permalink / raw)
  To: u-boot

On Tue, Oct 16, 2012 at 07:28:29PM -0500, Kim Phillips wrote:

> command.c:44:38: error: bad constant expression
> console.c:537:18: warning: symbol 'search_device' was not declared. Should it be static?
> dlmalloc.c:1468:2: warning: Using plain integer as NULL pointer
> dlmalloc.c:1468:5: warning: Using plain integer as NULL pointer
> dlmalloc.c:2176:12: warning: Using plain integer as NULL pointer
> dlmalloc.c:2179:31: warning: Using plain integer as NULL pointer
> dlmalloc.c:2382:14: warning: Using plain integer as NULL pointer
> dlmalloc.c:2436:14: warning: Using plain integer as NULL pointer
> dlmalloc.c:2582:31: warning: Using plain integer as NULL pointer
> dlmalloc.c:2585:17: warning: Using plain integer as NULL pointer
> dlmalloc.c:2646:14: warning: Using plain integer as NULL pointer
> dlmalloc.c:2659:19: warning: Using plain integer as NULL pointer
> dlmalloc.c:2692:19: warning: Using plain integer as NULL pointer
> dlmalloc.c:2707:19: warning: Using plain integer as NULL pointer
> dlmalloc.c:2708:14: warning: Using plain integer as NULL pointer
> dlmalloc.c:2786:31: warning: Using plain integer as NULL pointer
> dlmalloc.c:2801:12: warning: Using plain integer as NULL pointer
> dlmalloc.c:2801:22: warning: Using plain integer as NULL pointer
> dlmalloc.c:2926:27: warning: Using plain integer as NULL pointer
> dlmalloc.c:2928:14: warning: Using plain integer as NULL pointer
> dlmalloc.c:2929:12: warning: Using plain integer as NULL pointer
> dlmalloc.c:3075:14: warning: Using plain integer as NULL pointer
> hush.c:292:14: warning: symbol 'last_return_code' was not declared. Should it be static?
> hush.c:293:5: warning: symbol 'nesting_level' was not declared. Should it be static?
> hush.c:2175:20: warning: Using plain integer as NULL pointer
> hush.c:2175:34: warning: Using plain integer as NULL pointer
> hush.c:2210:41: warning: Using plain integer as NULL pointer
> hush.c:2216:45: warning: Using plain integer as NULL pointer
> hush.c:2249:25: warning: Using plain integer as NULL pointer
> hush.c:2332:13: warning: symbol 'new_pipe' was not declared. Should it be static?
> hush.c:2390:5: warning: symbol 'reserved_word' was not declared. Should it be static?
> hush.c:2927:5: warning: symbol 'parse_stream' was not declared. Should it be static?
> hush.c:3127:6: warning: symbol 'mapset' was not declared. Should it be static?
> hush.c:3133:6: warning: symbol 'update_ifs_map' was not declared. Should it be static?
> hush.c:3161:5: warning: symbol 'parse_stream_outer' was not declared. Should it be static?
> hush.c:3295:34: warning: Using plain integer as NULL pointer
> hush.c:3631:5: warning: symbol 'do_showvar' was not declared. Should it be static
> image.c:1282:29: warning: Using plain integer as NULL pointer
> image.c:1315:41: warning: Using plain integer as NULL pointer
> image.c:1330:25: warning: Using plain integer as NULL pointer
> image.c:1706:25: warning: Using plain integer as NULL pointer
> main.c:510:10: warning: symbol 'hist_num' was not declared. Should it be static?
> main.c:512:5: warning: symbol 'hist_list' was not declared. Should it be static?
> main.c:513:6: warning: symbol 'hist_lines' was not declared. Should it be static?
> usb_storage.c:195:6: warning: symbol 'usb_show_progress' was not declared. Should it be static?
> usb_storage.c:440:48: warning: Using plain integer as NULL pointer
> usb_storage.c:503:5: warning: symbol 'usb_stor_BBB_comdat' was not declared. Should it be static?
> usb_storage.c:551:5: warning: symbol 'usb_stor_CB_comdat' was not declared. Should it be static?
> usb_storage.c:629:55: warning: Using plain integer as NULL pointer
> usb_storage.c:620:5: warning: symbol 'usb_stor_CBI_get_status' was not declared. Should it be static?
> usb_storage.c:675:43: warning: Using plain integer as NULL pointer
> usb_storage.c:668:5: warning: symbol 'usb_stor_BBB_clear_endpt_stall' was not declared. Should it be static?
> usb_storage.c:679:5: warning: symbol 'usb_stor_BBB_transport' was not declared. Should it be static?
> usb_storage.c:801:5: warning: symbol 'usb_stor_CB_transport' was not declared. Sh
> xyzModem.c:104:1: warning: symbol 'CYGACC_COMM_IF_GETC_TIMEOUT' was not declared. Should it be static?
> xyzModem.c:122:1: warning: symbol 'CYGACC_COMM_IF_PUTC' was not declared. Should it be static?
> xyzModem.c:169:1: warning: symbol 'parse_num' was not declared. Should it be stat
> 
> note: hush.c's nesting_level deleted because not used.
> 
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>

This causes problems such as:
$ uboot-build.sh netspace_lite_v2
Testing netspace_lite_v2 on -00399-gef44c78
Thu Oct 25 10:31:26 MST 2012
Configuring for netspace_lite_v2 - Board: lacie_kw, Options:NETSPACE_LITE_V2
console.c:537:26: error: static declaration of 'search_device' follows non-static declaration

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121025/4c589c9e/attachment.pgp>

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 01/32] include/linux/byteorder: import latest endian definitions from linux
  2012-10-17  0:28 ` [U-Boot] [PATCH 01/32] include/linux/byteorder: import latest endian definitions from linux Kim Phillips
@ 2012-10-25 17:37   ` Tom Rini
  0 siblings, 0 replies; 133+ messages in thread
From: Tom Rini @ 2012-10-25 17:37 UTC (permalink / raw)
  To: u-boot

On Tue, Oct 16, 2012 at 07:28:17PM -0500, Kim Phillips wrote:

> u-boot's byteorder headers did not contain endianness attributions
> for use with sparse, causing a lot of false positives.  Import the
> kernel's latest definitions, and enable them by including compiler.h
> and types.h.  They come with 'const' added for some swab functions, so
> fix those up, too:
> 
> include/linux/byteorder/big_endian.h:46:2: warning: passing argument 1 of '__swab64p' discards 'const' qualifier from pointer target type [enabled by default]
> 
> Also, note: u-boot's historic __BYTE_ORDER definition has been
> preserved (for the time being at least).
> 
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>

This causes:
$ uboot-build.sh afeb9260
Testing afeb9260 on -00382-g8391387
Thu Oct 25 10:36:06 MST 2012
Configuring for afeb9260 board...
   text    data     bss     dec     hex filename
 198034    5648   72652  276334   4376e afeb9260/u-boot
macb.c:54:0: warning: "barrier" redefined [enabled by default]
.../include/linux/compiler-gcc.h:12:0: note: this is the location of the previous definition

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121025/41e038f7/attachment.pgp>

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 00/32] Initial sparse fix series
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (33 preceding siblings ...)
  2012-10-18 16:53 ` [U-Boot] [PATCH 00/32] Initial sparse fix series Tom Rini
@ 2012-10-25 17:46 ` Tom Rini
  2012-10-25 18:59   ` Kim Phillips
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
  35 siblings, 1 reply; 133+ messages in thread
From: Tom Rini @ 2012-10-25 17:46 UTC (permalink / raw)
  To: u-boot

On Tue, Oct 16, 2012 at 07:28:16PM -0500, Kim Phillips wrote:

> This 32-patch series only begins to address making u-boot source more
> 'sparseable,' or sparse-clean, ultimately to catch type, address space,
> and endianness mismatches and generally improve code quality. E.g., in this
> initial dose whose main purpose is to reduce the output volume to workable
> levels, a couple of endianness bugs are found and fixed in
> of_bus_default_translate() and fdt_get_base_address().  See [PATCH 14/32]
> common/fdt_support.c: sparse fixes.

I want to repeat myself that I want to see sparse fixes come in.  That
said, I expect that for v2 you will have done MAKEALL -a $arch for every
arch there's an ELDK 5.2.x toolchain for, at least, and there's no new
problems popping up.  If you like I can pastebin my MAKEALL wrapper that
lets you tell it things like --arch arm --eldk-521 and it sets up the
environment for the toolchain.

I also needed to not apply patch 01/32 and so I can really only take 27
and 32 right now (I'll reply separately once I really do).

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121025/4ca9516d/attachment.pgp>

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 00/32] Initial sparse fix series
  2012-10-25 17:46 ` Tom Rini
@ 2012-10-25 18:59   ` Kim Phillips
  2012-10-25 19:28     ` Tom Rini
  0 siblings, 1 reply; 133+ messages in thread
From: Kim Phillips @ 2012-10-25 18:59 UTC (permalink / raw)
  To: u-boot

On Thu, 25 Oct 2012 10:46:54 -0700
Tom Rini <trini@ti.com> wrote:

> On Tue, Oct 16, 2012 at 07:28:16PM -0500, Kim Phillips wrote:
> 
> > This 32-patch series only begins to address making u-boot source more
> > 'sparseable,' or sparse-clean, ultimately to catch type, address space,
> > and endianness mismatches and generally improve code quality. E.g., in this
> > initial dose whose main purpose is to reduce the output volume to workable
> > levels, a couple of endianness bugs are found and fixed in
> > of_bus_default_translate() and fdt_get_base_address().  See [PATCH 14/32]
> > common/fdt_support.c: sparse fixes.
> 
> I want to repeat myself that I want to see sparse fixes come in.  That
> said, I expect that for v2 you will have done MAKEALL -a $arch for every
> arch there's an ELDK 5.2.x toolchain for, at least, and there's no new

so power, arm, and mips.

> problems popping up.  If you like I can pastebin my MAKEALL wrapper that
> lets you tell it things like --arch arm --eldk-521 and it sets up the
> environment for the toolchain.

please do.

> I also needed to not apply patch 01/32 and so I can really only take 27
> and 32 right now (I'll reply separately once I really do).

that's fine, thanks.

Kim

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 00/32] Initial sparse fix series
  2012-10-25 18:59   ` Kim Phillips
@ 2012-10-25 19:28     ` Tom Rini
  0 siblings, 0 replies; 133+ messages in thread
From: Tom Rini @ 2012-10-25 19:28 UTC (permalink / raw)
  To: u-boot

On Thu, Oct 25, 2012 at 01:59:45PM -0500, Kim Phillips wrote:
> On Thu, 25 Oct 2012 10:46:54 -0700
> Tom Rini <trini@ti.com> wrote:
> 
> > On Tue, Oct 16, 2012 at 07:28:16PM -0500, Kim Phillips wrote:
> > 
> > > This 32-patch series only begins to address making u-boot source more
> > > 'sparseable,' or sparse-clean, ultimately to catch type, address space,
> > > and endianness mismatches and generally improve code quality. E.g., in this
> > > initial dose whose main purpose is to reduce the output volume to workable
> > > levels, a couple of endianness bugs are found and fixed in
> > > of_bus_default_translate() and fdt_get_base_address().  See [PATCH 14/32]
> > > common/fdt_support.c: sparse fixes.
> > 
> > I want to repeat myself that I want to see sparse fixes come in.  That
> > said, I expect that for v2 you will have done MAKEALL -a $arch for every
> > arch there's an ELDK 5.2.x toolchain for, at least, and there's no new
> 
> so power, arm, and mips.

Correct.

> > problems popping up.  If you like I can pastebin my MAKEALL wrapper that
> > lets you tell it things like --arch arm --eldk-521 and it sets up the
> > environment for the toolchain.
> 
> please do.

http://pastebin.com/rkRSL2d3 has it now.  It's a little clumsy at times,
for example for not-arm (biased, sorry) you need to do uboot-build.sh
--arch powerpc --eldk-521 --cpu mpc85xx so that it sets up for arch/powerpc,
and then the toolchain and then re-sets itself for cpu/mpc85xx.
arch/cpu/soc default to NCPUS=1 NBUILDS=`grep -c processor
/proc/cpuinfo` and single board targets default to letting MAKEALL guess
right.  I'm pretty sure that even on the bigger boxes this is still
right.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121025/91db66c3/attachment.pgp>

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [U-Boot,27/32] drivers/i2c/fsl_i2c.c: sparse fix
  2012-10-17  0:28 ` [U-Boot] [PATCH 27/32] drivers/i2c/fsl_i2c.c: " Kim Phillips
  2012-10-17  3:57   ` Heiko Schocher
@ 2012-10-26  3:29   ` Tom Rini
  1 sibling, 0 replies; 133+ messages in thread
From: Tom Rini @ 2012-10-26  3:29 UTC (permalink / raw)
  To: u-boot

On Tue, Oct 16, 2012 at 02:28:43PM -0000, Kim Phillips wrote:

> fsl_i2c.c:217:14: warning: symbol 'get_i2c_clock' was not declared. Should it be static?
> 
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
> Acked-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121025/e28d929a/attachment.pgp>

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [U-Boot, 32/32] drivers/serial/serial_ns16550.c: sparse fixes
  2012-10-17  0:28 ` [U-Boot] [PATCH 32/32] drivers/serial/serial_ns16550.c: " Kim Phillips
@ 2012-10-26  3:30   ` Tom Rini
  0 siblings, 0 replies; 133+ messages in thread
From: Tom Rini @ 2012-10-26  3:30 UTC (permalink / raw)
  To: u-boot

On Tue, Oct 16, 2012 at 02:28:48PM -0000, Kim Phillips wrote:

> serial_ns16550.c:222:1: warning: symbol 'eserial1_init' was not declared. Should it be static?
> serial_ns16550.c:222:1: warning: symbol 'eserial1_setbrg' was not declared. Should it be static?
> serial_ns16550.c:222:1: warning: symbol 'eserial1_getc' was not declared. Should it be static?
> serial_ns16550.c:222:1: warning: symbol 'eserial1_tstc' was not declared. Should it be static?
> serial_ns16550.c:222:1: warning: symbol 'eserial1_putc' was not declared. Should it be static?
> serial_ns16550.c:222:1: warning: symbol 'eserial1_puts' was not declared. Should it be static?
> serial_ns16550.c:225:1: warning: symbol 'eserial2_init' was not declared. Should it be static?
> serial_ns16550.c:225:1: warning: symbol 'eserial2_setbrg' was not declared. Should it be static?
> serial_ns16550.c:225:1: warning: symbol 'eserial2_getc' was not declared. Should it be static?
> serial_ns16550.c:225:1: warning: symbol 'eserial2_tstc' was not declared. Should it be static?
> serial_ns16550.c:225:1: warning: symbol 'eserial2_putc' was not declared. Should it be static?
> serial_ns16550.c:225:1: warning: symbol 'eserial2_puts' was not declared. Should it be static?
> serial_ns16550.c:228:1: warning: symbol 'eserial3_init' was not declared. Should it be static?
> serial_ns16550.c:228:1: warning: symbol 'eserial3_setbrg' was not declared. Should it be static?
> serial_ns16550.c:228:1: warning: symbol 'eserial3_getc' was not declared. Should it be static?
> serial_ns16550.c:228:1: warning: symbol 'eserial3_tstc' was not declared. Should it be static?
> serial_ns16550.c:228:1: warning: symbol 'eserial3_putc' was not declared. Should it be static?
> serial_ns16550.c:228:1: warning: symbol 'eserial3_puts' was not declared. Should it be static?
> serial_ns16550.c:231:1: warning: symbol 'eserial4_init' was not declared. Should it be static?
> serial_ns16550.c:231:1: warning: symbol 'eserial4_setbrg' was not declared. Should it be static?
> serial_ns16550.c:231:1: warning: symbol 'eserial4_getc' was not declared. Should it be static?
> serial_ns16550.c:231:1: warning: symbol 'eserial4_tstc' was not declared. Should it be static?
> serial_ns16550.c:231:1: warning: symbol 'eserial4_putc' was not declared. Should it be static?
> serial_ns16550.c:231:1: warning: symbol 'eserial4_puts' was not declared. Should it be static?
> 
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121025/6d019295/attachment.pgp>

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 00/32] Initial sparse fix series
  2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
                   ` (34 preceding siblings ...)
  2012-10-25 17:46 ` Tom Rini
@ 2012-10-29 23:34 ` Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 01/25] include/linux/byteorder: import latest endian definitions from linux Kim Phillips
                     ` (25 more replies)
  35 siblings, 26 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

[v2 summary: zero inter-commit build errors on all power, arm,
and mips boards (which means some patches got merged into patch #1),
checkpatch fixes, and postponement of the libfdt changes, primarily
to get the bulk of these in during this merge window]

This 25-patch series only begins to address making u-boot source more
'sparseable,' or sparse-clean, ultimately to catch type, address space,
and endianness mismatches and generally improve code quality. E.g., 
a couple of endianness bugs are found in of_bus_default_translate()
and fdt_get_base_address() (not includeded in this v2 series - fixes
pending libfdt patch for dtc).

Patch 1 adds endianness attributes to byteorder.h helpers, e.g.,
cpu_to_be32().  This is required for correct operation and prevents
sparse from emitting false-positives.  It comes with the side effect
of breaking many builds, because u-boot has various places where
attributes were being defined differently, so it includes fixes for those.

Patches 2-5 fix issues where u-boot had imported linux header code
and the importer simply force-#defined sparse-specific attributes to
nothing, to allow u-boot to build without redefined warnings.

Patches 6-7 are general sparse fixes to common powerpc areas.

Patches 8-10 are general sparse fixes to common header areas (e.g.,
patch 8 changes the long-standing u-boot image header types to __be32,
as per u-boot image definition).

Patches 11-12 addresses sparse fixes for the net subsystem.

Patches 13-14 do the same for lib/.

Patches 15-17 for Power Arch's mpc8xxx, 83xx, and 85xx subsystems.

Last but not least, patches 18-25 attempt to clean up various drivers.

Note that the two libfdt patches present in series one are omitted here
for u-boot merge window, they will be resubmitted after dtc have merged
a libfdt-dependent patch.

For authors of new patches not willing to sift through the still quite
large sparse output for their board/platform, though interested in what
sparse has to say about their new code, it is recommended to build
with make C=1 after changes such that sparse output will only include
newly built code.

fyi, I've pushed the series onto the u-boot-mpc83xx tree,
'sparsefixes' branch:

http://git.denx.de/u-boot.git/?p=u-boot/u-boot-mpc83xx.git;a=shortlog;h=refs/heads/sparsefixes

All power, arm, mips boards tested.

Thanks,

Kim


Kim Phillips (25):
  include/linux/byteorder: import latest endian definitions from linux
  include/linux/compat.h: fix warning: preprocessor token
    {__iomem,__user} redefined
  include/linux/unaligned/generic.h: fix warning: preprocessor token
    __force redefined
  include/linux/stddef.h: avoid 'warning: preprocessor token offsetof
    redefined'
  arch/powerpc/include/asm/io.h: fix warning: preprocessor token
    __iomem redefined
  arch/powerpc/lib/extable.c: sparse fix
  arch/powerpc/lib/board.c,*traps.c: sparse fixes
  include/image.h: sparse fixes
  common/cmd_*.c: sparse fixes
  common/misc: sparse fixes
  net/: sparse fixes
  drivers/net/: sparse fixes
  lib/zlib: sparse fixes
  lib/vsprintf.c: sparse fixes
  arch/powerpc/cpu/mpc8xxx/: sparse fixes
  powerpc/mpc85xx: sparse fixes
  powerpc/mpc83xx: sparse fixes
  drivers/block/: sparse fixes
  drivers/gpio/mpc83xx_gpio.c: sparse fixes
  drivers/input/input.c: sparse fix
  drivers/mmc/mmc.c: sparse fixes
  drivers/mmc/fsl_esdhc.c: sparse fixes
  drivers/mtd/cfi_flash.c: sparse fixes
  drivers/mtd/nand: sparse fixes
  drivers/serial/serial_ns16550.c: checkpatch fixes

 arch/arm/cpu/arm1176/tnetv107x/clock.c             |   4 -
 arch/powerpc/cpu/74xx_7xx/traps.c                  |  28 +-
 arch/powerpc/cpu/mpc512x/traps.c                   | 110 ++++----
 arch/powerpc/cpu/mpc5xx/traps.c                    |   6 +-
 arch/powerpc/cpu/mpc5xxx/traps.c                   |  29 +-
 arch/powerpc/cpu/mpc8220/traps.c                   | 119 ++++----
 arch/powerpc/cpu/mpc824x/traps.c                   |  29 +-
 arch/powerpc/cpu/mpc8260/traps.c                   |  29 +-
 arch/powerpc/cpu/mpc83xx/fdt.c                     |   6 +-
 arch/powerpc/cpu/mpc83xx/speed.c                   |   4 +-
 arch/powerpc/cpu/mpc83xx/traps.c                   |  29 +-
 arch/powerpc/cpu/mpc85xx/cpu_init.c                |   2 +-
 arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c      |   2 +-
 arch/powerpc/cpu/mpc85xx/traps.c                   |  36 +--
 arch/powerpc/cpu/mpc86xx/traps.c                   |  27 +-
 arch/powerpc/cpu/mpc8xx/traps.c                    |  29 +-
 arch/powerpc/cpu/mpc8xxx/cpu.c                     |   9 +-
 arch/powerpc/cpu/mpc8xxx/ddr/ctrl_regs.c           |   2 +-
 .../cpu/mpc8xxx/ddr/lc_common_dimm_params.c        |   4 +-
 arch/powerpc/cpu/mpc8xxx/fsl_lbc.c                 |   2 +-
 arch/powerpc/cpu/ppc4xx/traps.c                    |  26 +-
 arch/powerpc/include/asm/io.h                      |   1 -
 arch/powerpc/include/asm/ppc4xx-sdram.h            |   2 +-
 arch/powerpc/lib/board.c                           |  12 +-
 arch/powerpc/lib/bootm.c                           |   2 +-
 arch/powerpc/lib/extable.c                         |   5 +-
 board/freescale/common/ngpixis.c                   |  12 +-
 board/freescale/mpc8313erdb/mpc8313erdb.c          |  24 +-
 board/freescale/mpc8568mds/bcsr.c                  |   8 +-
 board/freescale/mpc8569mds/bcsr.c                  |   8 +-
 common/cmd_boot.c                                  |   5 +-
 common/cmd_bootm.c                                 |  31 ++-
 common/cmd_console.c                               |   2 +-
 common/cmd_date.c                                  |   2 +-
 common/cmd_echo.c                                  |   2 +-
 common/cmd_exit.c                                  |   2 +-
 common/cmd_fat.c                                   |   5 +-
 common/cmd_fdt.c                                   |  21 +-
 common/cmd_flash.c                                 |   6 +-
 common/cmd_help.c                                  |   2 +-
 common/cmd_i2c.c                                   |  20 +-
 common/cmd_irq.c                                   |   3 +-
 common/cmd_itest.c                                 |   4 +-
 common/cmd_load.c                                  | 303 ++++++++++-----------
 common/cmd_mdio.c                                  |  20 +-
 common/cmd_mem.c                                   |  25 +-
 common/cmd_misc.c                                  |   6 +-
 common/cmd_mmc.c                                   |   6 +-
 common/cmd_mp.c                                    |  22 +-
 common/cmd_mtdparts.c                              |  26 +-
 common/cmd_nand.c                                  |  19 +-
 common/cmd_net.c                                   |  76 +++---
 common/cmd_nvedit.c                                |  25 +-
 common/cmd_pci.c                                   |  17 +-
 common/cmd_reginfo.c                               |   3 +-
 common/cmd_sata.c                                  |   4 +-
 common/cmd_setexpr.c                               |   2 +-
 common/cmd_source.c                                |  11 +-
 common/cmd_test.c                                  |   6 +-
 common/cmd_usb.c                                   |  30 +-
 common/cmd_version.c                               |   2 +-
 common/cmd_ximg.c                                  |  13 +-
 common/command.c                                   |   9 +-
 common/dlmalloc.c                                  |  36 +--
 common/hush.c                                      |  31 ++-
 common/image.c                                     |   8 +-
 common/main.c                                      |  10 +-
 common/update.c                                    |   1 +
 common/usb_storage.c                               |  20 +-
 common/xyzModem.c                                  |   6 +-
 drivers/block/fsl_sata.c                           |  81 +-----
 drivers/block/fsl_sata.h                           |  13 +-
 drivers/block/sata_sil.c                           |  13 +-
 drivers/gpio/mpc83xx_gpio.c                        |   4 +-
 drivers/input/input.c                              |   2 +-
 drivers/mmc/fsl_esdhc.c                            |   4 +-
 drivers/mmc/mmc.c                                  |  37 +--
 drivers/mtd/cfi_flash.c                            |  22 +-
 drivers/mtd/nand/nand_base.c                       |  13 +-
 drivers/mtd/nand/nand_ecc.c                        |   1 +
 drivers/mtd/ubi/crc32.c                            |  12 +-
 drivers/net/fm/eth.c                               |   2 +-
 drivers/net/fm/p1023.c                             |   2 +-
 drivers/net/fm/p4080.c                             |   2 +-
 drivers/net/fm/p5020.c                             |   2 +-
 drivers/net/fm/tgec_phy.c                          |  10 +-
 drivers/net/macb.c                                 |   2 -
 drivers/net/phy/atheros.c                          |   2 +-
 drivers/net/phy/phy.c                              |  19 +-
 drivers/net/phy/vitesse.c                          |   2 +-
 drivers/net/smc91111.c                             |   2 -
 drivers/net/vsc7385.c                              |   1 +
 drivers/serial/s3c64xx.c                           |   2 -
 drivers/serial/serial_ns16550.c                    |  42 ++-
 fs/yaffs2/ydirectenv.h                             |   2 -
 include/common.h                                   |   4 -
 include/image.h                                    |  15 +-
 include/linux/byteorder/big_endian.h               | 135 +++++----
 include/linux/byteorder/little_endian.h            | 133 +++++----
 include/linux/byteorder/swab.h                     |   6 +-
 include/linux/compat.h                             |   3 -
 include/linux/mtd/mtd-abi.h                        |   2 +
 include/linux/stddef.h                             |   2 +
 include/linux/unaligned/generic.h                  |   3 -
 include/net.h                                      |   9 +-
 include/u-boot/zlib.h                              |   2 +-
 lib/vsprintf.c                                     |   4 +-
 lib/zlib/adler32.c                                 |   5 +-
 lib/zlib/inffast.c                                 |   5 +-
 lib/zlib/inflate.c                                 |  29 +-
 lib/zlib/inftrees.c                                |  10 +-
 lib/zlib/zutil.c                                   |  10 +-
 net/arp.c                                          |   6 +-
 net/bootp.c                                        |   6 +-
 net/net.c                                          |   2 +-
 net/ping.h                                         |   3 -
 net/tftp.h                                         |   3 +
 117 files changed, 1052 insertions(+), 1087 deletions(-)

-- 
1.8.0

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 01/25] include/linux/byteorder: import latest endian definitions from linux
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 02/25] include/linux/compat.h: fix warning: preprocessor token {__iomem, __user} redefined Kim Phillips
                     ` (24 subsequent siblings)
  25 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

u-boot's byteorder headers did not contain endianness attributions
for use with sparse, causing a lot of false positives.  Import the
kernel's latest definitions, and enable them by including compiler.h
and types.h.  They come with 'const' added for some swab functions, so
fix those up, too:

include/linux/byteorder/big_endian.h:46:2: warning: passing argument 1 of '__swab64p' discards 'const' qualifier from pointer target type [enabled by default]

Also, note: u-boot's historic __BYTE_ORDER definition has been
preserved (for the time being at least).

We also remove ad-hoc barrier() definitions, since we're including
compiler.h in files that hadn't in the past:

macb.c:54:0: warning: "barrier" redefined [enabled by default]

In addition, including compiler.h in byteorder changes the 'noinline'
definition to expand to __attribute__((noinline)).  This fixes
arch/powerpc/lib/bootm.c:

bootm.c:329:16: error: attribute '__attribute__': unknown attribute
bootm.c:329:16: error: expected ')' before '__attribute__'
bootm.c:329:25: error: expected identifier or '(' before ')' token

powerpc sparse builds yield:

include/common.h:356:22: error: marked inline, but without a definition

the unknown-reason inlining without a definition is considered obsolete
given it was part of the 2002 initial commit, and no arm version was
'fixed.'

also fixed:
ydirectenv.h:60:0: warning: "inline" redefined [enabled by default]

and:

Configuring for devconcenter - Board: intip, Options: DEVCONCENTER
make[1]: *** [4xx_ibm_ddr2_autocalib.o] Error 1
make: *** [arch/powerpc/cpu/ppc4xx/libppc4xx.o] Error 2
powerpc-fsl-linux-size: './u-boot': No such file
4xx_ibm_ddr2_autocalib.c: In function 'DQS_autocalibration':
include/asm/ppc4xx-sdram.h:1407:13: sorry, unimplemented: inlining failed in call to 'ppc4xx_ibm_ddr2_register_dump': function body not available
4xx_ibm_ddr2_autocalib.c:1243:32: sorry, unimplemented: called from here

and:

In file included from crc32.c:50:0:
crc32table.h:4:1: warning: implicit declaration of function '___constant_swab32' [-Wimplicit-function-declaration]
crc32table.h:4:1: error: initializer element is not constant
crc32table.h:4:1: error: (near initialization for 'crc32table_le[0]')

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: adds the last four fixes mentioned above

 arch/arm/cpu/arm1176/tnetv107x/clock.c  |   4 -
 arch/powerpc/include/asm/ppc4xx-sdram.h |   2 +-
 arch/powerpc/lib/bootm.c                |   2 +-
 drivers/mtd/ubi/crc32.c                 |  12 +--
 drivers/net/macb.c                      |   2 -
 drivers/net/smc91111.c                  |   2 -
 drivers/serial/s3c64xx.c                |   2 -
 fs/yaffs2/ydirectenv.h                  |   2 -
 include/common.h                        |   4 -
 include/linux/byteorder/big_endian.h    | 135 +++++++++++++++++++++-----------
 include/linux/byteorder/little_endian.h | 133 ++++++++++++++++++++-----------
 include/linux/byteorder/swab.h          |   6 +-
 12 files changed, 182 insertions(+), 124 deletions(-)

diff --git a/arch/arm/cpu/arm1176/tnetv107x/clock.c b/arch/arm/cpu/arm1176/tnetv107x/clock.c
index e26fec1..16876ae 100644
--- a/arch/arm/cpu/arm1176/tnetv107x/clock.c
+++ b/arch/arm/cpu/arm1176/tnetv107x/clock.c
@@ -168,10 +168,6 @@ static unsigned long pll_div_mask[] = { 0x01ff, 0x00ff, 0x00ff };
 #define tdm_extra_clk		{TDM_PLL, 1}
 #define tdm1_clk		{TDM_PLL, 2}
 
-/* Optimization barrier */
-#define barrier()	\
-	__asm__ __volatile__("mov r0, r0\n" : : : "memory");
-
 static const struct lpsc_map lpsc_clk_map[] = {
 	[TNETV107X_LPSC_ARM]			= sys_arm1176_clk,
 	[TNETV107X_LPSC_GEM]			= sys_dsp_clk,
diff --git a/arch/powerpc/include/asm/ppc4xx-sdram.h b/arch/powerpc/include/asm/ppc4xx-sdram.h
index d570d79..e35d9b6 100644
--- a/arch/powerpc/include/asm/ppc4xx-sdram.h
+++ b/arch/powerpc/include/asm/ppc4xx-sdram.h
@@ -1404,7 +1404,7 @@ struct sdram_timing {
 /*
  * Prototypes
  */
-inline void ppc4xx_ibm_ddr2_register_dump(void);
+void ppc4xx_ibm_ddr2_register_dump(void);
 u32 mfdcr_any(u32);
 void mtdcr_any(u32, u32);
 u32 ddr_wrdtr(u32);
diff --git a/arch/powerpc/lib/bootm.c b/arch/powerpc/lib/bootm.c
index 53dc4df..ac5bd6d 100644
--- a/arch/powerpc/lib/bootm.c
+++ b/arch/powerpc/lib/bootm.c
@@ -326,7 +326,7 @@ static int boot_body_linux(bootm_headers_t *images)
 	return 0;
 }
 
-__attribute__((noinline))
+noinline
 int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images)
 {
 	int	ret;
diff --git a/drivers/mtd/ubi/crc32.c b/drivers/mtd/ubi/crc32.c
index a7e26b0..ab439b3 100644
--- a/drivers/mtd/ubi/crc32.c
+++ b/drivers/mtd/ubi/crc32.c
@@ -38,17 +38,9 @@
 #include "crc32defs.h"
 #define CRC_LE_BITS 8
 
-# define __force
-#ifndef __constant_cpu_to_le32
-#define __constant_cpu_to_le32(x) ((__force __le32)(__u32)(x))
-#endif
-#ifndef __constant_le32_to_cpu
-#define __constant_le32_to_cpu(x) ((__force __u32)(__le32)(x))
-#endif
-
 #if CRC_LE_BITS == 8
-#define tole(x) __constant_cpu_to_le32(x)
-#define tobe(x) __constant_cpu_to_be32(x)
+#define tole(x) cpu_to_le32(x)
+#define tobe(x) cpu_to_be32(x)
 #else
 #define tole(x) (x)
 #define tobe(x) (x)
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 0e1ced7..8bacbda 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -51,8 +51,6 @@
 
 #include "macb.h"
 
-#define barrier() asm volatile("" ::: "memory")
-
 #define CONFIG_SYS_MACB_RX_BUFFER_SIZE		4096
 #define CONFIG_SYS_MACB_RX_RING_SIZE		(CONFIG_SYS_MACB_RX_BUFFER_SIZE / 128)
 #define CONFIG_SYS_MACB_TX_RING_SIZE		16
diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c
index 6dc7ad5..1357ede 100644
--- a/drivers/net/smc91111.c
+++ b/drivers/net/smc91111.c
@@ -178,8 +178,6 @@ static void smc_phy_configure(struct eth_device *dev);
  * inx,outx functions fixed this problem.
  */
 
-#define barrier() __asm__ __volatile__("": : :"memory")
-
 static inline word SMC_inw(struct eth_device *dev, dword offset)
 {
 	word v;
diff --git a/drivers/serial/s3c64xx.c b/drivers/serial/s3c64xx.c
index ea8d734..f53c2bf 100644
--- a/drivers/serial/s3c64xx.c
+++ b/drivers/serial/s3c64xx.c
@@ -40,8 +40,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #error "Bad: you didn't configure serial ..."
 #endif
 
-#define barrier() asm volatile("" ::: "memory")
-
 /*
  * The coefficient, used to calculate the baudrate on S3C6400 UARTs is
  * calculated as
diff --git a/fs/yaffs2/ydirectenv.h b/fs/yaffs2/ydirectenv.h
index c912b09..c2ffbfd 100644
--- a/fs/yaffs2/ydirectenv.h
+++ b/fs/yaffs2/ydirectenv.h
@@ -56,8 +56,6 @@ void yaffs_qsort(void *aa, size_t n, size_t es,
 
 #ifdef NO_inline
 #define inline
-#else
-#define inline __inline__
 #endif
 
 #define cond_resched()  do {} while (0)
diff --git a/include/common.h b/include/common.h
index b23e90b..5e3c5ee 100644
--- a/include/common.h
+++ b/include/common.h
@@ -341,13 +341,9 @@ char	*getenv	     (const char *);
 int	getenv_f     (const char *name, char *buf, unsigned len);
 ulong getenv_ulong(const char *name, int base, ulong default_val);
 int	saveenv	     (void);
-#ifdef CONFIG_PPC		/* ARM version to be fixed! */
-int inline setenv    (const char *, const char *);
-#else
 int	setenv	     (const char *, const char *);
 int setenv_ulong(const char *varname, ulong value);
 int setenv_addr(const char *varname, const void *addr);
-#endif /* CONFIG_PPC */
 #ifdef CONFIG_ARM
 # include <asm/mach-types.h>
 # include <asm/setup.h>
diff --git a/include/linux/byteorder/big_endian.h b/include/linux/byteorder/big_endian.h
index 19b0c86..aaf7757 100644
--- a/include/linux/byteorder/big_endian.h
+++ b/include/linux/byteorder/big_endian.h
@@ -7,63 +7,104 @@
 #ifndef __BIG_ENDIAN_BITFIELD
 #define __BIG_ENDIAN_BITFIELD
 #endif
-#define	__BYTE_ORDER	__BIG_ENDIAN
+#define __BYTE_ORDER	__BIG_ENDIAN
 
+#include <linux/compiler.h>
+#include <linux/types.h>
 #include <linux/byteorder/swab.h>
 
-#define __constant_htonl(x) ((__u32)(x))
-#define __constant_ntohl(x) ((__u32)(x))
-#define __constant_htons(x) ((__u16)(x))
-#define __constant_ntohs(x) ((__u16)(x))
-#define __constant_cpu_to_le64(x) ___swab64((x))
-#define __constant_le64_to_cpu(x) ___swab64((x))
-#define __constant_cpu_to_le32(x) ___swab32((x))
-#define __constant_le32_to_cpu(x) ___swab32((x))
-#define __constant_cpu_to_le16(x) ___swab16((x))
-#define __constant_le16_to_cpu(x) ___swab16((x))
-#define __constant_cpu_to_be64(x) ((__u64)(x))
-#define __constant_be64_to_cpu(x) ((__u64)(x))
-#define __constant_cpu_to_be32(x) ((__u32)(x))
-#define __constant_be32_to_cpu(x) ((__u32)(x))
-#define __constant_cpu_to_be16(x) ((__u16)(x))
-#define __constant_be16_to_cpu(x) ((__u16)(x))
-#define __cpu_to_le64(x) __swab64((x))
-#define __le64_to_cpu(x) __swab64((x))
-#define __cpu_to_le32(x) __swab32((x))
-#define __le32_to_cpu(x) __swab32((x))
-#define __cpu_to_le16(x) __swab16((x))
-#define __le16_to_cpu(x) __swab16((x))
-#define __cpu_to_be64(x) ((__u64)(x))
-#define __be64_to_cpu(x) ((__u64)(x))
-#define __cpu_to_be32(x) ((__u32)(x))
-#define __be32_to_cpu(x) ((__u32)(x))
-#define __cpu_to_be16(x) ((__u16)(x))
-#define __be16_to_cpu(x) ((__u16)(x))
-#define __cpu_to_le64p(x) __swab64p((x))
-#define __le64_to_cpup(x) __swab64p((x))
-#define __cpu_to_le32p(x) __swab32p((x))
-#define __le32_to_cpup(x) __swab32p((x))
-#define __cpu_to_le16p(x) __swab16p((x))
-#define __le16_to_cpup(x) __swab16p((x))
-#define __cpu_to_be64p(x) (*(__u64*)(x))
-#define __be64_to_cpup(x) (*(__u64*)(x))
-#define __cpu_to_be32p(x) (*(__u32*)(x))
-#define __be32_to_cpup(x) (*(__u32*)(x))
-#define __cpu_to_be16p(x) (*(__u16*)(x))
-#define __be16_to_cpup(x) (*(__u16*)(x))
+#define __constant_htonl(x) ((__force __be32)(__u32)(x))
+#define __constant_ntohl(x) ((__force __u32)(__be32)(x))
+#define __constant_htons(x) ((__force __be16)(__u16)(x))
+#define __constant_ntohs(x) ((__force __u16)(__be16)(x))
+#define __constant_cpu_to_le64(x) ((__force __le64)___constant_swab64((x)))
+#define __constant_le64_to_cpu(x) ___constant_swab64((__force __u64)(__le64)(x))
+#define __constant_cpu_to_le32(x) ((__force __le32)___constant_swab32((x)))
+#define __constant_le32_to_cpu(x) ___constant_swab32((__force __u32)(__le32)(x))
+#define __constant_cpu_to_le16(x) ((__force __le16)___constant_swab16((x)))
+#define __constant_le16_to_cpu(x) ___constant_swab16((__force __u16)(__le16)(x))
+#define __constant_cpu_to_be64(x) ((__force __be64)(__u64)(x))
+#define __constant_be64_to_cpu(x) ((__force __u64)(__be64)(x))
+#define __constant_cpu_to_be32(x) ((__force __be32)(__u32)(x))
+#define __constant_be32_to_cpu(x) ((__force __u32)(__be32)(x))
+#define __constant_cpu_to_be16(x) ((__force __be16)(__u16)(x))
+#define __constant_be16_to_cpu(x) ((__force __u16)(__be16)(x))
+#define __cpu_to_le64(x) ((__force __le64)__swab64((x)))
+#define __le64_to_cpu(x) __swab64((__force __u64)(__le64)(x))
+#define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
+#define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
+#define __cpu_to_le16(x) ((__force __le16)__swab16((x)))
+#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
+#define __cpu_to_be64(x) ((__force __be64)(__u64)(x))
+#define __be64_to_cpu(x) ((__force __u64)(__be64)(x))
+#define __cpu_to_be32(x) ((__force __be32)(__u32)(x))
+#define __be32_to_cpu(x) ((__force __u32)(__be32)(x))
+#define __cpu_to_be16(x) ((__force __be16)(__u16)(x))
+#define __be16_to_cpu(x) ((__force __u16)(__be16)(x))
+
+static inline __le64 __cpu_to_le64p(const __u64 *p)
+{
+	return (__force __le64)__swab64p(p);
+}
+static inline __u64 __le64_to_cpup(const __le64 *p)
+{
+	return __swab64p((__u64 *)p);
+}
+static inline __le32 __cpu_to_le32p(const __u32 *p)
+{
+	return (__force __le32)__swab32p(p);
+}
+static inline __u32 __le32_to_cpup(const __le32 *p)
+{
+	return __swab32p((__u32 *)p);
+}
+static inline __le16 __cpu_to_le16p(const __u16 *p)
+{
+	return (__force __le16)__swab16p(p);
+}
+static inline __u16 __le16_to_cpup(const __le16 *p)
+{
+	return __swab16p((__u16 *)p);
+}
+static inline __be64 __cpu_to_be64p(const __u64 *p)
+{
+	return (__force __be64)*p;
+}
+static inline __u64 __be64_to_cpup(const __be64 *p)
+{
+	return (__force __u64)*p;
+}
+static inline __be32 __cpu_to_be32p(const __u32 *p)
+{
+	return (__force __be32)*p;
+}
+static inline __u32 __be32_to_cpup(const __be32 *p)
+{
+	return (__force __u32)*p;
+}
+static inline __be16 __cpu_to_be16p(const __u16 *p)
+{
+	return (__force __be16)*p;
+}
+static inline __u16 __be16_to_cpup(const __be16 *p)
+{
+	return (__force __u16)*p;
+}
 #define __cpu_to_le64s(x) __swab64s((x))
 #define __le64_to_cpus(x) __swab64s((x))
 #define __cpu_to_le32s(x) __swab32s((x))
 #define __le32_to_cpus(x) __swab32s((x))
 #define __cpu_to_le16s(x) __swab16s((x))
 #define __le16_to_cpus(x) __swab16s((x))
-#define __cpu_to_be64s(x) do {} while (0)
-#define __be64_to_cpus(x) do {} while (0)
-#define __cpu_to_be32s(x) do {} while (0)
-#define __be32_to_cpus(x) do {} while (0)
-#define __cpu_to_be16s(x) do {} while (0)
-#define __be16_to_cpus(x) do {} while (0)
+#define __cpu_to_be64s(x) do { (void)(x); } while (0)
+#define __be64_to_cpus(x) do { (void)(x); } while (0)
+#define __cpu_to_be32s(x) do { (void)(x); } while (0)
+#define __be32_to_cpus(x) do { (void)(x); } while (0)
+#define __cpu_to_be16s(x) do { (void)(x); } while (0)
+#define __be16_to_cpus(x) do { (void)(x); } while (0)
 
+#ifdef __KERNEL__
 #include <linux/byteorder/generic.h>
+#endif
 
 #endif /* _LINUX_BYTEORDER_BIG_ENDIAN_H */
diff --git a/include/linux/byteorder/little_endian.h b/include/linux/byteorder/little_endian.h
index a46f3ec..a4cb3bf 100644
--- a/include/linux/byteorder/little_endian.h
+++ b/include/linux/byteorder/little_endian.h
@@ -9,54 +9,93 @@
 #endif
 #define	__BYTE_ORDER	__LITTLE_ENDIAN
 
+#include <linux/compiler.h>
+#include <linux/types.h>
 #include <linux/byteorder/swab.h>
 
-#define __constant_htonl(x) ___constant_swab32((x))
-#define __constant_ntohl(x) ___constant_swab32((x))
-#define __constant_htons(x) ___constant_swab16((x))
-#define __constant_ntohs(x) ___constant_swab16((x))
-#define __constant_cpu_to_le64(x) ((__u64)(x))
-#define __constant_le64_to_cpu(x) ((__u64)(x))
-#define __constant_cpu_to_le32(x) ((__u32)(x))
-#define __constant_le32_to_cpu(x) ((__u32)(x))
-#define __constant_cpu_to_le16(x) ((__u16)(x))
-#define __constant_le16_to_cpu(x) ((__u16)(x))
-#define __constant_cpu_to_be64(x) ___constant_swab64((x))
-#define __constant_be64_to_cpu(x) ___constant_swab64((x))
-#define __constant_cpu_to_be32(x) ___constant_swab32((x))
-#define __constant_be32_to_cpu(x) ___constant_swab32((x))
-#define __constant_cpu_to_be16(x) ___constant_swab16((x))
-#define __constant_be16_to_cpu(x) ___constant_swab16((x))
-#define __cpu_to_le64(x) ((__u64)(x))
-#define __le64_to_cpu(x) ((__u64)(x))
-#define __cpu_to_le32(x) ((__u32)(x))
-#define __le32_to_cpu(x) ((__u32)(x))
-#define __cpu_to_le16(x) ((__u16)(x))
-#define __le16_to_cpu(x) ((__u16)(x))
-#define __cpu_to_be64(x) __swab64((x))
-#define __be64_to_cpu(x) __swab64((x))
-#define __cpu_to_be32(x) __swab32((x))
-#define __be32_to_cpu(x) __swab32((x))
-#define __cpu_to_be16(x) __swab16((x))
-#define __be16_to_cpu(x) __swab16((x))
-#define __cpu_to_le64p(x) (*(__u64*)(x))
-#define __le64_to_cpup(x) (*(__u64*)(x))
-#define __cpu_to_le32p(x) (*(__u32*)(x))
-#define __le32_to_cpup(x) (*(__u32*)(x))
-#define __cpu_to_le16p(x) (*(__u16*)(x))
-#define __le16_to_cpup(x) (*(__u16*)(x))
-#define __cpu_to_be64p(x) __swab64p((x))
-#define __be64_to_cpup(x) __swab64p((x))
-#define __cpu_to_be32p(x) __swab32p((x))
-#define __be32_to_cpup(x) __swab32p((x))
-#define __cpu_to_be16p(x) __swab16p((x))
-#define __be16_to_cpup(x) __swab16p((x))
-#define __cpu_to_le64s(x) do {} while (0)
-#define __le64_to_cpus(x) do {} while (0)
-#define __cpu_to_le32s(x) do {} while (0)
-#define __le32_to_cpus(x) do {} while (0)
-#define __cpu_to_le16s(x) do {} while (0)
-#define __le16_to_cpus(x) do {} while (0)
+#define __constant_htonl(x) ((__force __be32)___constant_swab32((x)))
+#define __constant_ntohl(x) ___constant_swab32((__force __be32)(x))
+#define __constant_htons(x) ((__force __be16)___constant_swab16((x)))
+#define __constant_ntohs(x) ___constant_swab16((__force __be16)(x))
+#define __constant_cpu_to_le64(x) ((__force __le64)(__u64)(x))
+#define __constant_le64_to_cpu(x) ((__force __u64)(__le64)(x))
+#define __constant_cpu_to_le32(x) ((__force __le32)(__u32)(x))
+#define __constant_le32_to_cpu(x) ((__force __u32)(__le32)(x))
+#define __constant_cpu_to_le16(x) ((__force __le16)(__u16)(x))
+#define __constant_le16_to_cpu(x) ((__force __u16)(__le16)(x))
+#define __constant_cpu_to_be64(x) ((__force __be64)___constant_swab64((x)))
+#define __constant_be64_to_cpu(x) ___constant_swab64((__force __u64)(__be64)(x))
+#define __constant_cpu_to_be32(x) ((__force __be32)___constant_swab32((x)))
+#define __constant_be32_to_cpu(x) ___constant_swab32((__force __u32)(__be32)(x))
+#define __constant_cpu_to_be16(x) ((__force __be16)___constant_swab16((x)))
+#define __constant_be16_to_cpu(x) ___constant_swab16((__force __u16)(__be16)(x))
+#define __cpu_to_le64(x) ((__force __le64)(__u64)(x))
+#define __le64_to_cpu(x) ((__force __u64)(__le64)(x))
+#define __cpu_to_le32(x) ((__force __le32)(__u32)(x))
+#define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
+#define __cpu_to_le16(x) ((__force __le16)(__u16)(x))
+#define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
+#define __cpu_to_be64(x) ((__force __be64)__swab64((x)))
+#define __be64_to_cpu(x) __swab64((__force __u64)(__be64)(x))
+#define __cpu_to_be32(x) ((__force __be32)__swab32((x)))
+#define __be32_to_cpu(x) __swab32((__force __u32)(__be32)(x))
+#define __cpu_to_be16(x) ((__force __be16)__swab16((x)))
+#define __be16_to_cpu(x) __swab16((__force __u16)(__be16)(x))
+
+static inline __le64 __cpu_to_le64p(const __u64 *p)
+{
+	return (__force __le64)*p;
+}
+static inline __u64 __le64_to_cpup(const __le64 *p)
+{
+	return (__force __u64)*p;
+}
+static inline __le32 __cpu_to_le32p(const __u32 *p)
+{
+	return (__force __le32)*p;
+}
+static inline __u32 __le32_to_cpup(const __le32 *p)
+{
+	return (__force __u32)*p;
+}
+static inline __le16 __cpu_to_le16p(const __u16 *p)
+{
+	return (__force __le16)*p;
+}
+static inline __u16 __le16_to_cpup(const __le16 *p)
+{
+	return (__force __u16)*p;
+}
+static inline __be64 __cpu_to_be64p(const __u64 *p)
+{
+	return (__force __be64)__swab64p(p);
+}
+static inline __u64 __be64_to_cpup(const __be64 *p)
+{
+	return __swab64p((__u64 *)p);
+}
+static inline __be32 __cpu_to_be32p(const __u32 *p)
+{
+	return (__force __be32)__swab32p(p);
+}
+static inline __u32 __be32_to_cpup(const __be32 *p)
+{
+	return __swab32p((__u32 *)p);
+}
+static inline __be16 __cpu_to_be16p(const __u16 *p)
+{
+	return (__force __be16)__swab16p(p);
+}
+static inline __u16 __be16_to_cpup(const __be16 *p)
+{
+	return __swab16p((__u16 *)p);
+}
+#define __cpu_to_le64s(x) do { (void)(x); } while (0)
+#define __le64_to_cpus(x) do { (void)(x); } while (0)
+#define __cpu_to_le32s(x) do { (void)(x); } while (0)
+#define __le32_to_cpus(x) do { (void)(x); } while (0)
+#define __cpu_to_le16s(x) do { (void)(x); } while (0)
+#define __le16_to_cpus(x) do { (void)(x); } while (0)
 #define __cpu_to_be64s(x) __swab64s((x))
 #define __be64_to_cpus(x) __swab64s((x))
 #define __cpu_to_be32s(x) __swab32s((x))
@@ -64,6 +103,8 @@
 #define __cpu_to_be16s(x) __swab16s((x))
 #define __be16_to_cpus(x) __swab16s((x))
 
+#ifdef __KERNEL__
 #include <linux/byteorder/generic.h>
+#endif
 
 #endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */
diff --git a/include/linux/byteorder/swab.h b/include/linux/byteorder/swab.h
index b1d570e..bb4a046 100644
--- a/include/linux/byteorder/swab.h
+++ b/include/linux/byteorder/swab.h
@@ -100,7 +100,7 @@ static __inline__ __attribute__((const)) __u16 __fswab16(__u16 x)
 {
 	return __arch__swab16(x);
 }
-static __inline__ __u16 __swab16p(__u16 *x)
+static __inline__ __u16 __swab16p(const __u16 *x)
 {
 	return __arch__swab16p(x);
 }
@@ -113,7 +113,7 @@ static __inline__ __attribute__((const)) __u32 __fswab32(__u32 x)
 {
 	return __arch__swab32(x);
 }
-static __inline__ __u32 __swab32p(__u32 *x)
+static __inline__ __u32 __swab32p(const __u32 *x)
 {
 	return __arch__swab32p(x);
 }
@@ -133,7 +133,7 @@ static __inline__ __attribute__((const)) __u64 __fswab64(__u64 x)
 	return __arch__swab64(x);
 #  endif
 }
-static __inline__ __u64 __swab64p(__u64 *x)
+static __inline__ __u64 __swab64p(const __u64 *x)
 {
 	return __arch__swab64p(x);
 }
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 02/25] include/linux/compat.h: fix warning: preprocessor token {__iomem, __user} redefined
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 01/25] include/linux/byteorder: import latest endian definitions from linux Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 03/25] include/linux/unaligned/generic.h: fix warning: preprocessor token __force redefined Kim Phillips
                     ` (23 subsequent siblings)
  25 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

include/linux/compat.h:4:9: warning: preprocessor token __user redefined
include/linux/compiler.h:7:10: this was the original definition
include/linux/compat.h:5:9: warning: preprocessor token __iomem redefined
include/linux/compiler.h:12:10: this was the original definition

fixup __iomem, __user definitions in compat.h code appears to be placed
there as a cover up from a code import from linux when u-boot didn't yet
have a compiler.h, introduced by commit
932394ac43e2e778e664eeb6e456fecd0fae6e59 "Rewrite of NAND code based on
what is in 2.6.12 Linux kernel".

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: add a fix for breakeage introduced by above:

In file included from .../u-boot/u-boot/include/linux/mtd/mtd.h:12:0,
from mtdcore.c:10: .../u-boot/include/linux/mtd/mtd-abi.h:22:23:
error: expected ':', ',', ';', '}' or '__attribute__' before '*' token

on a number of omap3 boards (mtd-abi.h was using __user without
being defined).

 include/linux/compat.h      | 3 ---
 include/linux/mtd/mtd-abi.h | 2 ++
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/include/linux/compat.h b/include/linux/compat.h
index 593b07f..e1338bf 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -1,9 +1,6 @@
 #ifndef _LINUX_COMPAT_H_
 #define _LINUX_COMPAT_H_
 
-#define __user
-#define __iomem
-
 #define ndelay(x)	udelay(1)
 
 #define printk	printf
diff --git a/include/linux/mtd/mtd-abi.h b/include/linux/mtd/mtd-abi.h
index 5991157..8bdd231 100644
--- a/include/linux/mtd/mtd-abi.h
+++ b/include/linux/mtd/mtd-abi.h
@@ -11,6 +11,8 @@
 #include <linux/compat.h>
 #endif
 
+#include <linux/compiler.h>
+
 struct erase_info_user {
 	uint32_t start;
 	uint32_t length;
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 03/25] include/linux/unaligned/generic.h: fix warning: preprocessor token __force redefined
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 01/25] include/linux/byteorder: import latest endian definitions from linux Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 02/25] include/linux/compat.h: fix warning: preprocessor token {__iomem, __user} redefined Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 04/25] include/linux/stddef.h: avoid 'warning: preprocessor token offsetof redefined' Kim Phillips
                     ` (22 subsequent siblings)
  25 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

include/linux/unaligned/generic.h:5:9: warning: preprocessor token __force redefined
include/linux/compiler.h:10:10: this was the original definition

fixup __force definitions in compat.h code appears to be placed
there as a cover up from a code import from linux when u-boot didn't yet
have a compiler.h, introduced by commit
b1b4e89a0f3b75854c39a62cae41bad56d210adf "Add LZO decompressor support".

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: no change

 include/linux/unaligned/generic.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/linux/unaligned/generic.h b/include/linux/unaligned/generic.h
index cc688e1..02d97ff 100644
--- a/include/linux/unaligned/generic.h
+++ b/include/linux/unaligned/generic.h
@@ -1,9 +1,6 @@
 #ifndef _LINUX_UNALIGNED_GENERIC_H
 #define _LINUX_UNALIGNED_GENERIC_H
 
-/* define __force to nothing in U-Boot */
-#define __force
-
 /*
  * Cause a link-time error if we try an unaligned access other than
  * 1,2,4 or 8 bytes long
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 04/25] include/linux/stddef.h: avoid 'warning: preprocessor token offsetof redefined'
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (2 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 03/25] include/linux/unaligned/generic.h: fix warning: preprocessor token __force redefined Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 05/25] arch/powerpc/include/asm/io.h: fix warning: preprocessor token __iomem redefined Kim Phillips
                     ` (21 subsequent siblings)
  25 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

hack to avoid:

/opt/gcc-4.6.3-nolibc/powerpc-linux/bin/../lib/gcc/powerpc-linux/4.6.3/include/stddef.h:413:9: warning: preprocessor token offsetof redefined
u-boot/include/linux/stddef.h:20:9: this was the original definition

tried protecting with __KERNEL__, and #including compiler.h first.

Even tried include dir reordering to no avail:

 +++ b/config.mk
 @@ -194,7 +194,11 @@ OBJCFLAGS += --gap-fill=0xff
 gccincdir := $(shell $(CC) -print-file-name=include)

 CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)                \
 -       -D__KERNEL__
 +       -D__KERNEL__  \
 +       -I $(gccincdir) \
 +       -nostdinc
 +
 +#      -isystem $(gccincdir) \

 # Enable garbage collection of un-used sections for SPL
 ifeq ($(CONFIG_SPL_BUILD),y)
 @@ -227,8 +231,7 @@ CPPFLAGS += -I$(OBJTREE)/include2 -I$(OBJTREE)/include
 endif

 CPPFLAGS += -I$(TOPDIR)/include
 -CPPFLAGS += -fno-builtin -ffreestanding -nostdinc      \
 -       -isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
 +CPPFLAGS += -fno-builtin -ffreestanding -pipe $(PLATFORM_CPPFLAGS)

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: no change

 include/linux/stddef.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/stddef.h b/include/linux/stddef.h
index 81e34c2..c540f61 100644
--- a/include/linux/stddef.h
+++ b/include/linux/stddef.h
@@ -12,7 +12,9 @@
 #include <linux/types.h>
 #endif
 
+#ifndef __CHECKER__
 #undef offsetof
 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
 
 #endif
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 05/25] arch/powerpc/include/asm/io.h: fix warning: preprocessor token __iomem redefined
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (3 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 04/25] include/linux/stddef.h: avoid 'warning: preprocessor token offsetof redefined' Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 06/25] arch/powerpc/lib/extable.c: sparse fix Kim Phillips
                     ` (20 subsequent siblings)
  25 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

a fixup __iomem definition in arch code appears to be placed there as a cover
up from a code import from linux when u-boot didn't yet have a compiler.h,
introduced by commit 812711ce6b3a386125dcf0d6a59588e461abbb87 "Implement
__raw_{read,write}[bwl] on all architectures".

git show 812711ce6b3a386125dcf0d6a59588e461abbb87:include/linux/compiler.h
fatal: Path 'include/linux/compiler.h' exists on disk, but not in '812711ce6b3a386125dcf0d6a59588e461abbb87'.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: no change

 arch/powerpc/include/asm/io.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index 9e20861..1f12c29 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -127,7 +127,6 @@ static inline void isync(void)
 /*
  * Non ordered and non-swapping "raw" accessors
  */
-#define __iomem
 #define PCI_FIX_ADDR(addr)	(addr)
 
 static inline unsigned char __raw_readb(const volatile void __iomem *addr)
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 06/25] arch/powerpc/lib/extable.c: sparse fix
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (4 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 05/25] arch/powerpc/include/asm/io.h: fix warning: preprocessor token __iomem redefined Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 07/25] arch/powerpc/lib/board.c, *traps.c: sparse fixes Kim Phillips
                     ` (19 subsequent siblings)
  25 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

extable.c:66:9: warning: symbol 'ex_tab_message' was not declared. Should it be static?

making it static can produce a new build warning on some boards:

extable.c:66:12: warning: 'ex_tab_message' defined but not used [-Wunused-variable]

but ex_tab_message doesn't do much even when used, so just remove it.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: doesn't make it static, it just deletes it

 arch/powerpc/lib/extable.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/powerpc/lib/extable.c b/arch/powerpc/lib/extable.c
index 7408d5c..60983ae 100644
--- a/arch/powerpc/lib/extable.c
+++ b/arch/powerpc/lib/extable.c
@@ -63,8 +63,6 @@ search_one_table(const struct exception_table_entry *first,
 	return 0;
 }
 
-int	ex_tab_message = 1;
-
 unsigned long
 search_exception_table(unsigned long addr)
 {
@@ -74,8 +72,7 @@ search_exception_table(unsigned long addr)
 	ret = search_one_table(__start___ex_table, __stop___ex_table-1, addr);
 	/* if the serial port does not hang in exception, printf can be used */
 #if !defined(CONFIG_SYS_SERIAL_HANG_IN_EXCEPTION)
-	if (ex_tab_message)
-		debug("Bus Fault @ 0x%08lx, fixup 0x%08lx\n", addr, ret);
+	debug("Bus Fault @ 0x%08lx, fixup 0x%08lx\n", addr, ret);
 #endif
 	if (ret) return ret;
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 07/25] arch/powerpc/lib/board.c, *traps.c: sparse fixes
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (5 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 06/25] arch/powerpc/lib/extable.c: sparse fix Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 08/25] include/image.h: " Kim Phillips
                     ` (18 subsequent siblings)
  25 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

traps.c:*:1: warning: symbol 'print_backtrace' was not declared. Should it be static?
traps.c:93:1: warning: symbol '_exception' was not declared. Should it be static?
board.c:166:6: warning: symbol '__board_add_ram_info' was not declared. Should it be static?
board.c:174:5: warning: symbol '__board_flash_wp_on' was not declared. Should it be static?
board.c:187:6: warning: symbol '__cpu_secondary_init_r' was not declared. Should it be static?
board.c:265:12: warning: symbol 'init_sequence' was not declared. Should it be static?
board.c:348:5: warning: symbol '__fixup_cpu' was not declared. Should it be static?
board.c:405:53: warning: Using plain integer as NULL pointer

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: added checkpatch fixes, undid making show_regs static, as it's
used in cmd_begbug:

traps.c:66:6: warning: symbol 'show_regs' was not declared. Should it be static?

 arch/powerpc/cpu/74xx_7xx/traps.c |  28 +++------
 arch/powerpc/cpu/mpc512x/traps.c  | 110 ++++++++++++++++-------------------
 arch/powerpc/cpu/mpc5xx/traps.c   |   6 +-
 arch/powerpc/cpu/mpc5xxx/traps.c  |  29 ++++------
 arch/powerpc/cpu/mpc8220/traps.c  | 119 ++++++++++++++++++--------------------
 arch/powerpc/cpu/mpc824x/traps.c  |  29 ++++------
 arch/powerpc/cpu/mpc8260/traps.c  |  29 ++++------
 arch/powerpc/cpu/mpc83xx/traps.c  |  29 ++++------
 arch/powerpc/cpu/mpc85xx/traps.c  |  36 ++++--------
 arch/powerpc/cpu/mpc86xx/traps.c  |  27 +++------
 arch/powerpc/cpu/mpc8xx/traps.c   |  29 ++++------
 arch/powerpc/cpu/ppc4xx/traps.c   |  26 +++------
 arch/powerpc/lib/board.c          |  12 ++--
 13 files changed, 206 insertions(+), 303 deletions(-)

diff --git a/arch/powerpc/cpu/74xx_7xx/traps.c b/arch/powerpc/cpu/74xx_7xx/traps.c
index 7ae81eb..a33e283 100644
--- a/arch/powerpc/cpu/74xx_7xx/traps.c
+++ b/arch/powerpc/cpu/74xx_7xx/traps.c
@@ -48,8 +48,7 @@ extern unsigned long search_exception_table(unsigned long);
  * Trap & Exception support
  */
 
-void
-print_backtrace(unsigned long *sp)
+static void print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
 	unsigned long i;
@@ -69,8 +68,7 @@ print_backtrace(unsigned long *sp)
 	printf("\n");
 }
 
-void
-show_regs(struct pt_regs * regs)
+void show_regs(struct pt_regs *regs)
 {
 	int i;
 
@@ -100,16 +98,14 @@ show_regs(struct pt_regs * regs)
 }
 
 
-void
-_exception(int signr, struct pt_regs *regs)
+static void _exception(int signr, struct pt_regs *regs)
 {
 	show_regs(regs);
 	print_backtrace((unsigned long *)regs->gpr[1]);
 	panic("Exception in kernel pc %lx signal %d",regs->nip,signr);
 }
 
-void
-MachineCheckException(struct pt_regs *regs)
+void MachineCheckException(struct pt_regs *regs)
 {
 	unsigned long fixup;
 
@@ -152,8 +148,7 @@ MachineCheckException(struct pt_regs *regs)
 	panic("machine check");
 }
 
-void
-AlignmentException(struct pt_regs *regs)
+void AlignmentException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -164,8 +159,7 @@ AlignmentException(struct pt_regs *regs)
 	panic("Alignment Exception");
 }
 
-void
-ProgramCheckException(struct pt_regs *regs)
+void ProgramCheckException(struct pt_regs *regs)
 {
 	unsigned char *p = regs ? (unsigned char *)(regs->nip) : NULL;
 	int i, j;
@@ -190,8 +184,7 @@ ProgramCheckException(struct pt_regs *regs)
 	panic("Program Check Exception");
 }
 
-void
-SoftEmuException(struct pt_regs *regs)
+void SoftEmuException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -202,9 +195,7 @@ SoftEmuException(struct pt_regs *regs)
 	panic("Software Emulation Exception");
 }
 
-
-void
-UnknownException(struct pt_regs *regs)
+void UnknownException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -218,8 +209,7 @@ UnknownException(struct pt_regs *regs)
 /* Probe an address by reading.  If not present, return -1, otherwise
  * return 0.
  */
-int
-addr_probe(uint *addr)
+int addr_probe(uint *addr)
 {
 #if 0
 	int	retval;
diff --git a/arch/powerpc/cpu/mpc512x/traps.c b/arch/powerpc/cpu/mpc512x/traps.c
index 786f4a5..15468e5 100644
--- a/arch/powerpc/cpu/mpc512x/traps.c
+++ b/arch/powerpc/cpu/mpc512x/traps.c
@@ -47,68 +47,65 @@ extern ulong get_effective_memsize(void);
  * Trap & Exception support
  */
 
-void
-print_backtrace (unsigned long *sp)
+static void print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
 	unsigned long i;
 
-	puts ("Call backtrace: ");
+	puts("Call backtrace: ");
 	while (sp) {
 		if ((uint)sp > END_OF_MEM)
 			break;
 
 		i = sp[1];
 		if (cnt++ % 7 == 0)
-			putc ('\n');
-		printf ("%08lX ", i);
+			putc('\n');
+		printf("%08lX ", i);
 		if (cnt > 32) break;
 		sp = (unsigned long *) *sp;
 	}
-	putc ('\n');
+	putc('\n');
 }
 
-void show_regs (struct pt_regs * regs)
+void show_regs(struct pt_regs *regs)
 {
 	int i;
 
-	printf ("NIP: %08lX XER: %08lX LR: %08lX REGS: %p TRAP: %04lx DAR: %08lX\n",
+	printf("NIP: %08lX XER: %08lX LR: %08lX REGS: %p TRAP: %04lx DAR: %08lX\n",
 	       regs->nip, regs->xer, regs->link, regs, regs->trap, regs->dar);
-	printf ("MSR: %08lx EE: %01x PR: %01x FP: %01x ME: %01x IR/DR: %01x%01x\n",
+	printf("MSR: %08lx EE: %01x PR: %01x FP: %01x ME: %01x IR/DR: %01x%01x\n",
 	       regs->msr, regs->msr & MSR_EE ? 1 : 0, regs->msr & MSR_PR ? 1 : 0,
 	       regs->msr & MSR_FP ? 1 : 0,regs->msr & MSR_ME ? 1 : 0,
 	       regs->msr & MSR_IR ? 1 : 0,
 	       regs->msr & MSR_DR ? 1 : 0);
 
-	putc ('\n');
+	putc('\n');
 	for (i = 0;  i < 32;  i++) {
 		if ((i % 8) == 0) {
-			printf ("GPR%02d: ", i);
+			printf("GPR%02d: ", i);
 		}
 
-		printf ("%08lX ", regs->gpr[i]);
+		printf("%08lX ", regs->gpr[i]);
 		if ((i % 8) == 7) {
-			putc ('\n');
+			putc('\n');
 		}
 	}
 }
 
 
-void
-_exception (int signr, struct pt_regs *regs)
+static void _exception(int signr, struct pt_regs *regs)
 {
-	show_regs (regs);
-	print_backtrace ((unsigned long *)regs->gpr[1]);
-	panic ("Exception at pc %lx signal %d", regs->nip,signr);
+	show_regs(regs);
+	print_backtrace((unsigned long *)regs->gpr[1]);
+	panic("Exception at pc %lx signal %d", regs->nip, signr);
 }
 
 
-void
-MachineCheckException (struct pt_regs *regs)
+void MachineCheckException(struct pt_regs *regs)
 {
-	unsigned long fixup;
+	unsigned long fixup = search_exception_table(regs->nip);
 
-	if ((fixup = search_exception_table (regs->nip)) != 0) {
+	if (fixup) {
 		regs->nip = fixup;
 		return;
 	}
@@ -118,95 +115,90 @@ MachineCheckException (struct pt_regs *regs)
 		return;
 #endif
 
-	puts ("Machine check.\nCaused by (from msr): ");
-	printf ("regs %p ",regs);
+	puts("Machine check.\nCaused by (from msr): ");
+	printf("regs %p ", regs);
 	switch (regs->msr & 0x00FF0000) {
 	case (0x80000000 >> 10):
-		puts ("Instruction cache parity signal\n");
+		puts("Instruction cache parity signal\n");
 		break;
 	case (0x80000000 >> 11):
-		puts ("Data cache parity signal\n");
+		puts("Data cache parity signal\n");
 		break;
 	case (0x80000000 >> 12):
-		puts ("Machine check signal\n");
+		puts("Machine check signal\n");
 		break;
 	case (0x80000000 >> 13):
-		puts ("Transfer error ack signal\n");
+		puts("Transfer error ack signal\n");
 		break;
 	case (0x80000000 >> 14):
-		puts ("Data parity signal\n");
+		puts("Data parity signal\n");
 		break;
 	case (0x80000000 >> 15):
-		puts ("Address parity signal\n");
+		puts("Address parity signal\n");
 		break;
 	default:
-		puts ("Unknown values in msr\n");
+		puts("Unknown values in msr\n");
 	}
-	show_regs (regs);
-	print_backtrace ((unsigned long *)regs->gpr[1]);
+	show_regs(regs);
+	print_backtrace((unsigned long *)regs->gpr[1]);
 
-	panic ("machine check");
+	panic("machine check");
 }
 
-void
-AlignmentException (struct pt_regs *regs)
+void AlignmentException(struct pt_regs *regs)
 {
 #ifdef CONFIG_CMD_KGDB
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
 		return;
 #endif
-	show_regs (regs);
-	print_backtrace ((unsigned long *)regs->gpr[1]);
-	panic ("Alignment Exception");
+	show_regs(regs);
+	print_backtrace((unsigned long *)regs->gpr[1]);
+	panic("Alignment Exception");
 }
 
-void
-ProgramCheckException (struct pt_regs *regs)
+void ProgramCheckException(struct pt_regs *regs)
 {
 #ifdef CONFIG_CMD_KGDB
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
 		return;
 #endif
-	show_regs (regs);
-	print_backtrace ((unsigned long *)regs->gpr[1]);
-	panic ("Program Check Exception");
+	show_regs(regs);
+	print_backtrace((unsigned long *)regs->gpr[1]);
+	panic("Program Check Exception");
 }
 
-void
-SoftEmuException (struct pt_regs *regs)
+void SoftEmuException(struct pt_regs *regs)
 {
 #ifdef CONFIG_CMD_KGDB
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
 		return;
 #endif
-	show_regs (regs);
-	print_backtrace ((unsigned long *)regs->gpr[1]);
-	panic ("Software Emulation Exception");
+	show_regs(regs);
+	print_backtrace((unsigned long *)regs->gpr[1]);
+	panic("Software Emulation Exception");
 }
 
 
-void
-UnknownException (struct pt_regs *regs)
+void UnknownException(struct pt_regs *regs)
 {
 #ifdef CONFIG_CMD_KGDB
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
 		return;
 #endif
-	printf ("Bad trap at PC: %lx, SR: %lx, vector=%lx\n",
+	printf("Bad trap at PC: %lx, SR: %lx, vector=%lx\n",
 	       regs->nip, regs->msr, regs->trap);
-	_exception (0, regs);
+	_exception(0, regs);
 }
 
 #ifdef CONFIG_CMD_BEDBUG
-extern void do_bedbug_breakpoint (struct pt_regs *);
+extern void do_bedbug_breakpoint(struct pt_regs *);
 #endif
 
-void
-DebugException (struct pt_regs *regs)
+void DebugException(struct pt_regs *regs)
 {
-	printf ("Debugger trap at @ %lx\n", regs->nip );
-	show_regs (regs);
+	printf("Debugger trap at @ %lx\n", regs->nip);
+	show_regs(regs);
 #ifdef CONFIG_CMD_BEDBUG
-	do_bedbug_breakpoint (regs);
+	do_bedbug_breakpoint(regs);
 #endif
 }
diff --git a/arch/powerpc/cpu/mpc5xx/traps.c b/arch/powerpc/cpu/mpc5xx/traps.c
index e3ce11b..90da73b 100644
--- a/arch/powerpc/cpu/mpc5xx/traps.c
+++ b/arch/powerpc/cpu/mpc5xx/traps.c
@@ -52,7 +52,7 @@ extern unsigned long search_exception_table(unsigned long);
 /*
  * Print stack backtrace
  */
-void print_backtrace(unsigned long *sp)
+static void print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
 	unsigned long i;
@@ -75,7 +75,7 @@ void print_backtrace(unsigned long *sp)
 /*
  * Print current registers
  */
-void show_regs(struct pt_regs * regs)
+void show_regs(struct pt_regs *regs)
 {
 	int i;
 	printf("NIP: %08lX XER: %08lX LR: %08lX REGS: %p TRAP: %04lx DAR: %08lX\n",
@@ -105,7 +105,7 @@ void show_regs(struct pt_regs * regs)
 /*
  * General exception handler routine
  */
-void _exception(int signr, struct pt_regs *regs)
+static void _exception(int signr, struct pt_regs *regs)
 {
 	show_regs(regs);
 	print_backtrace((unsigned long *)regs->gpr[1]);
diff --git a/arch/powerpc/cpu/mpc5xxx/traps.c b/arch/powerpc/cpu/mpc5xxx/traps.c
index 5972f34..438f8d3 100644
--- a/arch/powerpc/cpu/mpc5xxx/traps.c
+++ b/arch/powerpc/cpu/mpc5xxx/traps.c
@@ -49,8 +49,7 @@ extern unsigned long search_exception_table(unsigned long);
  * Trap & Exception support
  */
 
-void
-print_backtrace(unsigned long *sp)
+static void print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
 	unsigned long i;
@@ -70,7 +69,7 @@ print_backtrace(unsigned long *sp)
 	printf("\n");
 }
 
-void show_regs(struct pt_regs * regs)
+void show_regs(struct pt_regs *regs)
 {
 	int i;
 
@@ -98,16 +97,14 @@ void show_regs(struct pt_regs * regs)
 }
 
 
-void
-_exception(int signr, struct pt_regs *regs)
+static void _exception(int signr, struct pt_regs *regs)
 {
 	show_regs(regs);
 	print_backtrace((unsigned long *)regs->gpr[1]);
 	panic("Exception in kernel pc %lx signal %d",regs->nip,signr);
 }
 
-void
-MachineCheckException(struct pt_regs *regs)
+void MachineCheckException(struct pt_regs *regs)
 {
 	unsigned long fixup;
 
@@ -152,8 +149,7 @@ MachineCheckException(struct pt_regs *regs)
 	panic("machine check");
 }
 
-void
-AlignmentException(struct pt_regs *regs)
+void AlignmentException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -164,8 +160,7 @@ AlignmentException(struct pt_regs *regs)
 	panic("Alignment Exception");
 }
 
-void
-ProgramCheckException(struct pt_regs *regs)
+void ProgramCheckException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -176,8 +171,7 @@ ProgramCheckException(struct pt_regs *regs)
 	panic("Program Check Exception");
 }
 
-void
-SoftEmuException(struct pt_regs *regs)
+void SoftEmuException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -189,8 +183,7 @@ SoftEmuException(struct pt_regs *regs)
 }
 
 
-void
-UnknownException(struct pt_regs *regs)
+void UnknownException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -205,8 +198,7 @@ UnknownException(struct pt_regs *regs)
 extern void do_bedbug_breakpoint(struct pt_regs *);
 #endif
 
-void
-DebugException(struct pt_regs *regs)
+void DebugException(struct pt_regs *regs)
 {
 
   printf("Debugger trap at @ %lx\n", regs->nip );
@@ -219,8 +211,7 @@ DebugException(struct pt_regs *regs)
 /* Probe an address by reading.  If not present, return -1, otherwise
  * return 0.
  */
-int
-addr_probe(uint *addr)
+int addr_probe(uint *addr)
 {
 #if 0
 	int	retval;
diff --git a/arch/powerpc/cpu/mpc8220/traps.c b/arch/powerpc/cpu/mpc8220/traps.c
index 13894c9..19d6cb5 100644
--- a/arch/powerpc/cpu/mpc8220/traps.c
+++ b/arch/powerpc/cpu/mpc8220/traps.c
@@ -39,7 +39,7 @@
 #include <asm/processor.h>
 
 /* Returns 0 if exception not found and fixup otherwise.  */
-extern unsigned long search_exception_table (unsigned long);
+extern unsigned long search_exception_table(unsigned long);
 
 /* THIS NEEDS CHANGING to use the board info structure.
 */
@@ -49,171 +49,166 @@ extern unsigned long search_exception_table (unsigned long);
  * Trap & Exception support
  */
 
-void print_backtrace (unsigned long *sp)
+static void print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
 	unsigned long i;
 
-	printf ("Call backtrace: ");
+	printf("Call backtrace: ");
 	while (sp) {
 		if ((uint) sp > END_OF_MEM)
 			break;
 
 		i = sp[1];
 		if (cnt++ % 7 == 0)
-			printf ("\n");
-		printf ("%08lX ", i);
+			printf("\n");
+		printf("%08lX ", i);
 		if (cnt > 32)
 			break;
 		sp = (unsigned long *) *sp;
 	}
-	printf ("\n");
+	printf("\n");
 }
 
-void show_regs (struct pt_regs *regs)
+void show_regs(struct pt_regs *regs)
 {
 	int i;
 
-	printf ("NIP: %08lX XER: %08lX LR: %08lX REGS: %p TRAP: %04lx DAR: %08lX\n",
+	printf("NIP: %08lX XER: %08lX LR: %08lX REGS: %p TRAP: %04lx DAR: %08lX\n",
 		regs->nip, regs->xer, regs->link, regs, regs->trap, regs->dar);
-	printf ("MSR: %08lx EE: %01x PR: %01x FP: %01x ME: %01x IR/DR: %01x%01x\n",
+	printf("MSR: %08lx EE: %01x PR: %01x FP: %01x ME: %01x IR/DR: %01x%01x\n",
 		regs->msr,
 		regs->msr & MSR_EE ? 1 : 0, regs->msr & MSR_PR ? 1 : 0,
 		regs->msr & MSR_FP ? 1 : 0, regs->msr & MSR_ME ? 1 : 0,
 		regs->msr & MSR_IR ? 1 : 0, regs->msr & MSR_DR ? 1 : 0);
 
-	printf ("\n");
+	printf("\n");
 	for (i = 0; i < 32; i++) {
 		if ((i % 8) == 0) {
-			printf ("GPR%02d: ", i);
+			printf("GPR%02d: ", i);
 		}
 
-		printf ("%08lX ", regs->gpr[i]);
+		printf("%08lX ", regs->gpr[i]);
 		if ((i % 8) == 7) {
-			printf ("\n");
+			printf("\n");
 		}
 	}
 }
 
 
-void _exception (int signr, struct pt_regs *regs)
+static void _exception(int signr, struct pt_regs *regs)
 {
-	show_regs (regs);
-	print_backtrace ((unsigned long *) regs->gpr[1]);
-	panic ("Exception in kernel pc %lx signal %d", regs->nip, signr);
+	show_regs(regs);
+	print_backtrace((unsigned long *) regs->gpr[1]);
+	panic("Exception in kernel pc %lx signal %d", regs->nip, signr);
 }
 
-void MachineCheckException (struct pt_regs *regs)
+void MachineCheckException(struct pt_regs *regs)
 {
-	unsigned long fixup;
+	unsigned long fixup = search_exception_table(regs->nip);
 
 	/* Probing PCI using config cycles cause this exception
 	 * when a device is not present.  Catch it and return to
 	 * the PCI exception handler.
 	 */
-	if ((fixup = search_exception_table (regs->nip)) != 0) {
+	if (fixup) {
 		regs->nip = fixup;
 		return;
 	}
 #if defined(CONFIG_CMD_KGDB)
-	if (debugger_exception_handler
-	    && (*debugger_exception_handler) (regs))
+	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
 		return;
 #endif
 
-	printf ("Machine check in kernel mode.\n");
-	printf ("Caused by (from msr): ");
-	printf ("regs %p ", regs);
+	printf("Machine check in kernel mode.\n");
+	printf("Caused by (from msr): ");
+	printf("regs %p ", regs);
 	/* refer to 603e Manual (MPC603EUM/AD), chapter 4.5.2.1 */
 	switch (regs->msr & 0x000F0000) {
 	case (0x80000000 >> 12):
-		printf ("Machine check signal - probably due to mm fault\n"
+		printf("Machine check signal - probably due to mm fault\n"
 			"with mmu off\n");
 		break;
 	case (0x80000000 >> 13):
-		printf ("Transfer error ack signal\n");
+		printf("Transfer error ack signal\n");
 		break;
 	case (0x80000000 >> 14):
-		printf ("Data parity signal\n");
+		printf("Data parity signal\n");
 		break;
 	case (0x80000000 >> 15):
-		printf ("Address parity signal\n");
+		printf("Address parity signal\n");
 		break;
 	default:
-		printf ("Unknown values in msr\n");
+		printf("Unknown values in msr\n");
 	}
-	show_regs (regs);
-	print_backtrace ((unsigned long *) regs->gpr[1]);
-	panic ("machine check");
+	show_regs(regs);
+	print_backtrace((unsigned long *) regs->gpr[1]);
+	panic("machine check");
 }
 
-void AlignmentException (struct pt_regs *regs)
+void AlignmentException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
-	if (debugger_exception_handler
-	    && (*debugger_exception_handler) (regs))
+	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
 		return;
 #endif
-	show_regs (regs);
-	print_backtrace ((unsigned long *) regs->gpr[1]);
-	panic ("Alignment Exception");
+	show_regs(regs);
+	print_backtrace((unsigned long *) regs->gpr[1]);
+	panic("Alignment Exception");
 }
 
-void ProgramCheckException (struct pt_regs *regs)
+void ProgramCheckException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
-	if (debugger_exception_handler
-	    && (*debugger_exception_handler) (regs))
+	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
 		return;
 #endif
-	show_regs (regs);
-	print_backtrace ((unsigned long *) regs->gpr[1]);
-	panic ("Program Check Exception");
+	show_regs(regs);
+	print_backtrace((unsigned long *) regs->gpr[1]);
+	panic("Program Check Exception");
 }
 
-void SoftEmuException (struct pt_regs *regs)
+void SoftEmuException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
-	if (debugger_exception_handler
-	    && (*debugger_exception_handler) (regs))
+	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
 		return;
 #endif
-	show_regs (regs);
-	print_backtrace ((unsigned long *) regs->gpr[1]);
-	panic ("Software Emulation Exception");
+	show_regs(regs);
+	print_backtrace((unsigned long *) regs->gpr[1]);
+	panic("Software Emulation Exception");
 }
 
 
-void UnknownException (struct pt_regs *regs)
+void UnknownException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
-	if (debugger_exception_handler
-	    && (*debugger_exception_handler) (regs))
+	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
 		return;
 #endif
-	printf ("Bad trap at PC: %lx, SR: %lx, vector=%lx\n",
+	printf("Bad trap at PC: %lx, SR: %lx, vector=%lx\n",
 		regs->nip, regs->msr, regs->trap);
-	_exception (0, regs);
+	_exception(0, regs);
 }
 
 #if defined(CONFIG_CMD_BEDBUG)
-extern void do_bedbug_breakpoint (struct pt_regs *);
+extern void do_bedbug_breakpoint(struct pt_regs *);
 #endif
 
-void DebugException (struct pt_regs *regs)
+void DebugException(struct pt_regs *regs)
 {
 
-	printf ("Debugger trap at @ %lx\n", regs->nip);
-	show_regs (regs);
+	printf("Debugger trap at @ %lx\n", regs->nip);
+	show_regs(regs);
 #if defined(CONFIG_CMD_BEDBUG)
-	do_bedbug_breakpoint (regs);
+	do_bedbug_breakpoint(regs);
 #endif
 }
 
 /* Probe an address by reading.  If not present, return -1, otherwise
  * return 0.
  */
-int addr_probe (uint * addr)
+int addr_probe(uint *addr)
 {
 #if 0
 	int retval;
diff --git a/arch/powerpc/cpu/mpc824x/traps.c b/arch/powerpc/cpu/mpc824x/traps.c
index 163b983..9bcdd8f 100644
--- a/arch/powerpc/cpu/mpc824x/traps.c
+++ b/arch/powerpc/cpu/mpc824x/traps.c
@@ -46,8 +46,7 @@ extern unsigned long search_exception_table(unsigned long);
  * Trap & Exception support
  */
 
-void
-print_backtrace(unsigned long *sp)
+static void print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
 	unsigned long i;
@@ -67,7 +66,7 @@ print_backtrace(unsigned long *sp)
 	printf("\n");
 }
 
-void show_regs(struct pt_regs * regs)
+void show_regs(struct pt_regs *regs)
 {
 	int i;
 
@@ -95,16 +94,14 @@ void show_regs(struct pt_regs * regs)
 }
 
 
-void
-_exception(int signr, struct pt_regs *regs)
+static void _exception(int signr, struct pt_regs *regs)
 {
 	show_regs(regs);
 	print_backtrace((unsigned long *)regs->gpr[1]);
 	panic("Exception in kernel pc %lx signal %d",regs->nip,signr);
 }
 
-void
-MachineCheckException(struct pt_regs *regs)
+void MachineCheckException(struct pt_regs *regs)
 {
 	unsigned long fixup;
 
@@ -142,24 +139,21 @@ MachineCheckException(struct pt_regs *regs)
 	panic("machine check");
 }
 
-void
-AlignmentException(struct pt_regs *regs)
+void AlignmentException(struct pt_regs *regs)
 {
 	show_regs(regs);
 	print_backtrace((unsigned long *)regs->gpr[1]);
 	panic("Alignment Exception");
 }
 
-void
-ProgramCheckException(struct pt_regs *regs)
+void ProgramCheckException(struct pt_regs *regs)
 {
 	show_regs(regs);
 	print_backtrace((unsigned long *)regs->gpr[1]);
 	panic("Program Check Exception");
 }
 
-void
-SoftEmuException(struct pt_regs *regs)
+void SoftEmuException(struct pt_regs *regs)
 {
 	show_regs(regs);
 	print_backtrace((unsigned long *)regs->gpr[1]);
@@ -167,8 +161,7 @@ SoftEmuException(struct pt_regs *regs)
 }
 
 
-void
-UnknownException(struct pt_regs *regs)
+void UnknownException(struct pt_regs *regs)
 {
 	printf("Bad trap at PC: %lx, SR: %lx, vector=%lx\n",
 	       regs->nip, regs->msr, regs->trap);
@@ -179,8 +172,7 @@ UnknownException(struct pt_regs *regs)
 extern void do_bedbug_breakpoint(struct pt_regs *);
 #endif
 
-void
-DebugException(struct pt_regs *regs)
+void DebugException(struct pt_regs *regs)
 {
 
   printf("Debugger trap at @ %lx\n", regs->nip );
@@ -193,8 +185,7 @@ DebugException(struct pt_regs *regs)
 /* Probe an address by reading.  If not present, return -1, otherwise
  * return 0.
  */
-int
-addr_probe(uint *addr)
+int addr_probe(uint *addr)
 {
 #if 0
 	int	retval;
diff --git a/arch/powerpc/cpu/mpc8260/traps.c b/arch/powerpc/cpu/mpc8260/traps.c
index c116cdf..e1e6845 100644
--- a/arch/powerpc/cpu/mpc8260/traps.c
+++ b/arch/powerpc/cpu/mpc8260/traps.c
@@ -49,8 +49,7 @@ extern unsigned long search_exception_table(unsigned long);
  * Trap & Exception support
  */
 
-void
-print_backtrace(unsigned long *sp)
+static void print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
 	unsigned long i;
@@ -70,7 +69,7 @@ print_backtrace(unsigned long *sp)
 	putc ('\n');
 }
 
-void show_regs(struct pt_regs * regs)
+void show_regs(struct pt_regs *regs)
 {
 	int i;
 
@@ -96,8 +95,7 @@ void show_regs(struct pt_regs * regs)
 }
 
 
-void
-_exception(int signr, struct pt_regs *regs)
+static void _exception(int signr, struct pt_regs *regs)
 {
 	show_regs(regs);
 	print_backtrace((unsigned long *)regs->gpr[1]);
@@ -122,8 +120,7 @@ void dump_pci (void)
 }
 #endif
 
-void
-MachineCheckException(struct pt_regs *regs)
+void MachineCheckException(struct pt_regs *regs)
 {
 	unsigned long fixup;
 
@@ -180,8 +177,7 @@ MachineCheckException(struct pt_regs *regs)
 	panic("machine check");
 }
 
-void
-AlignmentException(struct pt_regs *regs)
+void AlignmentException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -192,8 +188,7 @@ AlignmentException(struct pt_regs *regs)
 	panic("Alignment Exception");
 }
 
-void
-ProgramCheckException(struct pt_regs *regs)
+void ProgramCheckException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -204,8 +199,7 @@ ProgramCheckException(struct pt_regs *regs)
 	panic("Program Check Exception");
 }
 
-void
-SoftEmuException(struct pt_regs *regs)
+void SoftEmuException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -217,8 +211,7 @@ SoftEmuException(struct pt_regs *regs)
 }
 
 
-void
-UnknownException(struct pt_regs *regs)
+void UnknownException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -233,8 +226,7 @@ UnknownException(struct pt_regs *regs)
 extern void do_bedbug_breakpoint(struct pt_regs *);
 #endif
 
-void
-DebugException(struct pt_regs *regs)
+void DebugException(struct pt_regs *regs)
 {
 
   printf("Debugger trap at @ %lx\n", regs->nip );
@@ -247,8 +239,7 @@ DebugException(struct pt_regs *regs)
 /* Probe an address by reading.  If not present, return -1, otherwise
  * return 0.
  */
-int
-addr_probe(uint *addr)
+int addr_probe(uint *addr)
 {
 #if 0
 	int	retval;
diff --git a/arch/powerpc/cpu/mpc83xx/traps.c b/arch/powerpc/cpu/mpc83xx/traps.c
index 9d71b8b..53a1062 100644
--- a/arch/powerpc/cpu/mpc83xx/traps.c
+++ b/arch/powerpc/cpu/mpc83xx/traps.c
@@ -42,8 +42,7 @@ extern unsigned long search_exception_table(unsigned long);
  * Trap & Exception support
  */
 
-void
-print_backtrace(unsigned long *sp)
+static void print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
 	unsigned long i;
@@ -63,7 +62,7 @@ print_backtrace(unsigned long *sp)
 	putc ('\n');
 }
 
-void show_regs(struct pt_regs * regs)
+void show_regs(struct pt_regs *regs)
 {
 	int i;
 
@@ -89,8 +88,7 @@ void show_regs(struct pt_regs * regs)
 }
 
 
-void
-_exception(int signr, struct pt_regs *regs)
+static void _exception(int signr, struct pt_regs *regs)
 {
 	show_regs(regs);
 	print_backtrace((unsigned long *)regs->gpr[1]);
@@ -114,8 +112,7 @@ void dump_pci (void)
 }
 #endif
 
-void
-MachineCheckException(struct pt_regs *regs)
+void MachineCheckException(struct pt_regs *regs)
 {
 	unsigned long fixup;
 
@@ -174,8 +171,7 @@ MachineCheckException(struct pt_regs *regs)
 	panic("machine check");
 }
 
-void
-AlignmentException(struct pt_regs *regs)
+void AlignmentException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -186,8 +182,7 @@ AlignmentException(struct pt_regs *regs)
 	panic("Alignment Exception");
 }
 
-void
-ProgramCheckException(struct pt_regs *regs)
+void ProgramCheckException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -198,8 +193,7 @@ ProgramCheckException(struct pt_regs *regs)
 	panic("Program Check Exception");
 }
 
-void
-SoftEmuException(struct pt_regs *regs)
+void SoftEmuException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -211,8 +205,7 @@ SoftEmuException(struct pt_regs *regs)
 }
 
 
-void
-UnknownException(struct pt_regs *regs)
+void UnknownException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -227,8 +220,7 @@ UnknownException(struct pt_regs *regs)
 extern void do_bedbug_breakpoint(struct pt_regs *);
 #endif
 
-void
-DebugException(struct pt_regs *regs)
+void DebugException(struct pt_regs *regs)
 {
 	printf("Debugger trap at @ %lx\n", regs->nip );
 	show_regs(regs);
@@ -240,8 +232,7 @@ DebugException(struct pt_regs *regs)
 /* Probe an address by reading.  If not present, return -1, otherwise
  * return 0.
  */
-int
-addr_probe(uint *addr)
+int addr_probe(uint *addr)
 {
 #if 0
 	int	retval;
diff --git a/arch/powerpc/cpu/mpc85xx/traps.c b/arch/powerpc/cpu/mpc85xx/traps.c
index 7800717..476ae93 100644
--- a/arch/powerpc/cpu/mpc85xx/traps.c
+++ b/arch/powerpc/cpu/mpc85xx/traps.c
@@ -82,8 +82,7 @@ extern void do_bedbug_breakpoint(struct pt_regs *);
  * Trap & Exception support
  */
 
-void
-print_backtrace(unsigned long *sp)
+static void print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
 	unsigned long i;
@@ -103,7 +102,7 @@ print_backtrace(unsigned long *sp)
 	printf("\n");
 }
 
-void show_regs(struct pt_regs * regs)
+void show_regs(struct pt_regs *regs)
 {
 	int i;
 
@@ -131,24 +130,21 @@ void show_regs(struct pt_regs * regs)
 }
 
 
-void
-_exception(int signr, struct pt_regs *regs)
+static void _exception(int signr, struct pt_regs *regs)
 {
 	show_regs(regs);
 	print_backtrace((unsigned long *)regs->gpr[1]);
 	panic("Exception in kernel pc %lx signal %d",regs->nip,signr);
 }
 
-void
-CritcalInputException(struct pt_regs *regs)
+void CritcalInputException(struct pt_regs *regs)
 {
 	panic("Critical Input Exception");
 }
 
 int machinecheck_count = 0;
 int machinecheck_error = 0;
-void
-MachineCheckException(struct pt_regs *regs)
+void MachineCheckException(struct pt_regs *regs)
 {
 	unsigned long fixup;
 	unsigned int mcsr, mcsrr0, mcsrr1, mcar;
@@ -220,8 +216,7 @@ MachineCheckException(struct pt_regs *regs)
 	}
 }
 
-void
-AlignmentException(struct pt_regs *regs)
+void AlignmentException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -233,8 +228,7 @@ AlignmentException(struct pt_regs *regs)
 	panic("Alignment Exception");
 }
 
-void
-ProgramCheckException(struct pt_regs *regs)
+void ProgramCheckException(struct pt_regs *regs)
 {
 	long esr_val;
 
@@ -257,8 +251,7 @@ ProgramCheckException(struct pt_regs *regs)
 	panic("Program Check Exception");
 }
 
-void
-PITException(struct pt_regs *regs)
+void PITException(struct pt_regs *regs)
 {
 	/*
 	 * Reset PIT interrupt
@@ -271,9 +264,7 @@ PITException(struct pt_regs *regs)
 	timer_interrupt(NULL);
 }
 
-
-void
-UnknownException(struct pt_regs *regs)
+void UnknownException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -285,8 +276,7 @@ UnknownException(struct pt_regs *regs)
 	_exception(0, regs);
 }
 
-void
-ExtIntException(struct pt_regs *regs)
+void ExtIntException(struct pt_regs *regs)
 {
 	volatile ccsr_pic_t *pic = (void *)(CONFIG_SYS_MPC8xxx_PIC_ADDR);
 
@@ -305,8 +295,7 @@ ExtIntException(struct pt_regs *regs)
 	print_backtrace((unsigned long *)regs->gpr[1]);
 }
 
-void
-DebugException(struct pt_regs *regs)
+void DebugException(struct pt_regs *regs)
 {
 	printf("Debugger trap at @ %lx\n", regs->nip );
 	show_regs(regs);
@@ -318,8 +307,7 @@ DebugException(struct pt_regs *regs)
 /* Probe an address by reading.	 If not present, return -1, otherwise
  * return 0.
  */
-int
-addr_probe(uint *addr)
+int addr_probe(uint *addr)
 {
 	return 0;
 }
diff --git a/arch/powerpc/cpu/mpc86xx/traps.c b/arch/powerpc/cpu/mpc86xx/traps.c
index 406403e..50069d5 100644
--- a/arch/powerpc/cpu/mpc86xx/traps.c
+++ b/arch/powerpc/cpu/mpc86xx/traps.c
@@ -52,8 +52,7 @@ extern ulong get_effective_memsize(void);
  * Trap & Exception support
  */
 
-void
-print_backtrace(unsigned long *sp)
+static void print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
 	unsigned long i;
@@ -74,8 +73,7 @@ print_backtrace(unsigned long *sp)
 	printf("\n");
 }
 
-void
-show_regs(struct pt_regs *regs)
+void show_regs(struct pt_regs *regs)
 {
 	int i;
 
@@ -103,16 +101,14 @@ show_regs(struct pt_regs *regs)
 }
 
 
-void
-_exception(int signr, struct pt_regs *regs)
+static void _exception(int signr, struct pt_regs *regs)
 {
 	show_regs(regs);
 	print_backtrace((unsigned long *)regs->gpr[1]);
 	panic("Exception in kernel pc %lx signal %d", regs->nip, signr);
 }
 
-void
-MachineCheckException(struct pt_regs *regs)
+void MachineCheckException(struct pt_regs *regs)
 {
 	unsigned long fixup;
 
@@ -158,8 +154,7 @@ MachineCheckException(struct pt_regs *regs)
 	panic("machine check");
 }
 
-void
-AlignmentException(struct pt_regs *regs)
+void AlignmentException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler) (regs))
@@ -170,8 +165,7 @@ AlignmentException(struct pt_regs *regs)
 	panic("Alignment Exception");
 }
 
-void
-ProgramCheckException(struct pt_regs *regs)
+void ProgramCheckException(struct pt_regs *regs)
 {
 	unsigned char *p = regs ? (unsigned char *)(regs->nip) : NULL;
 	int i, j;
@@ -196,8 +190,7 @@ ProgramCheckException(struct pt_regs *regs)
 	panic("Program Check Exception");
 }
 
-void
-SoftEmuException(struct pt_regs *regs)
+void SoftEmuException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler) (regs))
@@ -208,8 +201,7 @@ SoftEmuException(struct pt_regs *regs)
 	panic("Software Emulation Exception");
 }
 
-void
-UnknownException(struct pt_regs *regs)
+void UnknownException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler) (regs))
@@ -226,8 +218,7 @@ UnknownException(struct pt_regs *regs)
  * If not present, return -1,
  * otherwise return 0.
  */
-int
-addr_probe(uint *addr)
+int addr_probe(uint *addr)
 {
 	return 0;
 }
diff --git a/arch/powerpc/cpu/mpc8xx/traps.c b/arch/powerpc/cpu/mpc8xx/traps.c
index 343dced..f0ab78d 100644
--- a/arch/powerpc/cpu/mpc8xx/traps.c
+++ b/arch/powerpc/cpu/mpc8xx/traps.c
@@ -52,8 +52,7 @@ extern unsigned long search_exception_table(unsigned long);
  * Trap & Exception support
  */
 
-void
-print_backtrace(unsigned long *sp)
+static void print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
 	unsigned long i;
@@ -73,7 +72,7 @@ print_backtrace(unsigned long *sp)
 	printf("\n");
 }
 
-void show_regs(struct pt_regs * regs)
+void show_regs(struct pt_regs *regs)
 {
 	int i;
 
@@ -101,16 +100,14 @@ void show_regs(struct pt_regs * regs)
 }
 
 
-void
-_exception(int signr, struct pt_regs *regs)
+static void _exception(int signr, struct pt_regs *regs)
 {
 	show_regs(regs);
 	print_backtrace((unsigned long *)regs->gpr[1]);
 	panic("Exception in kernel pc %lx signal %d",regs->nip,signr);
 }
 
-void
-MachineCheckException(struct pt_regs *regs)
+void MachineCheckException(struct pt_regs *regs)
 {
 	unsigned long fixup;
 
@@ -153,8 +150,7 @@ MachineCheckException(struct pt_regs *regs)
 	panic("machine check");
 }
 
-void
-AlignmentException(struct pt_regs *regs)
+void AlignmentException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -165,8 +161,7 @@ AlignmentException(struct pt_regs *regs)
 	panic("Alignment Exception");
 }
 
-void
-ProgramCheckException(struct pt_regs *regs)
+void ProgramCheckException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -177,8 +172,7 @@ ProgramCheckException(struct pt_regs *regs)
 	panic("Program Check Exception");
 }
 
-void
-SoftEmuException(struct pt_regs *regs)
+void SoftEmuException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -190,8 +184,7 @@ SoftEmuException(struct pt_regs *regs)
 }
 
 
-void
-UnknownException(struct pt_regs *regs)
+void UnknownException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -202,8 +195,7 @@ UnknownException(struct pt_regs *regs)
 	_exception(0, regs);
 }
 
-void
-DebugException(struct pt_regs *regs)
+void DebugException(struct pt_regs *regs)
 {
   printf("Debugger trap at @ %lx\n", regs->nip );
   show_regs(regs);
@@ -215,8 +207,7 @@ DebugException(struct pt_regs *regs)
 /* Probe an address by reading.  If not present, return -1, otherwise
  * return 0.
  */
-int
-addr_probe(uint *addr)
+int addr_probe(uint *addr)
 {
 #if 0
 	int	retval;
diff --git a/arch/powerpc/cpu/ppc4xx/traps.c b/arch/powerpc/cpu/ppc4xx/traps.c
index 9baa7a1..dae19cb 100644
--- a/arch/powerpc/cpu/ppc4xx/traps.c
+++ b/arch/powerpc/cpu/ppc4xx/traps.c
@@ -74,8 +74,7 @@ extern void do_bedbug_breakpoint(struct pt_regs *);
  * Trap & Exception support
  */
 
-void
-print_backtrace(unsigned long *sp)
+static void print_backtrace(unsigned long *sp)
 {
 	int cnt = 0;
 	unsigned long i;
@@ -95,7 +94,7 @@ print_backtrace(unsigned long *sp)
 	printf("\n");
 }
 
-void show_regs(struct pt_regs * regs)
+void show_regs(struct pt_regs *regs)
 {
 	int i;
 
@@ -121,16 +120,14 @@ void show_regs(struct pt_regs * regs)
 }
 
 
-void
-_exception(int signr, struct pt_regs *regs)
+static void _exception(int signr, struct pt_regs *regs)
 {
 	show_regs(regs);
 	print_backtrace((unsigned long *)regs->gpr[1]);
 	panic("Exception");
 }
 
-void
-MachineCheckException(struct pt_regs *regs)
+void MachineCheckException(struct pt_regs *regs)
 {
 	unsigned long fixup, val;
 #if defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
@@ -312,8 +309,7 @@ MachineCheckException(struct pt_regs *regs)
 	panic("machine check");
 }
 
-void
-AlignmentException(struct pt_regs *regs)
+void AlignmentException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -325,8 +321,7 @@ AlignmentException(struct pt_regs *regs)
 	panic("Alignment Exception");
 }
 
-void
-ProgramCheckException(struct pt_regs *regs)
+void ProgramCheckException(struct pt_regs *regs)
 {
 	long esr_val;
 
@@ -349,8 +344,7 @@ ProgramCheckException(struct pt_regs *regs)
 	panic("Program Check Exception");
 }
 
-void
-DecrementerPITException(struct pt_regs *regs)
+void DecrementerPITException(struct pt_regs *regs)
 {
 	/*
 	 * Reset PIT interrupt
@@ -364,8 +358,7 @@ DecrementerPITException(struct pt_regs *regs)
 }
 
 
-void
-UnknownException(struct pt_regs *regs)
+void UnknownException(struct pt_regs *regs)
 {
 #if defined(CONFIG_CMD_KGDB)
 	if (debugger_exception_handler && (*debugger_exception_handler)(regs))
@@ -377,8 +370,7 @@ UnknownException(struct pt_regs *regs)
 	_exception(0, regs);
 }
 
-void
-DebugException(struct pt_regs *regs)
+void DebugException(struct pt_regs *regs)
 {
 	printf("Debugger trap at @ %lx\n", regs->nip );
 	show_regs(regs);
diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c
index ebf4008..1b051e1 100644
--- a/arch/powerpc/lib/board.c
+++ b/arch/powerpc/lib/board.c
@@ -163,7 +163,7 @@ static int init_baudrate(void)
 
 /***********************************************************************/
 
-void __board_add_ram_info(int use_default)
+static void __board_add_ram_info(int use_default)
 {
 	/* please define platform specific board_add_ram_info() */
 }
@@ -171,7 +171,7 @@ void __board_add_ram_info(int use_default)
 void board_add_ram_info(int)
 	__attribute__ ((weak, alias("__board_add_ram_info")));
 
-int __board_flash_wp_on(void)
+static int __board_flash_wp_on(void)
 {
 	/*
 	 * Most flashes can't be detected when write protection is enabled,
@@ -184,7 +184,7 @@ int __board_flash_wp_on(void)
 int board_flash_wp_on(void)
 	__attribute__ ((weak, alias("__board_flash_wp_on")));
 
-void __cpu_secondary_init_r(void)
+static void __cpu_secondary_init_r(void)
 {
 }
 
@@ -262,7 +262,7 @@ static int init_func_watchdog_reset(void)
  * Initialization sequence
  */
 
-init_fnc_t *init_sequence[] = {
+static init_fnc_t *init_sequence[] = {
 #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
 	probecpu,
 #endif
@@ -345,7 +345,7 @@ ulong get_effective_memsize(void)
 #endif
 }
 
-int __fixup_cpu(void)
+static int __fixup_cpu(void)
 {
 	return 0;
 }
@@ -402,7 +402,7 @@ void board_init_f(ulong bootflag)
 
 #ifdef CONFIG_POST
 	post_bootmode_init();
-	post_run(NULL, POST_ROM | post_bootmode_get(0));
+	post_run(NULL, POST_ROM | post_bootmode_get(NULL));
 #endif
 
 	WATCHDOG_RESET();
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 08/25] include/image.h: sparse fixes
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (6 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 07/25] arch/powerpc/lib/board.c, *traps.c: sparse fixes Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 09/25] common/cmd_*.c: " Kim Phillips
                     ` (17 subsequent siblings)
  25 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

include/image.h:378:1: warning: cast to restricted __be32
include/image.h:381:1: warning: cast to restricted __be32
include/image.h:382:1: warning: cast to restricted __be32
include/image.h:383:1: warning: cast to restricted __be32

fix by annotating image header integers big endian.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: no changes

 include/image.h | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/include/image.h b/include/image.h
index 4e5863f..0a895f2 100644
--- a/include/image.h
+++ b/include/image.h
@@ -34,6 +34,7 @@
 #define __IMAGE_H__
 
 #include "compiler.h"
+#include <asm/byteorder.h>
 
 #ifdef USE_HOSTCC
 
@@ -183,13 +184,13 @@
  * all data in network byte order (aka natural aka bigendian).
  */
 typedef struct image_header {
-	uint32_t	ih_magic;	/* Image Header Magic Number	*/
-	uint32_t	ih_hcrc;	/* Image Header CRC Checksum	*/
-	uint32_t	ih_time;	/* Image Creation Timestamp	*/
-	uint32_t	ih_size;	/* Image Data Size		*/
-	uint32_t	ih_load;	/* Data	 Load  Address		*/
-	uint32_t	ih_ep;		/* Entry Point Address		*/
-	uint32_t	ih_dcrc;	/* Image Data CRC Checksum	*/
+	__be32		ih_magic;	/* Image Header Magic Number	*/
+	__be32		ih_hcrc;	/* Image Header CRC Checksum	*/
+	__be32		ih_time;	/* Image Creation Timestamp	*/
+	__be32		ih_size;	/* Image Data Size		*/
+	__be32		ih_load;	/* Data	 Load  Address		*/
+	__be32		ih_ep;		/* Entry Point Address		*/
+	__be32		ih_dcrc;	/* Image Data CRC Checksum	*/
 	uint8_t		ih_os;		/* Operating System		*/
 	uint8_t		ih_arch;	/* CPU architecture		*/
 	uint8_t		ih_type;	/* Image Type			*/
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 09/25] common/cmd_*.c: sparse fixes
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (7 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 08/25] include/image.h: " Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-11-08 10:48     ` Wolfgang Denk
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 10/25] common/misc: " Kim Phillips
                     ` (16 subsequent siblings)
  25 siblings, 1 reply; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

cmd_boot.c:40:5: warning: symbol 'do_go' was not declared. Should it be static?
cmd_bootm.c:164:6: warning: symbol '__arch_preboot_os' was not declared. Should it be static?
cmd_bootm.c:477:5: warning: symbol 'do_bootm_subcommand' was not declared. Should it be static?
cmd_bootm.c:1022:1: error: directive in argument list
cmd_bootm.c:1028:1: error: directive in argument list
cmd_bootm.c:1029:1: error: directive in argument list
cmd_bootm.c:1036:1: error: directive in argument list
cmd_bootm.c:1042:1: error: directive in argument list
cmd_bootm.c:1044:1: error: directive in argument list
cmd_bootm.c:1045:1: error: directive in argument list
cmd_bootm.c:1047:1: error: directive in argument list
cmd_bootm.c:1089:5: warning: symbol 'do_iminfo' was not declared. Should it be static?
cmd_bootm.c:1176:5: warning: symbol 'do_imls' was not declared. Should it be static?
cmd_bootm.c:1654:1: error: directive in argument list
cmd_bootm.c:1660:1: error: directive in argument list
cmd_console.c:32:5: warning: symbol 'do_coninfo' was not declared. Should it be s
cmd_date.c:46:5: warning: symbol 'do_date' was not declared. Should it be static?
cmd_echo.c:27:5: warning: symbol 'do_echo' was not declared. Should it be static?
cmd_exit.c:27:5: warning: symbol 'do_exit' was not declared. Should it be static?
cmd_fat.c:97:5: warning: symbol 'do_fat_ls' was not declared. Should it be static?
cmd_fat.c:136:5: warning: symbol 'do_fat_fsinfo' was not declared. Should it be s
cmd_fdt.c:66:5: warning: symbol 'do_fdt' was not declared. Should it be static?
cmd_fdt.c:542:43: warning: incorrect type in assignment (different base types)
cmd_fdt.c:542:43:    expected unsigned int [unsigned] [usertype] <noident>
cmd_fdt.c:542:43:    got restricted __be32 [usertype] <noident>
cmd_fdt.c:679:42: warning: cast to restricted __be32
cmd_fdt.c:820:1: error: directive in argument list
cmd_fdt.c:822:1: error: directive in argument list
cmd_flash.c:292:5: warning: symbol 'do_flinfo' was not declared. Should it be static?
cmd_flash.c:324:5: warning: symbol 'do_flerase' was not declared. Should it be static?
cmd_flash.c:457:5: warning: symbol 'do_protect' was not declared. Should it be st
cmd_help.c:27:5: warning: symbol 'do_help' was not declared. Should it be static?
cmd_i2c.c:136:6: warning: symbol '__def_i2c_init_board' was not declared. Should it be static?
cmd_i2c.c:144:14: warning: symbol '__def_i2c_get_bus_speed' was not declared. Should it be static?
cmd_i2c.c:151:5: warning: symbol '__def_i2c_set_bus_speed' was not declared. Should it be static?
cmd_i2c.c:1322:1: error: directive in argument list
cmd_i2c.c:1324:1: error: directive in argument list
cmd_i2c.c:1326:1: error: directive in argument list
cmd_i2c.c:1328:1: error: directive in argument list
cmd_i2c.c:1337:1: error: directive in argument list
cmd_i2c.c:1339:1: error: directive in argument list
cmd_irq.c:27:5: warning: symbol 'do_interrupts' was not declared. Should it be static?
cmd_itest.c:133:5: warning: symbol 'binary_test' was not declared. Should it be static?
cmd_itest.c:158:5: warning: symbol 'do_itest' was not declared. Should it be stat
cmd_load.c:54:5: warning: symbol 'do_load_serial' was not declared. Should it be static?
cmd_load.c:431:6: warning: symbol 'his_eol' was not declared. Should it be static?
cmd_load.c:432:6: warning: symbol 'his_pad_count' was not declared. Should it be static?
cmd_load.c:433:6: warning: symbol 'his_pad_char' was not declared. Should it be static?
cmd_load.c:434:6: warning: symbol 'his_quote' was not declared. Should it be static?
cmd_load.c:436:5: warning: symbol 'do_load_serial_bin' was not declared. Should it be static?
cmd_load.c:549:6: warning: symbol 'send_pad' was not declared. Should it be static?
cmd_load.c:558:6: warning: symbol 'ktrans' was not declared. Should it be static?
cmd_load.c:568:5: warning: symbol 'chk1' was not declared. Should it be static?
cmd_load.c:578:6: warning: symbol 's1_sendpacket' was not declared. Should it be static?
cmd_load.c:587:6: warning: symbol 'send_ack' was not declared. Should it be static?
cmd_load.c:600:6: warning: symbol 'send_nack' was not declared. Should it be static?
cmd_load.c:614:6: warning: symbol 'os_data_init' was not declared. Should it be static?
cmd_load.c:615:6: warning: symbol 'os_data_char' was not declared. Should it be static?
cmd_load.c:657:6: warning: symbol 'k_data_init' was not declared. Should it be static?
cmd_load.c:663:6: warning: symbol 'k_data_save' was not declared. Should it be static?
cmd_load.c:669:6: warning: symbol 'k_data_restore' was not declared. Should it be static?
cmd_load.c:675:6: warning: symbol 'k_data_char' was not declared. Should it be static?
cmd_load.c:693:6: warning: symbol 'send_parms' was not declared. Should it be static?
cmd_load.c:694:6: warning: symbol 'send_ptr' was not declared. Should it be static?
cmd_load.c:698:6: warning: symbol 'handle_send_packet' was not declared. Should i
cmd_mdio.c:60:5: warning: symbol 'mdio_write_ranges' was not declared. Should it be static?
cmd_mdio.c:82:5: warning: symbol 'mdio_read_ranges' was not declared. Should it be static?
cmd_mdio.c:115:5: warning: symbol 'extract_reg_range' was not declared. Should it be static?
cmd_mdio.c:144:5: warning: symbol 'extract_phy_range' was not declared. Should it
cmd_mem.c:54:5: warning: symbol 'do_mem_md' was not declared. Should it be static?
cmd_mem.c:150:5: warning: symbol 'do_mem_mm' was not declared. Should it be static?
cmd_mem.c:154:5: warning: symbol 'do_mem_nm' was not declared. Should it be static?
cmd_mem.c:159:5: warning: symbol 'do_mem_mw' was not declared. Should it be static?
cmd_mem.c:256:5: warning: symbol 'do_mem_cmp' was not declared. Should it be static?
cmd_mem.c:326:5: warning: symbol 'do_mem_cp' was not declared. Should it be static?
cmd_mem.c:436:5: warning: symbol 'do_mem_base' was not declared. Should it be static?
cmd_mem.c:449:5: warning: symbol 'do_mem_loop' was not declared. Should it be static?
cmd_mem.c:595:5: warning: symbol 'do_mem_mtest' was not declared. Should it be static?
cmd_mem.c:618:26: warning: Using plain integer as NULL pointer
cmd_mem.c:1057:5: warning: symbol 'do_mem_crc' was not declared. Should it be static?
cmd_misc.c:30:5: warning: symbol 'do_sleep' was not declared. Should it be static
cmd_mmc.c:118:5: warning: symbol 'do_mmcinfo' was not declared. Should it be static?
cmd_mmc.c:272:32: warning: Using plain integer as NULL pointer
cmd_mmc.c:150:5: warning: symbol 'do_mmcops' was not declared. Should it be stati
cmd_mp.c:27:1: warning: symbol 'cpu_cmd' was not declared. Should it be static?
cmd_mp.c:85:1: error: directive in argument list
cmd_mp.c:88:1: error: directive in argument list
cmd_mtdparts.c:150:18: warning: symbol 'mtdids' was not declared. Should it be static?
cmd_mtdparts.c:153:18: warning: symbol 'devices' was not declared. Should it be static?
cmd_mtdparts.c:713:5: warning: symbol 'mtd_device_validate' was not declared. Should it be static?
cmd_mtdparts.c:1887:5: warning: symbol 'do_chpart' was not declared. Should it be static?
cmd_mtdparts.c:1925:5: warning: symbol 'do_mtdparts' was not declared. Should it be static?
cmd_mtdparts.c:2060:1: error: directive in argument list
cmd_mtdparts.c:2063:1: error: directive in argument list
cmd_mtdparts.c:2066:1: error: directive in argument list
cmd_mtdparts.c:2071:1: error: directive in argument list
cmd_mtdparts.c:2073:1: error: directive in argument list
cmd_nand.c:377:18: error: bad constant expression
cmd_nand.c:431:5: warning: symbol 'do_nand' was not declared. Should it be static?
cmd_nand.c:796:1: error: directive in argument list
cmd_nand.c:801:1: error: directive in argument list
cmd_nand.c:802:1: error: directive in argument list
cmd_nand.c:806:1: error: directive in argument list
cmd_nand.c:819:1: error: directive in argument list
cmd_nand.c:824:1: error: directive in argument list
cmd_nand.c:825:1: error: directive in argument list
cmd_nand.c:831:1: error: directive in argument list
cmd_nand.c:918:5: warning: symbol 'do_nandboot' was not declared. Should it be static?
cmd_net.c:33:5: warning: symbol 'do_bootp' was not declared. Should it be static?
cmd_net.c:107:5: warning: symbol 'do_dhcp' was not declared. Should it be static?
cmd_net.c:120:5: warning: symbol 'do_nfs' was not declared. Should it be static?
cmd_nvedit.c:138:5: warning: symbol 'do_env_print' was not declared. Should it be static?
cmd_nvedit.c:323:5: warning: symbol '_do_env_set' was not declared. Should it be static?
cmd_nvedit.c:435:5: warning: symbol 'do_env_set' was not declared. Should it be static?
cmd_nvedit.c:514:5: warning: symbol 'do_env_edit' was not declared. Should it be static?
cmd_nvedit.c:620:5: warning: symbol 'do_env_save' was not declared. Should it be static?
cmd_nvedit.c:1016:1: error: directive in argument list
cmd_nvedit.c:1018:1: error: directive in argument list
cmd_nvedit.c:1021:1: error: directive in argument list
cmd_nvedit.c:1023:1: error: directive in argument list
cmd_nvedit.c:1024:1: error: directive in argument list
cmd_nvedit.c:1026:1: error: directive in argument list
cmd_nvedit.c:1027:1: error: directive in argument list
cmd_nvedit.c:1029:1: error: directive in argument list
cmd_nvedit.c:1030:1: error: directive in argument list
cmd_nvedit.c:1032:1: error: directive in argument list
cmd_nvedit.c:1034:1: error: directive in argument list
cmd_nvedit.c:1036:1: error: directive in argument list
cmd_nvedit.c:1037:1: error: directive in argument list
cmd_nvedit.c:1039:1: error: directive in argument list
cmd_pci.c:38:17: warning: symbol 'ShortPCIListing' was not declared. Should it be static?
cmd_pci.c:38:22: warning: 'ShortPCIListing' defined but not used [-Wunused-variable]
cmd_pci.c:411:5: warning: symbol 'do_pci' was not declared. Should it be static?
cmd_pci.c:494:1: error: directive in argument list
cmd_pci.c:497:1: error: directive in argument list
cmd_reginfo.c:40:5: warning: symbol 'do_reginfo' was not declared. Should it be static?
cmd_sata.c:31:5: warning: symbol 'sata_curr_device' was not declared. Should it be static?
 note -> ata_piix.c doesn't seem to use 'sata_curr_device'; deleted.
cmd_sata.c:32:18: warning: symbol 'sata_dev_desc' was not declared. Should it be static?
cmd_sata.c:70:5: warning: symbol 'do_sata' was not declared. Should it be static?
cmd_setexpr.c:53:5: warning: symbol 'do_setexpr' was not declared. Should it be static?
cmd_source.c:186:1: error: directive in argument list
cmd_source.c:190:1: error: directive in argument list
cmd_test.c:27:5: warning: symbol 'do_test' was not declared. Should it be static?
cmd_test.c:153:5: warning: symbol 'do_false' was not declared. Should it be static?
cmd_test.c:164:5: warning: symbol 'do_true' was not declared. Should it be static
cmd_usb.c:43:6: warning: symbol 'usb_get_class_desc' was not declared. Should it be static?
cmd_usb.c:69:6: warning: symbol 'usb_display_class_sub' was not declared. Should it be static?
cmd_usb.c:151:6: warning: symbol 'usb_display_string' was not declared. Should it be static?
cmd_usb.c:161:6: warning: symbol 'usb_display_desc' was not declared. Should it be static?
cmd_usb.c:195:6: warning: symbol 'usb_display_conf_desc' was not declared. Should it be static?
cmd_usb.c:210:6: warning: symbol 'usb_display_if_desc' was not declared. Should it be static?
cmd_usb.c:227:6: warning: symbol 'usb_display_ep_desc' was not declared. Should it be static?
cmd_usb.c:252:6: warning: symbol 'usb_display_config' was not declared. Should it be static?
cmd_usb.c:283:6: warning: symbol 'usb_show_tree_graph' was not declared. Should it be static?
cmd_usb.c:343:6: warning: symbol 'usb_show_tree' was not declared. Should it be static?
cmd_usb.c:356:5: warning: symbol 'do_usbboot' was not declared. Should it be static?
cmd_usb.c:366:5: warning: symbol 'do_usb' was not declared. Should it be static?
cmd_version.c:31:5: warning: symbol 'do_version' was not declared. Should it be s
cmd_ximg.c:46:1: warning: symbol 'do_imgextract' was not declared. Should it be static?
cmd_ximg.c:272:1: error: directive in argument list
cmd_ximg.c:276:1: error: directive in argument list

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2 undoes fix for:

cmd_mtdparts.c:156:19: warning: symbol 'current_mtd_dev' was not declared. Should it be static?
cmd_mtdparts.c:157:4: warning: symbol 'current_mtd_partnum' was not declared. Should it be static?

which were being used by common/cmd_jffs2.c.  Also undid fix for:

cmd_mtdparts.c:1045:5: warning: symbol 'mtd_id_parse' was not declared. Should it be static?

which is shared with common/cmd_flash.c, and:

cmd_source.c:155:1: warning: symbol 'do_source' was not declared. Should it be static?

which board/esd/common/cmd_loadpci.c uses.  Also:

cmd_boot.c:35:15: warning: symbol 'do_go_exec' was not declared. Should it be static?
cmd_boot.c:35:22: error: weak declaration of 'do_go_exec' must be public

for which arch/x86/lib/cmd_boot.c defines a weak function.

In addition, fix help_texts in cmd_* to depend on CONFIG_SYS_LONGHELP:

cmd_bootm.c:1016:13: warning: 'bootm_help_text' defined but not used [-Wunused-variable]
cmd_nvedit.c:1029:13: warning: 'env_help_text' defined but not used [-Wunused-variable]
cmd_source.c:180:13: warning: 'source_help_text' defined but not used [-Wunused-variable]
cmd_ximg.c:267:13: warning: 'imgextract_help_text' defined but not used [-Wunused-variable]

v2 also includes checkpatch fixes.

 common/cmd_boot.c     |   5 +-
 common/cmd_bootm.c    |  31 ++++--
 common/cmd_console.c  |   2 +-
 common/cmd_date.c     |   2 +-
 common/cmd_echo.c     |   2 +-
 common/cmd_exit.c     |   2 +-
 common/cmd_fat.c      |   5 +-
 common/cmd_fdt.c      |  21 ++--
 common/cmd_flash.c    |   6 +-
 common/cmd_help.c     |   2 +-
 common/cmd_i2c.c      |  20 ++--
 common/cmd_irq.c      |   3 +-
 common/cmd_itest.c    |   4 +-
 common/cmd_load.c     | 303 +++++++++++++++++++++++++-------------------------
 common/cmd_mdio.c     |  20 ++--
 common/cmd_mem.c      |  25 +++--
 common/cmd_misc.c     |   6 +-
 common/cmd_mmc.c      |   6 +-
 common/cmd_mp.c       |  22 ++--
 common/cmd_mtdparts.c |  26 +++--
 common/cmd_nand.c     |  19 ++--
 common/cmd_net.c      |  76 +++++++------
 common/cmd_nvedit.c   |  25 +++--
 common/cmd_pci.c      |  17 +--
 common/cmd_reginfo.c  |   3 +-
 common/cmd_sata.c     |   4 +-
 common/cmd_setexpr.c  |   2 +-
 common/cmd_source.c   |  11 +-
 common/cmd_test.c     |   6 +-
 common/cmd_usb.c      |  30 ++---
 common/cmd_version.c  |   2 +-
 common/cmd_ximg.c     |  13 ++-
 32 files changed, 387 insertions(+), 334 deletions(-)

diff --git a/common/cmd_boot.c b/common/cmd_boot.c
index a799b33..d3836fd 100644
--- a/common/cmd_boot.c
+++ b/common/cmd_boot.c
@@ -32,12 +32,13 @@
 
 /* Allow ports to override the default behavior */
 __attribute__((weak))
-unsigned long do_go_exec (ulong (*entry)(int, char * const []), int argc, char * const argv[])
+unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
+				 char * const argv[])
 {
 	return entry (argc, argv);
 }
 
-int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong	addr, rc;
 	int     rcode = 0;
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 83fa5d7..d256ddf 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -161,7 +161,7 @@ static boot_os_fn *boot_os[] = {
 bootm_headers_t images;		/* pointers to os/initrd/fdt images */
 
 /* Allow for arch specific config before we boot */
-void __arch_preboot_os(void)
+static void __arch_preboot_os(void)
 {
 	/* please define platform specific arch_preboot_os() */
 }
@@ -474,7 +474,7 @@ static cmd_tbl_t cmd_bootm_sub[] = {
 	U_BOOT_CMD_MKENT(go, 0, 1, (void *)BOOTM_STATE_OS_GO, "", ""),
 };
 
-int do_bootm_subcommand(cmd_tbl_t *cmdtp, int flag, int argc,
+static int do_bootm_subcommand(cmd_tbl_t *cmdtp, int flag, int argc,
 			char * const argv[])
 {
 	int ret = 0;
@@ -1013,9 +1013,8 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
 	return (void *)img_addr;
 }
 
-U_BOOT_CMD(
-	bootm,	CONFIG_SYS_MAXARGS,	1,	do_bootm,
-	"boot application image from memory",
+#ifdef CONFIG_SYS_LONGHELP
+static char bootm_help_text[] =
 	"[addr [arg ...]]\n    - boot application image stored in memory\n"
 	"\tpassing arguments 'arg ...'; when booting a Linux kernel,\n"
 	"\t'arg' can be the address of an initrd image\n"
@@ -1048,7 +1047,12 @@ U_BOOT_CMD(
 	"\tcmdline - OS specific command line processing/setup\n"
 	"\tbdt     - OS specific bd_t processing\n"
 	"\tprep    - OS specific prep before relocation or go\n"
-	"\tgo      - start OS"
+	"\tgo      - start OS";
+#endif
+
+U_BOOT_CMD(
+	bootm,	CONFIG_SYS_MAXARGS,	1,	do_bootm,
+	"boot application image from memory", bootm_help_text
 );
 
 /*******************************************************************/
@@ -1084,7 +1088,7 @@ U_BOOT_CMD(
 /* iminfo - print header info for a requested image */
 /*******************************************************************/
 #if defined(CONFIG_CMD_IMI)
-int do_iminfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_iminfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	int	arg;
 	ulong	addr;
@@ -1171,7 +1175,7 @@ U_BOOT_CMD(
 /* imls - list all images found in flash */
 /*******************************************************************/
 #if defined(CONFIG_CMD_IMLS)
-int do_imls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_imls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	flash_info_t *info;
 	int i, j;
@@ -1643,9 +1647,8 @@ static int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return 1;
 }
 
-U_BOOT_CMD(
-	bootz,	CONFIG_SYS_MAXARGS,	1,	do_bootz,
-	"boot Linux zImage image from memory",
+#ifdef CONFIG_SYS_LONGHELP
+static char bootz_help_text[] =
 	"[addr [initrd[:size]] [fdt]]\n"
 	"    - boot Linux zImage stored in memory\n"
 	"\tThe argument 'initrd' is optional and specifies the address\n"
@@ -1658,5 +1661,11 @@ U_BOOT_CMD(
 	"\tuse a '-' for the second argument. If you do not pass a third\n"
 	"\ta bd_info struct will be passed instead\n"
 #endif
+	"";
+#endif
+
+U_BOOT_CMD(
+	bootz,	CONFIG_SYS_MAXARGS,	1,	do_bootz,
+	"boot Linux zImage image from memory", bootz_help_text
 );
 #endif	/* CONFIG_CMD_BOOTZ */
diff --git a/common/cmd_console.c b/common/cmd_console.c
index d8cad6b..e8d9f11 100644
--- a/common/cmd_console.c
+++ b/common/cmd_console.c
@@ -29,7 +29,7 @@
 #include <stdio_dev.h>
 
 extern void _do_coninfo (void);
-int do_coninfo (cmd_tbl_t * cmd, int flag, int argc, char * const argv[])
+static int do_coninfo(cmd_tbl_t *cmd, int flag, int argc, char * const argv[])
 {
 	int l;
 	struct list_head *list = stdio_get_list();
diff --git a/common/cmd_date.c b/common/cmd_date.c
index 335bc05..0ac032c 100644
--- a/common/cmd_date.c
+++ b/common/cmd_date.c
@@ -43,7 +43,7 @@ static const char * const weekdays[] = {
 
 int mk_date (const char *, struct rtc_time *);
 
-int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_date(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	struct rtc_time tm;
 	int rcode = 0;
diff --git a/common/cmd_echo.c b/common/cmd_echo.c
index 1e499fb..52123fe 100644
--- a/common/cmd_echo.c
+++ b/common/cmd_echo.c
@@ -24,7 +24,7 @@
 #include <common.h>
 #include <command.h>
 
-int do_echo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_echo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	int i;
 	int putnl = 1;
diff --git a/common/cmd_exit.c b/common/cmd_exit.c
index f3fc8f5..0f2ee40 100644
--- a/common/cmd_exit.c
+++ b/common/cmd_exit.c
@@ -24,7 +24,7 @@
 #include <common.h>
 #include <command.h>
 
-int do_exit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_exit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	int r;
 
diff --git a/common/cmd_fat.c b/common/cmd_fat.c
index c38302d..3219b54 100644
--- a/common/cmd_fat.c
+++ b/common/cmd_fat.c
@@ -94,7 +94,7 @@ U_BOOT_CMD(
 	"      the load stops on end of file."
 );
 
-int do_fat_ls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_fat_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	char *filename = "/";
 	int ret, dev, part;
@@ -133,7 +133,8 @@ U_BOOT_CMD(
 	"    - list files from 'dev' on 'interface' in a 'directory'"
 );
 
-int do_fat_fsinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_fat_fsinfo(cmd_tbl_t *cmdtp, int flag, int argc,
+			 char * const argv[])
 {
 	int dev, part;
 	block_dev_desc_t *dev_desc;
diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c
index a5e2cfc..a67a103 100644
--- a/common/cmd_fdt.c
+++ b/common/cmd_fdt.c
@@ -95,7 +95,7 @@ static int fdt_value_setenv(const void *nodep, int len, const char *var)
 /*
  * Flattened Device Tree command, see the help for parameter definitions.
  */
-int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	if (argc < 2)
 		return CMD_RET_USAGE;
@@ -682,7 +682,7 @@ static int fdt_parse_prop(char * const *newval, int count, char *data, int *len)
 
 			cp = newp;
 			tmp = simple_strtoul(cp, &newp, 0);
-			*(uint32_t *)data = __cpu_to_be32(tmp);
+			*(__be32 *)data = __cpu_to_be32(tmp);
 			data  += 4;
 			*len += 4;
 
@@ -818,7 +818,7 @@ static void print_data(const void *data, int len)
 		if (len > CONFIG_CMD_FDT_MAX_DUMP)
 			printf("* 0x%08x [0x%08x]", (unsigned int)data, len);
 		else {
-			const u32 *p;
+			const __be32 *p;
 
 			printf("<");
 			for (j = 0, p = data; j < len/4; j++)
@@ -964,11 +964,9 @@ static int fdt_print(const char *pathp, char *prop, int depth)
 }
 
 /********************************************************************/
-
-U_BOOT_CMD(
-	fdt,	255,	0,	do_fdt,
-	"flattened device tree utility commands",
-	    "addr   <addr> [<length>]        - Set the fdt location to <addr>\n"
+#ifdef CONFIG_SYS_LONGHELP
+static char fdt_help_text[] =
+	"addr   <addr> [<length>]        - Set the fdt location to <addr>\n"
 #ifdef CONFIG_OF_BOARD_SETUP
 	"fdt boardsetup                      - Do board-specific set up\n"
 #endif
@@ -992,5 +990,10 @@ U_BOOT_CMD(
 	"fdt chosen [<start> <end>]          - Add/update the /chosen branch in the tree\n"
 	"                                        <start>/<end> - initrd start/end addr\n"
 	"NOTE: Dereference aliases by omiting the leading '/', "
-		"e.g. fdt print ethernet0."
+		"e.g. fdt print ethernet0.";
+#endif
+
+U_BOOT_CMD(
+	fdt,	255,	0,	do_fdt,
+	"flattened device tree utility commands", fdt_help_text
 );
diff --git a/common/cmd_flash.c b/common/cmd_flash.c
index e55d366..687eb68 100644
--- a/common/cmd_flash.c
+++ b/common/cmd_flash.c
@@ -289,7 +289,7 @@ flash_fill_sect_ranges (ulong addr_first, ulong addr_last,
 }
 #endif /* CONFIG_SYS_NO_FLASH */
 
-int do_flinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_flinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 #ifndef CONFIG_SYS_NO_FLASH
 	ulong bank;
@@ -321,7 +321,7 @@ int do_flinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return 0;
 }
 
-int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_flerase(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 #ifndef CONFIG_SYS_NO_FLASH
 	flash_info_t *info = NULL;
@@ -454,7 +454,7 @@ int flash_sect_erase (ulong addr_first, ulong addr_last)
 }
 #endif /* CONFIG_SYS_NO_FLASH */
 
-int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_protect(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	int rcode = 0;
 #ifndef CONFIG_SYS_NO_FLASH
diff --git a/common/cmd_help.c b/common/cmd_help.c
index 3178a1a..f832a96 100644
--- a/common/cmd_help.c
+++ b/common/cmd_help.c
@@ -24,7 +24,7 @@
 #include <common.h>
 #include <command.h>
 
-int do_help(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+static int do_help(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	cmd_tbl_t *start = ll_entry_start(cmd_tbl_t, cmd);
 	const int len = ll_entry_count(cmd_tbl_t, cmd);
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index 82e63e1..4438db5 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -133,7 +133,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #define DISP_LINE_LEN	16
 
 /* implement possible board specific board init */
-void __def_i2c_init_board(void)
+static void __def_i2c_init_board(void)
 {
 	return;
 }
@@ -141,14 +141,14 @@ void i2c_init_board(void)
 	__attribute__((weak, alias("__def_i2c_init_board")));
 
 /* TODO: Implement architecture-specific get/set functions */
-unsigned int __def_i2c_get_bus_speed(void)
+static unsigned int __def_i2c_get_bus_speed(void)
 {
 	return CONFIG_SYS_I2C_SPEED;
 }
 unsigned int i2c_get_bus_speed(void)
 	__attribute__((weak, alias("__def_i2c_get_bus_speed")));
 
-int __def_i2c_set_bus_speed(unsigned int speed)
+static int __def_i2c_set_bus_speed(unsigned int speed)
 {
 	if (speed != CONFIG_SYS_I2C_SPEED)
 		return -1;
@@ -1376,10 +1376,8 @@ static int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 }
 
 /***************************************************/
-
-U_BOOT_CMD(
-	i2c, 6, 1, do_i2c,
-	"I2C sub-system",
+#ifdef CONFIG_SYS_LONGHELP
+static char i2c_help_text[] =
 #if defined(CONFIG_I2C_MUX)
 	"bus [muxtype:muxaddr:muxchannel] - add a new bus reached over muxes\ni2c "
 #endif  /* CONFIG_I2C_MUX */
@@ -1399,7 +1397,13 @@ U_BOOT_CMD(
 #if defined(CONFIG_CMD_SDRAM)
 	"i2c sdram chip - print SDRAM configuration information\n"
 #endif
-	"i2c speed [speed] - show or set I2C bus speed"
+	"i2c speed [speed] - show or set I2C bus speed";
+#endif
+
+U_BOOT_CMD(
+	i2c, 6, 1, do_i2c,
+	"I2C sub-system",
+	i2c_help_text
 );
 
 #if defined(CONFIG_I2C_MUX)
diff --git a/common/cmd_irq.c b/common/cmd_irq.c
index 9f158ef..1e82883 100644
--- a/common/cmd_irq.c
+++ b/common/cmd_irq.c
@@ -24,7 +24,8 @@
 #include <config.h>
 #include <command.h>
 
-int do_interrupts(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_interrupts(cmd_tbl_t *cmdtp, int flag, int argc,
+			 char * const argv[])
 {
 
 	if (argc != 2)
diff --git a/common/cmd_itest.c b/common/cmd_itest.c
index d5df758..2c8e5d0 100644
--- a/common/cmd_itest.c
+++ b/common/cmd_itest.c
@@ -130,7 +130,7 @@ static int arithcomp (char *s, char *t, int op, int w)
 	return (0);
 }
 
-int binary_test (char *op, char *arg1, char *arg2, int w)
+static int binary_test(char *op, char *arg1, char *arg2, int w)
 {
 	int len, i;
 	const op_tbl_t *optp;
@@ -155,7 +155,7 @@ int binary_test (char *op, char *arg1, char *arg2, int w)
 }
 
 /* command line interface to the shell test */
-int do_itest ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] )
+static int do_itest(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	int	value, w;
 
diff --git a/common/cmd_load.c b/common/cmd_load.c
index f4d66de..2c8dab1 100644
--- a/common/cmd_load.c
+++ b/common/cmd_load.c
@@ -34,15 +34,15 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 #if defined(CONFIG_CMD_LOADB)
-static ulong load_serial_ymodem (ulong offset);
+static ulong load_serial_ymodem(ulong offset);
 #endif
 
 #if defined(CONFIG_CMD_LOADS)
-static ulong load_serial (long offset);
-static int read_record (char *buf, ulong len);
+static ulong load_serial(long offset);
+static int read_record(char *buf, ulong len);
 # if defined(CONFIG_CMD_SAVES)
-static int save_serial (ulong offset, ulong size);
-static int write_record (char *buf);
+static int save_serial(ulong offset, ulong size);
+static int write_record(char *buf);
 #endif
 
 static int do_echo = 1;
@@ -51,7 +51,8 @@ static int do_echo = 1;
 /* -------------------------------------------------------------------- */
 
 #if defined(CONFIG_CMD_LOADS)
-int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_load_serial(cmd_tbl_t *cmdtp, int flag, int argc,
+			  char * const argv[])
 {
 	long offset = 0;
 	ulong addr;
@@ -82,11 +83,11 @@ int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			load_baudrate = current_baudrate;
 	}
 	if (load_baudrate != current_baudrate) {
-		printf ("## Switch baudrate to %d bps and press ENTER ...\n",
+		printf("## Switch baudrate to %d bps and press ENTER ...\n",
 			load_baudrate);
 		udelay(50000);
 		gd->baudrate = load_baudrate;
-		serial_setbrg ();
+		serial_setbrg();
 		udelay(50000);
 		for (;;) {
 			if (getc() == '\r')
@@ -99,9 +100,9 @@ int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	}
 #endif	/* CONFIG_SYS_LOADS_BAUD_CHANGE */
 
-	printf ("## Ready for S-Record download ...\n");
+	printf("## Ready for S-Record download ...\n");
 
-	addr = load_serial (offset);
+	addr = load_serial(offset);
 
 	/*
 	 * Gather any trailing characters (for instance, the ^D which
@@ -116,21 +117,21 @@ int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	}
 
 	if (addr == ~0) {
-		printf ("## S-Record download aborted\n");
+		printf("## S-Record download aborted\n");
 		rcode = 1;
 	} else {
-		printf ("## Start Addr      = 0x%08lX\n", addr);
+		printf("## Start Addr      = 0x%08lX\n", addr);
 		load_addr = addr;
 	}
 
 #ifdef	CONFIG_SYS_LOADS_BAUD_CHANGE
 	if (load_baudrate != current_baudrate) {
-		printf ("## Switch baudrate to %d bps and press ESC ...\n",
+		printf("## Switch baudrate to %d bps and press ESC ...\n",
 			current_baudrate);
-		udelay (50000);
+		udelay(50000);
 		gd->baudrate = current_baudrate;
-		serial_setbrg ();
-		udelay (50000);
+		serial_setbrg();
+		udelay(50000);
 		for (;;) {
 			if (getc() == 0x1B) /* ESC */
 				break;
@@ -140,8 +141,7 @@ int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return rcode;
 }
 
-static ulong
-load_serial (long offset)
+static ulong load_serial(long offset)
 {
 	char	record[SREC_MAXRECLEN + 1];	/* buffer for one S-Record	*/
 	char	binbuf[SREC_MAXBINLEN];		/* buffer for binary data	*/
@@ -156,7 +156,7 @@ load_serial (long offset)
 	int	line_count =  0;
 
 	while (read_record(record, SREC_MAXRECLEN + 1) >= 0) {
-		type = srec_decode (record, &binlen, &addr, binbuf);
+		type = srec_decode(record, &binlen, &addr, binbuf);
 
 		if (type < 0) {
 			return (~0);		/* Invalid S-Record		*/
@@ -173,13 +173,13 @@ load_serial (long offset)
 
 			rc = flash_write((char *)binbuf,store_addr,binlen);
 			if (rc != 0) {
-				flash_perror (rc);
+				flash_perror(rc);
 				return (~0);
 			}
 		    } else
 #endif
 		    {
-			memcpy ((char *)(store_addr), binbuf, binlen);
+			memcpy((char *)(store_addr), binbuf, binlen);
 		    }
 		    if ((store_addr) < start_addr)
 			start_addr = store_addr;
@@ -189,15 +189,15 @@ load_serial (long offset)
 		case SREC_END2:
 		case SREC_END3:
 		case SREC_END4:
-		    udelay (10000);
+		    udelay(10000);
 		    size = end_addr - start_addr + 1;
-		    printf ("\n"
+		    printf("\n"
 			    "## First Load Addr = 0x%08lX\n"
 			    "## Last  Load Addr = 0x%08lX\n"
 			    "## Total Size      = 0x%08lX = %ld Bytes\n",
 			    start_addr, end_addr, size, size
 		    );
-		    flush_cache (start_addr, size);
+		    flush_cache(start_addr, size);
 		    sprintf(buf, "%lX", size);
 		    setenv("filesize", buf);
 		    return (addr);
@@ -208,15 +208,14 @@ load_serial (long offset)
 		}
 		if (!do_echo) {	/* print a '.' every 100 lines */
 			if ((++line_count % 100) == 0)
-				putc ('.');
+				putc('.');
 		}
 	}
 
 	return (~0);			/* Download aborted		*/
 }
 
-static int
-read_record (char *buf, ulong len)
+static int read_record(char *buf, ulong len)
 {
 	char *p;
 	char c;
@@ -226,7 +225,7 @@ read_record (char *buf, ulong len)
 	for (p=buf; p < buf+len; ++p) {
 		c = getc();		/* read character		*/
 		if (do_echo)
-			putc (c);	/* ... and echo it		*/
+			putc(c);	/* ... and echo it		*/
 
 		switch (c) {
 		case '\r':
@@ -280,11 +279,11 @@ int do_save_serial (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			save_baudrate = current_baudrate;
 	}
 	if (save_baudrate != current_baudrate) {
-		printf ("## Switch baudrate to %d bps and press ENTER ...\n",
+		printf("## Switch baudrate to %d bps and press ENTER ...\n",
 			save_baudrate);
 		udelay(50000);
 		gd->baudrate = save_baudrate;
-		serial_setbrg ();
+		serial_setbrg();
 		udelay(50000);
 		for (;;) {
 			if (getc() == '\r')
@@ -297,24 +296,24 @@ int do_save_serial (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	}
 #endif	/* CONFIG_SYS_LOADS_BAUD_CHANGE */
 
-	printf ("## Ready for S-Record upload, press ENTER to proceed ...\n");
+	printf("## Ready for S-Record upload, press ENTER to proceed ...\n");
 	for (;;) {
 		if (getc() == '\r')
 			break;
 	}
-	if(save_serial (offset, size)) {
-		printf ("## S-Record upload aborted\n");
+	if (save_serial(offset, size)) {
+		printf("## S-Record upload aborted\n");
 	} else {
-		printf ("## S-Record upload complete\n");
+		printf("## S-Record upload complete\n");
 	}
 #ifdef	CONFIG_SYS_LOADS_BAUD_CHANGE
 	if (save_baudrate != current_baudrate) {
-		printf ("## Switch baudrate to %d bps and press ESC ...\n",
+		printf("## Switch baudrate to %d bps and press ESC ...\n",
 			(int)current_baudrate);
-		udelay (50000);
+		udelay(50000);
 		gd->baudrate = current_baudrate;
-		serial_setbrg ();
-		udelay (50000);
+		serial_setbrg();
+		udelay(50000);
 		for (;;) {
 			if (getc() == 0x1B) /* ESC */
 				break;
@@ -329,7 +328,7 @@ int do_save_serial (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 #define SREC3_END				"S70500000000FA\n"
 #define SREC_BYTES_PER_RECORD	16
 
-static int save_serial (ulong address, ulong count)
+static int save_serial(ulong address, ulong count)
 {
 	int i, c, reclen, checksum, length;
 	char *hex = "0123456789ABCDEF";
@@ -384,8 +383,7 @@ static int save_serial (ulong address, ulong count)
 	return(0);
 }
 
-static int
-write_record (char *buf)
+static int write_record(char *buf)
 {
 	char c;
 
@@ -425,15 +423,16 @@ write_record (char *buf)
 
 static void set_kerm_bin_mode(unsigned long *);
 static int k_recv(void);
-static ulong load_serial_bin (ulong offset);
+static ulong load_serial_bin(ulong offset);
 
 
-char his_eol;        /* character he needs at end of packet */
-int  his_pad_count;  /* number of pad chars he needs */
-char his_pad_char;   /* pad chars he needs */
-char his_quote;      /* quote chars he'll use */
+static char his_eol;        /* character he needs at end of packet */
+static int  his_pad_count;  /* number of pad chars he needs */
+static char his_pad_char;   /* pad chars he needs */
+static char his_quote;      /* quote chars he'll use */
 
-int do_load_serial_bin (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_load_serial_bin(cmd_tbl_t *cmdtp, int flag, int argc,
+			      char * const argv[])
 {
 	ulong offset = 0;
 	ulong addr;
@@ -463,11 +462,11 @@ int do_load_serial_bin (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[
 	}
 
 	if (load_baudrate != current_baudrate) {
-		printf ("## Switch baudrate to %d bps and press ENTER ...\n",
+		printf("## Switch baudrate to %d bps and press ENTER ...\n",
 			load_baudrate);
 		udelay(50000);
 		gd->baudrate = load_baudrate;
-		serial_setbrg ();
+		serial_setbrg();
 		udelay(50000);
 		for (;;) {
 			if (getc() == '\r')
@@ -476,37 +475,37 @@ int do_load_serial_bin (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[
 	}
 
 	if (strcmp(argv[0],"loady")==0) {
-		printf ("## Ready for binary (ymodem) download "
+		printf("## Ready for binary (ymodem) download "
 			"to 0x%08lX at %d bps...\n",
 			offset,
 			load_baudrate);
 
-		addr = load_serial_ymodem (offset);
+		addr = load_serial_ymodem(offset);
 
 	} else {
 
-		printf ("## Ready for binary (kermit) download "
+		printf("## Ready for binary (kermit) download "
 			"to 0x%08lX at %d bps...\n",
 			offset,
 			load_baudrate);
-		addr = load_serial_bin (offset);
+		addr = load_serial_bin(offset);
 
 		if (addr == ~0) {
 			load_addr = 0;
-			printf ("## Binary (kermit) download aborted\n");
+			printf("## Binary (kermit) download aborted\n");
 			rcode = 1;
 		} else {
-			printf ("## Start Addr      = 0x%08lX\n", addr);
+			printf("## Start Addr      = 0x%08lX\n", addr);
 			load_addr = addr;
 		}
 	}
 	if (load_baudrate != current_baudrate) {
-		printf ("## Switch baudrate to %d bps and press ESC ...\n",
+		printf("## Switch baudrate to %d bps and press ESC ...\n",
 			current_baudrate);
-		udelay (50000);
+		udelay(50000);
 		gd->baudrate = current_baudrate;
-		serial_setbrg ();
-		udelay (50000);
+		serial_setbrg();
+		udelay(50000);
 		for (;;) {
 			if (getc() == 0x1B) /* ESC */
 				break;
@@ -517,13 +516,13 @@ int do_load_serial_bin (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[
 }
 
 
-static ulong load_serial_bin (ulong offset)
+static ulong load_serial_bin(ulong offset)
 {
 	int size, i;
 	char buf[32];
 
-	set_kerm_bin_mode ((ulong *) offset);
-	size = k_recv ();
+	set_kerm_bin_mode((ulong *) offset);
+	size = k_recv();
 
 	/*
 	 * Gather any trailing characters (for instance, the ^D which
@@ -537,7 +536,7 @@ static ulong load_serial_bin (ulong offset)
 		udelay(1000);
 	}
 
-	flush_cache (offset, size);
+	flush_cache(offset, size);
 
 	printf("## Total Size      = 0x%08x = %d Bytes\n", size, size);
 	sprintf(buf, "%X", size);
@@ -546,16 +545,16 @@ static ulong load_serial_bin (ulong offset)
 	return offset;
 }
 
-void send_pad (void)
+static void send_pad(void)
 {
 	int count = his_pad_count;
 
 	while (count-- > 0)
-		putc (his_pad_char);
+		putc(his_pad_char);
 }
 
 /* converts escaped kermit char to binary char */
-char ktrans (char in)
+static char ktrans(char in)
 {
 	if ((in & 0x60) == 0x40) {
 		return (char) (in & ~0x40);
@@ -565,7 +564,7 @@ char ktrans (char in)
 		return in;
 }
 
-int chk1 (char *buffer)
+static int chk1(char *buffer)
 {
 	int total = 0;
 
@@ -575,67 +574,67 @@ int chk1 (char *buffer)
 	return (int) ((total + ((total >> 6) & 0x03)) & 0x3f);
 }
 
-void s1_sendpacket (char *packet)
+static void s1_sendpacket(char *packet)
 {
-	send_pad ();
+	send_pad();
 	while (*packet) {
-		putc (*packet++);
+		putc(*packet++);
 	}
 }
 
 static char a_b[24];
-void send_ack (int n)
+static void send_ack(int n)
 {
 	a_b[0] = START_CHAR;
-	a_b[1] = tochar (3);
-	a_b[2] = tochar (n);
+	a_b[1] = tochar(3);
+	a_b[2] = tochar(n);
 	a_b[3] = ACK_TYPE;
 	a_b[4] = '\0';
-	a_b[4] = tochar (chk1 (&a_b[1]));
+	a_b[4] = tochar(chk1(&a_b[1]));
 	a_b[5] = his_eol;
 	a_b[6] = '\0';
-	s1_sendpacket (a_b);
+	s1_sendpacket(a_b);
 }
 
-void send_nack (int n)
+static void send_nack(int n)
 {
 	a_b[0] = START_CHAR;
-	a_b[1] = tochar (3);
-	a_b[2] = tochar (n);
+	a_b[1] = tochar(3);
+	a_b[2] = tochar(n);
 	a_b[3] = NACK_TYPE;
 	a_b[4] = '\0';
-	a_b[4] = tochar (chk1 (&a_b[1]));
+	a_b[4] = tochar(chk1(&a_b[1]));
 	a_b[5] = his_eol;
 	a_b[6] = '\0';
-	s1_sendpacket (a_b);
+	s1_sendpacket(a_b);
 }
 
 
-void (*os_data_init) (void);
-void (*os_data_char) (char new_char);
+static void (*os_data_init)(void);
+static void (*os_data_char)(char new_char);
 static int os_data_state, os_data_state_saved;
 static char *os_data_addr, *os_data_addr_saved;
 static char *bin_start_address;
 
-static void bin_data_init (void)
+static void bin_data_init(void)
 {
 	os_data_state = 0;
 	os_data_addr = bin_start_address;
 }
 
-static void os_data_save (void)
+static void os_data_save(void)
 {
 	os_data_state_saved = os_data_state;
 	os_data_addr_saved = os_data_addr;
 }
 
-static void os_data_restore (void)
+static void os_data_restore(void)
 {
 	os_data_state = os_data_state_saved;
 	os_data_addr = os_data_addr_saved;
 }
 
-static void bin_data_char (char new_char)
+static void bin_data_char(char new_char)
 {
 	switch (os_data_state) {
 	case 0:					/* data */
@@ -644,7 +643,7 @@ static void bin_data_char (char new_char)
 	}
 }
 
-static void set_kerm_bin_mode (unsigned long *addr)
+static void set_kerm_bin_mode(unsigned long *addr)
 {
 	bin_start_address = (char *) addr;
 	os_data_init = bin_data_init;
@@ -654,29 +653,29 @@ static void set_kerm_bin_mode (unsigned long *addr)
 
 /* k_data_* simply handles the kermit escape translations */
 static int k_data_escape, k_data_escape_saved;
-void k_data_init (void)
+static void k_data_init(void)
 {
 	k_data_escape = 0;
-	os_data_init ();
+	os_data_init();
 }
 
-void k_data_save (void)
+static void k_data_save(void)
 {
 	k_data_escape_saved = k_data_escape;
-	os_data_save ();
+	os_data_save();
 }
 
-void k_data_restore (void)
+static void k_data_restore(void)
 {
 	k_data_escape = k_data_escape_saved;
-	os_data_restore ();
+	os_data_restore();
 }
 
-void k_data_char (char new_char)
+static void k_data_char(char new_char)
 {
 	if (k_data_escape) {
 		/* last char was escape - translate this character */
-		os_data_char (ktrans (new_char));
+		os_data_char(ktrans(new_char));
 		k_data_escape = 0;
 	} else {
 		if (new_char == his_quote) {
@@ -684,18 +683,18 @@ void k_data_char (char new_char)
 			k_data_escape = 1;
 		} else {
 			/* otherwise send this char as-is */
-			os_data_char (new_char);
+			os_data_char(new_char);
 		}
 	}
 }
 
 #define SEND_DATA_SIZE  20
-char send_parms[SEND_DATA_SIZE];
-char *send_ptr;
+static char send_parms[SEND_DATA_SIZE];
+static char *send_ptr;
 
 /* handle_send_packet interprits the protocol info and builds and
    sends an appropriate ack for what we can do */
-void handle_send_packet (int n)
+static void handle_send_packet(int n)
 {
 	int length = 3;
 	int bytes;
@@ -715,30 +714,30 @@ void handle_send_packet (int n)
 			break;
 		/* handle MAXL - max length */
 		/* ignore what he says - most I'll take (here) is 94 */
-		a_b[++length] = tochar (94);
+		a_b[++length] = tochar(94);
 		if (bytes-- <= 0)
 			break;
 		/* handle TIME - time you should wait for my packets */
 		/* ignore what he says - don't wait for my ack longer than 1 second */
-		a_b[++length] = tochar (1);
+		a_b[++length] = tochar(1);
 		if (bytes-- <= 0)
 			break;
 		/* handle NPAD - number of pad chars I need */
 		/* remember what he says - I need none */
-		his_pad_count = untochar (send_parms[2]);
-		a_b[++length] = tochar (0);
+		his_pad_count = untochar(send_parms[2]);
+		a_b[++length] = tochar(0);
 		if (bytes-- <= 0)
 			break;
 		/* handle PADC - pad chars I need */
 		/* remember what he says - I need none */
-		his_pad_char = ktrans (send_parms[3]);
+		his_pad_char = ktrans(send_parms[3]);
 		a_b[++length] = 0x40;	/* He should ignore this */
 		if (bytes-- <= 0)
 			break;
 		/* handle EOL - end of line he needs */
 		/* remember what he says - I need CR */
-		his_eol = untochar (send_parms[4]);
-		a_b[++length] = tochar (END_CHAR);
+		his_eol = untochar(send_parms[4]);
+		a_b[++length] = tochar(END_CHAR);
 		if (bytes-- <= 0)
 			break;
 		/* handle QCTL - quote control char he'll use */
@@ -764,25 +763,25 @@ void handle_send_packet (int n)
 			break;
 		/* handle CAPAS - the capabilities mask */
 		/* ignore what he says - I only do long packets - I don't do windows */
-		a_b[++length] = tochar (2);	/* only long packets */
-		a_b[++length] = tochar (0);	/* no windows */
-		a_b[++length] = tochar (94);	/* large packet msb */
-		a_b[++length] = tochar (94);	/* large packet lsb */
+		a_b[++length] = tochar(2);	/* only long packets */
+		a_b[++length] = tochar(0);	/* no windows */
+		a_b[++length] = tochar(94);	/* large packet msb */
+		a_b[++length] = tochar(94);	/* large packet lsb */
 	} while (0);
 
 	a_b[0] = START_CHAR;
-	a_b[1] = tochar (length);
-	a_b[2] = tochar (n);
+	a_b[1] = tochar(length);
+	a_b[2] = tochar(n);
 	a_b[3] = ACK_TYPE;
 	a_b[++length] = '\0';
-	a_b[length] = tochar (chk1 (&a_b[1]));
+	a_b[length] = tochar(chk1(&a_b[1]));
 	a_b[++length] = his_eol;
 	a_b[++length] = '\0';
-	s1_sendpacket (a_b);
+	s1_sendpacket(a_b);
 }
 
 /* k_recv receives a OS Open image file over kermit line */
-static int k_recv (void)
+static int k_recv(void)
 {
 	char new_char;
 	char k_state, k_state_saved;
@@ -801,9 +800,9 @@ static int k_recv (void)
 	/* initialize the k_recv and k_data state machine */
 	done = 0;
 	k_state = 0;
-	k_data_init ();
+	k_data_init();
 	k_state_saved = k_state;
-	k_data_save ();
+	k_data_save();
 	n = 0;				/* just to get rid of a warning */
 	last_n = -1;
 
@@ -848,17 +847,17 @@ static int k_recv (void)
 START:
 		/* get length of packet */
 		sum = 0;
-		new_char = getc ();
+		new_char = getc();
 		if ((new_char & 0xE0) == 0)
 			goto packet_error;
 		sum += new_char & 0xff;
-		length = untochar (new_char);
+		length = untochar(new_char);
 		/* get sequence number */
-		new_char = getc ();
+		new_char = getc();
 		if ((new_char & 0xE0) == 0)
 			goto packet_error;
 		sum += new_char & 0xff;
-		n = untochar (new_char);
+		n = untochar(new_char);
 		--length;
 
 		/* NEW CODE - check sequence numbers for retried packets */
@@ -871,17 +870,17 @@ START:
 		if (n == last_n) {
 			/* same sequence number, restore the previous state */
 			k_state = k_state_saved;
-			k_data_restore ();
+			k_data_restore();
 		} else {
 			/* new sequence number, checkpoint the download */
 			last_n = n;
 			k_state_saved = k_state;
-			k_data_save ();
+			k_data_save();
 		}
 		/* END NEW CODE */
 
 		/* get packet type */
-		new_char = getc ();
+		new_char = getc();
 		if ((new_char & 0xE0) == 0)
 			goto packet_error;
 		sum += new_char & 0xff;
@@ -891,29 +890,29 @@ START:
 		if (length == -2) {
 			/* (length byte was 0, decremented twice) */
 			/* get the two length bytes */
-			new_char = getc ();
+			new_char = getc();
 			if ((new_char & 0xE0) == 0)
 				goto packet_error;
 			sum += new_char & 0xff;
-			len_hi = untochar (new_char);
-			new_char = getc ();
+			len_hi = untochar(new_char);
+			new_char = getc();
 			if ((new_char & 0xE0) == 0)
 				goto packet_error;
 			sum += new_char & 0xff;
-			len_lo = untochar (new_char);
+			len_lo = untochar(new_char);
 			length = len_hi * 95 + len_lo;
 			/* check header checksum */
-			new_char = getc ();
+			new_char = getc();
 			if ((new_char & 0xE0) == 0)
 				goto packet_error;
-			if (new_char != tochar ((sum + ((sum >> 6) & 0x03)) & 0x3f))
+			if (new_char != tochar((sum + ((sum >> 6) & 0x03)) & 0x3f))
 				goto packet_error;
 			sum += new_char & 0xff;
 /* --length; */ /* new length includes only data and block check to come */
 		}
 		/* bring in rest of packet */
 		while (length > 1) {
-			new_char = getc ();
+			new_char = getc();
 			if ((new_char & 0xE0) == 0)
 				goto packet_error;
 			sum += new_char & 0xff;
@@ -930,26 +929,26 @@ START:
 			}
 		}
 		/* get and validate checksum character */
-		new_char = getc ();
+		new_char = getc();
 		if ((new_char & 0xE0) == 0)
 			goto packet_error;
-		if (new_char != tochar ((sum + ((sum >> 6) & 0x03)) & 0x3f))
+		if (new_char != tochar((sum + ((sum >> 6) & 0x03)) & 0x3f))
 			goto packet_error;
 		/* get END_CHAR */
-		new_char = getc ();
+		new_char = getc();
 		if (new_char != END_CHAR) {
 		  packet_error:
 			/* restore state machines */
 			k_state = k_state_saved;
-			k_data_restore ();
+			k_data_restore();
 			/* send a negative acknowledge packet in */
-			send_nack (n);
+			send_nack(n);
 		} else if (k_state == SEND_TYPE) {
 			/* crack the protocol parms, build an appropriate ack packet */
-			handle_send_packet (n);
+			handle_send_packet(n);
 		} else {
 			/* send simple acknowledge packet in */
-			send_ack (n);
+			send_ack(n);
 			/* quit if end of transmission */
 			if (k_state == BREAK_TYPE)
 				done = 1;
@@ -963,7 +962,7 @@ static int getcxmodem(void) {
 		return (getc());
 	return -1;
 }
-static ulong load_serial_ymodem (ulong offset)
+static ulong load_serial_ymodem(ulong offset)
 {
 	int size;
 	char buf[32];
@@ -976,19 +975,19 @@ static ulong load_serial_ymodem (ulong offset)
 
 	size = 0;
 	info.mode = xyzModem_ymodem;
-	res = xyzModem_stream_open (&info, &err);
+	res = xyzModem_stream_open(&info, &err);
 	if (!res) {
 
 		while ((res =
-			xyzModem_stream_read (ymodemBuf, 1024, &err)) > 0) {
+			xyzModem_stream_read(ymodemBuf, 1024, &err)) > 0) {
 			store_addr = addr + offset;
 			size += res;
 			addr += res;
 #ifndef CONFIG_SYS_NO_FLASH
-			if (addr2info (store_addr)) {
+			if (addr2info(store_addr)) {
 				int rc;
 
-				rc = flash_write ((char *) ymodemBuf,
+				rc = flash_write((char *) ymodemBuf,
 						  store_addr, res);
 				if (rc != 0) {
 					flash_perror (rc);
@@ -997,24 +996,24 @@ static ulong load_serial_ymodem (ulong offset)
 			} else
 #endif
 			{
-				memcpy ((char *) (store_addr), ymodemBuf,
+				memcpy((char *)(store_addr), ymodemBuf,
 					res);
 			}
 
 		}
 	} else {
-		printf ("%s\n", xyzModem_error (err));
+		printf("%s\n", xyzModem_error(err));
 	}
 
-	xyzModem_stream_close (&err);
-	xyzModem_stream_terminate (false, &getcxmodem);
+	xyzModem_stream_close(&err);
+	xyzModem_stream_terminate(false, &getcxmodem);
 
 
-	flush_cache (offset, size);
+	flush_cache(offset, size);
 
-	printf ("## Total Size      = 0x%08x = %d Bytes\n", size, size);
-	sprintf (buf, "%X", size);
-	setenv ("filesize", buf);
+	printf("## Total Size      = 0x%08x = %d Bytes\n", size, size);
+	sprintf(buf, "%X", size);
+	setenv("filesize", buf);
 
 	return offset;
 }
@@ -1091,7 +1090,7 @@ U_BOOT_CMD(
 /* -------------------------------------------------------------------- */
 
 #if defined(CONFIG_CMD_HWFLOW)
-int do_hwflow (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+int do_hwflow(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	extern int hwflow_onoff(int);
 
diff --git a/common/cmd_mdio.c b/common/cmd_mdio.c
index 77d8df1..ff0063b 100644
--- a/common/cmd_mdio.c
+++ b/common/cmd_mdio.c
@@ -57,9 +57,9 @@ static int extract_range(char *input, int *plo, int *phi)
 	return 0;
 }
 
-int mdio_write_ranges(struct mii_dev *bus, int addrlo,
-			int addrhi, int devadlo, int devadhi,
-			int reglo, int reghi, unsigned short data)
+static int mdio_write_ranges(struct mii_dev *bus, int addrlo,
+			     int addrhi, int devadlo, int devadhi,
+			     int reglo, int reghi, unsigned short data)
 {
 	int addr, devad, reg;
 	int err = 0;
@@ -79,9 +79,9 @@ err_out:
 	return err;
 }
 
-int mdio_read_ranges(struct mii_dev *bus, int addrlo,
-			int addrhi, int devadlo, int devadhi,
-			int reglo, int reghi)
+static int mdio_read_ranges(struct mii_dev *bus, int addrlo,
+			    int addrhi, int devadlo, int devadhi,
+			    int reglo, int reghi)
 {
 	int addr, devad, reg;
 
@@ -112,8 +112,8 @@ int mdio_read_ranges(struct mii_dev *bus, int addrlo,
 }
 
 /* The register will be in the form [a[-b].]x[-y] */
-int extract_reg_range(char *input, int *devadlo, int *devadhi,
-		int *reglo, int *reghi)
+static int extract_reg_range(char *input, int *devadlo, int *devadhi,
+			     int *reglo, int *reghi)
 {
 	char *regstr;
 
@@ -141,8 +141,8 @@ int extract_reg_range(char *input, int *devadlo, int *devadhi,
 	return extract_range(regstr, reglo, reghi);
 }
 
-int extract_phy_range(char *const argv[], int argc, struct mii_dev **bus,
-		int *addrlo, int *addrhi)
+static int extract_phy_range(char *const argv[], int argc, struct mii_dev **bus,
+			     int *addrlo, int *addrhi)
 {
 	struct phy_device *phydev;
 
diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index 18f0a3f..4d64cff 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -51,7 +51,7 @@ static	ulong	base_address = 0;
  *	md{.b, .w, .l} {addr} {len}
  */
 #define DISP_LINE_LEN	16
-int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_md(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong	addr, length;
 #if defined(CONFIG_HAS_DATAFLASH)
@@ -147,16 +147,16 @@ int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return (rc);
 }
 
-int do_mem_mm ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_mm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	return mod_mem (cmdtp, 1, flag, argc, argv);
 }
-int do_mem_nm ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_nm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	return mod_mem (cmdtp, 0, flag, argc, argv);
 }
 
-int do_mem_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong	addr, writeval, count;
 	int	size;
@@ -253,7 +253,7 @@ int do_mem_mwc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 }
 #endif /* CONFIG_MX_CYCLIC */
 
-int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong	addr1, addr2, count, ngood;
 	int	size;
@@ -323,7 +323,7 @@ int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return rcode;
 }
 
-int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong	addr, dest, count;
 	int	size;
@@ -433,7 +433,8 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return 0;
 }
 
-int do_mem_base (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_base(cmd_tbl_t *cmdtp, int flag, int argc,
+		       char * const argv[])
 {
 	if (argc > 1) {
 		/* Set new base address.
@@ -446,7 +447,8 @@ int do_mem_base (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return 0;
 }
 
-int do_mem_loop (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_loop(cmd_tbl_t *cmdtp, int flag, int argc,
+		       char * const argv[])
 {
 	ulong	addr, length, i;
 	int	size;
@@ -592,7 +594,8 @@ int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until
  * interrupted by ctrl-c or by a failure of one of the sub-tests.
  */
-int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
+			char * const argv[])
 {
 	vu_long	*addr, *start, *end;
 	ulong	val;
@@ -612,7 +615,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 #if defined(CONFIG_SYS_MEMTEST_SCRATCH)
 	vu_long *dummy = (vu_long*)CONFIG_SYS_MEMTEST_SCRATCH;
 #else
-	vu_long *dummy = 0;	/* yes, this is address 0x0, not NULL */
+	vu_long *dummy = NULL;	/* yes, this is address 0x0, not NULL */
 #endif
 	int	j;
 
@@ -1054,7 +1057,7 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
 
 #ifndef CONFIG_CRC32_VERIFY
 
-int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mem_crc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong addr, length;
 	ulong crc;
diff --git a/common/cmd_misc.c b/common/cmd_misc.c
index 3b47a0c..dc2772e 100644
--- a/common/cmd_misc.c
+++ b/common/cmd_misc.c
@@ -27,7 +27,7 @@
 #include <common.h>
 #include <command.h>
 
-int do_sleep (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_sleep(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong start = get_timer(0);
 	ulong delay;
@@ -38,10 +38,10 @@ int do_sleep (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	delay = simple_strtoul(argv[1], NULL, 10) * CONFIG_SYS_HZ;
 
 	while (get_timer(start) < delay) {
-		if (ctrlc ())
+		if (ctrlc())
 			return (-1);
 
-		udelay (100);
+		udelay(100);
 	}
 
 	return 0;
diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index 79a1088..62a1c22 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -115,7 +115,7 @@ static void print_mmcinfo(struct mmc *mmc)
 	printf("Bus Width: %d-bit\n", mmc->bus_width);
 }
 
-int do_mmcinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mmcinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	struct mmc *mmc;
 
@@ -147,7 +147,7 @@ U_BOOT_CMD(
 	"- dislay info of the current MMC device"
 );
 
-int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	enum mmc_state state;
 
@@ -269,7 +269,7 @@ int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			addr = (void *)simple_strtoul(argv[idx], NULL, 16);
 			++idx;
 		} else
-			addr = 0;
+			addr = NULL;
 		blk = simple_strtoul(argv[idx], NULL, 16);
 		cnt = simple_strtoul(argv[idx + 1], NULL, 16);
 
diff --git a/common/cmd_mp.c b/common/cmd_mp.c
index 4b27be4..2143814 100644
--- a/common/cmd_mp.c
+++ b/common/cmd_mp.c
@@ -23,7 +23,7 @@
 #include <common.h>
 #include <command.h>
 
-int
+static int
 cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	unsigned long cpuid;
@@ -61,8 +61,14 @@ cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return 0;
 }
 
+#ifdef CONFIG_SYS_LONGHELP
+static char cpu_help_text[] =
+	    "<num> reset                 - Reset cpu <num>\n"
+	"cpu <num> status                - Status of cpu <num>\n"
+	"cpu <num> disable               - Disable cpu <num>\n"
+	"cpu <num> release <addr> [args] - Release cpu <num> at <addr> with [args]"
 #ifdef CONFIG_PPC
-#define CPU_ARCH_HELP \
+	"\n"
 	"                         [args] : <pir> <r3> <r6>\n" \
 	"                                   pir - processor id (if writeable)\n" \
 	"                                    r3 - value for gpr 3\n" \
@@ -74,16 +80,10 @@ cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	"     When cpu <num> is released r4 and r5 = 0.\n" \
 	"     r7 will contain the size of the initial mapped area"
 #endif
+	"";
+#endif
 
 U_BOOT_CMD(
 	cpu, CONFIG_SYS_MAXARGS, 1, cpu_cmd,
-	"Multiprocessor CPU boot manipulation and release",
-	    "<num> reset                 - Reset cpu <num>\n"
-	"cpu <num> status                - Status of cpu <num>\n"
-	"cpu <num> disable               - Disable cpu <num>\n"
-	"cpu <num> release <addr> [args] - Release cpu <num> at <addr> with [args]"
-#ifdef CPU_ARCH_HELP
-	"\n"
-	CPU_ARCH_HELP
-#endif
+	"Multiprocessor CPU boot manipulation and release", cpu_help_text
 );
diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c
index 2268829..06fc171 100644
--- a/common/cmd_mtdparts.c
+++ b/common/cmd_mtdparts.c
@@ -147,10 +147,10 @@ static char last_partition[PARTITION_MAXLEN];
 extern void jffs2_free_cache(struct part_info *part);
 
 /* mtdids mapping list, filled by parse_ids() */
-struct list_head mtdids;
+static struct list_head mtdids;
 
 /* device/partition list, parse_cmdline() parses into here */
-struct list_head devices;
+static struct list_head devices;
 
 /* current active device and partition number */
 struct mtd_device *current_mtd_dev = NULL;
@@ -710,7 +710,7 @@ static int part_parse(const char *const partdef, const char **ret, struct part_i
  * @param size a pointer to the size of the mtd device (output)
  * @return 0 if device is valid, 1 otherwise
  */
-int mtd_device_validate(u8 type, u8 num, u32 *size)
+static int mtd_device_validate(u8 type, u8 num, u32 *size)
 {
 	struct mtd_info *mtd = NULL;
 
@@ -1042,7 +1042,8 @@ static struct mtdids* id_find_by_mtd_id(const char *mtd_id, unsigned int mtd_id_
  * @param dev_num parsed device number (output)
  * @return 0 on success, 1 otherwise
  */
-int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num)
+int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type,
+		 u8 *dev_num)
 {
 	const char *p = id;
 
@@ -1884,7 +1885,7 @@ static struct part_info* mtd_part_info(struct mtd_device *dev, unsigned int part
  * @param argv arguments list
  * @return 0 on success, 1 otherwise
  */
-int do_chpart(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_chpart(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 /* command line only */
 	struct mtd_device *dev;
@@ -1922,7 +1923,8 @@ int do_chpart(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  * @param argv arguments list
  * @return 0 on success, 1 otherwise
  */
-int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc,
+		       char * const argv[])
 {
 	if (argc == 2) {
 		if (strcmp(argv[1], "default") == 0) {
@@ -2046,9 +2048,8 @@ U_BOOT_CMD(
 	"    - change active partition (e.g. part-id = nand0,1)"
 );
 
-U_BOOT_CMD(
-	mtdparts,	6,	0,	do_mtdparts,
-	"define flash/nand partitions",
+#ifdef CONFIG_SYS_LONGHELP
+static char mtdparts_help_text[] =
 	"\n"
 	"    - list partition table\n"
 	"mtdparts delall\n"
@@ -2090,6 +2091,11 @@ U_BOOT_CMD(
 	"<size>     := standard linux memsize OR '-' to denote all remaining space\n"
 	"<offset>   := partition start offset within the device\n"
 	"<name>     := '(' NAME ')'\n"
-	"<ro-flag>  := when set to 'ro' makes partition read-only (not used, passed to kernel)"
+	"<ro-flag>  := when set to 'ro' makes partition read-only (not used, passed to kernel)";
+#endif
+
+U_BOOT_CMD(
+	mtdparts,	6,	0,	do_mtdparts,
+	"define flash/nand partitions", mtdparts_help_text
 );
 /***************************************************/
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index e24ed7f..4b16069 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -373,8 +373,7 @@ static void nand_print_and_set_info(int idx)
 {
 	nand_info_t *nand = &nand_info[idx];
 	struct nand_chip *chip = nand->priv;
-	const int bufsz = 32;
-	char buf[bufsz];
+	char buf[32];
 
 	printf("Device %d: ", idx);
 	if (chip->numchips > 1)
@@ -429,7 +428,7 @@ static int raw_access(nand_info_t *nand, ulong addr, loff_t off, ulong count,
 	return ret;
 }
 
-int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	int i, ret = 0;
 	ulong addr;
@@ -781,9 +780,8 @@ usage:
 	return CMD_RET_USAGE;
 }
 
-U_BOOT_CMD(
-	nand, CONFIG_SYS_MAXARGS, 1, do_nand,
-	"NAND sub-system",
+#ifdef CONFIG_SYS_LONGHELP
+static char nand_help_text[] =
 	"info - show available NAND devices\n"
 	"nand device [dev] - show or set current device\n"
 	"nand read - addr off|partition size\n"
@@ -829,6 +827,12 @@ U_BOOT_CMD(
 	"nand env.oob set off|partition - set enviromnent offset\n"
 	"nand env.oob get - get environment offset"
 #endif
+	"";
+#endif
+
+U_BOOT_CMD(
+	nand, CONFIG_SYS_MAXARGS, 1, do_nand,
+	"NAND sub-system", nand_help_text
 );
 
 static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
@@ -913,7 +917,8 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
 	return bootm_maybe_autostart(cmdtp, cmd);
 }
 
-int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+static int do_nandboot(cmd_tbl_t *cmdtp, int flag, int argc,
+		       char * const argv[])
 {
 	char *boot_device = NULL;
 	int idx;
diff --git a/common/cmd_net.c b/common/cmd_net.c
index a9ade8b..3b93ef2 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -30,9 +30,9 @@
 
 static int netboot_common(enum proto_t, cmd_tbl_t *, int, char * const []);
 
-int do_bootp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_bootp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-	return netboot_common (BOOTP, cmdtp, argc, argv);
+	return netboot_common(BOOTP, cmdtp, argc, argv);
 }
 
 U_BOOT_CMD(
@@ -41,7 +41,7 @@ U_BOOT_CMD(
 	"[loadAddress] [[hostIPaddr:]bootfilename]"
 );
 
-int do_tftpb (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	int ret;
 
@@ -91,9 +91,9 @@ U_BOOT_CMD(
 
 
 #ifdef CONFIG_CMD_RARP
-int do_rarpb (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+int do_rarpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-	return netboot_common (RARP, cmdtp, argc, argv);
+	return netboot_common(RARP, cmdtp, argc, argv);
 }
 
 U_BOOT_CMD(
@@ -104,7 +104,7 @@ U_BOOT_CMD(
 #endif
 
 #if defined(CONFIG_CMD_DHCP)
-int do_dhcp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_dhcp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	return netboot_common(DHCP, cmdtp, argc, argv);
 }
@@ -117,7 +117,7 @@ U_BOOT_CMD(
 #endif
 
 #if defined(CONFIG_CMD_NFS)
-int do_nfs (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_nfs(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	return netboot_common(NFS, cmdtp, argc, argv);
 }
@@ -129,29 +129,29 @@ U_BOOT_CMD(
 );
 #endif
 
-static void netboot_update_env (void)
+static void netboot_update_env(void)
 {
 	char tmp[22];
 
 	if (NetOurGatewayIP) {
-		ip_to_string (NetOurGatewayIP, tmp);
-		setenv ("gatewayip", tmp);
+		ip_to_string(NetOurGatewayIP, tmp);
+		setenv("gatewayip", tmp);
 	}
 
 	if (NetOurSubnetMask) {
-		ip_to_string (NetOurSubnetMask, tmp);
-		setenv ("netmask", tmp);
+		ip_to_string(NetOurSubnetMask, tmp);
+		setenv("netmask", tmp);
 	}
 
 	if (NetOurHostName[0])
-		setenv ("hostname", NetOurHostName);
+		setenv("hostname", NetOurHostName);
 
 	if (NetOurRootPath[0])
-		setenv ("rootpath", NetOurRootPath);
+		setenv("rootpath", NetOurRootPath);
 
 	if (NetOurIP) {
-		ip_to_string (NetOurIP, tmp);
-		setenv ("ipaddr", tmp);
+		ip_to_string(NetOurIP, tmp);
+		setenv("ipaddr", tmp);
 	}
 #if !defined(CONFIG_BOOTP_SERVERIP)
 	/*
@@ -159,35 +159,35 @@ static void netboot_update_env (void)
 	 * could have set it
 	 */
 	if (NetServerIP) {
-		ip_to_string (NetServerIP, tmp);
-		setenv ("serverip", tmp);
+		ip_to_string(NetServerIP, tmp);
+		setenv("serverip", tmp);
 	}
 #endif
 	if (NetOurDNSIP) {
-		ip_to_string (NetOurDNSIP, tmp);
-		setenv ("dnsip", tmp);
+		ip_to_string(NetOurDNSIP, tmp);
+		setenv("dnsip", tmp);
 	}
 #if defined(CONFIG_BOOTP_DNS2)
 	if (NetOurDNS2IP) {
-		ip_to_string (NetOurDNS2IP, tmp);
-		setenv ("dnsip2", tmp);
+		ip_to_string(NetOurDNS2IP, tmp);
+		setenv("dnsip2", tmp);
 	}
 #endif
 	if (NetOurNISDomain[0])
-		setenv ("domain", NetOurNISDomain);
+		setenv("domain", NetOurNISDomain);
 
 #if defined(CONFIG_CMD_SNTP) \
     && defined(CONFIG_BOOTP_TIMEOFFSET)
 	if (NetTimeOffset) {
-		sprintf (tmp, "%d", NetTimeOffset);
-		setenv ("timeoffset", tmp);
+		sprintf(tmp, "%d", NetTimeOffset);
+		setenv("timeoffset", tmp);
 	}
 #endif
 #if defined(CONFIG_CMD_SNTP) \
     && defined(CONFIG_BOOTP_NTPSERVER)
 	if (NetNtpServerIP) {
-		ip_to_string (NetNtpServerIP, tmp);
-		setenv ("ntpserverip", tmp);
+		ip_to_string(NetNtpServerIP, tmp);
+		setenv("ntpserverip", tmp);
 	}
 #endif
 }
@@ -224,7 +224,7 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc,
 		break;
 
 	case 3:	load_addr = simple_strtoul(argv[1], NULL, 16);
-		copy_filename (BootFile, argv[2], sizeof(BootFile));
+		copy_filename(BootFile, argv[2], sizeof(BootFile));
 
 		break;
 
@@ -274,7 +274,7 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc,
 }
 
 #if defined(CONFIG_CMD_PING)
-int do_ping (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_ping(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	if (argc < 2)
 		return -1;
@@ -322,7 +322,7 @@ static void cdp_update_env(void)
 
 }
 
-int do_cdp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+int do_cdp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	int r;
 
@@ -345,27 +345,29 @@ U_BOOT_CMD(
 #endif
 
 #if defined(CONFIG_CMD_SNTP)
-int do_sntp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+int do_sntp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	char *toff;
 
 	if (argc < 2) {
-		NetNtpServerIP = getenv_IPaddr ("ntpserverip");
+		NetNtpServerIP = getenv_IPaddr("ntpserverip");
 		if (NetNtpServerIP == 0) {
-			printf ("ntpserverip not set\n");
+			printf("ntpserverip not set\n");
 			return (1);
 		}
 	} else {
 		NetNtpServerIP = string_to_ip(argv[1]);
 		if (NetNtpServerIP == 0) {
-			printf ("Bad NTP server IP address\n");
+			printf("Bad NTP server IP address\n");
 			return (1);
 		}
 	}
 
-	toff = getenv ("timeoffset");
-	if (toff == NULL) NetTimeOffset = 0;
-	else NetTimeOffset = simple_strtol (toff, NULL, 10);
+	toff = getenv("timeoffset");
+	if (toff == NULL)
+		NetTimeOffset = 0;
+	else
+		NetTimeOffset = simple_strtol(toff, NULL, 10);
 
 	if (NetLoop(SNTP) < 0) {
 		printf("SNTP failed: host %pI4 not responding\n",
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 68c38f4..006131f 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -136,7 +136,8 @@ static int env_print(char *name)
 	return 0;
 }
 
-int do_env_print (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_env_print(cmd_tbl_t *cmdtp, int flag, int argc,
+			char * const argv[])
 {
 	int i;
 	int rcode = 0;
@@ -322,7 +323,7 @@ int env_check_apply(const char *name, const char *oldval,
  * Set a new environment variable,
  * or replace or delete an existing one.
 */
-int _do_env_set(int flag, int argc, char * const argv[])
+static int _do_env_set(int flag, int argc, char * const argv[])
 {
 	int   i, len;
 	char  *name, *value, *s;
@@ -435,7 +436,7 @@ int setenv_addr(const char *varname, const void *addr)
 }
 
 #ifndef CONFIG_SPL_BUILD
-int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	if (argc < 2)
 		return CMD_RET_USAGE;
@@ -514,7 +515,8 @@ int do_env_ask(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  * Interactively edit an environment variable
  */
 #if defined(CONFIG_CMD_EDITENV)
-int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc,
+		       char * const argv[])
 {
 	char buffer[CONFIG_SYS_CBSIZE];
 	char *init_val;
@@ -622,7 +624,8 @@ ulong getenv_ulong(const char *name, int base, ulong default_val)
 
 #ifndef CONFIG_SPL_BUILD
 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
-int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc,
+		       char * const argv[])
 {
 	printf("Saving Environment to %s...\n", env_name_spec);
 
@@ -1020,9 +1023,8 @@ static int do_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return CMD_RET_USAGE;
 }
 
-U_BOOT_CMD(
-	env, CONFIG_SYS_MAXARGS, 1, do_env,
-	"environment handling commands",
+#ifdef CONFIG_SYS_LONGHELP
+static char env_help_text[] =
 #if defined(CONFIG_CMD_ASKENV)
 	"ask name [message] [size] - ask for environment variable\nenv "
 #endif
@@ -1047,7 +1049,12 @@ U_BOOT_CMD(
 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
 	"env save - save environment\n"
 #endif
-	"env set [-f] name [arg ...]\n"
+	"env set [-f] name [arg ...]\n";
+#endif
+
+U_BOOT_CMD(
+	env, CONFIG_SYS_MAXARGS, 1, do_env,
+	"environment handling commands", env_help_text
 );
 
 /*
diff --git a/common/cmd_pci.c b/common/cmd_pci.c
index a1fe519..8550b64 100644
--- a/common/cmd_pci.c
+++ b/common/cmd_pci.c
@@ -35,8 +35,6 @@
 #include <asm/io.h>
 #include <pci.h>
 
-unsigned char	ShortPCIListing = 1;
-
 /*
  * Follows routines for the output of infos about devices on PCI bus.
  */
@@ -408,7 +406,7 @@ pci_cfg_modify (pci_dev_t bdf, ulong addr, ulong size, ulong value, int incrflag
  *      pci modify[.b, .w, .l] bus.device.function [addr]
  *      pci write[.b, .w, .l] bus.device.function addr value
  */
-int do_pci (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong addr = 0, value = 0, size = 0;
 	pci_dev_t bdf = 0;
@@ -485,10 +483,8 @@ int do_pci (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 /***************************************************/
 
-
-U_BOOT_CMD(
-	pci,	5,	1,	do_pci,
-	"list and access PCI Configuration Space",
+#ifdef CONFIG_SYS_LONGHELP
+static char pci_help_text[] =
 	"[bus] [long]\n"
 	"    - short or long list of PCI devices on bus 'bus'\n"
 #ifdef CONFIG_CMD_PCI_ENUM
@@ -504,5 +500,10 @@ U_BOOT_CMD(
 	"pci modify[.b, .w, .l] b.d.f address\n"
 	"    -  modify, auto increment CFG address\n"
 	"pci write[.b, .w, .l] b.d.f address value\n"
-	"    - write to CFG address"
+	"    - write to CFG address";
+#endif
+
+U_BOOT_CMD(
+	pci,	5,	1,	do_pci,
+	"list and access PCI Configuration Space", pci_help_text
 );
diff --git a/common/cmd_reginfo.c b/common/cmd_reginfo.c
index 908876c..08a6563 100644
--- a/common/cmd_reginfo.c
+++ b/common/cmd_reginfo.c
@@ -37,7 +37,8 @@ extern void mpc86xx_reginfo(void);
 extern void mpc85xx_reginfo(void);
 #endif
 
-int do_reginfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_reginfo(cmd_tbl_t *cmdtp, int flag, int argc,
+		       char * const argv[])
 {
 #if defined(CONFIG_8xx)
 	volatile immap_t     *immap  = (immap_t *)CONFIG_SYS_IMMR;
diff --git a/common/cmd_sata.c b/common/cmd_sata.c
index 3f98235..b401bd1 100644
--- a/common/cmd_sata.c
+++ b/common/cmd_sata.c
@@ -28,7 +28,7 @@
 #include <part.h>
 #include <sata.h>
 
-int sata_curr_device = -1;
+static int sata_curr_device = -1;
 block_dev_desc_t sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE];
 
 int __sata_initialize(void)
@@ -67,7 +67,7 @@ block_dev_desc_t *sata_get_dev(int dev)
 }
 #endif
 
-int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	int rc = 0;
 
diff --git a/common/cmd_setexpr.c b/common/cmd_setexpr.c
index 1b3edb7..7b140de 100644
--- a/common/cmd_setexpr.c
+++ b/common/cmd_setexpr.c
@@ -50,7 +50,7 @@ static ulong get_arg(char *s, int w)
 	}
 }
 
-int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong a, b;
 	char buf[16];
diff --git a/common/cmd_source.c b/common/cmd_source.c
index c4cde98..02a862c 100644
--- a/common/cmd_source.c
+++ b/common/cmd_source.c
@@ -177,9 +177,8 @@ do_source (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return rcode;
 }
 
-U_BOOT_CMD(
-	source, 2, 0,	do_source,
-	"run script from memory",
+#ifdef CONFIG_SYS_LONGHELP
+static char source_help_text[] =
 	"[addr]\n"
 	"\t- run script starting at addr\n"
 	"\t- A valid image header must be present"
@@ -188,5 +187,11 @@ U_BOOT_CMD(
 	"For FIT format uImage addr must include subimage\n"
 	"unit name in the form of addr:<subimg_uname>"
 #endif
+	"";
+#endif
+
+U_BOOT_CMD(
+	source, 2, 0,	do_source,
+	"run script from memory", source_help_text
 );
 #endif
diff --git a/common/cmd_test.c b/common/cmd_test.c
index 6da06b9..d4ec186 100644
--- a/common/cmd_test.c
+++ b/common/cmd_test.c
@@ -24,7 +24,7 @@
 #include <common.h>
 #include <command.h>
 
-int do_test(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_test(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	char * const *ap;
 	int left, adv, expr, last_expr, neg, last_cmp;
@@ -150,7 +150,7 @@ U_BOOT_CMD(
 	"[args..]"
 );
 
-int do_false(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_false(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	return 1;
 }
@@ -161,7 +161,7 @@ U_BOOT_CMD(
 	NULL
 );
 
-int do_true(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_true(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	return 0;
 }
diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index c128455..8ad0b23 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -40,7 +40,7 @@ static int usb_ether_curr_dev = -1; /* current ethernet device */
 #endif
 
 /* some display routines (info command) */
-char *usb_get_class_desc(unsigned char dclass)
+static char *usb_get_class_desc(unsigned char dclass)
 {
 	switch (dclass) {
 	case USB_CLASS_PER_INTERFACE:
@@ -66,8 +66,8 @@ char *usb_get_class_desc(unsigned char dclass)
 	}
 }
 
-void usb_display_class_sub(unsigned char dclass, unsigned char subclass,
-			   unsigned char proto)
+static void usb_display_class_sub(unsigned char dclass, unsigned char subclass,
+				  unsigned char proto)
 {
 	switch (dclass) {
 	case USB_CLASS_PER_INTERFACE:
@@ -148,7 +148,7 @@ void usb_display_class_sub(unsigned char dclass, unsigned char subclass,
 	}
 }
 
-void usb_display_string(struct usb_device *dev, int index)
+static void usb_display_string(struct usb_device *dev, int index)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(char, buffer, 256);
 
@@ -158,7 +158,7 @@ void usb_display_string(struct usb_device *dev, int index)
 	}
 }
 
-void usb_display_desc(struct usb_device *dev)
+static void usb_display_desc(struct usb_device *dev)
 {
 	if (dev->descriptor.bDescriptorType == USB_DT_DEVICE) {
 		printf("%d: %s,  USB Revision %x.%x\n", dev->devnum,
@@ -192,8 +192,8 @@ void usb_display_desc(struct usb_device *dev)
 
 }
 
-void usb_display_conf_desc(struct usb_configuration_descriptor *config,
-			   struct usb_device *dev)
+static void usb_display_conf_desc(struct usb_configuration_descriptor *config,
+				  struct usb_device *dev)
 {
 	printf("   Configuration: %d\n", config->bConfigurationValue);
 	printf("   - Interfaces: %d %s%s%dmA\n", config->bNumInterfaces,
@@ -207,8 +207,8 @@ void usb_display_conf_desc(struct usb_configuration_descriptor *config,
 	}
 }
 
-void usb_display_if_desc(struct usb_interface_descriptor *ifdesc,
-			 struct usb_device *dev)
+static void usb_display_if_desc(struct usb_interface_descriptor *ifdesc,
+				struct usb_device *dev)
 {
 	printf("     Interface: %d\n", ifdesc->bInterfaceNumber);
 	printf("     - Alternate Setting %d, Endpoints: %d\n",
@@ -224,7 +224,7 @@ void usb_display_if_desc(struct usb_interface_descriptor *ifdesc,
 	}
 }
 
-void usb_display_ep_desc(struct usb_endpoint_descriptor *epdesc)
+static void usb_display_ep_desc(struct usb_endpoint_descriptor *epdesc)
 {
 	printf("     - Endpoint %d %s ", epdesc->bEndpointAddress & 0xf,
 		(epdesc->bEndpointAddress & 0x80) ? "In" : "Out");
@@ -249,7 +249,7 @@ void usb_display_ep_desc(struct usb_endpoint_descriptor *epdesc)
 }
 
 /* main routine to diasplay the configs, interfaces and endpoints */
-void usb_display_config(struct usb_device *dev)
+static void usb_display_config(struct usb_device *dev)
 {
 	struct usb_config *config;
 	struct usb_interface *ifdesc;
@@ -280,7 +280,7 @@ static inline char *portspeed(int speed)
 }
 
 /* shows the device tree recursively */
-void usb_show_tree_graph(struct usb_device *dev, char *pre)
+static void usb_show_tree_graph(struct usb_device *dev, char *pre)
 {
 	int i, index;
 	int has_child, last_child;
@@ -340,7 +340,7 @@ void usb_show_tree_graph(struct usb_device *dev, char *pre)
 }
 
 /* main routine for the tree command */
-void usb_show_tree(struct usb_device *dev)
+static void usb_show_tree(struct usb_device *dev)
 {
 	char preamble[32];
 
@@ -353,7 +353,7 @@ void usb_show_tree(struct usb_device *dev)
  * usb boot command intepreter. Derived from diskboot
  */
 #ifdef CONFIG_USB_STORAGE
-int do_usbboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_usbboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	return common_diskboot(cmdtp, "usb", argc, argv);
 }
@@ -363,7 +363,7 @@ int do_usbboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 /******************************************************************************
  * usb command intepreter
  */
-int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 
 	int i;
diff --git a/common/cmd_version.c b/common/cmd_version.c
index e4b2ac1..ab4c560 100644
--- a/common/cmd_version.c
+++ b/common/cmd_version.c
@@ -28,7 +28,7 @@
 
 const char __weak version_string[] = U_BOOT_VERSION_STRING;
 
-int do_version(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_version(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	printf("\n%s\n", version_string);
 #ifdef CC_VERSION_STRING
diff --git a/common/cmd_ximg.c b/common/cmd_ximg.c
index 0414589..42a7eba 100644
--- a/common/cmd_ximg.c
+++ b/common/cmd_ximg.c
@@ -42,7 +42,7 @@
 #define CONFIG_SYS_XIMG_LEN	0x800000
 #endif
 
-int
+static int
 do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong		addr = load_addr;
@@ -264,9 +264,8 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 	return 0;
 }
 
-U_BOOT_CMD(
-	imxtract, 4, 1, do_imgextract,
-	"extract a part of a multi-image",
+#ifdef CONFIG_SYS_LONGHELP
+static char imgextract_help_text[] =
 	"addr part [dest]\n"
 	"    - extract <part> from legacy image at <addr> and copy to <dest>"
 #if defined(CONFIG_FIT)
@@ -274,4 +273,10 @@ U_BOOT_CMD(
 	"addr uname [dest]\n"
 	"    - extract <uname> subimage from FIT image at <addr> and copy to <dest>"
 #endif
+	"";
+#endif
+
+U_BOOT_CMD(
+	imxtract, 4, 1, do_imgextract,
+	"extract a part of a multi-image", imgextract_help_text
 );
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 10/25] common/misc: sparse fixes
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (8 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 09/25] common/cmd_*.c: " Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-11-05 21:30     ` Henrik Nordström
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 11/25] net/: sparse fixes Kim Phillips
                     ` (15 subsequent siblings)
  25 siblings, 1 reply; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

command.c:44:38: error: bad constant expression
dlmalloc.c:1468:2: warning: Using plain integer as NULL pointer
dlmalloc.c:1468:5: warning: Using plain integer as NULL pointer
dlmalloc.c:2176:12: warning: Using plain integer as NULL pointer
dlmalloc.c:2179:31: warning: Using plain integer as NULL pointer
dlmalloc.c:2382:14: warning: Using plain integer as NULL pointer
dlmalloc.c:2436:14: warning: Using plain integer as NULL pointer
dlmalloc.c:2582:31: warning: Using plain integer as NULL pointer
dlmalloc.c:2585:17: warning: Using plain integer as NULL pointer
dlmalloc.c:2646:14: warning: Using plain integer as NULL pointer
dlmalloc.c:2659:19: warning: Using plain integer as NULL pointer
dlmalloc.c:2692:19: warning: Using plain integer as NULL pointer
dlmalloc.c:2707:19: warning: Using plain integer as NULL pointer
dlmalloc.c:2708:14: warning: Using plain integer as NULL pointer
dlmalloc.c:2786:31: warning: Using plain integer as NULL pointer
dlmalloc.c:2801:12: warning: Using plain integer as NULL pointer
dlmalloc.c:2801:22: warning: Using plain integer as NULL pointer
dlmalloc.c:2926:27: warning: Using plain integer as NULL pointer
dlmalloc.c:2928:14: warning: Using plain integer as NULL pointer
dlmalloc.c:2929:12: warning: Using plain integer as NULL pointer
dlmalloc.c:3075:14: warning: Using plain integer as NULL pointer
hush.c:292:14: warning: symbol 'last_return_code' was not declared. Should it be static?
hush.c:293:5: warning: symbol 'nesting_level' was not declared. Should it be static?
hush.c:2175:20: warning: Using plain integer as NULL pointer
hush.c:2175:34: warning: Using plain integer as NULL pointer
hush.c:2210:41: warning: Using plain integer as NULL pointer
hush.c:2216:45: warning: Using plain integer as NULL pointer
hush.c:2249:25: warning: Using plain integer as NULL pointer
hush.c:2332:13: warning: symbol 'new_pipe' was not declared. Should it be static?
hush.c:2390:5: warning: symbol 'reserved_word' was not declared. Should it be static?
hush.c:2927:5: warning: symbol 'parse_stream' was not declared. Should it be static?
hush.c:3127:6: warning: symbol 'mapset' was not declared. Should it be static?
hush.c:3133:6: warning: symbol 'update_ifs_map' was not declared. Should it be static?
hush.c:3161:5: warning: symbol 'parse_stream_outer' was not declared. Should it be static?
hush.c:3295:34: warning: Using plain integer as NULL pointer
hush.c:3631:5: warning: symbol 'do_showvar' was not declared. Should it be static
image.c:1282:29: warning: Using plain integer as NULL pointer
image.c:1315:41: warning: Using plain integer as NULL pointer
image.c:1330:25: warning: Using plain integer as NULL pointer
image.c:1706:25: warning: Using plain integer as NULL pointer
main.c:510:10: warning: symbol 'hist_num' was not declared. Should it be static?
main.c:512:5: warning: symbol 'hist_list' was not declared. Should it be static?
main.c:513:6: warning: symbol 'hist_lines' was not declared. Should it be static?
usb_storage.c:195:6: warning: symbol 'usb_show_progress' was not declared. Should it be static?
usb_storage.c:440:48: warning: Using plain integer as NULL pointer
usb_storage.c:503:5: warning: symbol 'usb_stor_BBB_comdat' was not declared. Should it be static?
usb_storage.c:551:5: warning: symbol 'usb_stor_CB_comdat' was not declared. Should it be static?
usb_storage.c:629:55: warning: Using plain integer as NULL pointer
usb_storage.c:620:5: warning: symbol 'usb_stor_CBI_get_status' was not declared. Should it be static?
usb_storage.c:675:43: warning: Using plain integer as NULL pointer
usb_storage.c:668:5: warning: symbol 'usb_stor_BBB_clear_endpt_stall' was not declared. Should it be static?
usb_storage.c:679:5: warning: symbol 'usb_stor_BBB_transport' was not declared. Should it be static?
usb_storage.c:801:5: warning: symbol 'usb_stor_CB_transport' was not declared. Sh
xyzModem.c:104:1: warning: symbol 'CYGACC_COMM_IF_GETC_TIMEOUT' was not declared. Should it be static?
xyzModem.c:122:1: warning: symbol 'CYGACC_COMM_IF_PUTC' was not declared. Should it be static?
xyzModem.c:169:1: warning: symbol 'parse_num' was not declared. Should it be stat

note: hush.c's nesting_level deleted because not used.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: un-static search_device, it is being used elsewhere. Tested on
netspace_lite_v2:

console.c:537:18: warning: symbol 'search_device' was not declared. Should it be static?

v2 also added checkpatch fixes, except for dlmalloc, which needs a
_lot_ of work.

 common/command.c     |  9 ++++++++-
 common/dlmalloc.c    | 36 ++++++++++++++++++------------------
 common/hush.c        | 31 ++++++++++++++++---------------
 common/image.c       |  8 ++++----
 common/main.c        | 10 +++++-----
 common/usb_storage.c | 20 ++++++++++----------
 common/xyzModem.c    |  6 +++---
 7 files changed, 64 insertions(+), 56 deletions(-)

diff --git a/common/command.c b/common/command.c
index 50c8429..f51df26 100644
--- a/common/command.c
+++ b/common/command.c
@@ -40,8 +40,15 @@ int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
 	int i;
 	int rcode = 0;
 
+	if (cmd_items > CONFIG_SYS_MAXARGS) {
+		printf("%s: cmd_items %d exceeds hardcoded limit %d."
+		       " Recompile with higher CONFIG_SYS_MAXARGS?\n",
+		       __func__, cmd_items, CONFIG_SYS_MAXARGS);
+		return -1;
+	}
+
 	if (argc == 1) {	/*show list of commands */
-		cmd_tbl_t *cmd_array[cmd_items];
+		cmd_tbl_t *cmd_array[CONFIG_SYS_MAXARGS];
 		int i, j, swaps;
 
 		/* Make array of commands from .uboot_cmd section */
diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index 1d7e527..b2f0a1a 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -1465,7 +1465,7 @@ typedef struct malloc_chunk* mbinptr;
 #define IAV(i)  bin_at(i), bin_at(i)
 
 static mbinptr av_[NAV * 2 + 2] = {
- 0, 0,
+ NULL, NULL,
  IAV(0),   IAV(1),   IAV(2),   IAV(3),   IAV(4),   IAV(5),   IAV(6),   IAV(7),
  IAV(8),   IAV(9),   IAV(10),  IAV(11),  IAV(12),  IAV(13),  IAV(14),  IAV(15),
  IAV(16),  IAV(17),  IAV(18),  IAV(19),  IAV(20),  IAV(21),  IAV(22),  IAV(23),
@@ -2173,10 +2173,10 @@ Void_t* mALLOc(bytes) size_t bytes;
   /* check if mem_malloc_init() was run */
   if ((mem_malloc_start == 0) && (mem_malloc_end == 0)) {
     /* not initialized yet */
-    return 0;
+    return NULL;
   }
 
-  if ((long)bytes < 0) return 0;
+  if ((long)bytes < 0) return NULL;
 
   nb = request2size(bytes);  /* padded request size; */
 
@@ -2379,7 +2379,7 @@ Void_t* mALLOc(bytes) size_t bytes;
     /* Try to extend */
     malloc_extend_top(nb);
     if ( (remainder_size = chunksize(top) - nb) < (long)MINSIZE)
-      return 0; /* propagate failure */
+      return NULL; /* propagate failure */
   }
 
   victim = top;
@@ -2433,7 +2433,7 @@ void fREe(mem) Void_t* mem;
   mchunkptr fwd;       /* misc temp for linking */
   int       islr;      /* track whether merging with last_remainder */
 
-  if (mem == 0)                              /* free(0) has no effect */
+  if (mem == NULL)                              /* free(0) has no effect */
     return;
 
   p = mem2chunk(mem);
@@ -2579,10 +2579,10 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
   if (bytes == 0) { fREe(oldmem); return 0; }
 #endif
 
-  if ((long)bytes < 0) return 0;
+  if ((long)bytes < 0) return NULL;
 
   /* realloc of null is supposed to be same as malloc */
-  if (oldmem == 0) return mALLOc(bytes);
+  if (oldmem == NULL) return mALLOc(bytes);
 
   newp    = oldp    = mem2chunk(oldmem);
   newsize = oldsize = chunksize(oldp);
@@ -2643,7 +2643,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
     }
     else
     {
-      next = 0;
+      next = NULL;
       nextsize = 0;
     }
 
@@ -2656,7 +2656,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
 
       /* try forward + backward first to save a later consolidation */
 
-      if (next != 0)
+      if (next != NULL)
       {
 	/* into top */
 	if (next == top)
@@ -2689,7 +2689,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
       }
 
       /* backward only */
-      if (prev != 0 && (long)(prevsize + newsize) >= (long)nb)
+      if (prev != NULL && (long)(prevsize + newsize) >= (long)nb)
       {
 	unlink(prev, bck, fwd);
 	newp = prev;
@@ -2704,8 +2704,8 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
 
     newmem = mALLOc (bytes);
 
-    if (newmem == 0)  /* propagate failure */
-      return 0;
+    if (newmem == NULL)  /* propagate failure */
+      return NULL;
 
     /* Avoid copy if newp is next chunk after oldp. */
     /* (This can only happen when new chunk is sbrk'ed.) */
@@ -2783,7 +2783,7 @@ Void_t* mEMALIGn(alignment, bytes) size_t alignment; size_t bytes;
   mchunkptr remainder;        /* spare room at end to split off */
   long      remainder_size;   /* its size */
 
-  if ((long)bytes < 0) return 0;
+  if ((long)bytes < 0) return NULL;
 
   /* If need less alignment than we give anyway, just relay to malloc */
 
@@ -2798,7 +2798,7 @@ Void_t* mEMALIGn(alignment, bytes) size_t alignment; size_t bytes;
   nb = request2size(bytes);
   m  = (char*)(mALLOc(nb + alignment + MINSIZE));
 
-  if (m == 0) return 0; /* propagate failure */
+  if (m == NULL) return NULL; /* propagate failure */
 
   p = mem2chunk(m);
 
@@ -2923,10 +2923,10 @@ Void_t* cALLOc(n, elem_size) size_t n; size_t elem_size;
 #endif
   Void_t* mem = mALLOc (sz);
 
-  if ((long)n < 0) return 0;
+  if ((long)n < 0) return NULL;
 
-  if (mem == 0)
-    return 0;
+  if (mem == NULL)
+    return NULL;
   else
   {
     p = mem2chunk(mem);
@@ -3072,7 +3072,7 @@ size_t malloc_usable_size(mem) Void_t* mem;
 #endif
 {
   mchunkptr p;
-  if (mem == 0)
+  if (mem == NULL)
     return 0;
   else
   {
diff --git a/common/hush.c b/common/hush.c
index 4c84c2f..eb6c879 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -289,8 +289,7 @@ struct variables {
 char **global_argv;
 unsigned int global_argc;
 #endif
-unsigned int last_return_code;
-int nesting_level;
+static unsigned int last_return_code;
 #ifndef __U_BOOT__
 extern char **environ; /* This is in <unistd.h>, but protected with __USE_GNU */
 #endif
@@ -2172,7 +2171,7 @@ int set_local_var(const char *s, int flg_export)
 	 * NAME=VALUE format.  So the first order of business is to
 	 * split 's' on the '=' into 'name' and 'value' */
 	value = strchr(name, '=');
-	if (value==0 && ++value==0) {
+	if (value == NULL && ++value == NULL) {
 		free(name);
 		return -1;
 	}
@@ -2207,13 +2206,13 @@ int set_local_var(const char *s, int flg_export)
 			result = -1;
 		} else {
 			cur->name = strdup(name);
-			if(cur->name == 0) {
+			if (cur->name == NULL) {
 				free(cur);
 				result = -1;
 			} else {
 				struct variables *bottom = top_vars;
 				cur->value = strdup(value);
-				cur->next = 0;
+				cur->next = NULL;
 				cur->flg_export = flg_export;
 				cur->flg_read_only = 0;
 				while(bottom->next) bottom=bottom->next;
@@ -2246,7 +2245,7 @@ void unset_local_var(const char *name)
 			if(strcmp(cur->name, name)==0)
 				break;
 		}
-		if(cur!=0) {
+		if (cur != NULL) {
 			struct variables *next = top_vars;
 			if(cur->flg_read_only) {
 				error_msg("%s: readonly variable", name);
@@ -2329,7 +2328,8 @@ static int setup_redirect(struct p_context *ctx, int fd, redir_type style,
 }
 #endif
 
-struct pipe *new_pipe(void) {
+static struct pipe *new_pipe(void)
+{
 	struct pipe *pi;
 	pi = xmalloc(sizeof(struct pipe));
 	pi->num_progs = 0;
@@ -2387,7 +2387,7 @@ static struct reserved_combo reserved_list[] = {
 };
 #define NRES (sizeof(reserved_list)/sizeof(struct reserved_combo))
 
-int reserved_word(o_string *dest, struct p_context *ctx)
+static int reserved_word(o_string *dest, struct p_context *ctx)
 {
 	struct reserved_combo *r;
 	for (r=reserved_list;
@@ -2924,8 +2924,8 @@ int parse_string(o_string *dest, struct p_context *ctx, const char *src)
 #endif
 
 /* return code is 0 for normal exit, 1 for syntax error */
-int parse_stream(o_string *dest, struct p_context *ctx,
-	struct in_str *input, int end_trigger)
+static int parse_stream(o_string *dest, struct p_context *ctx,
+			struct in_str *input, int end_trigger)
 {
 	unsigned int ch, m;
 #ifndef __U_BOOT__
@@ -3124,13 +3124,13 @@ int parse_stream(o_string *dest, struct p_context *ctx,
 	return 0;
 }
 
-void mapset(const unsigned char *set, int code)
+static void mapset(const unsigned char *set, int code)
 {
 	const unsigned char *s;
 	for (s=set; *s; s++) map[*s] = code;
 }
 
-void update_ifs_map(void)
+static void update_ifs_map(void)
 {
 	/* char *ifs and char map[256] are both globals. */
 	ifs = (uchar *)getenv("IFS");
@@ -3158,7 +3158,7 @@ void update_ifs_map(void)
 
 /* most recursion does not come through here, the exeception is
  * from builtin_source() */
-int parse_stream_outer(struct in_str *inp, int flag)
+static int parse_stream_outer(struct in_str *inp, int flag)
 {
 
 	struct p_context ctx;
@@ -3292,7 +3292,7 @@ int u_boot_hush_start(void)
 		top_vars = malloc(sizeof(struct variables));
 		top_vars->name = "HUSH_VERSION";
 		top_vars->value = "0.01";
-		top_vars->next = 0;
+		top_vars->next = NULL;
 		top_vars->flg_export = 0;
 		top_vars->flg_read_only = 1;
 #ifdef CONFIG_NEEDS_MANUAL_RELOC
@@ -3628,7 +3628,8 @@ static char * make_string(char ** inp)
 }
 
 #ifdef __U_BOOT__
-int do_showvar (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_showvar(cmd_tbl_t *cmdtp, int flag, int argc,
+		      char * const argv[])
 {
 	int i, k;
 	int rcode = 0;
diff --git a/common/image.c b/common/image.c
index 750a98b..df642e6 100644
--- a/common/image.c
+++ b/common/image.c
@@ -1279,7 +1279,7 @@ void boot_fdt_add_mem_rsv_regions(struct lmb *lmb, void *fdt_blob)
 int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size)
 {
 	void	*fdt_blob = *of_flat_tree;
-	void	*of_start = 0;
+	void	*of_start = NULL;
 	char	*fdt_high;
 	ulong	of_len = 0;
 	int	err;
@@ -1312,7 +1312,7 @@ int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size)
 			of_start =
 			    (void *)(ulong) lmb_alloc_base(lmb, of_len, 0x1000,
 							   (ulong)desired_addr);
-			if (of_start == 0) {
+			if (of_start == NULL) {
 				puts("Failed using fdt_high value for Device Tree");
 				goto error;
 			}
@@ -1327,7 +1327,7 @@ int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size)
 						   + getenv_bootm_low());
 	}
 
-	if (of_start == 0) {
+	if (of_start == NULL) {
 		puts("device tree - allocation error\n");
 		goto error;
 	}
@@ -1703,7 +1703,7 @@ int boot_get_fdt(int flag, int argc, char * const argv[],
 	return 0;
 
 error:
-	*of_flat_tree = 0;
+	*of_flat_tree = NULL;
 	*of_size = 0;
 	return 1;
 }
diff --git a/common/main.c b/common/main.c
index 9507cec..592ce07 100644
--- a/common/main.c
+++ b/common/main.c
@@ -505,13 +505,13 @@ void reset_cmd_timeout(void)
 #define HIST_MAX		20
 #define HIST_SIZE		CONFIG_SYS_CBSIZE
 
-static int hist_max = 0;
-static int hist_add_idx = 0;
+static int hist_max;
+static int hist_add_idx;
 static int hist_cur = -1;
-unsigned hist_num = 0;
+static unsigned hist_num;
 
-char* hist_list[HIST_MAX];
-char hist_lines[HIST_MAX][HIST_SIZE + 1];	 /* Save room for NULL */
+static char *hist_list[HIST_MAX];
+static char hist_lines[HIST_MAX][HIST_SIZE + 1];	/* Save room for NULL */
 
 #define add_idx_minus_one() ((hist_add_idx == 0) ? hist_max : hist_add_idx-1)
 
diff --git a/common/usb_storage.c b/common/usb_storage.c
index 0c2a4c7..2d92ee1 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -192,7 +192,7 @@ block_dev_desc_t *usb_stor_get_dev(int index)
 }
 #endif
 
-void usb_show_progress(void)
+static void usb_show_progress(void)
 {
 	debug(".");
 }
@@ -437,7 +437,7 @@ static int usb_stor_BBB_reset(struct us_data *us)
 	result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev, 0),
 				 US_BBB_RESET,
 				 USB_TYPE_CLASS | USB_RECIP_INTERFACE,
-				 0, us->ifnum, 0, 0, USB_CNTL_TIMEOUT * 5);
+				 0, us->ifnum, NULL, 0, USB_CNTL_TIMEOUT * 5);
 
 	if ((result < 0) && (us->pusb_dev->status & USB_ST_STALLED)) {
 		USB_STOR_PRINTF("RESET:stall\n");
@@ -500,7 +500,7 @@ static int usb_stor_CB_reset(struct us_data *us)
  * Set up the command for a BBB device. Note that the actual SCSI
  * command is copied into cbw.CBWCDB.
  */
-int usb_stor_BBB_comdat(ccb *srb, struct us_data *us)
+static int usb_stor_BBB_comdat(ccb *srb, struct us_data *us)
 {
 	int result;
 	int actlen;
@@ -548,7 +548,7 @@ int usb_stor_BBB_comdat(ccb *srb, struct us_data *us)
 /* FIXME: we also need a CBI_command which sets up the completion
  * interrupt, and waits for it
  */
-int usb_stor_CB_comdat(ccb *srb, struct us_data *us)
+static int usb_stor_CB_comdat(ccb *srb, struct us_data *us)
 {
 	int result = 0;
 	int dir_in, retry;
@@ -617,7 +617,7 @@ int usb_stor_CB_comdat(ccb *srb, struct us_data *us)
 }
 
 
-int usb_stor_CBI_get_status(ccb *srb, struct us_data *us)
+static int usb_stor_CBI_get_status(ccb *srb, struct us_data *us)
 {
 	int timeout;
 
@@ -626,7 +626,7 @@ int usb_stor_CBI_get_status(ccb *srb, struct us_data *us)
 			(void *) &us->ip_data, us->irqmaxp, us->irqinterval);
 	timeout = 1000;
 	while (timeout--) {
-		if ((volatile int *) us->ip_wanted == 0)
+		if ((volatile int *) us->ip_wanted == NULL)
 			break;
 		mdelay(10);
 	}
@@ -665,18 +665,18 @@ int usb_stor_CBI_get_status(ccb *srb, struct us_data *us)
 #define USB_TRANSPORT_NOT_READY_RETRY 10
 
 /* clear a stall on an endpoint - special for BBB devices */
-int usb_stor_BBB_clear_endpt_stall(struct us_data *us, __u8 endpt)
+static int usb_stor_BBB_clear_endpt_stall(struct us_data *us, __u8 endpt)
 {
 	int result;
 
 	/* ENDPOINT_HALT = 0, so set value to 0 */
 	result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev, 0),
 				USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT,
-				0, endpt, 0, 0, USB_CNTL_TIMEOUT * 5);
+				0, endpt, NULL, 0, USB_CNTL_TIMEOUT * 5);
 	return result;
 }
 
-int usb_stor_BBB_transport(ccb *srb, struct us_data *us)
+static int usb_stor_BBB_transport(ccb *srb, struct us_data *us)
 {
 	int result, retry;
 	int dir_in;
@@ -798,7 +798,7 @@ again:
 	return result;
 }
 
-int usb_stor_CB_transport(ccb *srb, struct us_data *us)
+static int usb_stor_CB_transport(ccb *srb, struct us_data *us)
 {
 	int result, status;
 	ccb *psrb;
diff --git a/common/xyzModem.c b/common/xyzModem.c
index a1f955b..f30b002 100644
--- a/common/xyzModem.c
+++ b/common/xyzModem.c
@@ -100,7 +100,7 @@ static struct
 
 #ifndef REDBOOT			/*SB */
 typedef int cyg_int32;
-int
+static int
 CYGACC_COMM_IF_GETC_TIMEOUT (char chan, char *c)
 {
 #define DELAY 20
@@ -118,7 +118,7 @@ CYGACC_COMM_IF_GETC_TIMEOUT (char chan, char *c)
   return 0;
 }
 
-void
+static void
 CYGACC_COMM_IF_PUTC (char x, char y)
 {
   putc (y);
@@ -165,7 +165,7 @@ _tolower (char c)
 }
 
 /* Parse (scan) a number */
-bool
+static bool
 parse_num (char *s, unsigned long *val, char **es, char *delim)
 {
   bool first = true;
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 11/25] net/: sparse fixes
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (9 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 10/25] common/misc: " Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 12/25] drivers/net/: " Kim Phillips
                     ` (14 subsequent siblings)
  25 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

bootp.c:44:14: warning: symbol 'dhcp_state' was not declared. Should it be static?
bootp.c:45:15: warning: symbol 'dhcp_leasetime' was not declared. Should it be static?
bootp.c:46:10: warning: symbol 'NetDHCPServerIP' was not declared. Should it be static?
arp.c:30:17: warning: symbol 'NetArpWaitReplyIP' was not declared. Should it be static?
arp.c:37:16: warning: symbol 'NetArpTxPacket' was not declared. Should it be static?
arp.c:38:17: warning: symbol 'NetArpPacketBuf' was not declared. Should it be static?
atheros.c:33:19: warning: symbol 'AR8021_driver' was not declared. Should it be static?
net.c:183:7: warning: symbol 'PktBuf' was not declared. Should it be static?
net.c:159:21: warning: symbol 'net_state' was not declared. Should it be static?
ping.c:73:6: warning: symbol 'ping_start' was not declared. Should it be static?
ping.c:82:13: warning: symbol 'ping_receive' was not declared. Should it be static?
tftp.c:53:7: warning: symbol 'TftpRRQTimeoutMSecs' was not declared. Should it be static?
tftp.c:54:5: warning: symbol 'TftpRRQTimeoutCountMax' was not declared. Should it be static?
eth.c:125:19: warning: symbol 'eth_current' was not declared. Should it be static?

Note: in the ping.c fix, commit a36b12f95a29647a06b5459198684fc142482020
"net: Move PING out of net.c" mistakenly carried the ifdef CMD_PING
clause from when it was necessary to avoid warnings when it was embedded
in net.c.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: no changes

 common/update.c           | 1 +
 drivers/net/phy/atheros.c | 2 +-
 include/net.h             | 9 +++++----
 net/arp.c                 | 6 +++---
 net/bootp.c               | 6 +++---
 net/net.c                 | 2 +-
 net/ping.h                | 3 ---
 net/tftp.h                | 3 +++
 8 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/common/update.c b/common/update.c
index 5b1a064..94d6a82 100644
--- a/common/update.c
+++ b/common/update.c
@@ -37,6 +37,7 @@
 #include <command.h>
 #include <flash.h>
 #include <net.h>
+#include <net/tftp.h>
 #include <malloc.h>
 
 /* env variable holding the location of the update file */
diff --git a/drivers/net/phy/atheros.c b/drivers/net/phy/atheros.c
index 798473d..9b3808b 100644
--- a/drivers/net/phy/atheros.c
+++ b/drivers/net/phy/atheros.c
@@ -30,7 +30,7 @@ static int ar8021_config(struct phy_device *phydev)
 	return 0;
 }
 
-struct phy_driver AR8021_driver =  {
+static struct phy_driver AR8021_driver =  {
 	.name = "AR8021",
 	.uid = 0x4dd040,
 	.mask = 0xfffff0,
diff --git a/include/net.h b/include/net.h
index 3539336..970d4d1 100644
--- a/include/net.h
+++ b/include/net.h
@@ -102,12 +102,13 @@ extern int eth_register(struct eth_device* dev);/* Register network device */
 extern int eth_unregister(struct eth_device *dev);/* Remove network device */
 extern void eth_try_another(int first_restart);	/* Change the device */
 extern void eth_set_current(void);		/* set nterface to ethcur var */
+
 /* get the current device MAC */
+extern struct eth_device *eth_current;
+
 static inline __attribute__((always_inline))
 struct eth_device *eth_get_dev(void)
 {
-	extern struct eth_device *eth_current;
-
 	return eth_current;
 }
 extern struct eth_device *eth_get_dev_by_name(const char *devname);
@@ -517,10 +518,10 @@ enum net_loop_state {
 	NETLOOP_SUCCESS,
 	NETLOOP_FAIL
 };
+extern enum net_loop_state net_state;
+
 static inline void net_set_state(enum net_loop_state state)
 {
-	extern enum net_loop_state net_state;
-
 	debug_cond(DEBUG_INT_STATE, "--- NetState set to %d\n", state);
 	net_state = state;
 }
diff --git a/net/arp.c b/net/arp.c
index 8e1d2ed..20c6b2d 100644
--- a/net/arp.c
+++ b/net/arp.c
@@ -27,15 +27,15 @@
 #endif
 
 IPaddr_t	NetArpWaitPacketIP;
-IPaddr_t	NetArpWaitReplyIP;
+static IPaddr_t	NetArpWaitReplyIP;
 /* MAC address of waiting packet's destination */
 uchar	       *NetArpWaitPacketMAC;
 int		NetArpWaitTxPacketSize;
 ulong		NetArpWaitTimerStart;
 int		NetArpWaitTry;
 
-uchar	       *NetArpTxPacket;	/* THE ARP transmit packet */
-uchar		NetArpPacketBuf[PKTSIZE_ALIGN + PKTALIGN];
+static uchar   *NetArpTxPacket;	/* THE ARP transmit packet */
+static uchar	NetArpPacketBuf[PKTSIZE_ALIGN + PKTALIGN];
 
 void ArpInit(void)
 {
diff --git a/net/bootp.c b/net/bootp.c
index cd5c5dd..4300f1c 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -41,9 +41,9 @@ ulong		BootpID;
 int		BootpTry;
 
 #if defined(CONFIG_CMD_DHCP)
-dhcp_state_t dhcp_state = INIT;
-unsigned long dhcp_leasetime;
-IPaddr_t NetDHCPServerIP;
+static dhcp_state_t dhcp_state = INIT;
+static unsigned long dhcp_leasetime;
+static IPaddr_t NetDHCPServerIP;
 static void DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
 			unsigned len);
 
diff --git a/net/net.c b/net/net.c
index 569fec4..82c4cc9 100644
--- a/net/net.c
+++ b/net/net.c
@@ -180,7 +180,7 @@ IPaddr_t	NetNtpServerIP;
 int		NetTimeOffset;
 #endif
 
-uchar PktBuf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN];
+static uchar PktBuf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN];
 
 /* Receive packet */
 uchar *NetRxPackets[PKTBUFSRX];
diff --git a/net/ping.h b/net/ping.h
index fd8d8d9..8c71be4 100644
--- a/net/ping.h
+++ b/net/ping.h
@@ -8,8 +8,6 @@
  *	Copyright 2000-2002 Wolfgang Denk, wd at denx.de
  */
 
-#if defined(CONFIG_CMD_PING)
-
 #ifndef __PING_H__
 #define __PING_H__
 
@@ -31,4 +29,3 @@ void ping_start(void);
 void ping_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len);
 
 #endif /* __PING_H__ */
-#endif
diff --git a/net/tftp.h b/net/tftp.h
index 18e4c9c..2b686e3 100644
--- a/net/tftp.h
+++ b/net/tftp.h
@@ -22,6 +22,9 @@ void TftpStart(enum proto_t protocol);	/* Begin TFTP get/put */
 extern void TftpStartServer(void);	/* Wait for incoming TFTP put */
 #endif
 
+extern ulong TftpRRQTimeoutMSecs;
+extern int TftpRRQTimeoutCountMax;
+
 /**********************************************************************/
 
 #endif /* __TFTP_H__ */
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 12/25] drivers/net/: sparse fixes
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (10 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 11/25] net/: sparse fixes Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 13/25] lib/zlib: " Kim Phillips
                     ` (13 subsequent siblings)
  25 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

phy.c:46:5: warning: symbol 'genphy_config_advert' was not declared. Should it be static?
phy.c:121:5: warning: symbol 'genphy_setup_forced' was not declared. Should it be static?
phy.c:468:5: warning: symbol 'phy_probe' was not declared. Should it be static?
phy.c:491:19: warning: symbol 'get_phy_driver' was not declared. Should it be static?
phy.c:508:19: warning: symbol 'phy_device_create' was not declared. Should it be static?
phy.c:552:5: warning: symbol 'get_phy_id' was not declared. Should it be static?
phy.c:584:19: warning: symbol 'get_phy_device' was not declared. Should it be sta
vitesse.c:126:5: warning: symbol 'vsc8601_config' was not declared. Should it be static?
vsc7385.c:33:5: warning: symbol 'vsc7385_upload_firmware' was not declared. Should it be static?
tgec_phy.c:33:5: warning: symbol 'tgec_mdio_write' was not declared. Should it be static?
tgec_phy.c:75:5: warning: symbol 'tgec_mdio_read' was not declared. Should it be static?
tgec_phy.c:117:5: warning: symbol 'tgec_mdio_reset' was not declared. Should it be static?
eth.c:48:6: warning: symbol 'dtsec_configure_serdes' was not declared. Should it be static?
p4080.c:26:5: warning: symbol 'port_to_devdisr' was not declared. Should it be static?

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: no changes

 drivers/net/fm/eth.c      |  2 +-
 drivers/net/fm/p1023.c    |  2 +-
 drivers/net/fm/p4080.c    |  2 +-
 drivers/net/fm/p5020.c    |  2 +-
 drivers/net/fm/tgec_phy.c | 10 +++++-----
 drivers/net/phy/phy.c     | 19 ++++++++++---------
 drivers/net/phy/vitesse.c |  2 +-
 drivers/net/vsc7385.c     |  1 +
 8 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/drivers/net/fm/eth.c b/drivers/net/fm/eth.c
index 82c787b..54b142f 100644
--- a/drivers/net/fm/eth.c
+++ b/drivers/net/fm/eth.c
@@ -46,7 +46,7 @@ static int num_controllers;
 			TBICR_FULL_DUPLEX | TBICR_SPEED1_SET)
 
 /* Configure the TBI for SGMII operation */
-void dtsec_configure_serdes(struct fm_eth *priv)
+static void dtsec_configure_serdes(struct fm_eth *priv)
 {
 #ifdef CONFIG_SYS_FMAN_V3
 	u32 value;
diff --git a/drivers/net/fm/p1023.c b/drivers/net/fm/p1023.c
index 9765da5..387d2a3 100644
--- a/drivers/net/fm/p1023.c
+++ b/drivers/net/fm/p1023.c
@@ -23,7 +23,7 @@
 #include <asm/immap_85xx.h>
 #include <asm/fsl_serdes.h>
 
-u32 port_to_devdisr[] = {
+static u32 port_to_devdisr[] = {
 	[FM1_DTSEC1] = MPC85xx_DEVDISR_TSEC1,
 	[FM1_DTSEC2] = MPC85xx_DEVDISR_TSEC2,
 };
diff --git a/drivers/net/fm/p4080.c b/drivers/net/fm/p4080.c
index 9dc6049..b04fd0f 100644
--- a/drivers/net/fm/p4080.c
+++ b/drivers/net/fm/p4080.c
@@ -23,7 +23,7 @@
 #include <asm/immap_85xx.h>
 #include <asm/fsl_serdes.h>
 
-u32 port_to_devdisr[] = {
+static u32 port_to_devdisr[] = {
 	[FM1_DTSEC1] = FSL_CORENET_DEVDISR2_DTSEC1_1,
 	[FM1_DTSEC2] = FSL_CORENET_DEVDISR2_DTSEC1_2,
 	[FM1_DTSEC3] = FSL_CORENET_DEVDISR2_DTSEC1_3,
diff --git a/drivers/net/fm/p5020.c b/drivers/net/fm/p5020.c
index a7a6e43..5391044 100644
--- a/drivers/net/fm/p5020.c
+++ b/drivers/net/fm/p5020.c
@@ -23,7 +23,7 @@
 #include <asm/immap_85xx.h>
 #include <asm/fsl_serdes.h>
 
-u32 port_to_devdisr[] = {
+static u32 port_to_devdisr[] = {
 	[FM1_DTSEC1] = FSL_CORENET_DEVDISR2_DTSEC1_1,
 	[FM1_DTSEC2] = FSL_CORENET_DEVDISR2_DTSEC1_2,
 	[FM1_DTSEC3] = FSL_CORENET_DEVDISR2_DTSEC1_3,
diff --git a/drivers/net/fm/tgec_phy.c b/drivers/net/fm/tgec_phy.c
index 2d349ad..2be69d7 100644
--- a/drivers/net/fm/tgec_phy.c
+++ b/drivers/net/fm/tgec_phy.c
@@ -30,8 +30,8 @@
  * until the write is done before it returns.  All PHY configuration has to be
  * done through the TSEC1 MIIM regs
  */
-int tgec_mdio_write(struct mii_dev *bus, int port_addr, int dev_addr,
-			int regnum, u16 value)
+static int tgec_mdio_write(struct mii_dev *bus, int port_addr, int dev_addr,
+			   int regnum, u16 value)
 {
 	u32 mdio_ctl;
 	u32 stat_val;
@@ -72,8 +72,8 @@ int tgec_mdio_write(struct mii_dev *bus, int port_addr, int dev_addr,
  * Clears miimcom first.  All PHY configuration has to be done through the
  * TSEC1 MIIM regs
  */
-int tgec_mdio_read(struct mii_dev *bus, int port_addr, int dev_addr,
-			int regnum)
+static int tgec_mdio_read(struct mii_dev *bus, int port_addr, int dev_addr,
+			  int regnum)
 {
 	u32 mdio_ctl;
 	u32 stat_val;
@@ -114,7 +114,7 @@ int tgec_mdio_read(struct mii_dev *bus, int port_addr, int dev_addr,
 	return in_be32(&regs->mdio_data) & 0xffff;
 }
 
-int tgec_mdio_reset(struct mii_dev *bus)
+static int tgec_mdio_reset(struct mii_dev *bus)
 {
 	return 0;
 }
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index baef60f..1ffa791 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -43,7 +43,7 @@
  *   what is supported.  Returns < 0 on error, 0 if the PHY's advertisement
  *   hasn't changed, and > 0 if it has changed.
  */
-int genphy_config_advert(struct phy_device *phydev)
+static int genphy_config_advert(struct phy_device *phydev)
 {
 	u32 advertise;
 	int oldadv, adv;
@@ -118,7 +118,7 @@ int genphy_config_advert(struct phy_device *phydev)
  * Description: Configures MII_BMCR to force speed/duplex
  *   to the values in phydev. Assumes that the values are valid.
  */
-int genphy_setup_forced(struct phy_device *phydev)
+static int genphy_setup_forced(struct phy_device *phydev)
 {
 	int err;
 	int ctl = 0;
@@ -465,7 +465,7 @@ int phy_register(struct phy_driver *drv)
 	return 0;
 }
 
-int phy_probe(struct phy_device *phydev)
+static int phy_probe(struct phy_device *phydev)
 {
 	int err = 0;
 
@@ -488,7 +488,7 @@ static struct phy_driver *generic_for_interface(phy_interface_t interface)
 	return &genphy_driver;
 }
 
-struct phy_driver *get_phy_driver(struct phy_device *phydev,
+static struct phy_driver *get_phy_driver(struct phy_device *phydev,
 				phy_interface_t interface)
 {
 	struct list_head *entry;
@@ -505,8 +505,9 @@ struct phy_driver *get_phy_driver(struct phy_device *phydev,
 	return generic_for_interface(interface);
 }
 
-struct phy_device *phy_device_create(struct mii_dev *bus, int addr, int phy_id,
-					phy_interface_t interface)
+static struct phy_device *phy_device_create(struct mii_dev *bus, int addr,
+					    int phy_id,
+					    phy_interface_t interface)
 {
 	struct phy_device *dev;
 
@@ -549,7 +550,7 @@ struct phy_device *phy_device_create(struct mii_dev *bus, int addr, int phy_id,
  * Description: Reads the ID registers of the PHY at @addr on the
  *   @bus, stores it in @phy_id and returns zero on success.
  */
-int get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id)
+static int get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id)
 {
 	int phy_reg;
 
@@ -581,8 +582,8 @@ int get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id)
  * Description: Reads the ID registers of the PHY at @addr on the
  *   @bus, then allocates and returns the phy_device to represent it.
  */
-struct phy_device *get_phy_device(struct mii_dev *bus, int addr,
-				phy_interface_t interface)
+static struct phy_device *get_phy_device(struct mii_dev *bus, int addr,
+					 phy_interface_t interface)
 {
 	u32 phy_id = 0x1fffffff;
 	int i;
diff --git a/drivers/net/phy/vitesse.c b/drivers/net/phy/vitesse.c
index 0a0f40d..6c5cb99 100644
--- a/drivers/net/phy/vitesse.c
+++ b/drivers/net/phy/vitesse.c
@@ -123,7 +123,7 @@ static int cis8204_config(struct phy_device *phydev)
 }
 
 /* Vitesse VSC8601 */
-int vsc8601_config(struct phy_device *phydev)
+static int vsc8601_config(struct phy_device *phydev)
 {
 	/* Configure some basic stuff */
 #ifdef CONFIG_SYS_VSC8601_SKEWFIX
diff --git a/drivers/net/vsc7385.c b/drivers/net/vsc7385.c
index ada42c4..a5110e5 100644
--- a/drivers/net/vsc7385.c
+++ b/drivers/net/vsc7385.c
@@ -16,6 +16,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/errno.h>
+#include "vsc7385.h"
 
 /*
  * Upload a Vitesse VSC7385 firmware image to the hardware
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 13/25] lib/zlib: sparse fixes
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (11 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 12/25] drivers/net/: " Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-11-08 11:20     ` Wolfgang Denk
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 14/25] lib/vsprintf.c: " Kim Phillips
                     ` (12 subsequent siblings)
  25 siblings, 1 reply; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

define Z_NULL to (void *)0 include/u-boot/zlib.h to get rid of most of
the NULL pointer warnings.

inflate.c:942:1: warning: non-ANSI definition of function 'inflateEnd'
inflate.c:9:1: warning: non-ANSI definition of function 'inflateReset'
inflate.c:12:17: warning: Using plain integer as NULL pointer
inflate.c:12:42: warning: Using plain integer as NULL pointer
inflate.c:15:17: warning: Using plain integer as NULL pointer
inflate.c:21:19: warning: Using plain integer as NULL pointer
inflate.c:35:1: warning: non-ANSI definition of function 'inflateInit2_'
inflate.c:38:20: warning: Using plain integer as NULL pointer
inflate.c:41:17: warning: Using plain integer as NULL pointer
inflate.c:42:17: warning: Using plain integer as NULL pointer
inflate.c:50:18: warning: Using plain integer as NULL pointer
inflate.c:65:23: warning: Using plain integer as NULL pointer
inflate.c:69:21: warning: Using plain integer as NULL pointer
inflate.c:78:1: warning: non-ANSI definition of function 'inflateInit_'
inflate.c:86:1: warning: non-ANSI definition of function 'fixedtables'
inflate.c:108:26: warning: Using plain integer as NULL pointer
inflate.c:109:1: warning: non-ANSI definition of function 'updatewindow'
inflate.c:112:30: warning: Using plain integer as NULL pointer
inflate.c:339:1: warning: non-ANSI definition of function 'inflate'
inflate.c:349:17: warning: Using plain integer as NULL pointer
inflate.c:349:42: warning: Using plain integer as NULL pointer
inflate.c:350:27: warning: Using plain integer as NULL pointer
inflate.c:369:42: warning: Using plain integer as NULL pointer
inflate.c:376:32: warning: Using plain integer as NULL pointer
inflate.c:401:54: warning: Using plain integer as NULL pointer
inflate.c:419:32: warning: Using plain integer as NULL pointer
inflate.c:426:32: warning: Using plain integer as NULL pointer
inflate.c:433:32: warning: Using plain integer as NULL pointer
inflate.c:444:36: warning: Using plain integer as NULL pointer
inflate.c:449:37: warning: Using plain integer as NULL pointer
inflate.c:450:38: warning: Using plain integer as NULL pointer
inflate.c:457:40: warning: Using plain integer as NULL pointer
inflate.c:458:47: warning: Using plain integer as NULL pointer
inflate.c:480:40: warning: Using plain integer as NULL pointer
inflate.c:481:50: warning: Using plain integer as NULL pointer
inflate.c:491:37: warning: Using plain integer as NULL pointer
inflate.c:492:37: warning: Using plain integer as NULL pointer
inflate.c:501:40: warning: Using plain integer as NULL pointer
inflate.c:502:53: warning: Using plain integer as NULL pointer
inflate.c:512:37: warning: Using plain integer as NULL pointer
inflate.c:513:40: warning: Using plain integer as NULL pointer
inflate.c:525:32: warning: Using plain integer as NULL pointer
inflate.c:529:52: warning: Using plain integer as NULL pointer
inflate.c:543:54: warning: Using plain integer as NULL pointer
inflate.c:932:17: warning: Using plain integer as NULL pointer
inflate.c:932:42: warning: Using plain integer as NULL pointer
inflate.c:935:26: warning: Using plain integer as NULL pointer
inflate.c:940:19: warning: Using plain integer as NULL pointer
adler32.c:58:5: warning: non-ANSI definition of function 'adler32'
adler32.c:81:16: warning: Using plain integer as NULL pointer
zutil.c:53:9: warning: non-ANSI definition of function 'zcalloc'
zutil.c:64:9: warning: non-ANSI definition of function 'zcfree'
inffast.c:70:1: warning: non-ANSI definition of function 'inflate_fast'
inftrees.c:33:1: warning: non-ANSI definition of function 'inflate_table'

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: added checkpatch fixes.

 include/u-boot/zlib.h |  2 +-
 lib/zlib/adler32.c    |  5 +----
 lib/zlib/inffast.c    |  5 ++---
 lib/zlib/inflate.c    | 29 ++++++++---------------------
 lib/zlib/inftrees.c   | 10 +++-------
 lib/zlib/zutil.c      | 10 ++--------
 6 files changed, 17 insertions(+), 44 deletions(-)

diff --git a/include/u-boot/zlib.h b/include/u-boot/zlib.h
index b611fe7..e23ceb5 100644
--- a/include/u-boot/zlib.h
+++ b/include/u-boot/zlib.h
@@ -505,7 +505,7 @@ typedef gz_header FAR *gz_headerp;
 #define Z_DEFLATED   8
 /* The deflate compression method (the only one supported in this version) */
 
-#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
+#define Z_NULL  (void *)0  /* for initializing zalloc, zfree, opaque */
 
                         /* basic functions */
 
diff --git a/lib/zlib/adler32.c b/lib/zlib/adler32.c
index dc9480d..b468441 100644
--- a/lib/zlib/adler32.c
+++ b/lib/zlib/adler32.c
@@ -54,10 +54,7 @@
 #endif
 
 /* ========================================================================= */
-uLong ZEXPORT adler32(adler, buf, len)
-    uLong adler;
-    const Bytef *buf;
-    uInt len;
+uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
 {
     unsigned long sum2;
     unsigned n;
diff --git a/lib/zlib/inffast.c b/lib/zlib/inffast.c
index 38f2f90..0700e04 100644
--- a/lib/zlib/inffast.c
+++ b/lib/zlib/inffast.c
@@ -66,9 +66,8 @@
       requires strm->avail_out >= 258 for each loop to avoid checking for
       output space.
  */
-void inflate_fast(strm, start)
-z_streamp strm;
-unsigned start;         /* inflate()'s starting value for strm->avail_out */
+void inflate_fast(z_streamp strm, unsigned start)
+/* start: inflate()'s starting value for strm->avail_out */
 {
     struct inflate_state FAR *state;
     unsigned char FAR *in;      /* local strm->next_in */
diff --git a/lib/zlib/inflate.c b/lib/zlib/inflate.c
index 1eef609..6411c47 100644
--- a/lib/zlib/inflate.c
+++ b/lib/zlib/inflate.c
@@ -5,8 +5,7 @@
 local void fixedtables OF((struct inflate_state FAR *state));
 local int updatewindow OF((z_streamp strm, unsigned out));
 
-int ZEXPORT inflateReset(strm)
-z_streamp strm;
+int ZEXPORT inflateReset(z_streamp strm)
 {
     struct inflate_state FAR *state;
 
@@ -31,11 +30,8 @@ z_streamp strm;
     return Z_OK;
 }
 
-int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
-z_streamp strm;
-int windowBits;
-const char *version;
-int stream_size;
+int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, const char *version,
+			  int stream_size)
 {
     struct inflate_state FAR *state;
 
@@ -74,16 +70,12 @@ int stream_size;
     return inflateReset(strm);
 }
 
-int ZEXPORT inflateInit_(strm, version, stream_size)
-z_streamp strm;
-const char *version;
-int stream_size;
+int ZEXPORT inflateInit_(z_streamp strm, const char *version, int stream_size)
 {
     return inflateInit2_(strm, DEF_WBITS, version, stream_size);
 }
 
-local void fixedtables(state)
-struct inflate_state FAR *state;
+local void fixedtables(struct inflate_state FAR *state)
 {
     state->lencode = lenfix;
     state->lenbits = 9;
@@ -105,9 +97,7 @@ struct inflate_state FAR *state;
    output will fall in the output data, making match copies simpler and faster.
    The advantage may be dependent on the size of the processor's data caches.
  */
-local int updatewindow(strm, out)
-z_streamp strm;
-unsigned out;
+local int updatewindow(z_streamp strm, unsigned out)
 {
     struct inflate_state FAR *state;
     unsigned copy, dist;
@@ -335,9 +325,7 @@ unsigned out;
    when flush is set to Z_FINISH, inflate() cannot return Z_OK.  Instead it
    will return Z_BUF_ERROR if it has not reached the end of the stream.
  */
-int ZEXPORT inflate(strm, flush)
-z_streamp strm;
-int flush;
+int ZEXPORT inflate(z_streamp strm, int flush)
 {
     struct inflate_state FAR *state;
     unsigned char FAR *next;    /* next input */
@@ -938,8 +926,7 @@ int flush;
     return ret;
 }
 
-int ZEXPORT inflateEnd(strm)
-z_streamp strm;
+int ZEXPORT inflateEnd(z_streamp strm)
 {
     struct inflate_state FAR *state;
     if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
diff --git a/lib/zlib/inftrees.c b/lib/zlib/inftrees.c
index c6d4c03..7474a52 100644
--- a/lib/zlib/inftrees.c
+++ b/lib/zlib/inftrees.c
@@ -29,13 +29,9 @@
    table index bits.  It will differ if the request is greater than the
    longest code or if it is less than the shortest code.
  */
-int inflate_table(type, lens, codes, table, bits, work)
-codetype type;
-unsigned short FAR *lens;
-unsigned codes;
-code FAR * FAR *table;
-unsigned FAR *bits;
-unsigned short FAR *work;
+int inflate_table(codetype type, unsigned short FAR *lens, unsigned codes,
+		  code FAR * FAR *table, unsigned FAR *bits,
+		  unsigned short FAR *work)
 {
     unsigned len;               /* a code's length in bits */
     unsigned sym;               /* index of code symbols */
diff --git a/lib/zlib/zutil.c b/lib/zlib/zutil.c
index 65f9554..14f6eb1 100644
--- a/lib/zlib/zutil.c
+++ b/lib/zlib/zutil.c
@@ -49,10 +49,7 @@ extern voidp    calloc OF((uInt items, uInt size));
 extern void     free   OF((voidpf ptr));
 #endif
 
-voidpf zcalloc (opaque, items, size)
-	voidpf opaque;
-	unsigned items;
-	unsigned size;
+voidpf zcalloc(voidpf opaque, unsigned items, unsigned size)
 {
 	if (opaque)
 		items += size - size; /* make compiler happy */
@@ -60,10 +57,7 @@ voidpf zcalloc (opaque, items, size)
 		(voidpf)calloc(items, size);
 }
 
-void  zcfree (opaque, ptr, nb)
-	voidpf opaque;
-	voidpf ptr;
-	unsigned nb;
+void  zcfree(voidpf opaque, voidpf ptr, unsigned nb)
 {
 	free(ptr);
 	if (opaque)
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 14/25] lib/vsprintf.c: sparse fixes
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (12 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 13/25] lib/zlib: " Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 15/25] arch/powerpc/cpu/mpc8xxx/: " Kim Phillips
                     ` (11 subsequent siblings)
  25 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

vsprintf.c:31:12: warning: symbol 'hex_asc' was not declared. Should it be static?
vsprintf.c:398:18: warning: Using plain integer as NULL pointer

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: no changes

 lib/vsprintf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index d762763..7215531 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -28,7 +28,7 @@
 /* some reluctance to put this into a new limits.h, so it is here */
 #define INT_MAX		((int)(~0U>>1))
 
-const char hex_asc[] = "0123456789abcdef";
+static const char hex_asc[] = "0123456789abcdef";
 #define hex_asc_lo(x)   hex_asc[((x) & 0x0f)]
 #define hex_asc_hi(x)   hex_asc[((x) & 0xf0) >> 4]
 
@@ -395,7 +395,7 @@ static char *string(char *buf, char *end, char *s, int field_width,
 {
 	int len, i;
 
-	if (s == 0)
+	if (s == NULL)
 		s = "<NULL>";
 
 	len = strnlen(s, precision);
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 15/25] arch/powerpc/cpu/mpc8xxx/: sparse fixes
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (13 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 14/25] lib/vsprintf.c: " Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 16/25] powerpc/mpc85xx: " Kim Phillips
                     ` (10 subsequent siblings)
  25 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

ctrl_regs.c:31:5: warning: symbol 'fsl_ddr_get_version' was not declared. Should it be static?
cpu.c:135:14: warning: non-ANSI function declaration of function 'cpu_mask'
cpu.c:154:18: warning: non-ANSI function declaration of function 'cpu_numcores'
cpu.c:37:17: warning: symbol 'cpu_type_list' was not declared. Should it be static?
cpu.c:117:17: warning: symbol 'cpu_type_unknown' was not declared. Should it be static?
fsl_lbc.c:14:6: warning: symbol '__lbc_sdram_init' was not declared. Should it be static?

and:

lc_common_dimm_params.c:15:1: warning: symbol 'compute_cas_latency_ddr3' was not declared. Should it be static?

making it static produces the following compiler warning:

lc_common_dimm_params.c:15:1: warning: 'compute_cas_latency_ddr3' defined but not used [-Wunused-function]

so we protect it with the preprocessor.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: added checkpatch fixes.

 arch/powerpc/cpu/mpc8xxx/cpu.c                       | 9 +++++----
 arch/powerpc/cpu/mpc8xxx/ddr/ctrl_regs.c             | 2 +-
 arch/powerpc/cpu/mpc8xxx/ddr/lc_common_dimm_params.c | 4 +++-
 arch/powerpc/cpu/mpc8xxx/fsl_lbc.c                   | 2 +-
 4 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/cpu/mpc8xxx/cpu.c b/arch/powerpc/cpu/mpc8xxx/cpu.c
index 2c487ca..e8613be 100644
--- a/arch/powerpc/cpu/mpc8xxx/cpu.c
+++ b/arch/powerpc/cpu/mpc8xxx/cpu.c
@@ -34,7 +34,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-struct cpu_type cpu_type_list [] = {
+static struct cpu_type cpu_type_list[] = {
 #if defined(CONFIG_MPC85xx)
 	CPU_TYPE_ENTRY(8533, 8533, 1),
 	CPU_TYPE_ENTRY(8535, 8535, 1),
@@ -125,7 +125,7 @@ u32 compute_ppc_cpumask(void)
 #define compute_ppc_cpumask()	1
 #endif /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */
 
-struct cpu_type cpu_type_unknown = CPU_TYPE_ENTRY(Unknown, Unknown, 0);
+static struct cpu_type cpu_type_unknown = CPU_TYPE_ENTRY(Unknown, Unknown, 0);
 
 struct cpu_type *identify_cpu(u32 ver)
 {
@@ -143,7 +143,7 @@ struct cpu_type *identify_cpu(u32 ver)
 /*
  * Return a 32-bit mask indicating which cores are present on this SOC.
  */
-u32 cpu_mask()
+u32 cpu_mask(void)
 {
 	ccsr_pic_t __iomem *pic = (void *)CONFIG_SYS_MPC8xxx_PIC_ADDR;
 	struct cpu_type *cpu = gd->cpu;
@@ -162,7 +162,8 @@ u32 cpu_mask()
 /*
  * Return the number of cores on this SOC.
  */
-int cpu_numcores() {
+int cpu_numcores(void)
+{
 	struct cpu_type *cpu = gd->cpu;
 
 	/*
diff --git a/arch/powerpc/cpu/mpc8xxx/ddr/ctrl_regs.c b/arch/powerpc/cpu/mpc8xxx/ddr/ctrl_regs.c
index 5928eb8..088cc0e 100644
--- a/arch/powerpc/cpu/mpc8xxx/ddr/ctrl_regs.c
+++ b/arch/powerpc/cpu/mpc8xxx/ddr/ctrl_regs.c
@@ -28,7 +28,7 @@
 	#error "Undefined _DDR_ADDR"
 #endif
 
-u32 fsl_ddr_get_version(void)
+static u32 fsl_ddr_get_version(void)
 {
 	ccsr_ddr_t *ddr;
 	u32 ver_major_minor_errata;
diff --git a/arch/powerpc/cpu/mpc8xxx/ddr/lc_common_dimm_params.c b/arch/powerpc/cpu/mpc8xxx/ddr/lc_common_dimm_params.c
index 6a1f4e4..9adde31 100644
--- a/arch/powerpc/cpu/mpc8xxx/ddr/lc_common_dimm_params.c
+++ b/arch/powerpc/cpu/mpc8xxx/ddr/lc_common_dimm_params.c
@@ -11,7 +11,8 @@
 
 #include "ddr.h"
 
-unsigned int
+#if defined(CONFIG_FSL_DDR3)
+static unsigned int
 compute_cas_latency_ddr3(const dimm_params_t *dimm_params,
 			 common_timing_params_t *outpdimm,
 			 unsigned int number_of_dimms)
@@ -65,6 +66,7 @@ compute_cas_latency_ddr3(const dimm_params_t *dimm_params,
 
 	return 0;
 }
+#endif
 
 /*
  * compute_lowest_common_dimm_parameters()
diff --git a/arch/powerpc/cpu/mpc8xxx/fsl_lbc.c b/arch/powerpc/cpu/mpc8xxx/fsl_lbc.c
index 023ac9a..c1fe579 100644
--- a/arch/powerpc/cpu/mpc8xxx/fsl_lbc.c
+++ b/arch/powerpc/cpu/mpc8xxx/fsl_lbc.c
@@ -11,7 +11,7 @@
 
 #ifdef CONFIG_MPC85xx
 /* Boards should provide their own version of this if they use lbc sdram */
-void __lbc_sdram_init(void)
+static void __lbc_sdram_init(void)
 {
 	/* Do nothing */
 }
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 16/25] powerpc/mpc85xx: sparse fixes
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (14 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 15/25] arch/powerpc/cpu/mpc8xxx/: " Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 17/25] powerpc/mpc83xx: " Kim Phillips
                     ` (9 subsequent siblings)
  25 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

fsl_corenet_serdes.c:485:6: warning: symbol '__soc_serdes_init' was not declared. Should it be static?
cpu_init.c:185:6: warning: symbol 'invalidate_cpc' was not declared. Should it be static?
bcsr.c:28:27: warning: non-ANSI function declaration of function 'enable_8568mds_duart'
bcsr.c:39:33: warning: non-ANSI function declaration of function 'enable_8568mds_flash_write'
bcsr.c:46:34: warning: non-ANSI function declaration of function 'disable_8568mds_flash_write'
bcsr.c:53:29: warning: non-ANSI function declaration of function 'enable_8568mds_qe_mdio'
bcsr.c:28:33: warning: non-ANSI function declaration of function 'enable_8569mds_flash_write'
bcsr.c:33:34: warning: non-ANSI function declaration of function 'disable_8569mds_flash_write'
bcsr.c:38:28: warning: non-ANSI function declaration of function 'enable_8569mds_qe_uec'
bcsr.c:63:47: warning: non-ANSI function declaration of function 'disable_8569mds_brd_eeprom_write_protect'
ngpixis.c:245:1: error: directive in argument list
ngpixis.c:247:1: error: directive in argument list

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: fix ngpixis command help to depend on CONFIG_SYS_LONGHELP

 arch/powerpc/cpu/mpc85xx/cpu_init.c           |  2 +-
 arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c |  2 +-
 board/freescale/common/ngpixis.c              | 12 ++++++++----
 board/freescale/mpc8568mds/bcsr.c             |  8 ++++----
 board/freescale/mpc8569mds/bcsr.c             |  8 ++++----
 5 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/arch/powerpc/cpu/mpc85xx/cpu_init.c b/arch/powerpc/cpu/mpc85xx/cpu_init.c
index 736293c..f01804b 100644
--- a/arch/powerpc/cpu/mpc85xx/cpu_init.c
+++ b/arch/powerpc/cpu/mpc85xx/cpu_init.c
@@ -182,7 +182,7 @@ static void enable_cpc(void)
 	printf("Corenet Platform Cache: %d KB enabled\n", size);
 }
 
-void invalidate_cpc(void)
+static void invalidate_cpc(void)
 {
 	int i;
 	cpc_corenet_t *cpc = (cpc_corenet_t *)CONFIG_SYS_FSL_CPC_ADDR;
diff --git a/arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c b/arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c
index e6b1b1b..7f466ac 100644
--- a/arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c
+++ b/arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c
@@ -489,7 +489,7 @@ static void wait_for_rstdone(unsigned int bank)
 }
 
 
-void __soc_serdes_init(void)
+static void __soc_serdes_init(void)
 {
 	/* Allow for SoC-specific initialization in <SOC>_serdes.c  */
 };
diff --git a/board/freescale/common/ngpixis.c b/board/freescale/common/ngpixis.c
index 276ae3c..3c75028 100644
--- a/board/freescale/common/ngpixis.c
+++ b/board/freescale/common/ngpixis.c
@@ -237,13 +237,17 @@ int pixis_reset_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return 0;
 }
 
-U_BOOT_CMD(
-	pixis_reset, CONFIG_SYS_MAXARGS, 1, pixis_reset_cmd,
-	"Reset the board using the FPGA sequencer",
+#ifdef CONFIG_SYS_LONGHELP
+static char pixis_help_text[] =
 	"- hard reset to default bank\n"
 	"pixis_reset altbank - reset to alternate bank\n"
 #ifdef DEBUG
 	"pixis_reset dump - display the PIXIS registers\n"
 #endif
-	"pixis_reset sysclk <SYSCLK_freq> - reset with SYSCLK frequency(KHz)\n"
+	"pixis_reset sysclk <SYSCLK_freq> - reset with SYSCLK frequency(KHz)\n";
+#endif
+
+U_BOOT_CMD(
+	pixis_reset, CONFIG_SYS_MAXARGS, 1, pixis_reset_cmd,
+	"Reset the board using the FPGA sequencer", pixis_help_text
 	);
diff --git a/board/freescale/mpc8568mds/bcsr.c b/board/freescale/mpc8568mds/bcsr.c
index 30676e1..2a172cc 100644
--- a/board/freescale/mpc8568mds/bcsr.c
+++ b/board/freescale/mpc8568mds/bcsr.c
@@ -25,7 +25,7 @@
 
 #include "bcsr.h"
 
-void enable_8568mds_duart()
+void enable_8568mds_duart(void)
 {
 	volatile uint* duart_mux	= (uint *)(CONFIG_SYS_CCSRBAR + 0xe0060);
 	volatile uint* devices		= (uint *)(CONFIG_SYS_CCSRBAR + 0xe0070);
@@ -36,21 +36,21 @@ void enable_8568mds_duart()
 	bcsr[5] |= 0x01;		/* Enable Duart in BCSR*/
 }
 
-void enable_8568mds_flash_write()
+void enable_8568mds_flash_write(void)
 {
 	volatile u8 *bcsr = (u8 *)(CONFIG_SYS_BCSR);
 
 	bcsr[9] |= 0x01;
 }
 
-void disable_8568mds_flash_write()
+void disable_8568mds_flash_write(void)
 {
 	volatile u8 *bcsr = (u8 *)(CONFIG_SYS_BCSR);
 
 	bcsr[9] &= ~(0x01);
 }
 
-void enable_8568mds_qe_mdio()
+void enable_8568mds_qe_mdio(void)
 {
 	u8 *bcsr = (u8 *)(CONFIG_SYS_BCSR);
 
diff --git a/board/freescale/mpc8569mds/bcsr.c b/board/freescale/mpc8569mds/bcsr.c
index b688e5c..37d0c5f 100644
--- a/board/freescale/mpc8569mds/bcsr.c
+++ b/board/freescale/mpc8569mds/bcsr.c
@@ -25,17 +25,17 @@
 
 #include "bcsr.h"
 
-void enable_8569mds_flash_write()
+void enable_8569mds_flash_write(void)
 {
 	setbits_8((u8 *)(CONFIG_SYS_BCSR_BASE + 17), BCSR17_FLASH_nWP);
 }
 
-void disable_8569mds_flash_write()
+void disable_8569mds_flash_write(void)
 {
 	clrbits_8((u8 *)(CONFIG_SYS_BCSR_BASE + 17), BCSR17_FLASH_nWP);
 }
 
-void enable_8569mds_qe_uec()
+void enable_8569mds_qe_uec(void)
 {
 #if defined(CONFIG_SYS_UCC_RGMII_MODE)
 	setbits_8((u8 *)(CONFIG_SYS_BCSR_BASE + 7),
@@ -60,7 +60,7 @@ void enable_8569mds_qe_uec()
 #endif
 }
 
-void disable_8569mds_brd_eeprom_write_protect()
+void disable_8569mds_brd_eeprom_write_protect(void)
 {
 	clrbits_8((u8 *)(CONFIG_SYS_BCSR_BASE + 7), BCSR7_BRD_WRT_PROTECT);
 }
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 17/25] powerpc/mpc83xx: sparse fixes
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (15 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 16/25] powerpc/mpc85xx: " Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 18/25] drivers/block/: " Kim Phillips
                     ` (8 subsequent siblings)
  25 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

fdt.c:91:78: warning: Using plain integer as NULL pointer
fdt.c:103:78: warning: Using plain integer as NULL pointer
speed.c:55:11: warning: symbol 'corecnf_tab' was not declared. Should it be static?
speed.c:519:5: warning: symbol 'do_clocks' was not declared. Should it be static?
mpc8313erdb.c:73:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:74:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:75:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:76:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:79:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:80:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:81:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:82:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:85:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:86:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:87:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:88:17: warning: obsolete struct initializer, use C99 syntax

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: checkpatch fixes.

 arch/powerpc/cpu/mpc83xx/fdt.c            |  6 ++++--
 arch/powerpc/cpu/mpc83xx/speed.c          |  4 ++--
 board/freescale/mpc8313erdb/mpc8313erdb.c | 24 ++++++++++++------------
 3 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/arch/powerpc/cpu/mpc83xx/fdt.c b/arch/powerpc/cpu/mpc83xx/fdt.c
index 028c8f0..1f54781 100644
--- a/arch/powerpc/cpu/mpc83xx/fdt.c
+++ b/arch/powerpc/cpu/mpc83xx/fdt.c
@@ -88,7 +88,8 @@ void ft_cpu_setup(void *blob, bd_t *bd)
 				u32 tmp[] = { 32, 0x8, 33, 0x8, 34, 0x8 };
 
 				path = fdt_path_offset(blob, prop);
-				prop = fdt_getprop(blob, path, "interrupts", 0);
+				prop = fdt_getprop(blob, path, "interrupts",
+						   NULL);
 				if (prop)
 					fdt_setprop(blob, path, "interrupts",
 						    &tmp, sizeof(tmp));
@@ -100,7 +101,8 @@ void ft_cpu_setup(void *blob, bd_t *bd)
 				u32 tmp[] = { 35, 0x8, 36, 0x8, 37, 0x8 };
 
 				path = fdt_path_offset(blob, prop);
-				prop = fdt_getprop(blob, path, "interrupts", 0);
+				prop = fdt_getprop(blob, path, "interrupts",
+						   NULL);
 				if (prop)
 					fdt_setprop(blob, path, "interrupts",
 						    &tmp, sizeof(tmp));
diff --git a/arch/powerpc/cpu/mpc83xx/speed.c b/arch/powerpc/cpu/mpc83xx/speed.c
index fb0f7aa..b8c05d1 100644
--- a/arch/powerpc/cpu/mpc83xx/speed.c
+++ b/arch/powerpc/cpu/mpc83xx/speed.c
@@ -52,7 +52,7 @@ typedef struct {
 	mult_t vco_divider;
 } corecnf_t;
 
-corecnf_t corecnf_tab[] = {
+static corecnf_t corecnf_tab[] = {
 	{_byp, _byp},		/* 0x00 */
 	{_byp, _byp},		/* 0x01 */
 	{_byp, _byp},		/* 0x02 */
@@ -531,7 +531,7 @@ ulong get_ddr_freq(ulong dummy)
 	return gd->mem_clk;
 }
 
-int do_clocks (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+static int do_clocks(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	char buf[32];
 
diff --git a/board/freescale/mpc8313erdb/mpc8313erdb.c b/board/freescale/mpc8313erdb/mpc8313erdb.c
index 730ec4e..1071803 100644
--- a/board/freescale/mpc8313erdb/mpc8313erdb.c
+++ b/board/freescale/mpc8313erdb/mpc8313erdb.c
@@ -70,22 +70,22 @@ int checkboard(void)
 #ifndef CONFIG_NAND_SPL
 static struct pci_region pci_regions[] = {
 	{
-		bus_start: CONFIG_SYS_PCI1_MEM_BASE,
-		phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
-		size: CONFIG_SYS_PCI1_MEM_SIZE,
-		flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
+		.bus_start = CONFIG_SYS_PCI1_MEM_BASE,
+		.phys_start = CONFIG_SYS_PCI1_MEM_PHYS,
+		.size = CONFIG_SYS_PCI1_MEM_SIZE,
+		.flags = PCI_REGION_MEM | PCI_REGION_PREFETCH
 	},
 	{
-		bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
-		phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
-		size: CONFIG_SYS_PCI1_MMIO_SIZE,
-		flags: PCI_REGION_MEM
+		.bus_start = CONFIG_SYS_PCI1_MMIO_BASE,
+		.phys_start = CONFIG_SYS_PCI1_MMIO_PHYS,
+		.size = CONFIG_SYS_PCI1_MMIO_SIZE,
+		.flags = PCI_REGION_MEM
 	},
 	{
-		bus_start: CONFIG_SYS_PCI1_IO_BASE,
-		phys_start: CONFIG_SYS_PCI1_IO_PHYS,
-		size: CONFIG_SYS_PCI1_IO_SIZE,
-		flags: PCI_REGION_IO
+		.bus_start = CONFIG_SYS_PCI1_IO_BASE,
+		.phys_start = CONFIG_SYS_PCI1_IO_PHYS,
+		.size = CONFIG_SYS_PCI1_IO_SIZE,
+		.flags = PCI_REGION_IO
 	}
 };
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 18/25] drivers/block/: sparse fixes
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (16 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 17/25] powerpc/mpc83xx: " Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 19/25] drivers/gpio/mpc83xx_gpio.c: " Kim Phillips
                     ` (7 subsequent siblings)
  25 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

sata_sil.c:371:7: warning: symbol 'sil_sata_rw_lba28' was not declared. Should it be static?
sata_sil.c:399:7: warning: symbol 'sil_sata_rw_lba48' was not declared. Should it be static?
sata_sil.c:429:6: warning: symbol 'sil_sata_cmd_flush_cache' was not declared. Should it be static?
sata_sil.c:441:6: warning: symbol 'sil_sata_cmd_flush_cache_ext' was not declared. Should it be static?
sata_sil.c:489:7: warning: symbol 'sata_read' was not declared. Should it be static?
sata_sil.c:505:7: warning: symbol 'sata_write' was not declared. Should it be static?
sata_sil.c:526:5: warning: symbol 'init_sata' was not declared. Should it be static?
sata_sil.c:588:5: warning: symbol 'scan_sata' was not declared. Should it be static?
fsl_sata.c:59:6: warning: symbol 'dprint_buffer' was not declared. Should it be static?
fsl_sata.c:187:42: warning: incorrect type in assignment (different base types)
fsl_sata.c:187:42:    expected unsigned int [unsigned] [usertype] cda
fsl_sata.c:187:42:    got restricted __le32 [usertype] <noident>
fsl_sata.c:291:6: warning: symbol 'fsl_sata_hardware_reset' was not declared. Should it be static?
fsl_sata.c:418:27: warning: incorrect type in assignment (different base types)
fsl_sata.c:418:27:    expected unsigned int [unsigned] [usertype] dba
fsl_sata.c:418:27:    got restricted __le32 [usertype] <noident>
fsl_sata.c:424:41: warning: incorrect type in assignment (different base types)
fsl_sata.c:424:41:    expected unsigned int [unsigned] [usertype] ext_c_ddc
fsl_sata.c:424:41:    got restricted __le32 [usertype] <noident>
fsl_sata.c:431:41: warning: incorrect type in assignment (different base types)
fsl_sata.c:431:41:    expected unsigned int [unsigned] [usertype] ext_c_ddc
fsl_sata.c:431:41:    got restricted __le32 [usertype] <noident>
fsl_sata.c:442:22: warning: incorrect type in assignment (different base types)
fsl_sata.c:442:22:    expected unsigned int [unsigned] [usertype] cda
fsl_sata.c:442:22:    got restricted __le32 [usertype] <noident>
fsl_sata.c:446:31: warning: incorrect type in assignment (different base types)
fsl_sata.c:446:31:    expected unsigned int [unsigned] [usertype] prde_fis_len
fsl_sata.c:446:31:    got restricted __le32 [usertype] <noident>
fsl_sata.c:448:22: warning: incorrect type in assignment (different base types)
fsl_sata.c:448:22:    expected unsigned int [unsigned] [usertype] ttl
fsl_sata.c:448:22:    got restricted __le32 [usertype] <noident>
fsl_sata.c:460:28: warning: incorrect type in assignment (different base types)
fsl_sata.c:460:28:    expected unsigned int [unsigned] [usertype] attribute
fsl_sata.c:460:28:    got restricted __le32 [usertype] <noident>
fsl_sata.c:623:6: warning: symbol 'fsl_sata_flush_cache' was not declared. Should it be static?
fsl_sata.c:667:5: warning: symbol 'fsl_sata_rw_ncq_cmd' was not declared. Should it be static?
fsl_sata.c:710:6: warning: symbol 'fsl_sata_flush_cache_ext' was not declared. Should it be static?
fsl_sata.c:725:6: warning: symbol 'fsl_sata_software_reset' was not declared. Should it be static?
fsl_sata.c:760:5: warning: symbol 'ata_low_level_rw_lba48' was not declared. Should it be static?
fsl_sata.c:795:5: warning: symbol 'ata_low_level_rw_lba28' was not declared. Should it be static?

the following compiler warnings show up after fixing the above, so
remove those three functions:

fsl_sata.c:59:13: warning: 'dprint_buffer' defined but not used [-Wunused-function]
fsl_sata.c:291:13: warning: 'fsl_sata_hardware_reset' defined but not used [-Wunused-function]
fsl_sata.c:726:13: warning: 'fsl_sata_software_reset' defined but not used [-Wunused-function]

Other than that, the following are fixed by __iomem annotation:

fsl_sata.c:84:39: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:84:39:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:84:39:    got unsigned int volatile *addr
fsl_sata.c:172:26: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:172:26:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:172:26:    got unsigned int *<noident>
fsl_sata.c:175:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:175:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:175:19:    got unsigned int *<noident>
fsl_sata.c:181:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:181:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:181:19:    got unsigned int *<noident>
fsl_sata.c:184:26: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:184:26:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:184:26:    got unsigned int *<noident>
fsl_sata.c:186:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:186:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:186:19:    got unsigned int *<noident>
fsl_sata.c:189:26: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:189:26:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:189:26:    got unsigned int *<noident>
fsl_sata.c:191:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:191:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:191:19:    got unsigned int *<noident>
fsl_sata.c:194:26: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:194:26:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:194:26:    got unsigned int *<noident>
fsl_sata.c:195:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:195:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:195:19:    got unsigned int *<noident>
fsl_sata.c:198:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:198:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:198:19:    got unsigned int *<noident>
fsl_sata.c:201:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:201:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:201:19:    got unsigned int *<noident>
fsl_sata.c:204:26: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:204:26:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:204:26:    got unsigned int *<noident>
fsl_sata.c:205:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:205:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:205:19:    got unsigned int *<noident>
fsl_sata.c:208:26: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:208:26:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:208:26:    got unsigned int *<noident>
fsl_sata.c:209:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:209:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:209:19:    got unsigned int *<noident>
fsl_sata.c:212:26: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:212:26:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:212:26:    got unsigned int *<noident>
fsl_sata.c:213:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:213:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:213:19:    got unsigned int *<noident>
fsl_sata.c:216:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:216:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:216:19:    got unsigned int *<noident>
fsl_sata.c:219:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:219:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:219:19:    got unsigned int *<noident>
fsl_sata.c:222:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:222:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:222:19:    got unsigned int *<noident>
fsl_sata.c:225:26: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:225:26:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:225:26:    got unsigned int *<noident>
fsl_sata.c:227:19: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:227:19:    expected unsigned int volatile [noderef] <asn:2>*addr
fsl_sata.c:227:19:    got unsigned int *<noident>
fsl_sata.c:242:26: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:242:26:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:242:26:    got unsigned int *<noident>
fsl_sata.c:256:32: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:256:32:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:256:32:    got unsigned int *<noident>
fsl_sata.c:262:26: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:262:26:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:262:26:    got unsigned int *<noident>
fsl_sata.c:274:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:274:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:274:53:    got unsigned int *<noident>
fsl_sata.c:275:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:275:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:275:53:    got unsigned int *<noident>
fsl_sata.c:276:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:276:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:276:53:    got unsigned int *<noident>
fsl_sata.c:277:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:277:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:277:53:    got unsigned int *<noident>
fsl_sata.c:278:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:278:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:278:53:    got unsigned int *<noident>
fsl_sata.c:279:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:279:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:279:53:    got unsigned int *<noident>
fsl_sata.c:280:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:280:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:280:53:    got unsigned int *<noident>
fsl_sata.c:281:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:281:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:281:53:    got unsigned int *<noident>
fsl_sata.c:282:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:282:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:282:53:    got unsigned int *<noident>
fsl_sata.c:283:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:283:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:283:53:    got unsigned int *<noident>
fsl_sata.c:284:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:284:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:284:53:    got unsigned int *<noident>
fsl_sata.c:285:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:285:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:285:53:    got unsigned int *<noident>
fsl_sata.c:286:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:286:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:286:53:    got unsigned int *<noident>
fsl_sata.c:287:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:287:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:287:53:    got unsigned int *<noident>
fsl_sata.c:288:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:288:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:288:53:    got unsigned int *<noident>
fsl_sata.c:289:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:289:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:289:53:    got unsigned int *<noident>
fsl_sata.c:290:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:290:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:290:53:    got unsigned int *<noident>
fsl_sata.c:291:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:291:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:291:53:    got unsigned int *<noident>
fsl_sata.c:292:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:292:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:292:53:    got unsigned int *<noident>
fsl_sata.c:293:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:293:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:293:53:    got unsigned int *<noident>
fsl_sata.c:294:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:294:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:294:53:    got unsigned int *<noident>
fsl_sata.c:295:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:295:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:295:53:    got unsigned int *<noident>
fsl_sata.c:296:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:296:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:296:53:    got unsigned int *<noident>
fsl_sata.c:297:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:297:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:297:53:    got unsigned int *<noident>
fsl_sata.c:298:53: warning: incorrect type in argument 1 (different address spaces)
fsl_sata.c:298:53:    expected unsigned int const volatile [noderef] <asn:2>*addr
fsl_sata.c:298:53:    got unsigned int *<noident>

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: checkpatch fixes.

 drivers/block/fsl_sata.c | 81 +++++++-----------------------------------------
 drivers/block/fsl_sata.h | 13 ++++----
 drivers/block/sata_sil.c | 13 ++++----
 3 files changed, 25 insertions(+), 82 deletions(-)

diff --git a/drivers/block/fsl_sata.c b/drivers/block/fsl_sata.c
index fda3389..1f9d7b0 100644
--- a/drivers/block/fsl_sata.c
+++ b/drivers/block/fsl_sata.c
@@ -56,25 +56,6 @@ static inline void sdelay(unsigned long sec)
 		mdelay(1000);
 }
 
-void dprint_buffer(unsigned char *buf, int len)
-{
-	int i, j;
-
-	i = 0;
-	j = 0;
-	printf("\n\r");
-
-	for (i = 0; i < len; i++) {
-		printf("%02x ", *buf++);
-		j++;
-		if (j == 16) {
-			printf("\n\r");
-			j = 0;
-		}
-	}
-	printf("\n\r");
-}
-
 static void fsl_sata_dump_sfis(struct sata_fis_d2h *s)
 {
 	printf("Status FIS dump:\n\r");
@@ -94,7 +75,7 @@ static void fsl_sata_dump_sfis(struct sata_fis_d2h *s)
 	printf("sector_count_exp:	%02x\n\r", s->sector_count_exp);
 }
 
-static int ata_wait_register(volatile unsigned *addr, u32 mask,
+static int ata_wait_register(unsigned __iomem *addr, u32 mask,
 			 u32 val, u32 timeout_msec)
 {
 	int i;
@@ -112,7 +93,7 @@ int init_sata(int dev)
 	cmd_hdr_tbl_t *cmd_hdr;
 	u32 cda;
 	u32 val32;
-	fsl_sata_reg_t *reg;
+	fsl_sata_reg_t __iomem *reg;
 	u32 sig;
 	int i;
 	fsl_sata_t *sata;
@@ -287,42 +268,7 @@ int init_sata(int dev)
 	return 0;
 }
 
-/* Hardware reset, like Power-on and COMRESET */
-void fsl_sata_hardware_reset(u32 reg_base)
-{
-	fsl_sata_reg_t *reg = (fsl_sata_reg_t *)reg_base;
-	u32 scontrol;
-
-	/* Disable the SATA interface and put PHY offline */
-	scontrol = in_le32(&reg->scontrol);
-	scontrol = (scontrol & 0x0f0) | 0x304;
-	out_le32(&reg->scontrol, scontrol);
-
-	/* No speed strict */
-	scontrol = in_le32(&reg->scontrol);
-	scontrol = scontrol & ~0x0f0;
-	out_le32(&reg->scontrol, scontrol);
-
-	/* Issue PHY wake/reset, Hardware_reset_asserted */
-	scontrol = in_le32(&reg->scontrol);
-	scontrol = (scontrol & 0x0f0) | 0x301;
-	out_le32(&reg->scontrol, scontrol);
-
-	mdelay(100);
-
-	/* Resume PHY, COMRESET negated, the device initialize hardware
-	 * and execute diagnostics, send good status-signature to host,
-	 * which is D2H register FIS, and then the device enter idle state.
-	 */
-	scontrol = in_le32(&reg->scontrol);
-	scontrol = (scontrol & 0x0f0) | 0x300;
-	out_le32(&reg->scontrol, scontrol);
-
-	mdelay(100);
-	return;
-}
-
-static void fsl_sata_dump_regs(fsl_sata_reg_t *reg)
+static void fsl_sata_dump_regs(fsl_sata_reg_t __iomem *reg)
 {
 	printf("\n\rSATA:           %08x\n\r", (u32)reg);
 	printf("CQR:            %08x\n\r", in_le32(&reg->cqr));
@@ -363,7 +309,7 @@ static int fsl_ata_exec_ata_cmd(struct fsl_sata *sata, struct sata_fis_h2d *cfis
 	u32 prde_count;
 	u32 val32;
 	u32 ttl;
-	fsl_sata_reg_t *reg = sata->reg_base;
+	fsl_sata_reg_t __iomem *reg = sata->reg_base;
 	int i;
 
 	/* Check xfer length */
@@ -620,7 +566,7 @@ static u32 fsl_sata_rw_cmd(int dev, u32 start, u32 blkcnt, u8 *buffer, int is_wr
 	return blkcnt;
 }
 
-void fsl_sata_flush_cache(int dev)
+static void fsl_sata_flush_cache(int dev)
 {
 	fsl_sata_t *sata = (fsl_sata_t *)sata_dev_desc[dev].priv;
 	struct sata_fis_h2d h2d, *cfis = &h2d;
@@ -664,7 +610,8 @@ static u32 fsl_sata_rw_cmd_ext(int dev, u32 start, u32 blkcnt, u8 *buffer, int i
 	return blkcnt;
 }
 
-u32 fsl_sata_rw_ncq_cmd(int dev, u32 start, u32 blkcnt, u8 *buffer, int is_write)
+static u32 fsl_sata_rw_ncq_cmd(int dev, u32 start, u32 blkcnt, u8 *buffer,
+			       int is_write)
 {
 	fsl_sata_t *sata = (fsl_sata_t *)sata_dev_desc[dev].priv;
 	struct sata_fis_h2d h2d, *cfis = &h2d;
@@ -707,7 +654,7 @@ u32 fsl_sata_rw_ncq_cmd(int dev, u32 start, u32 blkcnt, u8 *buffer, int is_write
 	return blkcnt;
 }
 
-void fsl_sata_flush_cache_ext(int dev)
+static void fsl_sata_flush_cache_ext(int dev)
 {
 	fsl_sata_t *sata = (fsl_sata_t *)sata_dev_desc[dev].priv;
 	struct sata_fis_h2d h2d, *cfis = &h2d;
@@ -721,12 +668,6 @@ void fsl_sata_flush_cache_ext(int dev)
 	fsl_sata_exec_cmd(sata, cfis, CMD_ATA, 0, NULL, 0);
 }
 
-/* Software reset, set SRST of the Device Control register */
-void fsl_sata_software_reset(int dev)
-{
-	return;
-}
-
 static void fsl_sata_init_wcache(int dev, u16 *id)
 {
 	fsl_sata_t *sata = (fsl_sata_t *)sata_dev_desc[dev].priv;
@@ -757,7 +698,7 @@ static int fsl_sata_get_flush_ext(int dev)
 	return sata->flush_ext;
 }
 
-u32 ata_low_level_rw_lba48(int dev, u32 blknr, lbaint_t blkcnt,
+static u32 ata_low_level_rw_lba48(int dev, u32 blknr, lbaint_t blkcnt,
 		const void *buffer, int is_write)
 {
 	u32 start, blks;
@@ -792,8 +733,8 @@ u32 ata_low_level_rw_lba48(int dev, u32 blknr, lbaint_t blkcnt,
 	return blkcnt;
 }
 
-u32 ata_low_level_rw_lba28(int dev, u32 blknr, u32 blkcnt, const void *buffer,
-		int is_write)
+static u32 ata_low_level_rw_lba28(int dev, u32 blknr, u32 blkcnt,
+				  const void *buffer, int is_write)
 {
 	u32 start, blks;
 	u8 *addr;
diff --git a/drivers/block/fsl_sata.h b/drivers/block/fsl_sata.h
index cecff68..a9c27bc 100644
--- a/drivers/block/fsl_sata.h
+++ b/drivers/block/fsl_sata.h
@@ -176,10 +176,11 @@ typedef struct fsl_sata_reg {
 * Command Header Entry
 */
 typedef struct cmd_hdr_entry {
-	u32 cda;		/* Command Descriptor Address, 4 bytes aligned */
-	u32 prde_fis_len;	/* Number of PRD entries and FIS length */
-	u32 ttl;		/* Total transfer length */
-	u32 attribute;		/* the attribute of command */
+	__le32 cda;		/* Command Descriptor Address,
+				   4 bytes aligned */
+	__le32 prde_fis_len;	/* Number of PRD entries and FIS length */
+	__le32 ttl;		/* Total transfer length */
+	__le32 attribute;	/* the attribute of command */
 } __attribute__ ((packed)) cmd_hdr_entry_t;
 
 #define SATA_HC_CMD_HDR_ENTRY_SIZE	sizeof(struct cmd_hdr_entry)
@@ -230,10 +231,10 @@ typedef struct cmd_hdr_tbl {
 * PRD entry - Physical Region Descriptor entry
 */
 typedef struct prd_entry {
-	u32 dba;	/* Data base address, 4 bytes aligned */
+	__le32 dba;	/* Data base address, 4 bytes aligned */
 	u32 res1;
 	u32 res2;
-	u32 ext_c_ddc;	/* Indirect PRD flags, snoop and data word count */
+	__le32 ext_c_ddc; /* Indirect PRD flags, snoop and data word count */
 } __attribute__ ((packed)) prd_entry_t;
 
 #define SATA_HC_CMD_DESC_PRD_SIZE	sizeof(struct prd_entry)
diff --git a/drivers/block/sata_sil.c b/drivers/block/sata_sil.c
index 245b872..b70f04d 100644
--- a/drivers/block/sata_sil.c
+++ b/drivers/block/sata_sil.c
@@ -27,6 +27,7 @@
 #include <fis.h>
 #include <sata.h>
 #include <libata.h>
+#include <sata.h>
 #include "sata_sil.h"
 
 /* Convert sectorsize to wordsize */
@@ -369,8 +370,8 @@ static ulong sil_sata_rw_cmd_ext(int dev, ulong start, ulong blkcnt,
 	return blkcnt;
 }
 
-ulong sil_sata_rw_lba28(int dev, ulong blknr, lbaint_t blkcnt,
-		const void *buffer, int is_write)
+static ulong sil_sata_rw_lba28(int dev, ulong blknr, lbaint_t blkcnt,
+			       const void *buffer, int is_write)
 {
 	ulong start, blks, max_blks;
 	u8 *addr;
@@ -397,8 +398,8 @@ ulong sil_sata_rw_lba28(int dev, ulong blknr, lbaint_t blkcnt,
 	return blkcnt;
 }
 
-ulong sil_sata_rw_lba48(int dev, ulong blknr, lbaint_t blkcnt,
-		const void *buffer, int is_write)
+static ulong sil_sata_rw_lba48(int dev, ulong blknr, lbaint_t blkcnt,
+			       const void *buffer, int is_write)
 {
 	ulong start, blks, max_blks;
 	u8 *addr;
@@ -427,7 +428,7 @@ ulong sil_sata_rw_lba48(int dev, ulong blknr, lbaint_t blkcnt,
 	return blkcnt;
 }
 
-void sil_sata_cmd_flush_cache(int dev)
+static void sil_sata_cmd_flush_cache(int dev)
 {
 	struct sil_cmd_block cmdb, *pcmd = &cmdb;
 
@@ -439,7 +440,7 @@ void sil_sata_cmd_flush_cache(int dev)
 	sil_exec_cmd(dev, pcmd, 0);
 }
 
-void sil_sata_cmd_flush_cache_ext(int dev)
+static void sil_sata_cmd_flush_cache_ext(int dev)
 {
 	struct sil_cmd_block cmdb, *pcmd = &cmdb;
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 19/25] drivers/gpio/mpc83xx_gpio.c: sparse fixes
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (17 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 18/25] drivers/block/: " Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 20/25] drivers/input/input.c: sparse fix Kim Phillips
                     ` (6 subsequent siblings)
  25 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

mpc83xx_gpio.c:166:26: warning: non-ANSI function declaration of function 'mpc83xx_gpio_init_f'
mpc83xx_gpio.c:190:26: warning: non-ANSI function declaration of function 'mpc83xx_gpio_init_r'

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: no changes

 drivers/gpio/mpc83xx_gpio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/mpc83xx_gpio.c b/drivers/gpio/mpc83xx_gpio.c
index a9afcb2..e167852 100644
--- a/drivers/gpio/mpc83xx_gpio.c
+++ b/drivers/gpio/mpc83xx_gpio.c
@@ -163,7 +163,7 @@ int gpio_set_value(unsigned gpio, int value)
 }
 
 /* Configure GPIO registers early */
-void mpc83xx_gpio_init_f()
+void mpc83xx_gpio_init_f(void)
 {
 	immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
 
@@ -187,7 +187,7 @@ void mpc83xx_gpio_init_f()
 }
 
 /* Initialize GPIO soft-copies */
-void mpc83xx_gpio_init_r()
+void mpc83xx_gpio_init_r(void)
 {
 #if MPC83XX_GPIO_CTRLRS >= 1
 	gpio_output_value[0] = CONFIG_MPC83XX_GPIO_0_INIT_VALUE;
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 20/25] drivers/input/input.c: sparse fix
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (18 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 19/25] drivers/gpio/mpc83xx_gpio.c: " Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-10-31  5:51     ` Simon Glass
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 21/25] drivers/mmc/mmc.c: sparse fixes Kim Phillips
                     ` (5 subsequent siblings)
  25 siblings, 1 reply; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

input.c:97:5: warning: symbol 'input_queue_ascii' was not declared. Should it be

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: no changes

 drivers/input/input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index 9800667..04fa5f0 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -110,7 +110,7 @@ static struct {
 /* Maximum number of output characters that an ANSI sequence expands to */
 #define ANSI_CHAR_MAX	3
 
-int input_queue_ascii(struct input_config *config, int ch)
+static int input_queue_ascii(struct input_config *config, int ch)
 {
 	if (config->fifo_in + 1 == INPUT_BUFFER_LEN) {
 		if (!config->fifo_out)
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 21/25] drivers/mmc/mmc.c: sparse fixes
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (19 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 20/25] drivers/input/input.c: sparse fix Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 22/25] drivers/mmc/fsl_esdhc.c: " Kim Phillips
                     ` (4 subsequent siblings)
  25 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

mmc.c:137:5: warning: symbol 'mmc_send_cmd' was not declared. Should it be static?
mmc.c:203:5: warning: symbol 'mmc_send_status' was not declared. Should it be static?
mmc.c:247:5: warning: symbol 'mmc_set_blocklen' was not declared. Should it be static?
mmc.c:440:5: warning: symbol 'mmc_read_blocks' was not declared. Should it be static?
mmc.c:510:5: warning: symbol 'mmc_go_idle' was not declared. Should it be static?
mmc.c:532:1: warning: symbol 'sd_send_op_cond' was not declared. Should it be static?
mmc.c:597:5: warning: symbol 'mmc_send_op_cond' was not declared. Should it be static?
mmc.c:661:5: warning: symbol 'mmc_send_ext_csd' was not declared. Should it be static?
mmc.c:683:5: warning: symbol 'mmc_switch' was not declared. Should it be static?
mmc.c:705:5: warning: symbol 'mmc_change_freq' was not declared. Should it be static?
mmc.c:775:5: warning: symbol 'sd_switch' was not declared. Should it be static?
mmc.c:796:5: warning: symbol 'sd_change_freq' was not declared. Should it be static?
mmc.c:935:6: warning: symbol 'mmc_set_ios' was not declared. Should it be static?
mmc.c:953:6: warning: symbol 'mmc_set_bus_width' was not declared. Should it be static?
mmc.c:1108:26: warning: dubious: !x & y
mmc.c:960:5: warning: symbol 'mmc_startup' was not declared. Should it be static?
mmc.c:1243:5: warning: symbol 'mmc_send_if_cond' was not declared. Should it be s

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: checkpatch fix.

 drivers/mmc/mmc.c | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 5fbf956..5ffd8c5 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -47,7 +47,8 @@ int __board_mmc_getcd(struct mmc *mmc) {
 int board_mmc_getcd(struct mmc *mmc)__attribute__((weak,
 	alias("__board_mmc_getcd")));
 
-int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
+static int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
+			struct mmc_data *data)
 {
 	struct mmc_data backup;
 	int ret;
@@ -108,7 +109,7 @@ int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
 	return ret;
 }
 
-int mmc_send_status(struct mmc *mmc, int timeout)
+static int mmc_send_status(struct mmc *mmc, int timeout)
 {
 	struct mmc_cmd cmd;
 	int err, retries = 5;
@@ -152,7 +153,7 @@ int mmc_send_status(struct mmc *mmc, int timeout)
 	return 0;
 }
 
-int mmc_set_blocklen(struct mmc *mmc, int len)
+static int mmc_set_blocklen(struct mmc *mmc, int len)
 {
 	struct mmc_cmd cmd;
 
@@ -345,7 +346,8 @@ mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const void*src)
 	return blkcnt;
 }
 
-int mmc_read_blocks(struct mmc *mmc, void *dst, ulong start, lbaint_t blkcnt)
+static int mmc_read_blocks(struct mmc *mmc, void *dst, ulong start,
+			   lbaint_t blkcnt)
 {
 	struct mmc_cmd cmd;
 	struct mmc_data data;
@@ -415,7 +417,7 @@ static ulong mmc_bread(int dev_num, ulong start, lbaint_t blkcnt, void *dst)
 	return blkcnt;
 }
 
-int mmc_go_idle(struct mmc* mmc)
+static int mmc_go_idle(struct mmc *mmc)
 {
 	struct mmc_cmd cmd;
 	int err;
@@ -436,8 +438,7 @@ int mmc_go_idle(struct mmc* mmc)
 	return 0;
 }
 
-int
-sd_send_op_cond(struct mmc *mmc)
+static int sd_send_op_cond(struct mmc *mmc)
 {
 	int timeout = 1000;
 	int err;
@@ -502,7 +503,7 @@ sd_send_op_cond(struct mmc *mmc)
 	return 0;
 }
 
-int mmc_send_op_cond(struct mmc *mmc)
+static int mmc_send_op_cond(struct mmc *mmc)
 {
 	int timeout = 10000;
 	struct mmc_cmd cmd;
@@ -566,7 +567,7 @@ int mmc_send_op_cond(struct mmc *mmc)
 }
 
 
-int mmc_send_ext_csd(struct mmc *mmc, u8 *ext_csd)
+static int mmc_send_ext_csd(struct mmc *mmc, u8 *ext_csd)
 {
 	struct mmc_cmd cmd;
 	struct mmc_data data;
@@ -588,7 +589,7 @@ int mmc_send_ext_csd(struct mmc *mmc, u8 *ext_csd)
 }
 
 
-int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
+static int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
 {
 	struct mmc_cmd cmd;
 	int timeout = 1000;
@@ -610,7 +611,7 @@ int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
 
 }
 
-int mmc_change_freq(struct mmc *mmc)
+static int mmc_change_freq(struct mmc *mmc)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(u8, ext_csd, 512);
 	char cardtype;
@@ -680,7 +681,7 @@ int mmc_getcd(struct mmc *mmc)
 	return cd;
 }
 
-int sd_switch(struct mmc *mmc, int mode, int group, u8 value, u8 *resp)
+static int sd_switch(struct mmc *mmc, int mode, int group, u8 value, u8 *resp)
 {
 	struct mmc_cmd cmd;
 	struct mmc_data data;
@@ -701,7 +702,7 @@ int sd_switch(struct mmc *mmc, int mode, int group, u8 value, u8 *resp)
 }
 
 
-int sd_change_freq(struct mmc *mmc)
+static int sd_change_freq(struct mmc *mmc)
 {
 	int err;
 	struct mmc_cmd cmd;
@@ -840,7 +841,7 @@ static const int multipliers[] = {
 	80,
 };
 
-void mmc_set_ios(struct mmc *mmc)
+static void mmc_set_ios(struct mmc *mmc)
 {
 	mmc->set_ios(mmc);
 }
@@ -858,14 +859,14 @@ void mmc_set_clock(struct mmc *mmc, uint clock)
 	mmc_set_ios(mmc);
 }
 
-void mmc_set_bus_width(struct mmc *mmc, uint width)
+static void mmc_set_bus_width(struct mmc *mmc, uint width)
 {
 	mmc->bus_width = width;
 
 	mmc_set_ios(mmc);
 }
 
-int mmc_startup(struct mmc *mmc)
+static int mmc_startup(struct mmc *mmc)
 {
 	int err, width;
 	uint mult, freq;
@@ -1013,7 +1014,7 @@ int mmc_startup(struct mmc *mmc)
 	if (!IS_SD(mmc) && (mmc->version >= MMC_VERSION_4)) {
 		/* check  ext_csd version and capacity */
 		err = mmc_send_ext_csd(mmc, ext_csd);
-		if (!err & (ext_csd[EXT_CSD_REV] >= 2)) {
+		if (!err && (ext_csd[EXT_CSD_REV] >= 2)) {
 			/*
 			 * According to the JEDEC Standard, the value of
 			 * ext_csd's capacity is valid if the value is more
@@ -1148,7 +1149,7 @@ int mmc_startup(struct mmc *mmc)
 	return 0;
 }
 
-int mmc_send_if_cond(struct mmc *mmc)
+static int mmc_send_if_cond(struct mmc *mmc)
 {
 	struct mmc_cmd cmd;
 	int err;
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 22/25] drivers/mmc/fsl_esdhc.c: sparse fixes
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (20 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 21/25] drivers/mmc/mmc.c: sparse fixes Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 23/25] drivers/mtd/cfi_flash.c: " Kim Phillips
                     ` (3 subsequent siblings)
  25 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

fsl_esdhc.c:71:6: warning: symbol 'esdhc_xfertyp' was not declared. Should it be static?
fsl_esdhc.c:413:6: warning: symbol 'set_sysctl' was not declared. Should it be st

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: no changes

 drivers/mmc/fsl_esdhc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index 3f8d30d..301dd8c 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -68,7 +68,7 @@ struct fsl_esdhc {
 };
 
 /* Return the XFERTYP flags for a given command and data packet */
-uint esdhc_xfertyp(struct mmc_cmd *cmd, struct mmc_data *data)
+static uint esdhc_xfertyp(struct mmc_cmd *cmd, struct mmc_data *data)
 {
 	uint xfertyp = 0;
 
@@ -410,7 +410,7 @@ esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
 	return 0;
 }
 
-void set_sysctl(struct mmc *mmc, uint clock)
+static void set_sysctl(struct mmc *mmc, uint clock)
 {
 	int sdhc_clk = gd->sdhc_clk;
 	int div, pre_div;
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 23/25] drivers/mtd/cfi_flash.c: sparse fixes
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (21 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 22/25] drivers/mmc/fsl_esdhc.c: " Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 24/25] drivers/mtd/nand: " Kim Phillips
                     ` (2 subsequent siblings)
  25 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

cfi_flash.c:756:43: warning: Using plain integer as NULL pointer
cfi_flash.c:1150:52: warning: cast to non-scalar
cfi_flash.c:1433:46: warning: cast truncates bits from constant value (890089 becomes 89)
cfi_flash.c:1490:61: warning: cast truncates bits from constant value (1f001f becomes 1f)
cfi_flash.c:1508:61: warning: cast truncates bits from constant value (10001 becomes 1)
cfi_flash.c:1738:63: warning: cast truncates bits from constant value (10001 becomes 1)
cfi_flash.c:1857:6: warning: symbol '__flash_cmd_reset' was not declared. Should it be static?

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: checkpatch fixes.

 drivers/mtd/cfi_flash.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 43140f3..b2dfc53 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -752,8 +752,8 @@ static void flash_add_byte (flash_info_t * info, cfiword_t * cword, uchar c)
  */
 static flash_sect_t find_sector (flash_info_t * info, ulong addr)
 {
-	static flash_sect_t saved_sector = 0; /* previously found sector */
-	static flash_info_t *saved_info = 0; /* previously used flash bank */
+	static flash_sect_t saved_sector; /* previously found sector */
+	static flash_info_t *saved_info; /* previously used flash bank */
 	flash_sect_t sector = saved_sector;
 
 	if ((info != saved_info) || (sector >= info->sector_count))
@@ -1147,8 +1147,9 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
 			}
 
 			if (use_flash_status_poll(info)) {
-				cfiword_t cword = (cfiword_t)0xffffffffffffffffULL;
+				cfiword_t cword;
 				void *dest;
+				cword.ll = 0xffffffffffffffffULL;
 				dest = flash_map(info, sect, 0);
 				st = flash_status_poll(info, &cword, dest,
 						       info->erase_blk_tout, "erase");
@@ -1430,8 +1431,8 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
 
 static int cfi_protect_bugfix(flash_info_t *info, long sector, int prot)
 {
-	if ((info->manufacturer_id == (uchar)INTEL_MANUFACT) &&
-		(info->device_id == NUMONYX_256MBIT)) {
+	if (info->manufacturer_id == ((INTEL_MANUFACT & FLASH_VENDMASK) >> 16)
+	    && info->device_id == NUMONYX_256MBIT) {
 		/*
 		 * see errata called
 		 * "Numonyx Axcell P33/P30 Specification Update" :)
@@ -1487,7 +1488,8 @@ int flash_real_protect (flash_info_t * info, long sector, int prot)
 		case CFI_CMDSET_AMD_EXTENDED:
 		case CFI_CMDSET_AMD_STANDARD:
 			/* U-Boot only checks the first byte */
-			if (info->manufacturer_id == (uchar)ATM_MANUFACT) {
+			if (info->manufacturer_id ==
+			    ((ATM_MANUFACT & FLASH_VENDMASK) >> 16)) {
 				if (prot) {
 					flash_unlock_seq (info, 0);
 					flash_write_cmd (info, 0,
@@ -1505,7 +1507,8 @@ int flash_real_protect (flash_info_t * info, long sector, int prot)
 							0, ATM_CMD_UNLOCK_SECT);
 				}
 			}
-			if (info->manufacturer_id == (uchar)AMD_MANUFACT) {
+			if (info->manufacturer_id ==
+			    ((AMD_MANUFACT & FLASH_VENDMASK) >> 16)) {
 				int flag = disable_interrupts();
 				int lock_flag;
 
@@ -1735,7 +1738,8 @@ static int cmdset_amd_init(flash_info_t *info, struct cfi_qry *qry)
 	flash_write_cmd(info, 0, info->cfi_offset, FLASH_CMD_CFI);
 
 #ifdef CONFIG_SYS_FLASH_PROTECTION
-	if (info->ext_addr && info->manufacturer_id == (uchar)AMD_MANUFACT) {
+	if (info->ext_addr && info->manufacturer_id ==
+	    ((AMD_MANUFACT & FLASH_VENDMASK) >> 16)) {
 		ushort spus;
 
 		/* read sector protect/unprotect scheme */
@@ -1854,7 +1858,7 @@ static void flash_read_cfi (flash_info_t *info, void *buf,
 		p[i] = flash_read_uchar(info, start + i);
 }
 
-void __flash_cmd_reset(flash_info_t *info)
+static void __flash_cmd_reset(flash_info_t *info)
 {
 	/*
 	 * We do not yet know what kind of commandset to use, so we issue
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 24/25] drivers/mtd/nand: sparse fixes
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (22 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 23/25] drivers/mtd/cfi_flash.c: " Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-10-30  0:43     ` Scott Wood
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 25/25] drivers/serial/serial_ns16550.c: " Kim Phillips
  2012-11-04 18:30   ` [U-Boot] [PATCH v2 00/32] Initial sparse fix series Tom Rini
  25 siblings, 1 reply; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

nand_ecc.c:82:5: warning: symbol 'nand_calculate_ecc' was not declared. Should it be static?
nand_ecc.c:155:5: warning: symbol 'nand_correct_data' was not declared. Should it be static?
nand_base.c:2854:1: error: directive in argument list
nand_base.c:2856:1: error: directive in argument list

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: re-worked based upon input from Scott, checkpatch fixes.

 drivers/mtd/nand/nand_base.c | 13 +++++++------
 drivers/mtd/nand/nand_ecc.c  |  1 +
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 71f5027..d3b71a5 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2601,6 +2601,7 @@ static const struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
 						  int *maf_id, int *dev_id,
 						  const struct nand_flash_dev *type)
 {
+	const char *name;
 	int i, maf_idx;
 	u8 id_data[8];
 	int ret;
@@ -2848,14 +2849,14 @@ ident_done:
 		chip->cmdfunc = nand_command_lp;
 
 	/* TODO onfi flash name */
-	MTDDEBUG (MTD_DEBUG_LEVEL0, "NAND device: Manufacturer ID:"
-		" 0x%02x, Chip ID: 0x%02x (%s %s)\n", *maf_id, *dev_id,
-		nand_manuf_ids[maf_idx].name,
+	name = type->name;
 #ifdef CONFIG_SYS_NAND_ONFI_DETECTION
-		chip->onfi_version ? chip->onfi_params.model : type->name);
-#else
-		type->name);
+	if (chip->onfi_version)
+		name = chip->onfi_params.model;
 #endif
+	MTDDEBUG(MTD_DEBUG_LEVEL0, "NAND device: Manufacturer ID:"
+		 " 0x%02x, Chip ID: 0x%02x (%s %s)\n", *maf_id, *dev_id,
+		 nand_manuf_ids[maf_idx].name, name);
 
 	return type;
 }
diff --git a/drivers/mtd/nand/nand_ecc.c b/drivers/mtd/nand/nand_ecc.c
index 81f0e08..097cf62 100644
--- a/drivers/mtd/nand/nand_ecc.c
+++ b/drivers/mtd/nand/nand_ecc.c
@@ -39,6 +39,7 @@
 
 #include <asm/errno.h>
 #include <linux/mtd/mtd.h>
+#include <linux/mtd/nand_ecc.h>
 
 /* The PPC4xx NDFC uses Smart Media (SMC) bytes order */
 #ifdef CONFIG_NAND_NDFC
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 25/25] drivers/serial/serial_ns16550.c: sparse fixes
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (23 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 24/25] drivers/mtd/nand: " Kim Phillips
@ 2012-10-29 23:34   ` Kim Phillips
  2012-11-04 18:30   ` [U-Boot] [PATCH v2 00/32] Initial sparse fix series Tom Rini
  25 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-29 23:34 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: checkpatch fixes.

 drivers/serial/serial_ns16550.c | 42 ++++++++++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index 4176e25..bf280ba 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -78,21 +78,33 @@ static NS16550_t serial_ports[4] = {
 
 /* Multi serial device functions */
 #define DECLARE_ESERIAL_FUNCTIONS(port) \
-    static int  eserial##port##_init (void) {\
-	int clock_divisor; \
-	clock_divisor = calc_divisor(serial_ports[port-1]); \
-	NS16550_init(serial_ports[port-1], clock_divisor); \
-	return(0);}\
-    static void eserial##port##_setbrg (void) {\
-	serial_setbrg_dev(port);}\
-    static int  eserial##port##_getc (void) {\
-	return serial_getc_dev(port);}\
-    static int  eserial##port##_tstc (void) {\
-	return serial_tstc_dev(port);}\
-    static void eserial##port##_putc (const char c) {\
-	serial_putc_dev(port, c);}\
-    static void eserial##port##_puts (const char *s) {\
-	serial_puts_dev(port, s);}
+	static int  eserial##port##_init(void) \
+	{ \
+		int clock_divisor; \
+		clock_divisor = calc_divisor(serial_ports[port-1]); \
+		NS16550_init(serial_ports[port-1], clock_divisor); \
+		return 0 ; \
+	} \
+	static void eserial##port##_setbrg(void) \
+	{ \
+		serial_setbrg_dev(port); \
+	} \
+	static int  eserial##port##_getc(void) \
+	{ \
+		return serial_getc_dev(port); \
+	} \
+	static int  eserial##port##_tstc(void) \
+	{ \
+		return serial_tstc_dev(port); \
+	} \
+	static void eserial##port##_putc(const char c) \
+	{ \
+		serial_putc_dev(port, c); \
+	} \
+	static void eserial##port##_puts(const char *s) \
+	{ \
+		serial_puts_dev(port, s); \
+	}
 
 /* Serial device descriptor */
 #define INIT_ESERIAL_STRUCTURE(port, __name) {	\
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 24/25] drivers/mtd/nand: sparse fixes
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 24/25] drivers/mtd/nand: " Kim Phillips
@ 2012-10-30  0:43     ` Scott Wood
  0 siblings, 0 replies; 133+ messages in thread
From: Scott Wood @ 2012-10-30  0:43 UTC (permalink / raw)
  To: u-boot

On 10/29/2012 06:34:46 PM, Kim Phillips wrote:
> nand_ecc.c:82:5: warning: symbol 'nand_calculate_ecc' was not  
> declared. Should it be static?
> nand_ecc.c:155:5: warning: symbol 'nand_correct_data' was not  
> declared. Should it be static?
> nand_base.c:2854:1: error: directive in argument list
> nand_base.c:2856:1: error: directive in argument list
> 
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
> ---
> v2: re-worked based upon input from Scott, checkpatch fixes.
> 
>  drivers/mtd/nand/nand_base.c | 13 +++++++------
>  drivers/mtd/nand/nand_ecc.c  |  1 +
>  2 files changed, 8 insertions(+), 6 deletions(-)

Acked-by: Scott Wood <scottwood@freescale.com>

-Scott

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [PATCH] libfdt: introduce fdt type annotation for use by endian checkers
  2012-10-19  0:43       ` David Gibson
@ 2012-10-30 21:57           ` Kim Phillips
  0 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-30 21:57 UTC (permalink / raw)
  To: Jon Loeliger; +Cc: u-boot, devicetree-discuss, David Gibson

Projects such as linux and u-boot run sparse on libfdt.  libfdt
contains the notion of endianness via usage of endian conversion
functions such as fdt32_to_cpu.  As such, in order to pass endian
checks, libfdt has to annotate its fdt variables as big endian.
This patch does that ifdef __CHECKER__ (a symbol sparse defines),
for two new fdt types: fdt32_t and fdt64_t, and subsequently
silences warnings emitted by sparse when parsing libfdt.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
note: wasn't sure whether to introduce the new fdt32 types, or
just have libfdt use __be32 directly.

 libfdt/fdt.c     |  2 +-
 libfdt/fdt.h     | 50 +++++++++++++++++++++++++++++---------------------
 libfdt/fdt_ro.c  |  2 +-
 libfdt/fdt_rw.c  |  4 ++--
 libfdt/fdt_sw.c  |  4 ++--
 libfdt/fdt_wip.c |  2 +-
 libfdt/libfdt.h  | 32 ++++++++++++++++----------------
 7 files changed, 52 insertions(+), 44 deletions(-)

diff --git a/libfdt/fdt.c b/libfdt/fdt.c
index e56833a..57faba3 100644
--- a/libfdt/fdt.c
+++ b/libfdt/fdt.c
@@ -92,7 +92,7 @@ const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)
 
 uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
 {
-	const uint32_t *tagp, *lenp;
+	const fdt32_t *tagp, *lenp;
 	uint32_t tag;
 	int offset = startoffset;
 	const char *p;
diff --git a/libfdt/fdt.h b/libfdt/fdt.h
index 48ccfd9..0d9c856 100644
--- a/libfdt/fdt.h
+++ b/libfdt/fdt.h
@@ -3,46 +3,54 @@
 
 #ifndef __ASSEMBLY__
 
+#ifdef __CHECKER__
+typedef __be32 fdt32_t;
+typedef __be64 fdt64_t;
+#else
+typedef uint32_t fdt32_t;
+typedef uint64_t fdt64_t;
+#endif
+
 struct fdt_header {
-	uint32_t magic;			 /* magic word FDT_MAGIC */
-	uint32_t totalsize;		 /* total size of DT block */
-	uint32_t off_dt_struct;		 /* offset to structure */
-	uint32_t off_dt_strings;	 /* offset to strings */
-	uint32_t off_mem_rsvmap;	 /* offset to memory reserve map */
-	uint32_t version;		 /* format version */
-	uint32_t last_comp_version;	 /* last compatible version */
+	fdt32_t magic;			 /* magic word FDT_MAGIC */
+	fdt32_t totalsize;		 /* total size of DT block */
+	fdt32_t off_dt_struct;		 /* offset to structure */
+	fdt32_t off_dt_strings;		 /* offset to strings */
+	fdt32_t off_mem_rsvmap;		 /* offset to memory reserve map */
+	fdt32_t version;		 /* format version */
+	fdt32_t last_comp_version;	 /* last compatible version */
 
 	/* version 2 fields below */
-	uint32_t boot_cpuid_phys;	 /* Which physical CPU id we're
+	fdt32_t boot_cpuid_phys;	 /* Which physical CPU id we're
 					    booting on */
 	/* version 3 fields below */
-	uint32_t size_dt_strings;	 /* size of the strings block */
+	fdt32_t size_dt_strings;	 /* size of the strings block */
 
 	/* version 17 fields below */
-	uint32_t size_dt_struct;	 /* size of the structure block */
+	fdt32_t size_dt_struct;		 /* size of the structure block */
 };
 
 struct fdt_reserve_entry {
-	uint64_t address;
-	uint64_t size;
+	fdt64_t address;
+	fdt64_t size;
 };
 
 struct fdt_node_header {
-	uint32_t tag;
+	fdt32_t tag;
 	char name[0];
 };
 
 struct fdt_property {
-	uint32_t tag;
-	uint32_t len;
-	uint32_t nameoff;
+	fdt32_t tag;
+	fdt32_t len;
+	fdt32_t nameoff;
 	char data[0];
 };
 
 #endif /* !__ASSEMBLY */
 
 #define FDT_MAGIC	0xd00dfeed	/* 4: version, 4: total size */
-#define FDT_TAGSIZE	sizeof(uint32_t)
+#define FDT_TAGSIZE	sizeof(fdt32_t)
 
 #define FDT_BEGIN_NODE	0x1		/* Start node: full name */
 #define FDT_END_NODE	0x2		/* End node */
@@ -51,10 +59,10 @@ struct fdt_property {
 #define FDT_NOP		0x4		/* nop */
 #define FDT_END		0x9
 
-#define FDT_V1_SIZE	(7*sizeof(uint32_t))
-#define FDT_V2_SIZE	(FDT_V1_SIZE + sizeof(uint32_t))
-#define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(uint32_t))
+#define FDT_V1_SIZE	(7*sizeof(fdt32_t))
+#define FDT_V2_SIZE	(FDT_V1_SIZE + sizeof(fdt32_t))
+#define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(fdt32_t))
 #define FDT_V16_SIZE	FDT_V3_SIZE
-#define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(uint32_t))
+#define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(fdt32_t))
 
 #endif /* _FDT_H */
diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index 02b6d68..42da2bd 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -322,7 +322,7 @@ const void *fdt_getprop(const void *fdt, int nodeoffset,
 
 uint32_t fdt_get_phandle(const void *fdt, int nodeoffset)
 {
-	const uint32_t *php;
+	const fdt32_t *php;
 	int len;
 
 	/* FIXME: This is a bit sub-optimal, since we potentially scan
diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c
index 24437df..fdba618 100644
--- a/libfdt/fdt_rw.c
+++ b/libfdt/fdt_rw.c
@@ -339,7 +339,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
 	int nodelen;
 	int err;
 	uint32_t tag;
-	uint32_t *endtag;
+	fdt32_t *endtag;
 
 	FDT_RW_CHECK_HEADER(fdt);
 
@@ -366,7 +366,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
 	nh->tag = cpu_to_fdt32(FDT_BEGIN_NODE);
 	memset(nh->name, 0, FDT_TAGALIGN(namelen+1));
 	memcpy(nh->name, name, namelen);
-	endtag = (uint32_t *)((char *)nh + nodelen - FDT_TAGSIZE);
+	endtag = (fdt32_t *)((char *)nh + nodelen - FDT_TAGSIZE);
 	*endtag = cpu_to_fdt32(FDT_END_NODE);
 
 	return offset;
diff --git a/libfdt/fdt_sw.c b/libfdt/fdt_sw.c
index 55ebebf..f422754 100644
--- a/libfdt/fdt_sw.c
+++ b/libfdt/fdt_sw.c
@@ -153,7 +153,7 @@ int fdt_begin_node(void *fdt, const char *name)
 
 int fdt_end_node(void *fdt)
 {
-	uint32_t *en;
+	fdt32_t *en;
 
 	FDT_SW_CHECK_HEADER(fdt);
 
@@ -213,7 +213,7 @@ int fdt_property(void *fdt, const char *name, const void *val, int len)
 int fdt_finish(void *fdt)
 {
 	char *p = (char *)fdt;
-	uint32_t *end;
+	fdt32_t *end;
 	int oldstroffset, newstroffset;
 	uint32_t tag;
 	int offset, nextoffset;
diff --git a/libfdt/fdt_wip.c b/libfdt/fdt_wip.c
index 6025fa1..c5bbb68 100644
--- a/libfdt/fdt_wip.c
+++ b/libfdt/fdt_wip.c
@@ -74,7 +74,7 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
 
 static void _fdt_nop_region(void *start, int len)
 {
-	uint32_t *p;
+	fdt32_t *p;
 
 	for (p = start; (char *)p < ((char *)start + len); p++)
 		*p = cpu_to_fdt32(FDT_NOP);
diff --git a/libfdt/libfdt.h b/libfdt/libfdt.h
index 73f4975..8e57a06 100644
--- a/libfdt/libfdt.h
+++ b/libfdt/libfdt.h
@@ -882,8 +882,8 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset,
 					  const char *name, uint32_t val)
 {
-	val = cpu_to_fdt32(val);
-	return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt32_t tmp = cpu_to_fdt32(val);
+	return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
@@ -917,8 +917,8 @@ static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset,
 static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset,
 					  const char *name, uint64_t val)
 {
-	val = cpu_to_fdt64(val);
-	return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt64_t tmp = cpu_to_fdt64(val);
+	return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
@@ -993,13 +993,13 @@ int fdt_begin_node(void *fdt, const char *name);
 int fdt_property(void *fdt, const char *name, const void *val, int len);
 static inline int fdt_property_u32(void *fdt, const char *name, uint32_t val)
 {
-	val = cpu_to_fdt32(val);
-	return fdt_property(fdt, name, &val, sizeof(val));
+	fdt32_t tmp = cpu_to_fdt32(val);
+	return fdt_property(fdt, name, &tmp, sizeof(tmp));
 }
 static inline int fdt_property_u64(void *fdt, const char *name, uint64_t val)
 {
-	val = cpu_to_fdt64(val);
-	return fdt_property(fdt, name, &val, sizeof(val));
+	fdt64_t tmp = cpu_to_fdt64(val);
+	return fdt_property(fdt, name, &tmp, sizeof(tmp));
 }
 static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val)
 {
@@ -1154,8 +1154,8 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,
 				  uint32_t val)
 {
-	val = cpu_to_fdt32(val);
-	return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt32_t tmp = cpu_to_fdt32(val);
+	return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
@@ -1189,8 +1189,8 @@ static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name,
 				  uint64_t val)
 {
-	val = cpu_to_fdt64(val);
-	return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt64_t tmp = cpu_to_fdt64(val);
+	return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
@@ -1296,8 +1296,8 @@ int fdt_appendprop(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_appendprop_u32(void *fdt, int nodeoffset,
 				     const char *name, uint32_t val)
 {
-	val = cpu_to_fdt32(val);
-	return fdt_appendprop(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt32_t tmp = cpu_to_fdt32(val);
+	return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
@@ -1331,8 +1331,8 @@ static inline int fdt_appendprop_u32(void *fdt, int nodeoffset,
 static inline int fdt_appendprop_u64(void *fdt, int nodeoffset,
 				     const char *name, uint64_t val)
 {
-	val = cpu_to_fdt64(val);
-	return fdt_appendprop(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt64_t tmp = cpu_to_fdt64(val);
+	return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH] libfdt: introduce fdt type annotation for use by endian checkers
@ 2012-10-30 21:57           ` Kim Phillips
  0 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-30 21:57 UTC (permalink / raw)
  To: u-boot

Projects such as linux and u-boot run sparse on libfdt.  libfdt
contains the notion of endianness via usage of endian conversion
functions such as fdt32_to_cpu.  As such, in order to pass endian
checks, libfdt has to annotate its fdt variables as big endian.
This patch does that ifdef __CHECKER__ (a symbol sparse defines),
for two new fdt types: fdt32_t and fdt64_t, and subsequently
silences warnings emitted by sparse when parsing libfdt.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
note: wasn't sure whether to introduce the new fdt32 types, or
just have libfdt use __be32 directly.

 libfdt/fdt.c     |  2 +-
 libfdt/fdt.h     | 50 +++++++++++++++++++++++++++++---------------------
 libfdt/fdt_ro.c  |  2 +-
 libfdt/fdt_rw.c  |  4 ++--
 libfdt/fdt_sw.c  |  4 ++--
 libfdt/fdt_wip.c |  2 +-
 libfdt/libfdt.h  | 32 ++++++++++++++++----------------
 7 files changed, 52 insertions(+), 44 deletions(-)

diff --git a/libfdt/fdt.c b/libfdt/fdt.c
index e56833a..57faba3 100644
--- a/libfdt/fdt.c
+++ b/libfdt/fdt.c
@@ -92,7 +92,7 @@ const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)
 
 uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
 {
-	const uint32_t *tagp, *lenp;
+	const fdt32_t *tagp, *lenp;
 	uint32_t tag;
 	int offset = startoffset;
 	const char *p;
diff --git a/libfdt/fdt.h b/libfdt/fdt.h
index 48ccfd9..0d9c856 100644
--- a/libfdt/fdt.h
+++ b/libfdt/fdt.h
@@ -3,46 +3,54 @@
 
 #ifndef __ASSEMBLY__
 
+#ifdef __CHECKER__
+typedef __be32 fdt32_t;
+typedef __be64 fdt64_t;
+#else
+typedef uint32_t fdt32_t;
+typedef uint64_t fdt64_t;
+#endif
+
 struct fdt_header {
-	uint32_t magic;			 /* magic word FDT_MAGIC */
-	uint32_t totalsize;		 /* total size of DT block */
-	uint32_t off_dt_struct;		 /* offset to structure */
-	uint32_t off_dt_strings;	 /* offset to strings */
-	uint32_t off_mem_rsvmap;	 /* offset to memory reserve map */
-	uint32_t version;		 /* format version */
-	uint32_t last_comp_version;	 /* last compatible version */
+	fdt32_t magic;			 /* magic word FDT_MAGIC */
+	fdt32_t totalsize;		 /* total size of DT block */
+	fdt32_t off_dt_struct;		 /* offset to structure */
+	fdt32_t off_dt_strings;		 /* offset to strings */
+	fdt32_t off_mem_rsvmap;		 /* offset to memory reserve map */
+	fdt32_t version;		 /* format version */
+	fdt32_t last_comp_version;	 /* last compatible version */
 
 	/* version 2 fields below */
-	uint32_t boot_cpuid_phys;	 /* Which physical CPU id we're
+	fdt32_t boot_cpuid_phys;	 /* Which physical CPU id we're
 					    booting on */
 	/* version 3 fields below */
-	uint32_t size_dt_strings;	 /* size of the strings block */
+	fdt32_t size_dt_strings;	 /* size of the strings block */
 
 	/* version 17 fields below */
-	uint32_t size_dt_struct;	 /* size of the structure block */
+	fdt32_t size_dt_struct;		 /* size of the structure block */
 };
 
 struct fdt_reserve_entry {
-	uint64_t address;
-	uint64_t size;
+	fdt64_t address;
+	fdt64_t size;
 };
 
 struct fdt_node_header {
-	uint32_t tag;
+	fdt32_t tag;
 	char name[0];
 };
 
 struct fdt_property {
-	uint32_t tag;
-	uint32_t len;
-	uint32_t nameoff;
+	fdt32_t tag;
+	fdt32_t len;
+	fdt32_t nameoff;
 	char data[0];
 };
 
 #endif /* !__ASSEMBLY */
 
 #define FDT_MAGIC	0xd00dfeed	/* 4: version, 4: total size */
-#define FDT_TAGSIZE	sizeof(uint32_t)
+#define FDT_TAGSIZE	sizeof(fdt32_t)
 
 #define FDT_BEGIN_NODE	0x1		/* Start node: full name */
 #define FDT_END_NODE	0x2		/* End node */
@@ -51,10 +59,10 @@ struct fdt_property {
 #define FDT_NOP		0x4		/* nop */
 #define FDT_END		0x9
 
-#define FDT_V1_SIZE	(7*sizeof(uint32_t))
-#define FDT_V2_SIZE	(FDT_V1_SIZE + sizeof(uint32_t))
-#define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(uint32_t))
+#define FDT_V1_SIZE	(7*sizeof(fdt32_t))
+#define FDT_V2_SIZE	(FDT_V1_SIZE + sizeof(fdt32_t))
+#define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(fdt32_t))
 #define FDT_V16_SIZE	FDT_V3_SIZE
-#define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(uint32_t))
+#define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(fdt32_t))
 
 #endif /* _FDT_H */
diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index 02b6d68..42da2bd 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -322,7 +322,7 @@ const void *fdt_getprop(const void *fdt, int nodeoffset,
 
 uint32_t fdt_get_phandle(const void *fdt, int nodeoffset)
 {
-	const uint32_t *php;
+	const fdt32_t *php;
 	int len;
 
 	/* FIXME: This is a bit sub-optimal, since we potentially scan
diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c
index 24437df..fdba618 100644
--- a/libfdt/fdt_rw.c
+++ b/libfdt/fdt_rw.c
@@ -339,7 +339,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
 	int nodelen;
 	int err;
 	uint32_t tag;
-	uint32_t *endtag;
+	fdt32_t *endtag;
 
 	FDT_RW_CHECK_HEADER(fdt);
 
@@ -366,7 +366,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
 	nh->tag = cpu_to_fdt32(FDT_BEGIN_NODE);
 	memset(nh->name, 0, FDT_TAGALIGN(namelen+1));
 	memcpy(nh->name, name, namelen);
-	endtag = (uint32_t *)((char *)nh + nodelen - FDT_TAGSIZE);
+	endtag = (fdt32_t *)((char *)nh + nodelen - FDT_TAGSIZE);
 	*endtag = cpu_to_fdt32(FDT_END_NODE);
 
 	return offset;
diff --git a/libfdt/fdt_sw.c b/libfdt/fdt_sw.c
index 55ebebf..f422754 100644
--- a/libfdt/fdt_sw.c
+++ b/libfdt/fdt_sw.c
@@ -153,7 +153,7 @@ int fdt_begin_node(void *fdt, const char *name)
 
 int fdt_end_node(void *fdt)
 {
-	uint32_t *en;
+	fdt32_t *en;
 
 	FDT_SW_CHECK_HEADER(fdt);
 
@@ -213,7 +213,7 @@ int fdt_property(void *fdt, const char *name, const void *val, int len)
 int fdt_finish(void *fdt)
 {
 	char *p = (char *)fdt;
-	uint32_t *end;
+	fdt32_t *end;
 	int oldstroffset, newstroffset;
 	uint32_t tag;
 	int offset, nextoffset;
diff --git a/libfdt/fdt_wip.c b/libfdt/fdt_wip.c
index 6025fa1..c5bbb68 100644
--- a/libfdt/fdt_wip.c
+++ b/libfdt/fdt_wip.c
@@ -74,7 +74,7 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
 
 static void _fdt_nop_region(void *start, int len)
 {
-	uint32_t *p;
+	fdt32_t *p;
 
 	for (p = start; (char *)p < ((char *)start + len); p++)
 		*p = cpu_to_fdt32(FDT_NOP);
diff --git a/libfdt/libfdt.h b/libfdt/libfdt.h
index 73f4975..8e57a06 100644
--- a/libfdt/libfdt.h
+++ b/libfdt/libfdt.h
@@ -882,8 +882,8 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset,
 					  const char *name, uint32_t val)
 {
-	val = cpu_to_fdt32(val);
-	return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt32_t tmp = cpu_to_fdt32(val);
+	return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
@@ -917,8 +917,8 @@ static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset,
 static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset,
 					  const char *name, uint64_t val)
 {
-	val = cpu_to_fdt64(val);
-	return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt64_t tmp = cpu_to_fdt64(val);
+	return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
@@ -993,13 +993,13 @@ int fdt_begin_node(void *fdt, const char *name);
 int fdt_property(void *fdt, const char *name, const void *val, int len);
 static inline int fdt_property_u32(void *fdt, const char *name, uint32_t val)
 {
-	val = cpu_to_fdt32(val);
-	return fdt_property(fdt, name, &val, sizeof(val));
+	fdt32_t tmp = cpu_to_fdt32(val);
+	return fdt_property(fdt, name, &tmp, sizeof(tmp));
 }
 static inline int fdt_property_u64(void *fdt, const char *name, uint64_t val)
 {
-	val = cpu_to_fdt64(val);
-	return fdt_property(fdt, name, &val, sizeof(val));
+	fdt64_t tmp = cpu_to_fdt64(val);
+	return fdt_property(fdt, name, &tmp, sizeof(tmp));
 }
 static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val)
 {
@@ -1154,8 +1154,8 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,
 				  uint32_t val)
 {
-	val = cpu_to_fdt32(val);
-	return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt32_t tmp = cpu_to_fdt32(val);
+	return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
@@ -1189,8 +1189,8 @@ static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name,
 				  uint64_t val)
 {
-	val = cpu_to_fdt64(val);
-	return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt64_t tmp = cpu_to_fdt64(val);
+	return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
@@ -1296,8 +1296,8 @@ int fdt_appendprop(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_appendprop_u32(void *fdt, int nodeoffset,
 				     const char *name, uint32_t val)
 {
-	val = cpu_to_fdt32(val);
-	return fdt_appendprop(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt32_t tmp = cpu_to_fdt32(val);
+	return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
@@ -1331,8 +1331,8 @@ static inline int fdt_appendprop_u32(void *fdt, int nodeoffset,
 static inline int fdt_appendprop_u64(void *fdt, int nodeoffset,
 				     const char *name, uint64_t val)
 {
-	val = cpu_to_fdt64(val);
-	return fdt_appendprop(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt64_t tmp = cpu_to_fdt64(val);
+	return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* Re: [PATCH] libfdt: introduce fdt type annotation for use by endian checkers
  2012-10-30 21:57           ` [U-Boot] " Kim Phillips
@ 2012-10-30 22:24             ` Stephen Warren
  -1 siblings, 0 replies; 133+ messages in thread
From: Stephen Warren @ 2012-10-30 22:24 UTC (permalink / raw)
  To: Kim Phillips; +Cc: u-boot, Jon Loeliger, devicetree-discuss, David Gibson

On 10/30/2012 03:57 PM, Kim Phillips wrote:
> Projects such as linux and u-boot run sparse on libfdt.  libfdt
> contains the notion of endianness via usage of endian conversion
> functions such as fdt32_to_cpu.  As such, in order to pass endian
> checks, libfdt has to annotate its fdt variables as big endian.
> This patch does that ifdef __CHECKER__ (a symbol sparse defines),
> for two new fdt types: fdt32_t and fdt64_t, and subsequently
> silences warnings emitted by sparse when parsing libfdt.

Should libfdt patches be committed to the main dtc repository (which I
assume is also upstream for libfdt?) rather than U-Boot first?
Otherwise, if we want to bring in a new libfdt from upstream, that would
trash all the U-Boot-specific changes in U-Boot's copy of libfdt.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH] libfdt: introduce fdt type annotation for use by endian checkers
@ 2012-10-30 22:24             ` Stephen Warren
  0 siblings, 0 replies; 133+ messages in thread
From: Stephen Warren @ 2012-10-30 22:24 UTC (permalink / raw)
  To: u-boot

On 10/30/2012 03:57 PM, Kim Phillips wrote:
> Projects such as linux and u-boot run sparse on libfdt.  libfdt
> contains the notion of endianness via usage of endian conversion
> functions such as fdt32_to_cpu.  As such, in order to pass endian
> checks, libfdt has to annotate its fdt variables as big endian.
> This patch does that ifdef __CHECKER__ (a symbol sparse defines),
> for two new fdt types: fdt32_t and fdt64_t, and subsequently
> silences warnings emitted by sparse when parsing libfdt.

Should libfdt patches be committed to the main dtc repository (which I
assume is also upstream for libfdt?) rather than U-Boot first?
Otherwise, if we want to bring in a new libfdt from upstream, that would
trash all the U-Boot-specific changes in U-Boot's copy of libfdt.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [PATCH] libfdt: introduce fdt type annotation for use by endian checkers
  2012-10-30 22:24             ` [U-Boot] " Stephen Warren
@ 2012-10-30 22:27               ` Kim Phillips
  -1 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-30 22:27 UTC (permalink / raw)
  To: Stephen Warren; +Cc: u-boot, Jon Loeliger, devicetree-discuss, David Gibson

On Tue, 30 Oct 2012 16:24:05 -0600
Stephen Warren <swarren@wwwdotorg.org> wrote:

> On 10/30/2012 03:57 PM, Kim Phillips wrote:
> > Projects such as linux and u-boot run sparse on libfdt.  libfdt
> > contains the notion of endianness via usage of endian conversion
> > functions such as fdt32_to_cpu.  As such, in order to pass endian
> > checks, libfdt has to annotate its fdt variables as big endian.
> > This patch does that ifdef __CHECKER__ (a symbol sparse defines),
> > for two new fdt types: fdt32_t and fdt64_t, and subsequently
> > silences warnings emitted by sparse when parsing libfdt.
> 
> Should libfdt patches be committed to the main dtc repository (which I
> assume is also upstream for libfdt?) rather than U-Boot first?

that's what this is meant to be: a patch for dtc, cc: u-boot, since
it was originally a patch to u-boot's copy.  Fyi, dtc sumbission
guidelines dictate To: jdl, Cc: devicetree-discuss...

> Otherwise, if we want to bring in a new libfdt from upstream, that would
> trash all the U-Boot-specific changes in U-Boot's copy of libfdt.

right, this patch is for the dtc.  I assume gvb will pull it into
u-boot once it's applied.

Kim

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH] libfdt: introduce fdt type annotation for use by endian checkers
@ 2012-10-30 22:27               ` Kim Phillips
  0 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-10-30 22:27 UTC (permalink / raw)
  To: u-boot

On Tue, 30 Oct 2012 16:24:05 -0600
Stephen Warren <swarren@wwwdotorg.org> wrote:

> On 10/30/2012 03:57 PM, Kim Phillips wrote:
> > Projects such as linux and u-boot run sparse on libfdt.  libfdt
> > contains the notion of endianness via usage of endian conversion
> > functions such as fdt32_to_cpu.  As such, in order to pass endian
> > checks, libfdt has to annotate its fdt variables as big endian.
> > This patch does that ifdef __CHECKER__ (a symbol sparse defines),
> > for two new fdt types: fdt32_t and fdt64_t, and subsequently
> > silences warnings emitted by sparse when parsing libfdt.
> 
> Should libfdt patches be committed to the main dtc repository (which I
> assume is also upstream for libfdt?) rather than U-Boot first?

that's what this is meant to be: a patch for dtc, cc: u-boot, since
it was originally a patch to u-boot's copy.  Fyi, dtc sumbission
guidelines dictate To: jdl, Cc: devicetree-discuss...

> Otherwise, if we want to bring in a new libfdt from upstream, that would
> trash all the U-Boot-specific changes in U-Boot's copy of libfdt.

right, this patch is for the dtc.  I assume gvb will pull it into
u-boot once it's applied.

Kim

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 20/25] drivers/input/input.c: sparse fix
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 20/25] drivers/input/input.c: sparse fix Kim Phillips
@ 2012-10-31  5:51     ` Simon Glass
  0 siblings, 0 replies; 133+ messages in thread
From: Simon Glass @ 2012-10-31  5:51 UTC (permalink / raw)
  To: u-boot

On Mon, Oct 29, 2012 at 4:34 PM, Kim Phillips
<kim.phillips@freescale.com> wrote:
> input.c:97:5: warning: symbol 'input_queue_ascii' was not declared. Should it be
>
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>

Acked-by: Simon Glass <sjg@chromium.org>

> ---
> v2: no changes
>
>  drivers/input/input.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index 9800667..04fa5f0 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -110,7 +110,7 @@ static struct {
>  /* Maximum number of output characters that an ANSI sequence expands to */
>  #define ANSI_CHAR_MAX  3
>
> -int input_queue_ascii(struct input_config *config, int ch)
> +static int input_queue_ascii(struct input_config *config, int ch)
>  {
>         if (config->fifo_in + 1 == INPUT_BUFFER_LEN) {
>                 if (!config->fifo_out)
> --
> 1.8.0
>
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 00/32] Initial sparse fix series
  2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
                     ` (24 preceding siblings ...)
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 25/25] drivers/serial/serial_ns16550.c: " Kim Phillips
@ 2012-11-04 18:30   ` Tom Rini
  25 siblings, 0 replies; 133+ messages in thread
From: Tom Rini @ 2012-11-04 18:30 UTC (permalink / raw)
  To: u-boot

On Mon, Oct 29, 2012 at 06:34:22PM -0500, Kim Phillips wrote:

> [v2 summary: zero inter-commit build errors on all power, arm,
> and mips boards (which means some patches got merged into patch #1),
> checkpatch fixes, and postponement of the libfdt changes, primarily
> to get the bulk of these in during this merge window]
> 
> This 25-patch series only begins to address making u-boot source more
> 'sparseable,' or sparse-clean, ultimately to catch type, address space,
> and endianness mismatches and generally improve code quality. E.g., 
> a couple of endianness bugs are found in of_bus_default_translate()
> and fdt_get_base_address() (not includeded in this v2 series - fixes
> pending libfdt patch for dtc).
> 
> Patch 1 adds endianness attributes to byteorder.h helpers, e.g.,
> cpu_to_be32().  This is required for correct operation and prevents
> sparse from emitting false-positives.  It comes with the side effect
> of breaking many builds, because u-boot has various places where
> attributes were being defined differently, so it includes fixes for those.
> 
> Patches 2-5 fix issues where u-boot had imported linux header code
> and the importer simply force-#defined sparse-specific attributes to
> nothing, to allow u-boot to build without redefined warnings.
> 
> Patches 6-7 are general sparse fixes to common powerpc areas.
> 
> Patches 8-10 are general sparse fixes to common header areas (e.g.,
> patch 8 changes the long-standing u-boot image header types to __be32,
> as per u-boot image definition).
> 
> Patches 11-12 addresses sparse fixes for the net subsystem.
> 
> Patches 13-14 do the same for lib/.
> 
> Patches 15-17 for Power Arch's mpc8xxx, 83xx, and 85xx subsystems.
> 
> Last but not least, patches 18-25 attempt to clean up various drivers.
> 
> Note that the two libfdt patches present in series one are omitted here
> for u-boot merge window, they will be resubmitted after dtc have merged
> a libfdt-dependent patch.
> 
> For authors of new patches not willing to sift through the still quite
> large sparse output for their board/platform, though interested in what
> sparse has to say about their new code, it is recommended to build
> with make C=1 after changes such that sparse output will only include
> newly built code.
> 
> fyi, I've pushed the series onto the u-boot-mpc83xx tree,
> 'sparsefixes' branch:
> 
> http://git.denx.de/u-boot.git/?p=u-boot/u-boot-mpc83xx.git;a=shortlog;h=refs/heads/sparsefixes
> 
> All power, arm, mips boards tested.

With a small change in #1 so that it applied correctly, applied to
u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121104/6ae94488/attachment.pgp>

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 10/25] common/misc: sparse fixes
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 10/25] common/misc: " Kim Phillips
@ 2012-11-05 21:30     ` Henrik Nordström
  2012-11-06  1:51       ` [U-Boot] [PATCH] common: fix help command breakage Kim Phillips
  0 siblings, 1 reply; 133+ messages in thread
From: Henrik Nordström @ 2012-11-05 21:30 UTC (permalink / raw)
  To: u-boot

m?n 2012-10-29 klockan 18:34 -0500 skrev Kim Phillips:

> diff --git a/common/command.c b/common/command.c
> index 50c8429..f51df26 100644
> --- a/common/command.c
> +++ b/common/command.c
> @@ -40,8 +40,15 @@ int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
>  	int i;
>  	int rcode = 0;
>  
> +	if (cmd_items > CONFIG_SYS_MAXARGS) {
> +		printf("%s: cmd_items %d exceeds hardcoded limit %d."
> +		       " Recompile with higher CONFIG_SYS_MAXARGS?\n",
> +		       __func__, cmd_items, CONFIG_SYS_MAXARGS);
> +		return -1;
> +	}
> +
>  	if (argc == 1) {	/*show list of commands */
> -		cmd_tbl_t *cmd_array[cmd_items];
> +		cmd_tbl_t *cmd_array[CONFIG_SYS_MAXARGS];
>  		int i, j, swaps;
>  


This breaks the help command if there is more than 16 commands enabled,
i.e. for everyone.

CONFIG_SYS_MAXARGS is not meant to be the maximum number of commands, it
is the maximum number of arguments to a single command.

Regards
Henrik

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH] common: fix help command breakage
  2012-11-05 21:30     ` Henrik Nordström
@ 2012-11-06  1:51       ` Kim Phillips
  2012-11-06  5:44         ` Henrik Nordström
                           ` (3 more replies)
  0 siblings, 4 replies; 133+ messages in thread
From: Kim Phillips @ 2012-11-06  1:51 UTC (permalink / raw)
  To: u-boot

commit 199adb601ff34bdbbd0667fac80dfe0a87bffc2b "common/misc: sparse
fixes" broke the help command trying to fix the sparse error
"command.c:44:38: error: bad constant expression".

As Henrik points out, the fix was bad because the commit used
CONFIG_SYS_MAXARGS whereas the code intended to use the maximum
number of commands (not arguments to a command).

this patch fixes both by making the allocation manually on the heap.

Reported-by: Henrik Nordstr?m <henrik@henriknordstrom.net>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
tested on an 8572ds board

 common/command.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/common/command.c b/common/command.c
index f51df26..991a7ee 100644
--- a/common/command.c
+++ b/common/command.c
@@ -28,6 +28,7 @@
 #include <common.h>
 #include <command.h>
 #include <linux/ctype.h>
+#include <malloc.h>
 
 /*
  * Use puts() instead of printf() to avoid printf buffer overflow
@@ -40,17 +41,16 @@ int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
 	int i;
 	int rcode = 0;
 
-	if (cmd_items > CONFIG_SYS_MAXARGS) {
-		printf("%s: cmd_items %d exceeds hardcoded limit %d."
-		       " Recompile with higher CONFIG_SYS_MAXARGS?\n",
-		       __func__, cmd_items, CONFIG_SYS_MAXARGS);
-		return -1;
-	}
-
 	if (argc == 1) {	/*show list of commands */
-		cmd_tbl_t *cmd_array[CONFIG_SYS_MAXARGS];
+		cmd_tbl_t **cmd_array;
 		int i, j, swaps;
 
+		cmd_array = malloc(cmd_items * sizeof(*cmd_array));
+		if (!cmd_array) {
+			printf("error: not enough memory\n");
+			return 1;
+		}
+
 		/* Make array of commands from .uboot_cmd section */
 		cmdtp = cmd_start;
 		for (i = 0; i < cmd_items; i++) {
@@ -79,13 +79,16 @@ int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
 			const char *usage = cmd_array[i]->usage;
 
 			/* allow user abort */
-			if (ctrlc ())
+			if (ctrlc()) {
+				free(cmd_array);
 				return 1;
+			}
 			if (usage == NULL)
 				continue;
 			printf("%-*s- %s\n", CONFIG_SYS_HELP_CMD_WIDTH,
 			       cmd_array[i]->name, usage);
 		}
+		free(cmd_array);
 		return 0;
 	}
 	/*
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH] common: fix help command breakage
  2012-11-06  1:51       ` [U-Boot] [PATCH] common: fix help command breakage Kim Phillips
@ 2012-11-06  5:44         ` Henrik Nordström
  2012-11-07 21:39           ` Simon Glass
  2012-11-07 22:23         ` Anatolij Gustschin
                           ` (2 subsequent siblings)
  3 siblings, 1 reply; 133+ messages in thread
From: Henrik Nordström @ 2012-11-06  5:44 UTC (permalink / raw)
  To: u-boot

m?n 2012-11-05 klockan 19:51 -0600 skrev Kim Phillips:
> commit 199adb601ff34bdbbd0667fac80dfe0a87bffc2b "common/misc: sparse
> fixes" broke the help command trying to fix the sparse error
> "command.c:44:38: error: bad constant expression".
> 
> As Henrik points out, the fix was bad because the commit used
> CONFIG_SYS_MAXARGS whereas the code intended to use the maximum
> number of commands (not arguments to a command).
> 
> this patch fixes both by making the allocation manually on the heap.
> 
> Reported-by: Henrik Nordstr?m <henrik@henriknordstrom.net>
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>

Tested-by: Henrik Nordstr?m <henrik@henriknordstrom.net>

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [PATCH] libfdt: introduce fdt type annotation for use by endian checkers
  2012-10-30 21:57           ` [U-Boot] " Kim Phillips
@ 2012-11-06  7:48               ` David Gibson
  -1 siblings, 0 replies; 133+ messages in thread
From: David Gibson @ 2012-11-06  7:48 UTC (permalink / raw)
  To: Kim Phillips
  Cc: u-boot-0aAXYlwwYIKGBzrmiIFOJg, Jerry Van Baren,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

On Tue, Oct 30, 2012 at 04:57:54PM -0500, Kim Phillips wrote:
> Projects such as linux and u-boot run sparse on libfdt.  libfdt
> contains the notion of endianness via usage of endian conversion
> functions such as fdt32_to_cpu.  As such, in order to pass endian
> checks, libfdt has to annotate its fdt variables as big endian.
> This patch does that ifdef __CHECKER__ (a symbol sparse defines),
> for two new fdt types: fdt32_t and fdt64_t, and subsequently
> silences warnings emitted by sparse when parsing libfdt.
> 
> Signed-off-by: Kim Phillips <kim.phillips-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> ---
> note: wasn't sure whether to introduce the new fdt32 types, or
> just have libfdt use __be32 directly.

I prefer having the fdt32 types, to match the cpu_to_fdt32() and so
forth functions we already use.

So I like this in principle, but a couple of nits.

First, I'd really like to see an accompanying patch that adds targets
to the dtc makefiles to run sparse over the sources.  I couldn't
really test this, because I couldn't figure out quite what options I
needed to invoke sparse with to get it to work properly.

And I'd also like to see the default libfdt_env.h updated to supply
the necessary sparse stuff - including the necessary __force casts in
its byteswap functions.

[snip]
> diff --git a/libfdt/fdt.h b/libfdt/fdt.h
> index 48ccfd9..0d9c856 100644
> --- a/libfdt/fdt.h
> +++ b/libfdt/fdt.h
> @@ -3,46 +3,54 @@
>  
>  #ifndef __ASSEMBLY__
>  
> +#ifdef __CHECKER__

So, I'd prefer not to use __CHECKER__ directly here.  I'd rather we
defined a new specific symbol, that libfdt_env.h can set based on
__CHECKER__ if it wants.  Let's say _FDT_SPARSE The reason is
because..

> +typedef __be32 fdt32_t;
> +typedef __be64 fdt64_t;

..just running sparse does *not* immediately give you __be32 and
__be64 types - those have to be defined in terms of
__attribute__((bitwise)) and whatnot.  Your uboot env probably does
that already, but the default libfdt_env.h certainly doesn't.
Effectively _FDT_SPARSE is sayint two things, first that we're
compiling under sparse, but also that we have suitably defined endian
types in the environment.

Actually, given that libfdt_env.h is already required to provide the
cpu_to_fdt32() and so forth macros, I think it's slightly neater to
just require it to directly supply the fdt32_t etc. types when it
defines _FDT_SPARSE as well, rather than defining them in terms of
__beXX here then in terms of the attributes in the environment.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH] libfdt: introduce fdt type annotation for use by endian checkers
@ 2012-11-06  7:48               ` David Gibson
  0 siblings, 0 replies; 133+ messages in thread
From: David Gibson @ 2012-11-06  7:48 UTC (permalink / raw)
  To: u-boot

On Tue, Oct 30, 2012 at 04:57:54PM -0500, Kim Phillips wrote:
> Projects such as linux and u-boot run sparse on libfdt.  libfdt
> contains the notion of endianness via usage of endian conversion
> functions such as fdt32_to_cpu.  As such, in order to pass endian
> checks, libfdt has to annotate its fdt variables as big endian.
> This patch does that ifdef __CHECKER__ (a symbol sparse defines),
> for two new fdt types: fdt32_t and fdt64_t, and subsequently
> silences warnings emitted by sparse when parsing libfdt.
> 
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
> ---
> note: wasn't sure whether to introduce the new fdt32 types, or
> just have libfdt use __be32 directly.

I prefer having the fdt32 types, to match the cpu_to_fdt32() and so
forth functions we already use.

So I like this in principle, but a couple of nits.

First, I'd really like to see an accompanying patch that adds targets
to the dtc makefiles to run sparse over the sources.  I couldn't
really test this, because I couldn't figure out quite what options I
needed to invoke sparse with to get it to work properly.

And I'd also like to see the default libfdt_env.h updated to supply
the necessary sparse stuff - including the necessary __force casts in
its byteswap functions.

[snip]
> diff --git a/libfdt/fdt.h b/libfdt/fdt.h
> index 48ccfd9..0d9c856 100644
> --- a/libfdt/fdt.h
> +++ b/libfdt/fdt.h
> @@ -3,46 +3,54 @@
>  
>  #ifndef __ASSEMBLY__
>  
> +#ifdef __CHECKER__

So, I'd prefer not to use __CHECKER__ directly here.  I'd rather we
defined a new specific symbol, that libfdt_env.h can set based on
__CHECKER__ if it wants.  Let's say _FDT_SPARSE The reason is
because..

> +typedef __be32 fdt32_t;
> +typedef __be64 fdt64_t;

..just running sparse does *not* immediately give you __be32 and
__be64 types - those have to be defined in terms of
__attribute__((bitwise)) and whatnot.  Your uboot env probably does
that already, but the default libfdt_env.h certainly doesn't.
Effectively _FDT_SPARSE is sayint two things, first that we're
compiling under sparse, but also that we have suitably defined endian
types in the environment.

Actually, given that libfdt_env.h is already required to provide the
cpu_to_fdt32() and so forth macros, I think it's slightly neater to
just require it to directly supply the fdt32_t etc. types when it
defines _FDT_SPARSE as well, rather than defining them in terms of
__beXX here then in terms of the attributes in the environment.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH] common: fix help command breakage
  2012-11-06  5:44         ` Henrik Nordström
@ 2012-11-07 21:39           ` Simon Glass
  0 siblings, 0 replies; 133+ messages in thread
From: Simon Glass @ 2012-11-07 21:39 UTC (permalink / raw)
  To: u-boot

On Mon, Nov 5, 2012 at 9:44 PM, Henrik Nordstr?m
<henrik@henriknordstrom.net> wrote:
> m?n 2012-11-05 klockan 19:51 -0600 skrev Kim Phillips:
>> commit 199adb601ff34bdbbd0667fac80dfe0a87bffc2b "common/misc: sparse
>> fixes" broke the help command trying to fix the sparse error
>> "command.c:44:38: error: bad constant expression".
>>
>> As Henrik points out, the fix was bad because the commit used
>> CONFIG_SYS_MAXARGS whereas the code intended to use the maximum
>> number of commands (not arguments to a command).
>>
>> this patch fixes both by making the allocation manually on the heap.
>>
>> Reported-by: Henrik Nordstr?m <henrik@henriknordstrom.net>
>> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>

Tested-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

>
> Tested-by: Henrik Nordstr?m <henrik@henriknordstrom.net>
>
>
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH] common: fix help command breakage
  2012-11-06  1:51       ` [U-Boot] [PATCH] common: fix help command breakage Kim Phillips
  2012-11-06  5:44         ` Henrik Nordström
@ 2012-11-07 22:23         ` Anatolij Gustschin
  2012-11-08 11:02           ` Anatolij Gustschin
  2012-11-08 10:41         ` Wolfgang Denk
  2012-11-08 11:52         ` [U-Boot] [PATCH] common/command.c: revert chanches from commit 199adb60 Anatolij Gustschin
  3 siblings, 1 reply; 133+ messages in thread
From: Anatolij Gustschin @ 2012-11-07 22:23 UTC (permalink / raw)
  To: u-boot

Hi,

On Mon, 5 Nov 2012 19:51:11 -0600
Kim Phillips <kim.phillips@freescale.com> wrote:

> commit 199adb601ff34bdbbd0667fac80dfe0a87bffc2b "common/misc: sparse
> fixes" broke the help command trying to fix the sparse error
> "command.c:44:38: error: bad constant expression".
> 
> As Henrik points out, the fix was bad because the commit used
> CONFIG_SYS_MAXARGS whereas the code intended to use the maximum
> number of commands (not arguments to a command).
> 
> this patch fixes both by making the allocation manually on the heap.
> 
> Reported-by: Henrik Nordstr?m <henrik@henriknordstrom.net>
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
> ---
> tested on an 8572ds board
> 
>  common/command.c | 21 ++++++++++++---------
>  1 file changed, 12 insertions(+), 9 deletions(-)

Applied to staging/agust at denx.de. Thanks!

Anatolij

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH] common: fix help command breakage
  2012-11-06  1:51       ` [U-Boot] [PATCH] common: fix help command breakage Kim Phillips
  2012-11-06  5:44         ` Henrik Nordström
  2012-11-07 22:23         ` Anatolij Gustschin
@ 2012-11-08 10:41         ` Wolfgang Denk
  2012-11-08 11:52         ` [U-Boot] [PATCH] common/command.c: revert chanches from commit 199adb60 Anatolij Gustschin
  3 siblings, 0 replies; 133+ messages in thread
From: Wolfgang Denk @ 2012-11-08 10:41 UTC (permalink / raw)
  To: u-boot

Dear Kim Phillips,

In message <20121105195111.8a326673862d0552354e2815@freescale.com> you wrote:
> commit 199adb601ff34bdbbd0667fac80dfe0a87bffc2b "common/misc: sparse
> fixes" broke the help command trying to fix the sparse error
> "command.c:44:38: error: bad constant expression".
> 
> As Henrik points out, the fix was bad because the commit used
> CONFIG_SYS_MAXARGS whereas the code intended to use the maximum
> number of commands (not arguments to a command).
> 
> this patch fixes both by making the allocation manually on the heap.
> 
> Reported-by: Henrik Nordstr=F6m <henrik@henriknordstrom.net>
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
> ---
> tested on an 8572ds board
> 
>  common/command.c | 21 ++++++++++++---------
>  1 file changed, 12 insertions(+), 9 deletions(-)

Thanks for the fix, and Anatolij, thanks for picking it up, but I
actually think the whole approach is broken,a nd we whould just revert
the original patch.

Theer is nothing wrong with the original code.  It was technically
correct, and only sparse had a different opinion.  In this case we
should find ways to silence sparse, or configure it in a way to allow
us using correct and efficient code.

What we have is not only slower, but also increases the memory
footprint with zero benefit.

I object against this, and ask to revert the original modification
instead.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Respect is a rational process
	-- McCoy, "The Galileo Seven", stardate 2822.3

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 09/25] common/cmd_*.c: sparse fixes
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 09/25] common/cmd_*.c: " Kim Phillips
@ 2012-11-08 10:48     ` Wolfgang Denk
  2012-11-09  1:04       ` Kim Phillips
  0 siblings, 1 reply; 133+ messages in thread
From: Wolfgang Denk @ 2012-11-08 10:48 UTC (permalink / raw)
  To: u-boot

Dear Kim Phillips,

In message <1351553687-12469-10-git-send-email-kim.phillips@freescale.com> you wrote:
>
...
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>

Has anybody tested the impact of this change on the memory
footprint?


I object against the implementation.

The whole idea of the U_BOOT_CMD() macro was to be able to write 
command entries in a _convenient_ way.  This patch makes this worse.

Please fix this such that we do NOT have to do all this ugly manual
encoding of the help texts.


Note also that this patch implements quite a few pretty much
different changes - these should be split into separate commits.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
When it is incorrect, it is, at least *authoritatively* incorrect.
                                    - Hitchiker's Guide To The Galaxy

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH] common: fix help command breakage
  2012-11-07 22:23         ` Anatolij Gustschin
@ 2012-11-08 11:02           ` Anatolij Gustschin
  2012-11-08 11:23             ` Wolfgang Denk
  0 siblings, 1 reply; 133+ messages in thread
From: Anatolij Gustschin @ 2012-11-08 11:02 UTC (permalink / raw)
  To: u-boot

On Wed, 7 Nov 2012 23:23:50 +0100
Anatolij Gustschin <agust@denx.de> wrote:
...
> Applied to staging/agust at denx.de. Thanks!

I'll drop this patch as requested by Wolfgang.


Thanks,
Anatolij

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 13/25] lib/zlib: sparse fixes
  2012-10-29 23:34   ` [U-Boot] [PATCH v2 13/25] lib/zlib: " Kim Phillips
@ 2012-11-08 11:20     ` Wolfgang Denk
  2012-11-09  1:06       ` Kim Phillips
  0 siblings, 1 reply; 133+ messages in thread
From: Wolfgang Denk @ 2012-11-08 11:20 UTC (permalink / raw)
  To: u-boot

Dear Kim Phillips,

In message <1351553687-12469-14-git-send-email-kim.phillips@freescale.com> you wrote:
> define Z_NULL to (void *)0 include/u-boot/zlib.h to get rid of most of
> the NULL pointer warnings.
...
> -#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
> +#define Z_NULL  (void *)0  /* for initializing zalloc, zfree, opaque */

Don't we have to put parens around such an expression?


> --- a/lib/zlib/adler32.c
> +++ b/lib/zlib/adler32.c
> @@ -54,10 +54,7 @@
>  #endif
>  
>  /* ========================================================================= */
> -uLong ZEXPORT adler32(adler, buf, len)
> -    uLong adler;
> -    const Bytef *buf;
> -    uInt len;
> +uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)

Hm... this code has been imported from another project.  This
modification makes updates (or even comparing what has changed in more
recent versions) much mor difficult, or even impossible
:-(

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I have a very small mind and must live with it.    -- Edsger Dijkstra

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH] common: fix help command breakage
  2012-11-08 11:02           ` Anatolij Gustschin
@ 2012-11-08 11:23             ` Wolfgang Denk
  0 siblings, 0 replies; 133+ messages in thread
From: Wolfgang Denk @ 2012-11-08 11:23 UTC (permalink / raw)
  To: u-boot

Dear Anatolij,

In message <20121108120224.3b377929@wker> you wrote:
> On Wed, 7 Nov 2012 23:23:50 +0100
> Anatolij Gustschin <agust@denx.de> wrote:
> ...
> > Applied to staging/agust at denx.de. Thanks!
> 
> I'll drop this patch as requested by Wolfgang.

But we have also to revert the other commit, to make "help" working
again.

This is actually urgent, as the breakage affects current mainline.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Backed up the system lately?

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH] common/command.c: revert chanches from commit 199adb60
  2012-11-06  1:51       ` [U-Boot] [PATCH] common: fix help command breakage Kim Phillips
                           ` (2 preceding siblings ...)
  2012-11-08 10:41         ` Wolfgang Denk
@ 2012-11-08 11:52         ` Anatolij Gustschin
  2012-11-08 12:42           ` Anatolij Gustschin
  3 siblings, 1 reply; 133+ messages in thread
From: Anatolij Gustschin @ 2012-11-08 11:52 UTC (permalink / raw)
  To: u-boot

commit 199adb601ff34bdbbd0667fac80dfe0a87bffc2b "common/misc: sparse
fixes" broke the help command trying to fix the sparse error
"command.c:44:38: error: bad constant expression".

As Henrik points out, the fix was bad because the commit used
CONFIG_SYS_MAXARGS whereas the code intended to use the maximum
number of commands (not arguments to a command).

Revert command.c changes to the original code as asked by Wolfgang.

Reported-by: Henrik Nordstr?m <henrik@henriknordstrom.net>
Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
 common/command.c |    9 +--------
 1 files changed, 1 insertions(+), 8 deletions(-)

diff --git a/common/command.c b/common/command.c
index f51df26..50c8429 100644
--- a/common/command.c
+++ b/common/command.c
@@ -40,15 +40,8 @@ int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
 	int i;
 	int rcode = 0;
 
-	if (cmd_items > CONFIG_SYS_MAXARGS) {
-		printf("%s: cmd_items %d exceeds hardcoded limit %d."
-		       " Recompile with higher CONFIG_SYS_MAXARGS?\n",
-		       __func__, cmd_items, CONFIG_SYS_MAXARGS);
-		return -1;
-	}
-
 	if (argc == 1) {	/*show list of commands */
-		cmd_tbl_t *cmd_array[CONFIG_SYS_MAXARGS];
+		cmd_tbl_t *cmd_array[cmd_items];
 		int i, j, swaps;
 
 		/* Make array of commands from .uboot_cmd section */
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH] common/command.c: revert chanches from commit 199adb60
  2012-11-08 11:52         ` [U-Boot] [PATCH] common/command.c: revert chanches from commit 199adb60 Anatolij Gustschin
@ 2012-11-08 12:42           ` Anatolij Gustschin
  2012-11-10 11:21             ` Albert ARIBAUD
  0 siblings, 1 reply; 133+ messages in thread
From: Anatolij Gustschin @ 2012-11-08 12:42 UTC (permalink / raw)
  To: u-boot

On Thu,  8 Nov 2012 12:52:13 +0100
Anatolij Gustschin <agust@denx.de> wrote:

> commit 199adb601ff34bdbbd0667fac80dfe0a87bffc2b "common/misc: sparse
> fixes" broke the help command trying to fix the sparse error
> "command.c:44:38: error: bad constant expression".
> 
> As Henrik points out, the fix was bad because the commit used
> CONFIG_SYS_MAXARGS whereas the code intended to use the maximum
> number of commands (not arguments to a command).
> 
> Revert command.c changes to the original code as asked by Wolfgang.
> 
> Reported-by: Henrik Nordstr?m <henrik@henriknordstrom.net>
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> ---
>  common/command.c |    9 +--------
>  1 files changed, 1 insertions(+), 8 deletions(-)

Applied to u-boot-staging/agust at denx.de-urgent.

Anatolij

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 09/25] common/cmd_*.c: sparse fixes
  2012-11-08 10:48     ` Wolfgang Denk
@ 2012-11-09  1:04       ` Kim Phillips
  0 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-11-09  1:04 UTC (permalink / raw)
  To: u-boot

On Thu, 8 Nov 2012 11:48:54 +0100
Wolfgang Denk <wd@denx.de> wrote:

> In message <1351553687-12469-10-git-send-email-kim.phillips@freescale.com> you wrote:
> >
> ...
> > Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
> 
> Has anybody tested the impact of this change on the memory
> footprint?

without this commit, a P4080DS build yields:

   text	   data	    bss	    dec	    hex	filename
 404934	  14340	 280400	 699674	  aad1a	./u-boot

with this commit:

   text	   data	    bss	    dec	    hex	filename
 398593	  19896	 280400	 698889	  aaa09	./u-boot

so basically it's a tiny improvement overall.  The U_BOOT_CMD
changes moved the help text from the .rodata section into the .data
section (text).

> I object against the implementation.
> 
> The whole idea of the U_BOOT_CMD() macro was to be able to write 
> command entries in a _convenient_ way.  This patch makes this worse.
> 
> Please fix this such that we do NOT have to do all this ugly manual
> encoding of the help texts.

it's only in the case of long help text that changes with
configurations, and I'm not sure on how it can be avoided.

> Note also that this patch implements quite a few pretty much
> different changes - these should be split into separate commits.

it's been applied already, but I can resubmit as a series by sparse
error type if you want to revert it (it does so cleanly).

Kim

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 13/25] lib/zlib: sparse fixes
  2012-11-08 11:20     ` Wolfgang Denk
@ 2012-11-09  1:06       ` Kim Phillips
  2012-11-21 16:37         ` Tom Rini
  0 siblings, 1 reply; 133+ messages in thread
From: Kim Phillips @ 2012-11-09  1:06 UTC (permalink / raw)
  To: u-boot

On Thu, 8 Nov 2012 12:20:51 +0100
Wolfgang Denk <wd@denx.de> wrote:

> In message <1351553687-12469-14-git-send-email-kim.phillips@freescale.com> you wrote:
> > define Z_NULL to (void *)0 include/u-boot/zlib.h to get rid of most of
> > the NULL pointer warnings.
> ...
> > -#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
> > +#define Z_NULL  (void *)0  /* for initializing zalloc, zfree, opaque */
> 
> Don't we have to put parens around such an expression?

I suppose.

> > --- a/lib/zlib/adler32.c
> > +++ b/lib/zlib/adler32.c
> > @@ -54,10 +54,7 @@
> >  #endif
> >  
> >  /* ========================================================================= */
> > -uLong ZEXPORT adler32(adler, buf, len)
> > -    uLong adler;
> > -    const Bytef *buf;
> > -    uInt len;
> > +uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
> 
> Hm... this code has been imported from another project.  This
> modification makes updates (or even comparing what has changed in more
> recent versions) much mor difficult, or even impossible
> :-(

my goal is to improve u-boot code quality by eliminating as much
sparse noise as possible - most boards use this code to decompress
kernels, so it's widely used.  E.g., this patch removes 52 lines of
sparse output.  But ok, we can revert this patch and turn off
checking for these files, in the form of an #ifndef __CHECKER__ at
the top, with an 'imported from another project' justification
comment.  Would that be better?

Kim

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH] common/command.c: revert chanches from commit 199adb60
  2012-11-08 12:42           ` Anatolij Gustschin
@ 2012-11-10 11:21             ` Albert ARIBAUD
  2012-11-10 11:41               ` Anatolij Gustschin
  0 siblings, 1 reply; 133+ messages in thread
From: Albert ARIBAUD @ 2012-11-10 11:21 UTC (permalink / raw)
  To: u-boot

Hi Anatolij,

On Thu, 8 Nov 2012 13:42:14 +0100, Anatolij Gustschin <agust@denx.de>
wrote:

> On Thu,  8 Nov 2012 12:52:13 +0100
> Anatolij Gustschin <agust@denx.de> wrote:
> 
> > commit 199adb601ff34bdbbd0667fac80dfe0a87bffc2b "common/misc: sparse
> > fixes" broke the help command trying to fix the sparse error
> > "command.c:44:38: error: bad constant expression".
> > 
> > As Henrik points out, the fix was bad because the commit used
> > CONFIG_SYS_MAXARGS whereas the code intended to use the maximum
> > number of commands (not arguments to a command).
> > 
> > Revert command.c changes to the original code as asked by Wolfgang.
> > 
> > Reported-by: Henrik Nordstr?m <henrik@henriknordstrom.net>
> > Signed-off-by: Anatolij Gustschin <agust@denx.de>
> > ---
> >  common/command.c |    9 +--------
> >  1 files changed, 1 insertions(+), 8 deletions(-)
> 
> Applied to u-boot-staging/agust at denx.de-urgent.

Did you fix the typo in the commit summary/subject on the fly?

Amicalement,
-- 
Albert.

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH] common/command.c: revert chanches from commit 199adb60
  2012-11-10 11:21             ` Albert ARIBAUD
@ 2012-11-10 11:41               ` Anatolij Gustschin
  2012-12-14  4:13                 ` Rommel Custodio
  0 siblings, 1 reply; 133+ messages in thread
From: Anatolij Gustschin @ 2012-11-10 11:41 UTC (permalink / raw)
  To: u-boot

Hi Albert,

On Sat, 10 Nov 2012 12:21:55 +0100
Albert ARIBAUD <albert.u.boot@aribaud.net> wrote:
...
> > 
> > Applied to u-boot-staging/agust at denx.de-urgent.
> 
> Did you fix the typo in the commit summary/subject on the fly?

yes, I noticed it when applying, it wasn't worth it to resubmit the patch.

Thanks,
Anatolij

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [PATCH 3/4 v2] dtc/libfdt: introduce fdt types for annotation by endian checkers
  2012-11-06  7:48               ` [U-Boot] " David Gibson
@ 2012-11-14  0:34                 ` Kim Phillips
  -1 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-11-14  0:34 UTC (permalink / raw)
  To: David Gibson, Jon Loeliger; +Cc: u-boot, devicetree-discuss

Projects such as linux and u-boot run sparse on libfdt.  libfdt
contains the notion of endianness via usage of endian conversion
functions such as fdt32_to_cpu.  As such, in order to pass endian
checks, libfdt has to annotate its fdt variables such that sparse
can warn when mixing bitwise and regular integers.  This patch adds
these new fdtXX_t types and, ifdef __CHECKER__ (a symbol sparse
defines), includes the bitwise annotation.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2:
adds bitwise awareness: determine host endianness manually, and
annotate swabs with __force in fdtXX_to_cpu and cpu_to_fdtXX
conversion functions (the inline endian condition checks are
optimized out at compile time).  This allows us to be able to check
libfdt bitwise conversions with sparse by building dtc with make
CC=cgcc. v2 also moves fdt32 definitions from fdt.h to libfdt_env.h
and changes fdt32 definitions to use __bitwise instead of __be32. No
separate _FDT_SPARSE was introduced because there's no need: using
__CHECKER__ directly is valid because it only occurs once, and in
libfdt_env.h.
In addition, the libfdt sparse fixes have been moved to a subsequent
patch.

I hope this addresses all your comments, David.

 libfdt/fdt.h        | 42 +++++++++++++++++-----------------
 libfdt/libfdt_env.h | 66 +++++++++++++++++++++++++++++++++++++++++------------
 2 files changed, 73 insertions(+), 35 deletions(-)

diff --git a/libfdt/fdt.h b/libfdt/fdt.h
index 48ccfd9..45dd134 100644
--- a/libfdt/fdt.h
+++ b/libfdt/fdt.h
@@ -4,45 +4,45 @@
 #ifndef __ASSEMBLY__
 
 struct fdt_header {
-	uint32_t magic;			 /* magic word FDT_MAGIC */
-	uint32_t totalsize;		 /* total size of DT block */
-	uint32_t off_dt_struct;		 /* offset to structure */
-	uint32_t off_dt_strings;	 /* offset to strings */
-	uint32_t off_mem_rsvmap;	 /* offset to memory reserve map */
-	uint32_t version;		 /* format version */
-	uint32_t last_comp_version;	 /* last compatible version */
+	fdt32_t magic;			 /* magic word FDT_MAGIC */
+	fdt32_t totalsize;		 /* total size of DT block */
+	fdt32_t off_dt_struct;		 /* offset to structure */
+	fdt32_t off_dt_strings;		 /* offset to strings */
+	fdt32_t off_mem_rsvmap;		 /* offset to memory reserve map */
+	fdt32_t version;		 /* format version */
+	fdt32_t last_comp_version;	 /* last compatible version */
 
 	/* version 2 fields below */
-	uint32_t boot_cpuid_phys;	 /* Which physical CPU id we're
+	fdt32_t boot_cpuid_phys;	 /* Which physical CPU id we're
 					    booting on */
 	/* version 3 fields below */
-	uint32_t size_dt_strings;	 /* size of the strings block */
+	fdt32_t size_dt_strings;	 /* size of the strings block */
 
 	/* version 17 fields below */
-	uint32_t size_dt_struct;	 /* size of the structure block */
+	fdt32_t size_dt_struct;		 /* size of the structure block */
 };
 
 struct fdt_reserve_entry {
-	uint64_t address;
-	uint64_t size;
+	fdt64_t address;
+	fdt64_t size;
 };
 
 struct fdt_node_header {
-	uint32_t tag;
+	fdt32_t tag;
 	char name[0];
 };
 
 struct fdt_property {
-	uint32_t tag;
-	uint32_t len;
-	uint32_t nameoff;
+	fdt32_t tag;
+	fdt32_t len;
+	fdt32_t nameoff;
 	char data[0];
 };
 
 #endif /* !__ASSEMBLY */
 
 #define FDT_MAGIC	0xd00dfeed	/* 4: version, 4: total size */
-#define FDT_TAGSIZE	sizeof(uint32_t)
+#define FDT_TAGSIZE	sizeof(fdt32_t)
 
 #define FDT_BEGIN_NODE	0x1		/* Start node: full name */
 #define FDT_END_NODE	0x2		/* End node */
@@ -51,10 +51,10 @@ struct fdt_property {
 #define FDT_NOP		0x4		/* nop */
 #define FDT_END		0x9
 
-#define FDT_V1_SIZE	(7*sizeof(uint32_t))
-#define FDT_V2_SIZE	(FDT_V1_SIZE + sizeof(uint32_t))
-#define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(uint32_t))
+#define FDT_V1_SIZE	(7*sizeof(fdt32_t))
+#define FDT_V2_SIZE	(FDT_V1_SIZE + sizeof(fdt32_t))
+#define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(fdt32_t))
 #define FDT_V16_SIZE	FDT_V3_SIZE
-#define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(uint32_t))
+#define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(fdt32_t))
 
 #endif /* _FDT_H */
diff --git a/libfdt/libfdt_env.h b/libfdt/libfdt_env.h
index 213d7fb..302d5cb 100644
--- a/libfdt/libfdt_env.h
+++ b/libfdt/libfdt_env.h
@@ -5,25 +5,63 @@
 #include <stdint.h>
 #include <string.h>
 
+#ifdef __CHECKER__
+#define __force __attribute__((force))
+#define __bitwise __attribute__((bitwise))
+typedef uint16_t __bitwise fdt16_t;
+typedef uint32_t __bitwise fdt32_t;
+typedef uint64_t __bitwise fdt64_t;
+#else
+#define __force
+#define __bitwise
+typedef uint16_t fdt16_t;
+typedef uint32_t fdt32_t;
+typedef uint64_t fdt64_t;
+#endif
+
 #define EXTRACT_BYTE(n)	((unsigned long long)((uint8_t *)&x)[n])
-static inline uint16_t fdt16_to_cpu(uint16_t x)
-{
-	return (EXTRACT_BYTE(0) << 8) | EXTRACT_BYTE(1);
-}
-#define cpu_to_fdt16(x) fdt16_to_cpu(x)
+#define __SWAB16X ((EXTRACT_BYTE(0) << 8) | EXTRACT_BYTE(1))
+#define __SWAB32X ((EXTRACT_BYTE(0) << 24) | (EXTRACT_BYTE(1) << 16) | (EXTRACT_BYTE(2) << 8) | EXTRACT_BYTE(3))
+#define __SWAB64X ((EXTRACT_BYTE(0) << 56) | (EXTRACT_BYTE(1) << 48) | (EXTRACT_BYTE(2) << 40) | (EXTRACT_BYTE(3) << 32) \
+		  | (EXTRACT_BYTE(4) << 24) | (EXTRACT_BYTE(5) << 16) | (EXTRACT_BYTE(6) << 8) | EXTRACT_BYTE(7))
 
-static inline uint32_t fdt32_to_cpu(uint32_t x)
-{
-	return (EXTRACT_BYTE(0) << 24) | (EXTRACT_BYTE(1) << 16) | (EXTRACT_BYTE(2) << 8) | EXTRACT_BYTE(3);
+/*
+ * determine host endianness:
+ * *__first_byte is 0x11 on big endian systems
+ * *__first_byte is 0x44 on little endian systems
+ */
+static const uint32_t __native = 0x11223344u;
+static const uint8_t *__first_byte = (const uint8_t *)&__native;
+
+#define DEF_FDT_TO_CPU(bits) \
+static inline uint##bits##_t fdt##bits##_to_cpu(fdt##bits##_t x) \
+{ \
+	if (*__first_byte == 0x11) \
+		return (__force uint##bits##_t)x; \
+	else \
+		return (__force uint##bits##_t)__SWAB##bits##X; \
 }
-#define cpu_to_fdt32(x) fdt32_to_cpu(x)
+DEF_FDT_TO_CPU(16)
+DEF_FDT_TO_CPU(32)
+DEF_FDT_TO_CPU(64)
 
-static inline uint64_t fdt64_to_cpu(uint64_t x)
-{
-	return (EXTRACT_BYTE(0) << 56) | (EXTRACT_BYTE(1) << 48) | (EXTRACT_BYTE(2) << 40) | (EXTRACT_BYTE(3) << 32)
-		| (EXTRACT_BYTE(4) << 24) | (EXTRACT_BYTE(5) << 16) | (EXTRACT_BYTE(6) << 8) | EXTRACT_BYTE(7);
+#define DEF_CPU_TO_FDT(bits) \
+static inline fdt##bits##_t cpu_to_fdt##bits(uint##bits##_t x) \
+{ \
+	if (*__first_byte == 0x11) \
+		return (__force fdt##bits##_t)x; \
+	else \
+		return (__force fdt##bits##_t)__SWAB##bits##X; \
 }
-#define cpu_to_fdt64(x) fdt64_to_cpu(x)
+DEF_CPU_TO_FDT(16)
+DEF_CPU_TO_FDT(32)
+DEF_CPU_TO_FDT(64)
+
+#undef DEF_FDT_TO_CPU
+#undef DEF_CPU_TO_FDT
+#undef __SWAB64X
+#undef __SWAB32X
+#undef __SWAB16X
 #undef EXTRACT_BYTE
 
 #endif /* _LIBFDT_ENV_H */
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 3/4 v2] dtc/libfdt: introduce fdt types for annotation by endian checkers
@ 2012-11-14  0:34                 ` Kim Phillips
  0 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-11-14  0:34 UTC (permalink / raw)
  To: u-boot

Projects such as linux and u-boot run sparse on libfdt.  libfdt
contains the notion of endianness via usage of endian conversion
functions such as fdt32_to_cpu.  As such, in order to pass endian
checks, libfdt has to annotate its fdt variables such that sparse
can warn when mixing bitwise and regular integers.  This patch adds
these new fdtXX_t types and, ifdef __CHECKER__ (a symbol sparse
defines), includes the bitwise annotation.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2:
adds bitwise awareness: determine host endianness manually, and
annotate swabs with __force in fdtXX_to_cpu and cpu_to_fdtXX
conversion functions (the inline endian condition checks are
optimized out at compile time).  This allows us to be able to check
libfdt bitwise conversions with sparse by building dtc with make
CC=cgcc. v2 also moves fdt32 definitions from fdt.h to libfdt_env.h
and changes fdt32 definitions to use __bitwise instead of __be32. No
separate _FDT_SPARSE was introduced because there's no need: using
__CHECKER__ directly is valid because it only occurs once, and in
libfdt_env.h.
In addition, the libfdt sparse fixes have been moved to a subsequent
patch.

I hope this addresses all your comments, David.

 libfdt/fdt.h        | 42 +++++++++++++++++-----------------
 libfdt/libfdt_env.h | 66 +++++++++++++++++++++++++++++++++++++++++------------
 2 files changed, 73 insertions(+), 35 deletions(-)

diff --git a/libfdt/fdt.h b/libfdt/fdt.h
index 48ccfd9..45dd134 100644
--- a/libfdt/fdt.h
+++ b/libfdt/fdt.h
@@ -4,45 +4,45 @@
 #ifndef __ASSEMBLY__
 
 struct fdt_header {
-	uint32_t magic;			 /* magic word FDT_MAGIC */
-	uint32_t totalsize;		 /* total size of DT block */
-	uint32_t off_dt_struct;		 /* offset to structure */
-	uint32_t off_dt_strings;	 /* offset to strings */
-	uint32_t off_mem_rsvmap;	 /* offset to memory reserve map */
-	uint32_t version;		 /* format version */
-	uint32_t last_comp_version;	 /* last compatible version */
+	fdt32_t magic;			 /* magic word FDT_MAGIC */
+	fdt32_t totalsize;		 /* total size of DT block */
+	fdt32_t off_dt_struct;		 /* offset to structure */
+	fdt32_t off_dt_strings;		 /* offset to strings */
+	fdt32_t off_mem_rsvmap;		 /* offset to memory reserve map */
+	fdt32_t version;		 /* format version */
+	fdt32_t last_comp_version;	 /* last compatible version */
 
 	/* version 2 fields below */
-	uint32_t boot_cpuid_phys;	 /* Which physical CPU id we're
+	fdt32_t boot_cpuid_phys;	 /* Which physical CPU id we're
 					    booting on */
 	/* version 3 fields below */
-	uint32_t size_dt_strings;	 /* size of the strings block */
+	fdt32_t size_dt_strings;	 /* size of the strings block */
 
 	/* version 17 fields below */
-	uint32_t size_dt_struct;	 /* size of the structure block */
+	fdt32_t size_dt_struct;		 /* size of the structure block */
 };
 
 struct fdt_reserve_entry {
-	uint64_t address;
-	uint64_t size;
+	fdt64_t address;
+	fdt64_t size;
 };
 
 struct fdt_node_header {
-	uint32_t tag;
+	fdt32_t tag;
 	char name[0];
 };
 
 struct fdt_property {
-	uint32_t tag;
-	uint32_t len;
-	uint32_t nameoff;
+	fdt32_t tag;
+	fdt32_t len;
+	fdt32_t nameoff;
 	char data[0];
 };
 
 #endif /* !__ASSEMBLY */
 
 #define FDT_MAGIC	0xd00dfeed	/* 4: version, 4: total size */
-#define FDT_TAGSIZE	sizeof(uint32_t)
+#define FDT_TAGSIZE	sizeof(fdt32_t)
 
 #define FDT_BEGIN_NODE	0x1		/* Start node: full name */
 #define FDT_END_NODE	0x2		/* End node */
@@ -51,10 +51,10 @@ struct fdt_property {
 #define FDT_NOP		0x4		/* nop */
 #define FDT_END		0x9
 
-#define FDT_V1_SIZE	(7*sizeof(uint32_t))
-#define FDT_V2_SIZE	(FDT_V1_SIZE + sizeof(uint32_t))
-#define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(uint32_t))
+#define FDT_V1_SIZE	(7*sizeof(fdt32_t))
+#define FDT_V2_SIZE	(FDT_V1_SIZE + sizeof(fdt32_t))
+#define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(fdt32_t))
 #define FDT_V16_SIZE	FDT_V3_SIZE
-#define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(uint32_t))
+#define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(fdt32_t))
 
 #endif /* _FDT_H */
diff --git a/libfdt/libfdt_env.h b/libfdt/libfdt_env.h
index 213d7fb..302d5cb 100644
--- a/libfdt/libfdt_env.h
+++ b/libfdt/libfdt_env.h
@@ -5,25 +5,63 @@
 #include <stdint.h>
 #include <string.h>
 
+#ifdef __CHECKER__
+#define __force __attribute__((force))
+#define __bitwise __attribute__((bitwise))
+typedef uint16_t __bitwise fdt16_t;
+typedef uint32_t __bitwise fdt32_t;
+typedef uint64_t __bitwise fdt64_t;
+#else
+#define __force
+#define __bitwise
+typedef uint16_t fdt16_t;
+typedef uint32_t fdt32_t;
+typedef uint64_t fdt64_t;
+#endif
+
 #define EXTRACT_BYTE(n)	((unsigned long long)((uint8_t *)&x)[n])
-static inline uint16_t fdt16_to_cpu(uint16_t x)
-{
-	return (EXTRACT_BYTE(0) << 8) | EXTRACT_BYTE(1);
-}
-#define cpu_to_fdt16(x) fdt16_to_cpu(x)
+#define __SWAB16X ((EXTRACT_BYTE(0) << 8) | EXTRACT_BYTE(1))
+#define __SWAB32X ((EXTRACT_BYTE(0) << 24) | (EXTRACT_BYTE(1) << 16) | (EXTRACT_BYTE(2) << 8) | EXTRACT_BYTE(3))
+#define __SWAB64X ((EXTRACT_BYTE(0) << 56) | (EXTRACT_BYTE(1) << 48) | (EXTRACT_BYTE(2) << 40) | (EXTRACT_BYTE(3) << 32) \
+		  | (EXTRACT_BYTE(4) << 24) | (EXTRACT_BYTE(5) << 16) | (EXTRACT_BYTE(6) << 8) | EXTRACT_BYTE(7))
 
-static inline uint32_t fdt32_to_cpu(uint32_t x)
-{
-	return (EXTRACT_BYTE(0) << 24) | (EXTRACT_BYTE(1) << 16) | (EXTRACT_BYTE(2) << 8) | EXTRACT_BYTE(3);
+/*
+ * determine host endianness:
+ * *__first_byte is 0x11 on big endian systems
+ * *__first_byte is 0x44 on little endian systems
+ */
+static const uint32_t __native = 0x11223344u;
+static const uint8_t *__first_byte = (const uint8_t *)&__native;
+
+#define DEF_FDT_TO_CPU(bits) \
+static inline uint##bits##_t fdt##bits##_to_cpu(fdt##bits##_t x) \
+{ \
+	if (*__first_byte == 0x11) \
+		return (__force uint##bits##_t)x; \
+	else \
+		return (__force uint##bits##_t)__SWAB##bits##X; \
 }
-#define cpu_to_fdt32(x) fdt32_to_cpu(x)
+DEF_FDT_TO_CPU(16)
+DEF_FDT_TO_CPU(32)
+DEF_FDT_TO_CPU(64)
 
-static inline uint64_t fdt64_to_cpu(uint64_t x)
-{
-	return (EXTRACT_BYTE(0) << 56) | (EXTRACT_BYTE(1) << 48) | (EXTRACT_BYTE(2) << 40) | (EXTRACT_BYTE(3) << 32)
-		| (EXTRACT_BYTE(4) << 24) | (EXTRACT_BYTE(5) << 16) | (EXTRACT_BYTE(6) << 8) | EXTRACT_BYTE(7);
+#define DEF_CPU_TO_FDT(bits) \
+static inline fdt##bits##_t cpu_to_fdt##bits(uint##bits##_t x) \
+{ \
+	if (*__first_byte == 0x11) \
+		return (__force fdt##bits##_t)x; \
+	else \
+		return (__force fdt##bits##_t)__SWAB##bits##X; \
 }
-#define cpu_to_fdt64(x) fdt64_to_cpu(x)
+DEF_CPU_TO_FDT(16)
+DEF_CPU_TO_FDT(32)
+DEF_CPU_TO_FDT(64)
+
+#undef DEF_FDT_TO_CPU
+#undef DEF_CPU_TO_FDT
+#undef __SWAB64X
+#undef __SWAB32X
+#undef __SWAB16X
 #undef EXTRACT_BYTE
 
 #endif /* _LIBFDT_ENV_H */
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* Re: [PATCH 3/4 v2] dtc/libfdt: introduce fdt types for annotation by endian checkers
  2012-11-14  0:34                 ` [U-Boot] " Kim Phillips
@ 2012-11-14 14:42                     ` Jon Loeliger
  -1 siblings, 0 replies; 133+ messages in thread
From: Jon Loeliger @ 2012-11-14 14:42 UTC (permalink / raw)
  To: Kim Phillips
  Cc: u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jerry Van Baren


Hi Kim,

> 
> I hope this addresses all your comments, David.

Which is why David didn't see this patch earlier. :-)


> index 213d7fb..302d5cb 100644
> --- a/libfdt/libfdt_env.h
> +++ b/libfdt/libfdt_env.h
> @@ -5,25 +5,63 @@
>  #include <stdint.h>
>  #include <string.h>
>  
> +#ifdef __CHECKER__
> +#define __force __attribute__((force))
> +#define __bitwise __attribute__((bitwise))
> +typedef uint16_t __bitwise fdt16_t;
> +typedef uint32_t __bitwise fdt32_t;
> +typedef uint64_t __bitwise fdt64_t;
> +#else
> +#define __force
> +#define __bitwise
> +typedef uint16_t fdt16_t;
> +typedef uint32_t fdt32_t;
> +typedef uint64_t fdt64_t;
> +#endif

Would this be simpler/better?

    #ifdef __CHECKER__
    #define __force __attribute__((force))
    #define __bitwise __attribute__((bitwise))
    #else
    #define __force
    #define __bitwise
    #endif

    typedef uint16_t __bitwise fdt16_t;
    typedef uint32_t __bitwise fdt32_t;
    typedef uint64_t __bitwise fdt64_t;



>  #define EXTRACT_BYTE(n)	((unsigned long long)((uint8_t *)&x)[n])
> -static inline uint16_t fdt16_to_cpu(uint16_t x)
> -{
> -	return (EXTRACT_BYTE(0) << 8) | EXTRACT_BYTE(1);
> -}
> -#define cpu_to_fdt16(x) fdt16_to_cpu(x)
> +#define __SWAB16X ((EXTRACT_BYTE(0) << 8) | EXTRACT_BYTE(1))
> +#define __SWAB32X ((EXTRACT_BYTE(0) << 24) | (EXTRACT_BYTE(1) << 16) | (EXTRACT_BYTE(2) <<
>  8) | EXTRACT_BYTE(3))
> +#define __SWAB64X ((EXTRACT_BYTE(0) << 56) | (EXTRACT_BYTE(1) << 48) | (EXTRACT_BYTE(2) <<
>  40) | (EXTRACT_BYTE(3) << 32) \
> +		  | (EXTRACT_BYTE(4) << 24) | (EXTRACT_BYTE(5) << 16) | (EXTRACT_BYTE(6) << 8
> ) | EXTRACT_BYTE(7))

I dislike function-like macros that grab global names.
Instead, can we re-work 'x' in as a parameter:

    >  #define EXTRACT_BYTE(x, n)	((unsigned long long)((uint8_t *)&x)[n])


> +#define DEF_FDT_TO_CPU(bits) \
> +static inline uint##bits##_t fdt##bits##_to_cpu(fdt##bits##_t x) \
> +{ \
> +	if (*__first_byte == 0x11) \
> +		return (__force uint##bits##_t)x; \
> +	else \
> +		return (__force uint##bits##_t)__SWAB##bits##X; \
>  }

Case check that last X...

> -static inline uint64_t fdt64_to_cpu(uint64_t x)
> -{
> -	return (EXTRACT_BYTE(0) << 56) | (EXTRACT_BYTE(1) << 48) | (EXTRACT_BYTE(2) << 40) | 
> (EXTRACT_BYTE(3) << 32)
> -		| (EXTRACT_BYTE(4) << 24) | (EXTRACT_BYTE(5) << 16) | (EXTRACT_BYTE(6) << 8) 
> | EXTRACT_BYTE(7);
> +#define DEF_CPU_TO_FDT(bits) \
> +static inline fdt##bits##_t cpu_to_fdt##bits(uint##bits##_t x) \
> +{ \
> +	if (*__first_byte == 0x11) \
> +		return (__force fdt##bits##_t)x; \
> +	else \
> +		return (__force fdt##bits##_t)__SWAB##bits##X; \
>  }

...and that one.

Thanks,
jdl

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH 3/4 v2] dtc/libfdt: introduce fdt types for annotation by endian checkers
@ 2012-11-14 14:42                     ` Jon Loeliger
  0 siblings, 0 replies; 133+ messages in thread
From: Jon Loeliger @ 2012-11-14 14:42 UTC (permalink / raw)
  To: u-boot


Hi Kim,

> 
> I hope this addresses all your comments, David.

Which is why David didn't see this patch earlier. :-)


> index 213d7fb..302d5cb 100644
> --- a/libfdt/libfdt_env.h
> +++ b/libfdt/libfdt_env.h
> @@ -5,25 +5,63 @@
>  #include <stdint.h>
>  #include <string.h>
>  
> +#ifdef __CHECKER__
> +#define __force __attribute__((force))
> +#define __bitwise __attribute__((bitwise))
> +typedef uint16_t __bitwise fdt16_t;
> +typedef uint32_t __bitwise fdt32_t;
> +typedef uint64_t __bitwise fdt64_t;
> +#else
> +#define __force
> +#define __bitwise
> +typedef uint16_t fdt16_t;
> +typedef uint32_t fdt32_t;
> +typedef uint64_t fdt64_t;
> +#endif

Would this be simpler/better?

    #ifdef __CHECKER__
    #define __force __attribute__((force))
    #define __bitwise __attribute__((bitwise))
    #else
    #define __force
    #define __bitwise
    #endif

    typedef uint16_t __bitwise fdt16_t;
    typedef uint32_t __bitwise fdt32_t;
    typedef uint64_t __bitwise fdt64_t;



>  #define EXTRACT_BYTE(n)	((unsigned long long)((uint8_t *)&x)[n])
> -static inline uint16_t fdt16_to_cpu(uint16_t x)
> -{
> -	return (EXTRACT_BYTE(0) << 8) | EXTRACT_BYTE(1);
> -}
> -#define cpu_to_fdt16(x) fdt16_to_cpu(x)
> +#define __SWAB16X ((EXTRACT_BYTE(0) << 8) | EXTRACT_BYTE(1))
> +#define __SWAB32X ((EXTRACT_BYTE(0) << 24) | (EXTRACT_BYTE(1) << 16) | (EXTRACT_BYTE(2) <<
>  8) | EXTRACT_BYTE(3))
> +#define __SWAB64X ((EXTRACT_BYTE(0) << 56) | (EXTRACT_BYTE(1) << 48) | (EXTRACT_BYTE(2) <<
>  40) | (EXTRACT_BYTE(3) << 32) \
> +		  | (EXTRACT_BYTE(4) << 24) | (EXTRACT_BYTE(5) << 16) | (EXTRACT_BYTE(6) << 8
> ) | EXTRACT_BYTE(7))

I dislike function-like macros that grab global names.
Instead, can we re-work 'x' in as a parameter:

    >  #define EXTRACT_BYTE(x, n)	((unsigned long long)((uint8_t *)&x)[n])


> +#define DEF_FDT_TO_CPU(bits) \
> +static inline uint##bits##_t fdt##bits##_to_cpu(fdt##bits##_t x) \
> +{ \
> +	if (*__first_byte == 0x11) \
> +		return (__force uint##bits##_t)x; \
> +	else \
> +		return (__force uint##bits##_t)__SWAB##bits##X; \
>  }

Case check that last X...

> -static inline uint64_t fdt64_to_cpu(uint64_t x)
> -{
> -	return (EXTRACT_BYTE(0) << 56) | (EXTRACT_BYTE(1) << 48) | (EXTRACT_BYTE(2) << 40) | 
> (EXTRACT_BYTE(3) << 32)
> -		| (EXTRACT_BYTE(4) << 24) | (EXTRACT_BYTE(5) << 16) | (EXTRACT_BYTE(6) << 8) 
> | EXTRACT_BYTE(7);
> +#define DEF_CPU_TO_FDT(bits) \
> +static inline fdt##bits##_t cpu_to_fdt##bits(uint##bits##_t x) \
> +{ \
> +	if (*__first_byte == 0x11) \
> +		return (__force fdt##bits##_t)x; \
> +	else \
> +		return (__force fdt##bits##_t)__SWAB##bits##X; \
>  }

...and that one.

Thanks,
jdl

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [PATCH v2 1/4] dtc/tests: don't include fdt.h prior to libfdt.h
  2012-11-14 14:42                     ` [U-Boot] " Jon Loeliger
@ 2012-11-15  0:59                       ` Kim Phillips
  -1 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-11-15  0:59 UTC (permalink / raw)
  To: jdl; +Cc: u-boot, devicetree-discuss, Kim Phillips, David Gibson

tests will need fdt type definitions provided in a subsequent patch
to libfdt_env.h.  Since libfdt.h includes libfdt_env.h in the right
order anyway, just remove the fdt.h include.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
---
v2: added David's Acked-by.

 tests/add_subnode_with_nops.c     | 1 -
 tests/appendprop1.c               | 1 -
 tests/appendprop2.c               | 1 -
 tests/asm_tree_dump.c             | 1 -
 tests/boot-cpuid.c                | 1 -
 tests/char_literal.c              | 1 -
 tests/del_node.c                  | 1 -
 tests/del_property.c              | 1 -
 tests/dtb_reverse.c               | 1 -
 tests/dtbs_equal_ordered.c        | 1 -
 tests/dtbs_equal_unordered.c      | 1 -
 tests/dumptrees.c                 | 2 --
 tests/extra-terminating-null.c    | 1 -
 tests/find_property.c             | 1 -
 tests/get_alias.c                 | 1 -
 tests/get_mem_rsv.c               | 1 -
 tests/get_name.c                  | 1 -
 tests/get_path.c                  | 1 -
 tests/get_phandle.c               | 1 -
 tests/getprop.c                   | 1 -
 tests/incbin.c                    | 1 -
 tests/integer-expressions.c       | 1 -
 tests/mangle-layout.c             | 1 -
 tests/move_and_save.c             | 1 -
 tests/node_check_compatible.c     | 1 -
 tests/node_offset_by_compatible.c | 1 -
 tests/node_offset_by_phandle.c    | 1 -
 tests/node_offset_by_prop_value.c | 1 -
 tests/nop_node.c                  | 1 -
 tests/nop_property.c              | 1 -
 tests/nopulate.c                  | 1 -
 tests/notfound.c                  | 1 -
 tests/open_pack.c                 | 1 -
 tests/parent_offset.c             | 1 -
 tests/path-references.c           | 1 -
 tests/path_offset.c               | 1 -
 tests/path_offset_aliases.c       | 1 -
 tests/phandle_format.c            | 1 -
 tests/propname_escapes.c          | 1 -
 tests/references.c                | 1 -
 tests/root_node.c                 | 1 -
 tests/rw_tree1.c                  | 1 -
 tests/set_name.c                  | 1 -
 tests/setprop.c                   | 1 -
 tests/setprop_inplace.c           | 1 -
 tests/sized_cells.c               | 1 -
 tests/string_escapes.c            | 1 -
 tests/subnode_offset.c            | 1 -
 tests/supernode_atdepth_offset.c  | 1 -
 tests/sw_tree1.c                  | 1 -
 tests/truncated_property.c        | 1 -
 tests/utilfdt_test.c              | 1 -
 tests/value-labels.c              | 1 -
 53 files changed, 54 deletions(-)

diff --git a/tests/add_subnode_with_nops.c b/tests/add_subnode_with_nops.c
index 4fb8f02..95ddf6a 100644
--- a/tests/add_subnode_with_nops.c
+++ b/tests/add_subnode_with_nops.c
@@ -24,7 +24,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/appendprop1.c b/tests/appendprop1.c
index d716f7a..9d6b3ad 100644
--- a/tests/appendprop1.c
+++ b/tests/appendprop1.c
@@ -24,7 +24,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/appendprop2.c b/tests/appendprop2.c
index 7eb243d..ca1446c 100644
--- a/tests/appendprop2.c
+++ b/tests/appendprop2.c
@@ -24,7 +24,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/asm_tree_dump.c b/tests/asm_tree_dump.c
index 5ff5087..bd12eda 100644
--- a/tests/asm_tree_dump.c
+++ b/tests/asm_tree_dump.c
@@ -26,7 +26,6 @@
 
 #include <dlfcn.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/boot-cpuid.c b/tests/boot-cpuid.c
index 7b5433d..ca39f4b 100644
--- a/tests/boot-cpuid.c
+++ b/tests/boot-cpuid.c
@@ -21,7 +21,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/char_literal.c b/tests/char_literal.c
index 150f2a0..d7a4773 100644
--- a/tests/char_literal.c
+++ b/tests/char_literal.c
@@ -23,7 +23,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/del_node.c b/tests/del_node.c
index afad502..45cb060 100644
--- a/tests/del_node.c
+++ b/tests/del_node.c
@@ -24,7 +24,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/del_property.c b/tests/del_property.c
index 449eca6..42fd7cb 100644
--- a/tests/del_property.c
+++ b/tests/del_property.c
@@ -24,7 +24,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/dtb_reverse.c b/tests/dtb_reverse.c
index 25e1eef..527fd71 100644
--- a/tests/dtb_reverse.c
+++ b/tests/dtb_reverse.c
@@ -24,7 +24,6 @@
 #include <stdint.h>
 #include <limits.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/dtbs_equal_ordered.c b/tests/dtbs_equal_ordered.c
index 1db25f4..12495de 100644
--- a/tests/dtbs_equal_ordered.c
+++ b/tests/dtbs_equal_ordered.c
@@ -23,7 +23,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/dtbs_equal_unordered.c b/tests/dtbs_equal_unordered.c
index df53318..20b4356 100644
--- a/tests/dtbs_equal_unordered.c
+++ b/tests/dtbs_equal_unordered.c
@@ -24,7 +24,6 @@
 #include <stdint.h>
 #include <limits.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/dumptrees.c b/tests/dumptrees.c
index fa1f563..bebf553 100644
--- a/tests/dumptrees.c
+++ b/tests/dumptrees.c
@@ -25,9 +25,7 @@
 #include <fcntl.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
-#include <libfdt_env.h>
 
 #include "testdata.h"
 
diff --git a/tests/extra-terminating-null.c b/tests/extra-terminating-null.c
index 8a2043f..dc1fe89 100644
--- a/tests/extra-terminating-null.c
+++ b/tests/extra-terminating-null.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/find_property.c b/tests/find_property.c
index 74a6965..4dc3030 100644
--- a/tests/find_property.c
+++ b/tests/find_property.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/get_alias.c b/tests/get_alias.c
index 1e0faf4..5060795 100644
--- a/tests/get_alias.c
+++ b/tests/get_alias.c
@@ -23,7 +23,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/get_mem_rsv.c b/tests/get_mem_rsv.c
index 554c788..1812639 100644
--- a/tests/get_mem_rsv.c
+++ b/tests/get_mem_rsv.c
@@ -23,7 +23,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/get_name.c b/tests/get_name.c
index 0262a12..c6ca9f9 100644
--- a/tests/get_name.c
+++ b/tests/get_name.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/get_path.c b/tests/get_path.c
index 1e05f7c..7352976 100644
--- a/tests/get_path.c
+++ b/tests/get_path.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/get_phandle.c b/tests/get_phandle.c
index 5735733..2079591 100644
--- a/tests/get_phandle.c
+++ b/tests/get_phandle.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/getprop.c b/tests/getprop.c
index 239856e..6255bad 100644
--- a/tests/getprop.c
+++ b/tests/getprop.c
@@ -23,7 +23,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/incbin.c b/tests/incbin.c
index 76d8626..4100ba0 100644
--- a/tests/incbin.c
+++ b/tests/incbin.c
@@ -23,7 +23,6 @@
 #include <stdint.h>
 #include <errno.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/integer-expressions.c b/tests/integer-expressions.c
index 5ba1566..57e2ff6 100644
--- a/tests/integer-expressions.c
+++ b/tests/integer-expressions.c
@@ -25,7 +25,6 @@
 #include <errno.h>
 
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/mangle-layout.c b/tests/mangle-layout.c
index 3b19788..a76e51e 100644
--- a/tests/mangle-layout.c
+++ b/tests/mangle-layout.c
@@ -24,7 +24,6 @@
 #include <limits.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/move_and_save.c b/tests/move_and_save.c
index 410ccb3..393b60a 100644
--- a/tests/move_and_save.c
+++ b/tests/move_and_save.c
@@ -24,7 +24,6 @@
 #include <limits.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/node_check_compatible.c b/tests/node_check_compatible.c
index 23abbf5..4bdf091 100644
--- a/tests/node_check_compatible.c
+++ b/tests/node_check_compatible.c
@@ -23,7 +23,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/node_offset_by_compatible.c b/tests/node_offset_by_compatible.c
index 2317930..f62b591 100644
--- a/tests/node_offset_by_compatible.c
+++ b/tests/node_offset_by_compatible.c
@@ -23,7 +23,6 @@
 #include <stdint.h>
 #include <stdarg.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/node_offset_by_phandle.c b/tests/node_offset_by_phandle.c
index a8442f1..becff0f 100644
--- a/tests/node_offset_by_phandle.c
+++ b/tests/node_offset_by_phandle.c
@@ -23,7 +23,6 @@
 #include <stdint.h>
 #include <stdarg.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/node_offset_by_prop_value.c b/tests/node_offset_by_prop_value.c
index 0f2a345..9212a4e 100644
--- a/tests/node_offset_by_prop_value.c
+++ b/tests/node_offset_by_prop_value.c
@@ -23,7 +23,6 @@
 #include <stdint.h>
 #include <stdarg.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/nop_node.c b/tests/nop_node.c
index ea3a18f..c316444 100644
--- a/tests/nop_node.c
+++ b/tests/nop_node.c
@@ -24,7 +24,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/nop_property.c b/tests/nop_property.c
index e6ef4d9..644b0a6 100644
--- a/tests/nop_property.c
+++ b/tests/nop_property.c
@@ -24,7 +24,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/nopulate.c b/tests/nopulate.c
index 3cbbe21..cd79872 100644
--- a/tests/nopulate.c
+++ b/tests/nopulate.c
@@ -24,7 +24,6 @@
 #include <limits.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/notfound.c b/tests/notfound.c
index 4d55b88..dc623d6 100644
--- a/tests/notfound.c
+++ b/tests/notfound.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/open_pack.c b/tests/open_pack.c
index 0a5a3fc..407ef6c 100644
--- a/tests/open_pack.c
+++ b/tests/open_pack.c
@@ -24,7 +24,6 @@
 #include <limits.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/parent_offset.c b/tests/parent_offset.c
index e7affcc..d4ab3cf 100644
--- a/tests/parent_offset.c
+++ b/tests/parent_offset.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/path-references.c b/tests/path-references.c
index 9f363b3..0746b3f 100644
--- a/tests/path-references.c
+++ b/tests/path-references.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/path_offset.c b/tests/path_offset.c
index d3e1f8e..4e5b7a1 100644
--- a/tests/path_offset.c
+++ b/tests/path_offset.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/path_offset_aliases.c b/tests/path_offset_aliases.c
index 3682da4..78d5a46 100644
--- a/tests/path_offset_aliases.c
+++ b/tests/path_offset_aliases.c
@@ -23,7 +23,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/phandle_format.c b/tests/phandle_format.c
index 7e4d816..5874ae7 100644
--- a/tests/phandle_format.c
+++ b/tests/phandle_format.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/propname_escapes.c b/tests/propname_escapes.c
index 3aec28f..e91bd99 100644
--- a/tests/propname_escapes.c
+++ b/tests/propname_escapes.c
@@ -24,7 +24,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/references.c b/tests/references.c
index b20f21f..c9d05a2 100644
--- a/tests/references.c
+++ b/tests/references.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/root_node.c b/tests/root_node.c
index 3f47829..58aebf6 100644
--- a/tests/root_node.c
+++ b/tests/root_node.c
@@ -23,7 +23,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/rw_tree1.c b/tests/rw_tree1.c
index 103a24d..efd4718 100644
--- a/tests/rw_tree1.c
+++ b/tests/rw_tree1.c
@@ -24,7 +24,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/set_name.c b/tests/set_name.c
index 5d1149e..9861587 100644
--- a/tests/set_name.c
+++ b/tests/set_name.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/setprop.c b/tests/setprop.c
index 9f2bc88..d089f8d 100644
--- a/tests/setprop.c
+++ b/tests/setprop.c
@@ -24,7 +24,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/setprop_inplace.c b/tests/setprop_inplace.c
index 82d8951..daef182 100644
--- a/tests/setprop_inplace.c
+++ b/tests/setprop_inplace.c
@@ -25,7 +25,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/sized_cells.c b/tests/sized_cells.c
index 847ec96..94da03b 100644
--- a/tests/sized_cells.c
+++ b/tests/sized_cells.c
@@ -23,7 +23,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/string_escapes.c b/tests/string_escapes.c
index 30eb6a8..8cdee4b 100644
--- a/tests/string_escapes.c
+++ b/tests/string_escapes.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/subnode_offset.c b/tests/subnode_offset.c
index e58c192..231fcb5 100644
--- a/tests/subnode_offset.c
+++ b/tests/subnode_offset.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/supernode_atdepth_offset.c b/tests/supernode_atdepth_offset.c
index 73f41ae..43e120d 100644
--- a/tests/supernode_atdepth_offset.c
+++ b/tests/supernode_atdepth_offset.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/sw_tree1.c b/tests/sw_tree1.c
index 5c71414..8eb6e5f 100644
--- a/tests/sw_tree1.c
+++ b/tests/sw_tree1.c
@@ -24,7 +24,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/truncated_property.c b/tests/truncated_property.c
index 56daa22..f820d99 100644
--- a/tests/truncated_property.c
+++ b/tests/truncated_property.c
@@ -23,7 +23,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/utilfdt_test.c b/tests/utilfdt_test.c
index 36b4aa5..274c3d6 100644
--- a/tests/utilfdt_test.c
+++ b/tests/utilfdt_test.c
@@ -24,7 +24,6 @@
 #include <stdint.h>
 #include <stdarg.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 #include <util.h>
 
diff --git a/tests/value-labels.c b/tests/value-labels.c
index abe2721..dcf2059 100644
--- a/tests/value-labels.c
+++ b/tests/value-labels.c
@@ -26,7 +26,6 @@
 
 #include <dlfcn.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 1/4] dtc/tests: don't include fdt.h prior to libfdt.h
@ 2012-11-15  0:59                       ` Kim Phillips
  0 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-11-15  0:59 UTC (permalink / raw)
  To: u-boot

tests will need fdt type definitions provided in a subsequent patch
to libfdt_env.h.  Since libfdt.h includes libfdt_env.h in the right
order anyway, just remove the fdt.h include.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
---
v2: added David's Acked-by.

 tests/add_subnode_with_nops.c     | 1 -
 tests/appendprop1.c               | 1 -
 tests/appendprop2.c               | 1 -
 tests/asm_tree_dump.c             | 1 -
 tests/boot-cpuid.c                | 1 -
 tests/char_literal.c              | 1 -
 tests/del_node.c                  | 1 -
 tests/del_property.c              | 1 -
 tests/dtb_reverse.c               | 1 -
 tests/dtbs_equal_ordered.c        | 1 -
 tests/dtbs_equal_unordered.c      | 1 -
 tests/dumptrees.c                 | 2 --
 tests/extra-terminating-null.c    | 1 -
 tests/find_property.c             | 1 -
 tests/get_alias.c                 | 1 -
 tests/get_mem_rsv.c               | 1 -
 tests/get_name.c                  | 1 -
 tests/get_path.c                  | 1 -
 tests/get_phandle.c               | 1 -
 tests/getprop.c                   | 1 -
 tests/incbin.c                    | 1 -
 tests/integer-expressions.c       | 1 -
 tests/mangle-layout.c             | 1 -
 tests/move_and_save.c             | 1 -
 tests/node_check_compatible.c     | 1 -
 tests/node_offset_by_compatible.c | 1 -
 tests/node_offset_by_phandle.c    | 1 -
 tests/node_offset_by_prop_value.c | 1 -
 tests/nop_node.c                  | 1 -
 tests/nop_property.c              | 1 -
 tests/nopulate.c                  | 1 -
 tests/notfound.c                  | 1 -
 tests/open_pack.c                 | 1 -
 tests/parent_offset.c             | 1 -
 tests/path-references.c           | 1 -
 tests/path_offset.c               | 1 -
 tests/path_offset_aliases.c       | 1 -
 tests/phandle_format.c            | 1 -
 tests/propname_escapes.c          | 1 -
 tests/references.c                | 1 -
 tests/root_node.c                 | 1 -
 tests/rw_tree1.c                  | 1 -
 tests/set_name.c                  | 1 -
 tests/setprop.c                   | 1 -
 tests/setprop_inplace.c           | 1 -
 tests/sized_cells.c               | 1 -
 tests/string_escapes.c            | 1 -
 tests/subnode_offset.c            | 1 -
 tests/supernode_atdepth_offset.c  | 1 -
 tests/sw_tree1.c                  | 1 -
 tests/truncated_property.c        | 1 -
 tests/utilfdt_test.c              | 1 -
 tests/value-labels.c              | 1 -
 53 files changed, 54 deletions(-)

diff --git a/tests/add_subnode_with_nops.c b/tests/add_subnode_with_nops.c
index 4fb8f02..95ddf6a 100644
--- a/tests/add_subnode_with_nops.c
+++ b/tests/add_subnode_with_nops.c
@@ -24,7 +24,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/appendprop1.c b/tests/appendprop1.c
index d716f7a..9d6b3ad 100644
--- a/tests/appendprop1.c
+++ b/tests/appendprop1.c
@@ -24,7 +24,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/appendprop2.c b/tests/appendprop2.c
index 7eb243d..ca1446c 100644
--- a/tests/appendprop2.c
+++ b/tests/appendprop2.c
@@ -24,7 +24,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/asm_tree_dump.c b/tests/asm_tree_dump.c
index 5ff5087..bd12eda 100644
--- a/tests/asm_tree_dump.c
+++ b/tests/asm_tree_dump.c
@@ -26,7 +26,6 @@
 
 #include <dlfcn.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/boot-cpuid.c b/tests/boot-cpuid.c
index 7b5433d..ca39f4b 100644
--- a/tests/boot-cpuid.c
+++ b/tests/boot-cpuid.c
@@ -21,7 +21,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/char_literal.c b/tests/char_literal.c
index 150f2a0..d7a4773 100644
--- a/tests/char_literal.c
+++ b/tests/char_literal.c
@@ -23,7 +23,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/del_node.c b/tests/del_node.c
index afad502..45cb060 100644
--- a/tests/del_node.c
+++ b/tests/del_node.c
@@ -24,7 +24,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/del_property.c b/tests/del_property.c
index 449eca6..42fd7cb 100644
--- a/tests/del_property.c
+++ b/tests/del_property.c
@@ -24,7 +24,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/dtb_reverse.c b/tests/dtb_reverse.c
index 25e1eef..527fd71 100644
--- a/tests/dtb_reverse.c
+++ b/tests/dtb_reverse.c
@@ -24,7 +24,6 @@
 #include <stdint.h>
 #include <limits.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/dtbs_equal_ordered.c b/tests/dtbs_equal_ordered.c
index 1db25f4..12495de 100644
--- a/tests/dtbs_equal_ordered.c
+++ b/tests/dtbs_equal_ordered.c
@@ -23,7 +23,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/dtbs_equal_unordered.c b/tests/dtbs_equal_unordered.c
index df53318..20b4356 100644
--- a/tests/dtbs_equal_unordered.c
+++ b/tests/dtbs_equal_unordered.c
@@ -24,7 +24,6 @@
 #include <stdint.h>
 #include <limits.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/dumptrees.c b/tests/dumptrees.c
index fa1f563..bebf553 100644
--- a/tests/dumptrees.c
+++ b/tests/dumptrees.c
@@ -25,9 +25,7 @@
 #include <fcntl.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
-#include <libfdt_env.h>
 
 #include "testdata.h"
 
diff --git a/tests/extra-terminating-null.c b/tests/extra-terminating-null.c
index 8a2043f..dc1fe89 100644
--- a/tests/extra-terminating-null.c
+++ b/tests/extra-terminating-null.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/find_property.c b/tests/find_property.c
index 74a6965..4dc3030 100644
--- a/tests/find_property.c
+++ b/tests/find_property.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/get_alias.c b/tests/get_alias.c
index 1e0faf4..5060795 100644
--- a/tests/get_alias.c
+++ b/tests/get_alias.c
@@ -23,7 +23,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/get_mem_rsv.c b/tests/get_mem_rsv.c
index 554c788..1812639 100644
--- a/tests/get_mem_rsv.c
+++ b/tests/get_mem_rsv.c
@@ -23,7 +23,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/get_name.c b/tests/get_name.c
index 0262a12..c6ca9f9 100644
--- a/tests/get_name.c
+++ b/tests/get_name.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/get_path.c b/tests/get_path.c
index 1e05f7c..7352976 100644
--- a/tests/get_path.c
+++ b/tests/get_path.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/get_phandle.c b/tests/get_phandle.c
index 5735733..2079591 100644
--- a/tests/get_phandle.c
+++ b/tests/get_phandle.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/getprop.c b/tests/getprop.c
index 239856e..6255bad 100644
--- a/tests/getprop.c
+++ b/tests/getprop.c
@@ -23,7 +23,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/incbin.c b/tests/incbin.c
index 76d8626..4100ba0 100644
--- a/tests/incbin.c
+++ b/tests/incbin.c
@@ -23,7 +23,6 @@
 #include <stdint.h>
 #include <errno.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/integer-expressions.c b/tests/integer-expressions.c
index 5ba1566..57e2ff6 100644
--- a/tests/integer-expressions.c
+++ b/tests/integer-expressions.c
@@ -25,7 +25,6 @@
 #include <errno.h>
 
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/mangle-layout.c b/tests/mangle-layout.c
index 3b19788..a76e51e 100644
--- a/tests/mangle-layout.c
+++ b/tests/mangle-layout.c
@@ -24,7 +24,6 @@
 #include <limits.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/move_and_save.c b/tests/move_and_save.c
index 410ccb3..393b60a 100644
--- a/tests/move_and_save.c
+++ b/tests/move_and_save.c
@@ -24,7 +24,6 @@
 #include <limits.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/node_check_compatible.c b/tests/node_check_compatible.c
index 23abbf5..4bdf091 100644
--- a/tests/node_check_compatible.c
+++ b/tests/node_check_compatible.c
@@ -23,7 +23,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/node_offset_by_compatible.c b/tests/node_offset_by_compatible.c
index 2317930..f62b591 100644
--- a/tests/node_offset_by_compatible.c
+++ b/tests/node_offset_by_compatible.c
@@ -23,7 +23,6 @@
 #include <stdint.h>
 #include <stdarg.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/node_offset_by_phandle.c b/tests/node_offset_by_phandle.c
index a8442f1..becff0f 100644
--- a/tests/node_offset_by_phandle.c
+++ b/tests/node_offset_by_phandle.c
@@ -23,7 +23,6 @@
 #include <stdint.h>
 #include <stdarg.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/node_offset_by_prop_value.c b/tests/node_offset_by_prop_value.c
index 0f2a345..9212a4e 100644
--- a/tests/node_offset_by_prop_value.c
+++ b/tests/node_offset_by_prop_value.c
@@ -23,7 +23,6 @@
 #include <stdint.h>
 #include <stdarg.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/nop_node.c b/tests/nop_node.c
index ea3a18f..c316444 100644
--- a/tests/nop_node.c
+++ b/tests/nop_node.c
@@ -24,7 +24,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/nop_property.c b/tests/nop_property.c
index e6ef4d9..644b0a6 100644
--- a/tests/nop_property.c
+++ b/tests/nop_property.c
@@ -24,7 +24,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/nopulate.c b/tests/nopulate.c
index 3cbbe21..cd79872 100644
--- a/tests/nopulate.c
+++ b/tests/nopulate.c
@@ -24,7 +24,6 @@
 #include <limits.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/notfound.c b/tests/notfound.c
index 4d55b88..dc623d6 100644
--- a/tests/notfound.c
+++ b/tests/notfound.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/open_pack.c b/tests/open_pack.c
index 0a5a3fc..407ef6c 100644
--- a/tests/open_pack.c
+++ b/tests/open_pack.c
@@ -24,7 +24,6 @@
 #include <limits.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/parent_offset.c b/tests/parent_offset.c
index e7affcc..d4ab3cf 100644
--- a/tests/parent_offset.c
+++ b/tests/parent_offset.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/path-references.c b/tests/path-references.c
index 9f363b3..0746b3f 100644
--- a/tests/path-references.c
+++ b/tests/path-references.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/path_offset.c b/tests/path_offset.c
index d3e1f8e..4e5b7a1 100644
--- a/tests/path_offset.c
+++ b/tests/path_offset.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/path_offset_aliases.c b/tests/path_offset_aliases.c
index 3682da4..78d5a46 100644
--- a/tests/path_offset_aliases.c
+++ b/tests/path_offset_aliases.c
@@ -23,7 +23,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/phandle_format.c b/tests/phandle_format.c
index 7e4d816..5874ae7 100644
--- a/tests/phandle_format.c
+++ b/tests/phandle_format.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/propname_escapes.c b/tests/propname_escapes.c
index 3aec28f..e91bd99 100644
--- a/tests/propname_escapes.c
+++ b/tests/propname_escapes.c
@@ -24,7 +24,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/references.c b/tests/references.c
index b20f21f..c9d05a2 100644
--- a/tests/references.c
+++ b/tests/references.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/root_node.c b/tests/root_node.c
index 3f47829..58aebf6 100644
--- a/tests/root_node.c
+++ b/tests/root_node.c
@@ -23,7 +23,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/rw_tree1.c b/tests/rw_tree1.c
index 103a24d..efd4718 100644
--- a/tests/rw_tree1.c
+++ b/tests/rw_tree1.c
@@ -24,7 +24,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/set_name.c b/tests/set_name.c
index 5d1149e..9861587 100644
--- a/tests/set_name.c
+++ b/tests/set_name.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/setprop.c b/tests/setprop.c
index 9f2bc88..d089f8d 100644
--- a/tests/setprop.c
+++ b/tests/setprop.c
@@ -24,7 +24,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/setprop_inplace.c b/tests/setprop_inplace.c
index 82d8951..daef182 100644
--- a/tests/setprop_inplace.c
+++ b/tests/setprop_inplace.c
@@ -25,7 +25,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/sized_cells.c b/tests/sized_cells.c
index 847ec96..94da03b 100644
--- a/tests/sized_cells.c
+++ b/tests/sized_cells.c
@@ -23,7 +23,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/string_escapes.c b/tests/string_escapes.c
index 30eb6a8..8cdee4b 100644
--- a/tests/string_escapes.c
+++ b/tests/string_escapes.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/subnode_offset.c b/tests/subnode_offset.c
index e58c192..231fcb5 100644
--- a/tests/subnode_offset.c
+++ b/tests/subnode_offset.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/supernode_atdepth_offset.c b/tests/supernode_atdepth_offset.c
index 73f41ae..43e120d 100644
--- a/tests/supernode_atdepth_offset.c
+++ b/tests/supernode_atdepth_offset.c
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/sw_tree1.c b/tests/sw_tree1.c
index 5c71414..8eb6e5f 100644
--- a/tests/sw_tree1.c
+++ b/tests/sw_tree1.c
@@ -24,7 +24,6 @@
 #include <ctype.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/truncated_property.c b/tests/truncated_property.c
index 56daa22..f820d99 100644
--- a/tests/truncated_property.c
+++ b/tests/truncated_property.c
@@ -23,7 +23,6 @@
 #include <string.h>
 #include <stdint.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
diff --git a/tests/utilfdt_test.c b/tests/utilfdt_test.c
index 36b4aa5..274c3d6 100644
--- a/tests/utilfdt_test.c
+++ b/tests/utilfdt_test.c
@@ -24,7 +24,6 @@
 #include <stdint.h>
 #include <stdarg.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 #include <util.h>
 
diff --git a/tests/value-labels.c b/tests/value-labels.c
index abe2721..dcf2059 100644
--- a/tests/value-labels.c
+++ b/tests/value-labels.c
@@ -26,7 +26,6 @@
 
 #include <dlfcn.h>
 
-#include <fdt.h>
 #include <libfdt.h>
 
 #include "tests.h"
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [PATCH v2 2/4] dtc/fdtdump: include libfdt_env.h prior to fdt.h
  2012-11-15  0:59                       ` [U-Boot] " Kim Phillips
@ 2012-11-15  0:59                           ` Kim Phillips
  -1 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-11-15  0:59 UTC (permalink / raw)
  To: jdl-CYoMK+44s/E
  Cc: u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jerry Van Baren

in order to get the upcoming fdt type definitions.

Signed-off-by: Kim Phillips <kim.phillips-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
Acked-by: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
---
v2: added David's Acked-by.

 fdtdump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fdtdump.c b/fdtdump.c
index 207a46d..8a7ae72 100644
--- a/fdtdump.c
+++ b/fdtdump.c
@@ -8,8 +8,8 @@
 #include <string.h>
 #include <ctype.h>
 
-#include <fdt.h>
 #include <libfdt_env.h>
+#include <fdt.h>
 
 #include "util.h"
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 2/4] dtc/fdtdump: include libfdt_env.h prior to fdt.h
@ 2012-11-15  0:59                           ` Kim Phillips
  0 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-11-15  0:59 UTC (permalink / raw)
  To: u-boot

in order to get the upcoming fdt type definitions.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
---
v2: added David's Acked-by.

 fdtdump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fdtdump.c b/fdtdump.c
index 207a46d..8a7ae72 100644
--- a/fdtdump.c
+++ b/fdtdump.c
@@ -8,8 +8,8 @@
 #include <string.h>
 #include <ctype.h>
 
-#include <fdt.h>
 #include <libfdt_env.h>
+#include <fdt.h>
 
 #include "util.h"
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [PATCH v3 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers
  2012-11-15  0:59                       ` [U-Boot] " Kim Phillips
@ 2012-11-15  0:59                           ` Kim Phillips
  -1 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-11-15  0:59 UTC (permalink / raw)
  To: jdl-CYoMK+44s/E
  Cc: u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jerry Van Baren

Projects such as linux and u-boot run sparse on libfdt.  libfdt
contains the notion of endianness via usage of endian conversion
functions such as fdt32_to_cpu.  As such, in order to pass endian
checks, libfdt has to annotate its fdt variables such that sparse
can warn when mixing bitwise and regular integers.  This patch adds
these new fdtXX_t types and, ifdef __CHECKER__ (a symbol sparse
defines), includes the bitwise annotation.

Signed-off-by: Kim Phillips <kim.phillips-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
---
v2:
adds bitwise awareness: determine host endianness manually, and
annotate swabs with __force in fdtXX_to_cpu and cpu_to_fdtXX
conversion functions (the inline endian condition checks are
optimized out at compile time).  This allows us to be able to check
libfdt bitwise conversions with sparse by building dtc with make
CC=cgcc. v2 also moves fdt32 definitions from fdt.h to libfdt_env.h
and changes fdt32 definitions to use __bitwise instead of __be32. No
separate _FDT_SPARSE was introduced because there's no need: using
__CHECKER__ directly is valid because it only occurs once, and in
libfdt_env.h.
In addition, the libfdt sparse fixes have been moved to a subsequent
patch.

v3:  address comments from jdl:
o single set of fdt typedefs, since __bitwise is not defined if !CHECKER
o re-work EXTRACT_BYTE to take 'x' as a parameter, not a global
o SWAB function macros converted to take lowercase 'x' as a parameter,
  not a global

 libfdt/fdt.h        | 42 ++++++++++++++++----------------
 libfdt/libfdt_env.h | 69 +++++++++++++++++++++++++++++++++++++++++------------
 2 files changed, 75 insertions(+), 36 deletions(-)

diff --git a/libfdt/fdt.h b/libfdt/fdt.h
index 48ccfd9..45dd134 100644
--- a/libfdt/fdt.h
+++ b/libfdt/fdt.h
@@ -4,45 +4,45 @@
 #ifndef __ASSEMBLY__
 
 struct fdt_header {
-	uint32_t magic;			 /* magic word FDT_MAGIC */
-	uint32_t totalsize;		 /* total size of DT block */
-	uint32_t off_dt_struct;		 /* offset to structure */
-	uint32_t off_dt_strings;	 /* offset to strings */
-	uint32_t off_mem_rsvmap;	 /* offset to memory reserve map */
-	uint32_t version;		 /* format version */
-	uint32_t last_comp_version;	 /* last compatible version */
+	fdt32_t magic;			 /* magic word FDT_MAGIC */
+	fdt32_t totalsize;		 /* total size of DT block */
+	fdt32_t off_dt_struct;		 /* offset to structure */
+	fdt32_t off_dt_strings;		 /* offset to strings */
+	fdt32_t off_mem_rsvmap;		 /* offset to memory reserve map */
+	fdt32_t version;		 /* format version */
+	fdt32_t last_comp_version;	 /* last compatible version */
 
 	/* version 2 fields below */
-	uint32_t boot_cpuid_phys;	 /* Which physical CPU id we're
+	fdt32_t boot_cpuid_phys;	 /* Which physical CPU id we're
 					    booting on */
 	/* version 3 fields below */
-	uint32_t size_dt_strings;	 /* size of the strings block */
+	fdt32_t size_dt_strings;	 /* size of the strings block */
 
 	/* version 17 fields below */
-	uint32_t size_dt_struct;	 /* size of the structure block */
+	fdt32_t size_dt_struct;		 /* size of the structure block */
 };
 
 struct fdt_reserve_entry {
-	uint64_t address;
-	uint64_t size;
+	fdt64_t address;
+	fdt64_t size;
 };
 
 struct fdt_node_header {
-	uint32_t tag;
+	fdt32_t tag;
 	char name[0];
 };
 
 struct fdt_property {
-	uint32_t tag;
-	uint32_t len;
-	uint32_t nameoff;
+	fdt32_t tag;
+	fdt32_t len;
+	fdt32_t nameoff;
 	char data[0];
 };
 
 #endif /* !__ASSEMBLY */
 
 #define FDT_MAGIC	0xd00dfeed	/* 4: version, 4: total size */
-#define FDT_TAGSIZE	sizeof(uint32_t)
+#define FDT_TAGSIZE	sizeof(fdt32_t)
 
 #define FDT_BEGIN_NODE	0x1		/* Start node: full name */
 #define FDT_END_NODE	0x2		/* End node */
@@ -51,10 +51,10 @@ struct fdt_property {
 #define FDT_NOP		0x4		/* nop */
 #define FDT_END		0x9
 
-#define FDT_V1_SIZE	(7*sizeof(uint32_t))
-#define FDT_V2_SIZE	(FDT_V1_SIZE + sizeof(uint32_t))
-#define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(uint32_t))
+#define FDT_V1_SIZE	(7*sizeof(fdt32_t))
+#define FDT_V2_SIZE	(FDT_V1_SIZE + sizeof(fdt32_t))
+#define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(fdt32_t))
 #define FDT_V16_SIZE	FDT_V3_SIZE
-#define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(uint32_t))
+#define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(fdt32_t))
 
 #endif /* _FDT_H */
diff --git a/libfdt/libfdt_env.h b/libfdt/libfdt_env.h
index 213d7fb..f0d97b9 100644
--- a/libfdt/libfdt_env.h
+++ b/libfdt/libfdt_env.h
@@ -5,25 +5,64 @@
 #include <stdint.h>
 #include <string.h>
 
-#define EXTRACT_BYTE(n)	((unsigned long long)((uint8_t *)&x)[n])
-static inline uint16_t fdt16_to_cpu(uint16_t x)
-{
-	return (EXTRACT_BYTE(0) << 8) | EXTRACT_BYTE(1);
-}
-#define cpu_to_fdt16(x) fdt16_to_cpu(x)
+#ifdef __CHECKER__
+#define __force __attribute__((force))
+#define __bitwise __attribute__((bitwise))
+#else
+#define __force
+#define __bitwise
+#endif
+
+typedef uint16_t __bitwise fdt16_t;
+typedef uint32_t __bitwise fdt32_t;
+typedef uint64_t __bitwise fdt64_t;
+
+#define EXTRACT_BYTE(x, n) ((unsigned long long)((uint8_t *)&x)[n])
+#define __SWAB16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1))
+#define __SWAB32(x) ((EXTRACT_BYTE(x, 0) << 24) | (EXTRACT_BYTE(x, 1) << 16) | \
+		     (EXTRACT_BYTE(x, 2) << 8) | EXTRACT_BYTE(x, 3))
+#define __SWAB64(x) ((EXTRACT_BYTE(x, 0) << 56) | (EXTRACT_BYTE(x, 1) << 48) | \
+		     (EXTRACT_BYTE(x, 2) << 40) | (EXTRACT_BYTE(x, 3) << 32) | \
+		     (EXTRACT_BYTE(x, 4) << 24) | (EXTRACT_BYTE(x, 5) << 16) | \
+		     (EXTRACT_BYTE(x, 6) << 8) | EXTRACT_BYTE(x, 7))
 
-static inline uint32_t fdt32_to_cpu(uint32_t x)
-{
-	return (EXTRACT_BYTE(0) << 24) | (EXTRACT_BYTE(1) << 16) | (EXTRACT_BYTE(2) << 8) | EXTRACT_BYTE(3);
+/*
+ * determine host endianness:
+ * *__first_byte is 0x11 on big endian systems
+ * *__first_byte is 0x44 on little endian systems
+ */
+static const uint32_t __native = 0x11223344u;
+static const uint8_t *__first_byte = (const uint8_t *)&__native;
+
+#define DEF_FDT_TO_CPU(bits) \
+static inline uint##bits##_t fdt##bits##_to_cpu(fdt##bits##_t x) \
+{ \
+	if (*__first_byte == 0x11) \
+		return (__force uint##bits##_t)x; \
+	else \
+		return (__force uint##bits##_t)__SWAB##bits(x); \
 }
-#define cpu_to_fdt32(x) fdt32_to_cpu(x)
+DEF_FDT_TO_CPU(16)
+DEF_FDT_TO_CPU(32)
+DEF_FDT_TO_CPU(64)
 
-static inline uint64_t fdt64_to_cpu(uint64_t x)
-{
-	return (EXTRACT_BYTE(0) << 56) | (EXTRACT_BYTE(1) << 48) | (EXTRACT_BYTE(2) << 40) | (EXTRACT_BYTE(3) << 32)
-		| (EXTRACT_BYTE(4) << 24) | (EXTRACT_BYTE(5) << 16) | (EXTRACT_BYTE(6) << 8) | EXTRACT_BYTE(7);
+#define DEF_CPU_TO_FDT(bits) \
+static inline fdt##bits##_t cpu_to_fdt##bits(uint##bits##_t x) \
+{ \
+	if (*__first_byte == 0x11) \
+		return (__force fdt##bits##_t)x; \
+	else \
+		return (__force fdt##bits##_t)__SWAB##bits(x); \
 }
-#define cpu_to_fdt64(x) fdt64_to_cpu(x)
+DEF_CPU_TO_FDT(16)
+DEF_CPU_TO_FDT(32)
+DEF_CPU_TO_FDT(64)
+
+#undef DEF_CPU_TO_FDT
+#undef DEF_FDT_TO_CPU
+#undef __SWAB64
+#undef __SWAB32
+#undef __SWAB16
 #undef EXTRACT_BYTE
 
 #endif /* _LIBFDT_ENV_H */
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v3 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers
@ 2012-11-15  0:59                           ` Kim Phillips
  0 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-11-15  0:59 UTC (permalink / raw)
  To: u-boot

Projects such as linux and u-boot run sparse on libfdt.  libfdt
contains the notion of endianness via usage of endian conversion
functions such as fdt32_to_cpu.  As such, in order to pass endian
checks, libfdt has to annotate its fdt variables such that sparse
can warn when mixing bitwise and regular integers.  This patch adds
these new fdtXX_t types and, ifdef __CHECKER__ (a symbol sparse
defines), includes the bitwise annotation.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2:
adds bitwise awareness: determine host endianness manually, and
annotate swabs with __force in fdtXX_to_cpu and cpu_to_fdtXX
conversion functions (the inline endian condition checks are
optimized out at compile time).  This allows us to be able to check
libfdt bitwise conversions with sparse by building dtc with make
CC=cgcc. v2 also moves fdt32 definitions from fdt.h to libfdt_env.h
and changes fdt32 definitions to use __bitwise instead of __be32. No
separate _FDT_SPARSE was introduced because there's no need: using
__CHECKER__ directly is valid because it only occurs once, and in
libfdt_env.h.
In addition, the libfdt sparse fixes have been moved to a subsequent
patch.

v3:  address comments from jdl:
o single set of fdt typedefs, since __bitwise is not defined if !CHECKER
o re-work EXTRACT_BYTE to take 'x' as a parameter, not a global
o SWAB function macros converted to take lowercase 'x' as a parameter,
  not a global

 libfdt/fdt.h        | 42 ++++++++++++++++----------------
 libfdt/libfdt_env.h | 69 +++++++++++++++++++++++++++++++++++++++++------------
 2 files changed, 75 insertions(+), 36 deletions(-)

diff --git a/libfdt/fdt.h b/libfdt/fdt.h
index 48ccfd9..45dd134 100644
--- a/libfdt/fdt.h
+++ b/libfdt/fdt.h
@@ -4,45 +4,45 @@
 #ifndef __ASSEMBLY__
 
 struct fdt_header {
-	uint32_t magic;			 /* magic word FDT_MAGIC */
-	uint32_t totalsize;		 /* total size of DT block */
-	uint32_t off_dt_struct;		 /* offset to structure */
-	uint32_t off_dt_strings;	 /* offset to strings */
-	uint32_t off_mem_rsvmap;	 /* offset to memory reserve map */
-	uint32_t version;		 /* format version */
-	uint32_t last_comp_version;	 /* last compatible version */
+	fdt32_t magic;			 /* magic word FDT_MAGIC */
+	fdt32_t totalsize;		 /* total size of DT block */
+	fdt32_t off_dt_struct;		 /* offset to structure */
+	fdt32_t off_dt_strings;		 /* offset to strings */
+	fdt32_t off_mem_rsvmap;		 /* offset to memory reserve map */
+	fdt32_t version;		 /* format version */
+	fdt32_t last_comp_version;	 /* last compatible version */
 
 	/* version 2 fields below */
-	uint32_t boot_cpuid_phys;	 /* Which physical CPU id we're
+	fdt32_t boot_cpuid_phys;	 /* Which physical CPU id we're
 					    booting on */
 	/* version 3 fields below */
-	uint32_t size_dt_strings;	 /* size of the strings block */
+	fdt32_t size_dt_strings;	 /* size of the strings block */
 
 	/* version 17 fields below */
-	uint32_t size_dt_struct;	 /* size of the structure block */
+	fdt32_t size_dt_struct;		 /* size of the structure block */
 };
 
 struct fdt_reserve_entry {
-	uint64_t address;
-	uint64_t size;
+	fdt64_t address;
+	fdt64_t size;
 };
 
 struct fdt_node_header {
-	uint32_t tag;
+	fdt32_t tag;
 	char name[0];
 };
 
 struct fdt_property {
-	uint32_t tag;
-	uint32_t len;
-	uint32_t nameoff;
+	fdt32_t tag;
+	fdt32_t len;
+	fdt32_t nameoff;
 	char data[0];
 };
 
 #endif /* !__ASSEMBLY */
 
 #define FDT_MAGIC	0xd00dfeed	/* 4: version, 4: total size */
-#define FDT_TAGSIZE	sizeof(uint32_t)
+#define FDT_TAGSIZE	sizeof(fdt32_t)
 
 #define FDT_BEGIN_NODE	0x1		/* Start node: full name */
 #define FDT_END_NODE	0x2		/* End node */
@@ -51,10 +51,10 @@ struct fdt_property {
 #define FDT_NOP		0x4		/* nop */
 #define FDT_END		0x9
 
-#define FDT_V1_SIZE	(7*sizeof(uint32_t))
-#define FDT_V2_SIZE	(FDT_V1_SIZE + sizeof(uint32_t))
-#define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(uint32_t))
+#define FDT_V1_SIZE	(7*sizeof(fdt32_t))
+#define FDT_V2_SIZE	(FDT_V1_SIZE + sizeof(fdt32_t))
+#define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(fdt32_t))
 #define FDT_V16_SIZE	FDT_V3_SIZE
-#define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(uint32_t))
+#define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(fdt32_t))
 
 #endif /* _FDT_H */
diff --git a/libfdt/libfdt_env.h b/libfdt/libfdt_env.h
index 213d7fb..f0d97b9 100644
--- a/libfdt/libfdt_env.h
+++ b/libfdt/libfdt_env.h
@@ -5,25 +5,64 @@
 #include <stdint.h>
 #include <string.h>
 
-#define EXTRACT_BYTE(n)	((unsigned long long)((uint8_t *)&x)[n])
-static inline uint16_t fdt16_to_cpu(uint16_t x)
-{
-	return (EXTRACT_BYTE(0) << 8) | EXTRACT_BYTE(1);
-}
-#define cpu_to_fdt16(x) fdt16_to_cpu(x)
+#ifdef __CHECKER__
+#define __force __attribute__((force))
+#define __bitwise __attribute__((bitwise))
+#else
+#define __force
+#define __bitwise
+#endif
+
+typedef uint16_t __bitwise fdt16_t;
+typedef uint32_t __bitwise fdt32_t;
+typedef uint64_t __bitwise fdt64_t;
+
+#define EXTRACT_BYTE(x, n) ((unsigned long long)((uint8_t *)&x)[n])
+#define __SWAB16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1))
+#define __SWAB32(x) ((EXTRACT_BYTE(x, 0) << 24) | (EXTRACT_BYTE(x, 1) << 16) | \
+		     (EXTRACT_BYTE(x, 2) << 8) | EXTRACT_BYTE(x, 3))
+#define __SWAB64(x) ((EXTRACT_BYTE(x, 0) << 56) | (EXTRACT_BYTE(x, 1) << 48) | \
+		     (EXTRACT_BYTE(x, 2) << 40) | (EXTRACT_BYTE(x, 3) << 32) | \
+		     (EXTRACT_BYTE(x, 4) << 24) | (EXTRACT_BYTE(x, 5) << 16) | \
+		     (EXTRACT_BYTE(x, 6) << 8) | EXTRACT_BYTE(x, 7))
 
-static inline uint32_t fdt32_to_cpu(uint32_t x)
-{
-	return (EXTRACT_BYTE(0) << 24) | (EXTRACT_BYTE(1) << 16) | (EXTRACT_BYTE(2) << 8) | EXTRACT_BYTE(3);
+/*
+ * determine host endianness:
+ * *__first_byte is 0x11 on big endian systems
+ * *__first_byte is 0x44 on little endian systems
+ */
+static const uint32_t __native = 0x11223344u;
+static const uint8_t *__first_byte = (const uint8_t *)&__native;
+
+#define DEF_FDT_TO_CPU(bits) \
+static inline uint##bits##_t fdt##bits##_to_cpu(fdt##bits##_t x) \
+{ \
+	if (*__first_byte == 0x11) \
+		return (__force uint##bits##_t)x; \
+	else \
+		return (__force uint##bits##_t)__SWAB##bits(x); \
 }
-#define cpu_to_fdt32(x) fdt32_to_cpu(x)
+DEF_FDT_TO_CPU(16)
+DEF_FDT_TO_CPU(32)
+DEF_FDT_TO_CPU(64)
 
-static inline uint64_t fdt64_to_cpu(uint64_t x)
-{
-	return (EXTRACT_BYTE(0) << 56) | (EXTRACT_BYTE(1) << 48) | (EXTRACT_BYTE(2) << 40) | (EXTRACT_BYTE(3) << 32)
-		| (EXTRACT_BYTE(4) << 24) | (EXTRACT_BYTE(5) << 16) | (EXTRACT_BYTE(6) << 8) | EXTRACT_BYTE(7);
+#define DEF_CPU_TO_FDT(bits) \
+static inline fdt##bits##_t cpu_to_fdt##bits(uint##bits##_t x) \
+{ \
+	if (*__first_byte == 0x11) \
+		return (__force fdt##bits##_t)x; \
+	else \
+		return (__force fdt##bits##_t)__SWAB##bits(x); \
 }
-#define cpu_to_fdt64(x) fdt64_to_cpu(x)
+DEF_CPU_TO_FDT(16)
+DEF_CPU_TO_FDT(32)
+DEF_CPU_TO_FDT(64)
+
+#undef DEF_CPU_TO_FDT
+#undef DEF_FDT_TO_CPU
+#undef __SWAB64
+#undef __SWAB32
+#undef __SWAB16
 #undef EXTRACT_BYTE
 
 #endif /* _LIBFDT_ENV_H */
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [PATCH v2 4/4] dtc/libfdt: uintXX_t to fdtXX_t conversion
  2012-11-15  0:59                       ` [U-Boot] " Kim Phillips
@ 2012-11-15  0:59                         ` Kim Phillips
  -1 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-11-15  0:59 UTC (permalink / raw)
  To: jdl; +Cc: u-boot, devicetree-discuss, Kim Phillips, David Gibson

Now that fdt types are defined and annotated, use them to
make sparse happy.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: reworded commit text

 libfdt/fdt.c     |  2 +-
 libfdt/fdt_ro.c  |  2 +-
 libfdt/fdt_rw.c  |  4 ++--
 libfdt/fdt_sw.c  |  4 ++--
 libfdt/fdt_wip.c |  2 +-
 libfdt/libfdt.h  | 32 ++++++++++++++++----------------
 6 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/libfdt/fdt.c b/libfdt/fdt.c
index e56833a..57faba3 100644
--- a/libfdt/fdt.c
+++ b/libfdt/fdt.c
@@ -92,7 +92,7 @@ const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)
 
 uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
 {
-	const uint32_t *tagp, *lenp;
+	const fdt32_t *tagp, *lenp;
 	uint32_t tag;
 	int offset = startoffset;
 	const char *p;
diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index 02b6d68..42da2bd 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -322,7 +322,7 @@ const void *fdt_getprop(const void *fdt, int nodeoffset,
 
 uint32_t fdt_get_phandle(const void *fdt, int nodeoffset)
 {
-	const uint32_t *php;
+	const fdt32_t *php;
 	int len;
 
 	/* FIXME: This is a bit sub-optimal, since we potentially scan
diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c
index 24437df..fdba618 100644
--- a/libfdt/fdt_rw.c
+++ b/libfdt/fdt_rw.c
@@ -339,7 +339,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
 	int nodelen;
 	int err;
 	uint32_t tag;
-	uint32_t *endtag;
+	fdt32_t *endtag;
 
 	FDT_RW_CHECK_HEADER(fdt);
 
@@ -366,7 +366,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
 	nh->tag = cpu_to_fdt32(FDT_BEGIN_NODE);
 	memset(nh->name, 0, FDT_TAGALIGN(namelen+1));
 	memcpy(nh->name, name, namelen);
-	endtag = (uint32_t *)((char *)nh + nodelen - FDT_TAGSIZE);
+	endtag = (fdt32_t *)((char *)nh + nodelen - FDT_TAGSIZE);
 	*endtag = cpu_to_fdt32(FDT_END_NODE);
 
 	return offset;
diff --git a/libfdt/fdt_sw.c b/libfdt/fdt_sw.c
index 55ebebf..f422754 100644
--- a/libfdt/fdt_sw.c
+++ b/libfdt/fdt_sw.c
@@ -153,7 +153,7 @@ int fdt_begin_node(void *fdt, const char *name)
 
 int fdt_end_node(void *fdt)
 {
-	uint32_t *en;
+	fdt32_t *en;
 
 	FDT_SW_CHECK_HEADER(fdt);
 
@@ -213,7 +213,7 @@ int fdt_property(void *fdt, const char *name, const void *val, int len)
 int fdt_finish(void *fdt)
 {
 	char *p = (char *)fdt;
-	uint32_t *end;
+	fdt32_t *end;
 	int oldstroffset, newstroffset;
 	uint32_t tag;
 	int offset, nextoffset;
diff --git a/libfdt/fdt_wip.c b/libfdt/fdt_wip.c
index 6025fa1..c5bbb68 100644
--- a/libfdt/fdt_wip.c
+++ b/libfdt/fdt_wip.c
@@ -74,7 +74,7 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
 
 static void _fdt_nop_region(void *start, int len)
 {
-	uint32_t *p;
+	fdt32_t *p;
 
 	for (p = start; (char *)p < ((char *)start + len); p++)
 		*p = cpu_to_fdt32(FDT_NOP);
diff --git a/libfdt/libfdt.h b/libfdt/libfdt.h
index 73f4975..8e57a06 100644
--- a/libfdt/libfdt.h
+++ b/libfdt/libfdt.h
@@ -882,8 +882,8 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset,
 					  const char *name, uint32_t val)
 {
-	val = cpu_to_fdt32(val);
-	return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt32_t tmp = cpu_to_fdt32(val);
+	return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
@@ -917,8 +917,8 @@ static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset,
 static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset,
 					  const char *name, uint64_t val)
 {
-	val = cpu_to_fdt64(val);
-	return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt64_t tmp = cpu_to_fdt64(val);
+	return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
@@ -993,13 +993,13 @@ int fdt_begin_node(void *fdt, const char *name);
 int fdt_property(void *fdt, const char *name, const void *val, int len);
 static inline int fdt_property_u32(void *fdt, const char *name, uint32_t val)
 {
-	val = cpu_to_fdt32(val);
-	return fdt_property(fdt, name, &val, sizeof(val));
+	fdt32_t tmp = cpu_to_fdt32(val);
+	return fdt_property(fdt, name, &tmp, sizeof(tmp));
 }
 static inline int fdt_property_u64(void *fdt, const char *name, uint64_t val)
 {
-	val = cpu_to_fdt64(val);
-	return fdt_property(fdt, name, &val, sizeof(val));
+	fdt64_t tmp = cpu_to_fdt64(val);
+	return fdt_property(fdt, name, &tmp, sizeof(tmp));
 }
 static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val)
 {
@@ -1154,8 +1154,8 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,
 				  uint32_t val)
 {
-	val = cpu_to_fdt32(val);
-	return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt32_t tmp = cpu_to_fdt32(val);
+	return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
@@ -1189,8 +1189,8 @@ static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name,
 				  uint64_t val)
 {
-	val = cpu_to_fdt64(val);
-	return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt64_t tmp = cpu_to_fdt64(val);
+	return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
@@ -1296,8 +1296,8 @@ int fdt_appendprop(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_appendprop_u32(void *fdt, int nodeoffset,
 				     const char *name, uint32_t val)
 {
-	val = cpu_to_fdt32(val);
-	return fdt_appendprop(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt32_t tmp = cpu_to_fdt32(val);
+	return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
@@ -1331,8 +1331,8 @@ static inline int fdt_appendprop_u32(void *fdt, int nodeoffset,
 static inline int fdt_appendprop_u64(void *fdt, int nodeoffset,
 				     const char *name, uint64_t val)
 {
-	val = cpu_to_fdt64(val);
-	return fdt_appendprop(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt64_t tmp = cpu_to_fdt64(val);
+	return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 4/4] dtc/libfdt: uintXX_t to fdtXX_t conversion
@ 2012-11-15  0:59                         ` Kim Phillips
  0 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-11-15  0:59 UTC (permalink / raw)
  To: u-boot

Now that fdt types are defined and annotated, use them to
make sparse happy.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: reworded commit text

 libfdt/fdt.c     |  2 +-
 libfdt/fdt_ro.c  |  2 +-
 libfdt/fdt_rw.c  |  4 ++--
 libfdt/fdt_sw.c  |  4 ++--
 libfdt/fdt_wip.c |  2 +-
 libfdt/libfdt.h  | 32 ++++++++++++++++----------------
 6 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/libfdt/fdt.c b/libfdt/fdt.c
index e56833a..57faba3 100644
--- a/libfdt/fdt.c
+++ b/libfdt/fdt.c
@@ -92,7 +92,7 @@ const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)
 
 uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
 {
-	const uint32_t *tagp, *lenp;
+	const fdt32_t *tagp, *lenp;
 	uint32_t tag;
 	int offset = startoffset;
 	const char *p;
diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index 02b6d68..42da2bd 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -322,7 +322,7 @@ const void *fdt_getprop(const void *fdt, int nodeoffset,
 
 uint32_t fdt_get_phandle(const void *fdt, int nodeoffset)
 {
-	const uint32_t *php;
+	const fdt32_t *php;
 	int len;
 
 	/* FIXME: This is a bit sub-optimal, since we potentially scan
diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c
index 24437df..fdba618 100644
--- a/libfdt/fdt_rw.c
+++ b/libfdt/fdt_rw.c
@@ -339,7 +339,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
 	int nodelen;
 	int err;
 	uint32_t tag;
-	uint32_t *endtag;
+	fdt32_t *endtag;
 
 	FDT_RW_CHECK_HEADER(fdt);
 
@@ -366,7 +366,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
 	nh->tag = cpu_to_fdt32(FDT_BEGIN_NODE);
 	memset(nh->name, 0, FDT_TAGALIGN(namelen+1));
 	memcpy(nh->name, name, namelen);
-	endtag = (uint32_t *)((char *)nh + nodelen - FDT_TAGSIZE);
+	endtag = (fdt32_t *)((char *)nh + nodelen - FDT_TAGSIZE);
 	*endtag = cpu_to_fdt32(FDT_END_NODE);
 
 	return offset;
diff --git a/libfdt/fdt_sw.c b/libfdt/fdt_sw.c
index 55ebebf..f422754 100644
--- a/libfdt/fdt_sw.c
+++ b/libfdt/fdt_sw.c
@@ -153,7 +153,7 @@ int fdt_begin_node(void *fdt, const char *name)
 
 int fdt_end_node(void *fdt)
 {
-	uint32_t *en;
+	fdt32_t *en;
 
 	FDT_SW_CHECK_HEADER(fdt);
 
@@ -213,7 +213,7 @@ int fdt_property(void *fdt, const char *name, const void *val, int len)
 int fdt_finish(void *fdt)
 {
 	char *p = (char *)fdt;
-	uint32_t *end;
+	fdt32_t *end;
 	int oldstroffset, newstroffset;
 	uint32_t tag;
 	int offset, nextoffset;
diff --git a/libfdt/fdt_wip.c b/libfdt/fdt_wip.c
index 6025fa1..c5bbb68 100644
--- a/libfdt/fdt_wip.c
+++ b/libfdt/fdt_wip.c
@@ -74,7 +74,7 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
 
 static void _fdt_nop_region(void *start, int len)
 {
-	uint32_t *p;
+	fdt32_t *p;
 
 	for (p = start; (char *)p < ((char *)start + len); p++)
 		*p = cpu_to_fdt32(FDT_NOP);
diff --git a/libfdt/libfdt.h b/libfdt/libfdt.h
index 73f4975..8e57a06 100644
--- a/libfdt/libfdt.h
+++ b/libfdt/libfdt.h
@@ -882,8 +882,8 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset,
 					  const char *name, uint32_t val)
 {
-	val = cpu_to_fdt32(val);
-	return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt32_t tmp = cpu_to_fdt32(val);
+	return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
@@ -917,8 +917,8 @@ static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset,
 static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset,
 					  const char *name, uint64_t val)
 {
-	val = cpu_to_fdt64(val);
-	return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt64_t tmp = cpu_to_fdt64(val);
+	return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
@@ -993,13 +993,13 @@ int fdt_begin_node(void *fdt, const char *name);
 int fdt_property(void *fdt, const char *name, const void *val, int len);
 static inline int fdt_property_u32(void *fdt, const char *name, uint32_t val)
 {
-	val = cpu_to_fdt32(val);
-	return fdt_property(fdt, name, &val, sizeof(val));
+	fdt32_t tmp = cpu_to_fdt32(val);
+	return fdt_property(fdt, name, &tmp, sizeof(tmp));
 }
 static inline int fdt_property_u64(void *fdt, const char *name, uint64_t val)
 {
-	val = cpu_to_fdt64(val);
-	return fdt_property(fdt, name, &val, sizeof(val));
+	fdt64_t tmp = cpu_to_fdt64(val);
+	return fdt_property(fdt, name, &tmp, sizeof(tmp));
 }
 static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val)
 {
@@ -1154,8 +1154,8 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,
 				  uint32_t val)
 {
-	val = cpu_to_fdt32(val);
-	return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt32_t tmp = cpu_to_fdt32(val);
+	return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
@@ -1189,8 +1189,8 @@ static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name,
 				  uint64_t val)
 {
-	val = cpu_to_fdt64(val);
-	return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt64_t tmp = cpu_to_fdt64(val);
+	return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
@@ -1296,8 +1296,8 @@ int fdt_appendprop(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_appendprop_u32(void *fdt, int nodeoffset,
 				     const char *name, uint32_t val)
 {
-	val = cpu_to_fdt32(val);
-	return fdt_appendprop(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt32_t tmp = cpu_to_fdt32(val);
+	return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
@@ -1331,8 +1331,8 @@ static inline int fdt_appendprop_u32(void *fdt, int nodeoffset,
 static inline int fdt_appendprop_u64(void *fdt, int nodeoffset,
 				     const char *name, uint64_t val)
 {
-	val = cpu_to_fdt64(val);
-	return fdt_appendprop(fdt, nodeoffset, name, &val, sizeof(val));
+	fdt64_t tmp = cpu_to_fdt64(val);
+	return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* Re: [PATCH v3 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers
  2012-11-15  0:59                           ` [U-Boot] " Kim Phillips
@ 2012-11-15  4:43                               ` David Gibson
  -1 siblings, 0 replies; 133+ messages in thread
From: David Gibson @ 2012-11-15  4:43 UTC (permalink / raw)
  To: Kim Phillips
  Cc: u-boot-0aAXYlwwYIKGBzrmiIFOJg, Jerry Van Baren,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

On Wed, Nov 14, 2012 at 06:59:58PM -0600, Kim Phillips wrote:
> Projects such as linux and u-boot run sparse on libfdt.  libfdt
> contains the notion of endianness via usage of endian conversion
> functions such as fdt32_to_cpu.  As such, in order to pass endian
> checks, libfdt has to annotate its fdt variables such that sparse
> can warn when mixing bitwise and regular integers.  This patch adds
> these new fdtXX_t types and, ifdef __CHECKER__ (a symbol sparse
> defines), includes the bitwise annotation.
> 
> Signed-off-by: Kim Phillips <kim.phillips-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> ---
> v2:
> adds bitwise awareness: determine host endianness manually, and
> annotate swabs with __force in fdtXX_to_cpu and cpu_to_fdtXX
> conversion functions (the inline endian condition checks are
> optimized out at compile time).  This allows us to be able to check
> libfdt bitwise conversions with sparse by building dtc with make
> CC=cgcc. v2 also moves fdt32 definitions from fdt.h to libfdt_env.h
> and changes fdt32 definitions to use __bitwise instead of __be32. No
> separate _FDT_SPARSE was introduced because there's no need: using
> __CHECKER__ directly is valid because it only occurs once, and in
> libfdt_env.h.
> In addition, the libfdt sparse fixes have been moved to a subsequent
> patch.
> 
> v3:  address comments from jdl:
> o single set of fdt typedefs, since __bitwise is not defined if !CHECKER
> o re-work EXTRACT_BYTE to take 'x' as a parameter, not a global
> o SWAB function macros converted to take lowercase 'x' as a parameter,
>   not a global
> 
>  libfdt/fdt.h        | 42 ++++++++++++++++----------------
>  libfdt/libfdt_env.h | 69 +++++++++++++++++++++++++++++++++++++++++------------
>  2 files changed, 75 insertions(+), 36 deletions(-)
> 
> diff --git a/libfdt/fdt.h b/libfdt/fdt.h
> index 48ccfd9..45dd134 100644
> --- a/libfdt/fdt.h
> +++ b/libfdt/fdt.h
[snip]
> diff --git a/libfdt/libfdt_env.h b/libfdt/libfdt_env.h
> index 213d7fb..f0d97b9 100644
> --- a/libfdt/libfdt_env.h
> +++ b/libfdt/libfdt_env.h
> @@ -5,25 +5,64 @@
>  #include <stdint.h>
>  #include <string.h>
>  
> -#define EXTRACT_BYTE(n)	((unsigned long long)((uint8_t *)&x)[n])
> -static inline uint16_t fdt16_to_cpu(uint16_t x)
> -{
> -	return (EXTRACT_BYTE(0) << 8) | EXTRACT_BYTE(1);
> -}
> -#define cpu_to_fdt16(x) fdt16_to_cpu(x)
> +#ifdef __CHECKER__
> +#define __force __attribute__((force))
> +#define __bitwise __attribute__((bitwise))
> +#else
> +#define __force
> +#define __bitwise
> +#endif
> +
> +typedef uint16_t __bitwise fdt16_t;
> +typedef uint32_t __bitwise fdt32_t;
> +typedef uint64_t __bitwise fdt64_t;

I agree with Jon that the approach above is better than the earlier one.

> +#define EXTRACT_BYTE(x, n) ((unsigned long long)((uint8_t *)&x)[n])
> +#define __SWAB16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1))
> +#define __SWAB32(x) ((EXTRACT_BYTE(x, 0) << 24) | (EXTRACT_BYTE(x, 1) << 16) | \
> +		     (EXTRACT_BYTE(x, 2) << 8) | EXTRACT_BYTE(x, 3))
> +#define __SWAB64(x) ((EXTRACT_BYTE(x, 0) << 56) | (EXTRACT_BYTE(x, 1) << 48) | \
> +		     (EXTRACT_BYTE(x, 2) << 40) | (EXTRACT_BYTE(x, 3) << 32) | \
> +		     (EXTRACT_BYTE(x, 4) << 24) | (EXTRACT_BYTE(x, 5) << 16) | \
> +		     (EXTRACT_BYTE(x, 6) << 8) | EXTRACT_BYTE(x, 7))

This is not right, or at least very misleading.  "swab" usually refers
to an unconditional byteswap.  But the macros above are nops on a
big-endian machine.

> -static inline uint32_t fdt32_to_cpu(uint32_t x)
> -{
> -	return (EXTRACT_BYTE(0) << 24) | (EXTRACT_BYTE(1) << 16) | (EXTRACT_BYTE(2) << 8) | EXTRACT_BYTE(3);
> +/*
> + * determine host endianness:
> + * *__first_byte is 0x11 on big endian systems
> + * *__first_byte is 0x44 on little endian systems
> + */
> +static const uint32_t __native = 0x11223344u;
> +static const uint8_t *__first_byte = (const uint8_t *)&__native;
> +
> +#define DEF_FDT_TO_CPU(bits) \
> +static inline uint##bits##_t fdt##bits##_to_cpu(fdt##bits##_t x) \
> +{ \
> +	if (*__first_byte == 0x11) \
> +		return (__force uint##bits##_t)x; \
> +	else \
> +		return (__force uint##bits##_t)__SWAB##bits(x); \
>  }
> -#define cpu_to_fdt32(x) fdt32_to_cpu(x)
> +DEF_FDT_TO_CPU(16)
> +DEF_FDT_TO_CPU(32)
> +DEF_FDT_TO_CPU(64)

In fact, I really don't see why you're rewriting the byteswapper
functions as part of this patch.  The existing versions aren't very
nice, but if you want to rewrite those, please do it in a separate
patch.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v3 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers
@ 2012-11-15  4:43                               ` David Gibson
  0 siblings, 0 replies; 133+ messages in thread
From: David Gibson @ 2012-11-15  4:43 UTC (permalink / raw)
  To: u-boot

On Wed, Nov 14, 2012 at 06:59:58PM -0600, Kim Phillips wrote:
> Projects such as linux and u-boot run sparse on libfdt.  libfdt
> contains the notion of endianness via usage of endian conversion
> functions such as fdt32_to_cpu.  As such, in order to pass endian
> checks, libfdt has to annotate its fdt variables such that sparse
> can warn when mixing bitwise and regular integers.  This patch adds
> these new fdtXX_t types and, ifdef __CHECKER__ (a symbol sparse
> defines), includes the bitwise annotation.
> 
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
> ---
> v2:
> adds bitwise awareness: determine host endianness manually, and
> annotate swabs with __force in fdtXX_to_cpu and cpu_to_fdtXX
> conversion functions (the inline endian condition checks are
> optimized out at compile time).  This allows us to be able to check
> libfdt bitwise conversions with sparse by building dtc with make
> CC=cgcc. v2 also moves fdt32 definitions from fdt.h to libfdt_env.h
> and changes fdt32 definitions to use __bitwise instead of __be32. No
> separate _FDT_SPARSE was introduced because there's no need: using
> __CHECKER__ directly is valid because it only occurs once, and in
> libfdt_env.h.
> In addition, the libfdt sparse fixes have been moved to a subsequent
> patch.
> 
> v3:  address comments from jdl:
> o single set of fdt typedefs, since __bitwise is not defined if !CHECKER
> o re-work EXTRACT_BYTE to take 'x' as a parameter, not a global
> o SWAB function macros converted to take lowercase 'x' as a parameter,
>   not a global
> 
>  libfdt/fdt.h        | 42 ++++++++++++++++----------------
>  libfdt/libfdt_env.h | 69 +++++++++++++++++++++++++++++++++++++++++------------
>  2 files changed, 75 insertions(+), 36 deletions(-)
> 
> diff --git a/libfdt/fdt.h b/libfdt/fdt.h
> index 48ccfd9..45dd134 100644
> --- a/libfdt/fdt.h
> +++ b/libfdt/fdt.h
[snip]
> diff --git a/libfdt/libfdt_env.h b/libfdt/libfdt_env.h
> index 213d7fb..f0d97b9 100644
> --- a/libfdt/libfdt_env.h
> +++ b/libfdt/libfdt_env.h
> @@ -5,25 +5,64 @@
>  #include <stdint.h>
>  #include <string.h>
>  
> -#define EXTRACT_BYTE(n)	((unsigned long long)((uint8_t *)&x)[n])
> -static inline uint16_t fdt16_to_cpu(uint16_t x)
> -{
> -	return (EXTRACT_BYTE(0) << 8) | EXTRACT_BYTE(1);
> -}
> -#define cpu_to_fdt16(x) fdt16_to_cpu(x)
> +#ifdef __CHECKER__
> +#define __force __attribute__((force))
> +#define __bitwise __attribute__((bitwise))
> +#else
> +#define __force
> +#define __bitwise
> +#endif
> +
> +typedef uint16_t __bitwise fdt16_t;
> +typedef uint32_t __bitwise fdt32_t;
> +typedef uint64_t __bitwise fdt64_t;

I agree with Jon that the approach above is better than the earlier one.

> +#define EXTRACT_BYTE(x, n) ((unsigned long long)((uint8_t *)&x)[n])
> +#define __SWAB16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1))
> +#define __SWAB32(x) ((EXTRACT_BYTE(x, 0) << 24) | (EXTRACT_BYTE(x, 1) << 16) | \
> +		     (EXTRACT_BYTE(x, 2) << 8) | EXTRACT_BYTE(x, 3))
> +#define __SWAB64(x) ((EXTRACT_BYTE(x, 0) << 56) | (EXTRACT_BYTE(x, 1) << 48) | \
> +		     (EXTRACT_BYTE(x, 2) << 40) | (EXTRACT_BYTE(x, 3) << 32) | \
> +		     (EXTRACT_BYTE(x, 4) << 24) | (EXTRACT_BYTE(x, 5) << 16) | \
> +		     (EXTRACT_BYTE(x, 6) << 8) | EXTRACT_BYTE(x, 7))

This is not right, or@least very misleading.  "swab" usually refers
to an unconditional byteswap.  But the macros above are nops on a
big-endian machine.

> -static inline uint32_t fdt32_to_cpu(uint32_t x)
> -{
> -	return (EXTRACT_BYTE(0) << 24) | (EXTRACT_BYTE(1) << 16) | (EXTRACT_BYTE(2) << 8) | EXTRACT_BYTE(3);
> +/*
> + * determine host endianness:
> + * *__first_byte is 0x11 on big endian systems
> + * *__first_byte is 0x44 on little endian systems
> + */
> +static const uint32_t __native = 0x11223344u;
> +static const uint8_t *__first_byte = (const uint8_t *)&__native;
> +
> +#define DEF_FDT_TO_CPU(bits) \
> +static inline uint##bits##_t fdt##bits##_to_cpu(fdt##bits##_t x) \
> +{ \
> +	if (*__first_byte == 0x11) \
> +		return (__force uint##bits##_t)x; \
> +	else \
> +		return (__force uint##bits##_t)__SWAB##bits(x); \
>  }
> -#define cpu_to_fdt32(x) fdt32_to_cpu(x)
> +DEF_FDT_TO_CPU(16)
> +DEF_FDT_TO_CPU(32)
> +DEF_FDT_TO_CPU(64)

In fact, I really don't see why you're rewriting the byteswapper
functions as part of this patch.  The existing versions aren't very
nice, but if you want to rewrite those, please do it in a separate
patch.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [PATCH v3 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers
  2012-11-15  4:43                               ` [U-Boot] " David Gibson
@ 2012-11-15  5:12                                 ` Kim Phillips
  -1 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-11-15  5:12 UTC (permalink / raw)
  To: David Gibson; +Cc: u-boot, jdl, devicetree-discuss

On Thu, 15 Nov 2012 15:43:40 +1100
David Gibson <david@gibson.dropbear.id.au> wrote:

> On Wed, Nov 14, 2012 at 06:59:58PM -0600, Kim Phillips wrote:
> > +#define EXTRACT_BYTE(x, n) ((unsigned long long)((uint8_t *)&x)[n])
> > +#define __SWAB16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1))
> > +#define __SWAB32(x) ((EXTRACT_BYTE(x, 0) << 24) | (EXTRACT_BYTE(x, 1) << 16) | \
> > +		     (EXTRACT_BYTE(x, 2) << 8) | EXTRACT_BYTE(x, 3))
> > +#define __SWAB64(x) ((EXTRACT_BYTE(x, 0) << 56) | (EXTRACT_BYTE(x, 1) << 48) | \
> > +		     (EXTRACT_BYTE(x, 2) << 40) | (EXTRACT_BYTE(x, 3) << 32) | \
> > +		     (EXTRACT_BYTE(x, 4) << 24) | (EXTRACT_BYTE(x, 5) << 16) | \
> > +		     (EXTRACT_BYTE(x, 6) << 8) | EXTRACT_BYTE(x, 7))
> 
> This is not right, or at least very misleading.  "swab" usually refers
> to an unconditional byteswap.  But the macros above are nops on a
> big-endian machine.

but they don't get called on a big endian system.  This is the name
linux uses.  If you want them renamed, please suggest names - I
can't read your mind.

> > -static inline uint32_t fdt32_to_cpu(uint32_t x)
> > -{
> > -	return (EXTRACT_BYTE(0) << 24) | (EXTRACT_BYTE(1) << 16) | (EXTRACT_BYTE(2) << 8) | EXTRACT_BYTE(3);
> > +/*
> > + * determine host endianness:
> > + * *__first_byte is 0x11 on big endian systems
> > + * *__first_byte is 0x44 on little endian systems
> > + */
> > +static const uint32_t __native = 0x11223344u;
> > +static const uint8_t *__first_byte = (const uint8_t *)&__native;
> > +
> > +#define DEF_FDT_TO_CPU(bits) \
> > +static inline uint##bits##_t fdt##bits##_to_cpu(fdt##bits##_t x) \
> > +{ \
> > +	if (*__first_byte == 0x11) \
> > +		return (__force uint##bits##_t)x; \
> > +	else \
> > +		return (__force uint##bits##_t)__SWAB##bits(x); \
> >  }
> > -#define cpu_to_fdt32(x) fdt32_to_cpu(x)
> > +DEF_FDT_TO_CPU(16)
> > +DEF_FDT_TO_CPU(32)
> > +DEF_FDT_TO_CPU(64)
> 
> In fact, I really don't see why you're rewriting the byteswapper
> functions as part of this patch.  The existing versions aren't very
> nice, but if you want to rewrite those, please do it in a separate
> patch.

This patchseries is about silencing sparse warnings in linux,
u-boot, and libfdt.  Sparse is intelligent in that if you mismatch a
native type of value 0 to a bitwise restricted type, it won't call a
warning.  The existing short-circuiting of the byteswapper
functions, i.e., defining cpu_to_fdt32(x) to fdt32_to_cpu(x) and
vice versa doesn't allow for correct attribution propagation.
Therefore I chose to allow sparse to see the actual conversion.  If
you have any other ideas on how to silence sparse in libfdt, let me
know.

Kim

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v3 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers
@ 2012-11-15  5:12                                 ` Kim Phillips
  0 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-11-15  5:12 UTC (permalink / raw)
  To: u-boot

On Thu, 15 Nov 2012 15:43:40 +1100
David Gibson <david@gibson.dropbear.id.au> wrote:

> On Wed, Nov 14, 2012 at 06:59:58PM -0600, Kim Phillips wrote:
> > +#define EXTRACT_BYTE(x, n) ((unsigned long long)((uint8_t *)&x)[n])
> > +#define __SWAB16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1))
> > +#define __SWAB32(x) ((EXTRACT_BYTE(x, 0) << 24) | (EXTRACT_BYTE(x, 1) << 16) | \
> > +		     (EXTRACT_BYTE(x, 2) << 8) | EXTRACT_BYTE(x, 3))
> > +#define __SWAB64(x) ((EXTRACT_BYTE(x, 0) << 56) | (EXTRACT_BYTE(x, 1) << 48) | \
> > +		     (EXTRACT_BYTE(x, 2) << 40) | (EXTRACT_BYTE(x, 3) << 32) | \
> > +		     (EXTRACT_BYTE(x, 4) << 24) | (EXTRACT_BYTE(x, 5) << 16) | \
> > +		     (EXTRACT_BYTE(x, 6) << 8) | EXTRACT_BYTE(x, 7))
> 
> This is not right, or at least very misleading.  "swab" usually refers
> to an unconditional byteswap.  But the macros above are nops on a
> big-endian machine.

but they don't get called on a big endian system.  This is the name
linux uses.  If you want them renamed, please suggest names - I
can't read your mind.

> > -static inline uint32_t fdt32_to_cpu(uint32_t x)
> > -{
> > -	return (EXTRACT_BYTE(0) << 24) | (EXTRACT_BYTE(1) << 16) | (EXTRACT_BYTE(2) << 8) | EXTRACT_BYTE(3);
> > +/*
> > + * determine host endianness:
> > + * *__first_byte is 0x11 on big endian systems
> > + * *__first_byte is 0x44 on little endian systems
> > + */
> > +static const uint32_t __native = 0x11223344u;
> > +static const uint8_t *__first_byte = (const uint8_t *)&__native;
> > +
> > +#define DEF_FDT_TO_CPU(bits) \
> > +static inline uint##bits##_t fdt##bits##_to_cpu(fdt##bits##_t x) \
> > +{ \
> > +	if (*__first_byte == 0x11) \
> > +		return (__force uint##bits##_t)x; \
> > +	else \
> > +		return (__force uint##bits##_t)__SWAB##bits(x); \
> >  }
> > -#define cpu_to_fdt32(x) fdt32_to_cpu(x)
> > +DEF_FDT_TO_CPU(16)
> > +DEF_FDT_TO_CPU(32)
> > +DEF_FDT_TO_CPU(64)
> 
> In fact, I really don't see why you're rewriting the byteswapper
> functions as part of this patch.  The existing versions aren't very
> nice, but if you want to rewrite those, please do it in a separate
> patch.

This patchseries is about silencing sparse warnings in linux,
u-boot, and libfdt.  Sparse is intelligent in that if you mismatch a
native type of value 0 to a bitwise restricted type, it won't call a
warning.  The existing short-circuiting of the byteswapper
functions, i.e., defining cpu_to_fdt32(x) to fdt32_to_cpu(x) and
vice versa doesn't allow for correct attribution propagation.
Therefore I chose to allow sparse to see the actual conversion.  If
you have any other ideas on how to silence sparse in libfdt, let me
know.

Kim

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [PATCH v3 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers
  2012-11-15  5:12                                 ` [U-Boot] " Kim Phillips
@ 2012-11-19  2:30                                     ` David Gibson
  -1 siblings, 0 replies; 133+ messages in thread
From: David Gibson @ 2012-11-19  2:30 UTC (permalink / raw)
  To: Kim Phillips
  Cc: u-boot-0aAXYlwwYIKGBzrmiIFOJg, Jerry Van Baren,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

On Wed, Nov 14, 2012 at 11:12:04PM -0600, Kim Phillips wrote:
> On Thu, 15 Nov 2012 15:43:40 +1100
> David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org> wrote:
> 
> > On Wed, Nov 14, 2012 at 06:59:58PM -0600, Kim Phillips wrote:
> > > +#define EXTRACT_BYTE(x, n) ((unsigned long long)((uint8_t *)&x)[n])
> > > +#define __SWAB16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1))
> > > +#define __SWAB32(x) ((EXTRACT_BYTE(x, 0) << 24) | (EXTRACT_BYTE(x, 1) << 16) | \
> > > +		     (EXTRACT_BYTE(x, 2) << 8) | EXTRACT_BYTE(x, 3))
> > > +#define __SWAB64(x) ((EXTRACT_BYTE(x, 0) << 56) | (EXTRACT_BYTE(x, 1) << 48) | \
> > > +		     (EXTRACT_BYTE(x, 2) << 40) | (EXTRACT_BYTE(x, 3) << 32) | \
> > > +		     (EXTRACT_BYTE(x, 4) << 24) | (EXTRACT_BYTE(x, 5) << 16) | \
> > > +		     (EXTRACT_BYTE(x, 6) << 8) | EXTRACT_BYTE(x, 7))
> > 
> > This is not right, or at least very misleading.  "swab" usually refers
> > to an unconditional byteswap.  But the macros above are nops on a
> > big-endian machine.
> 
> but they don't get called on a big endian system.

Yes, which means the nop-on-bigendian is double-implemented which is
also ugly.

> This is the name
> linux uses.

I'm not sure exactly which *swab* functions in Linux you're referring
to, but I'm pretty sure most of those are unconditional swaps.

>  If you want them renamed, please suggest names - I
> can't read your mind.

Well, FDT_TO_CPU would do.

> > > -static inline uint32_t fdt32_to_cpu(uint32_t x)
> > > -{
> > > -	return (EXTRACT_BYTE(0) << 24) | (EXTRACT_BYTE(1) << 16) | (EXTRACT_BYTE(2) << 8) | EXTRACT_BYTE(3);
> > > +/*
> > > + * determine host endianness:
> > > + * *__first_byte is 0x11 on big endian systems
> > > + * *__first_byte is 0x44 on little endian systems
> > > + */
> > > +static const uint32_t __native = 0x11223344u;
> > > +static const uint8_t *__first_byte = (const uint8_t *)&__native;
> > > +
> > > +#define DEF_FDT_TO_CPU(bits) \
> > > +static inline uint##bits##_t fdt##bits##_to_cpu(fdt##bits##_t x) \
> > > +{ \
> > > +	if (*__first_byte == 0x11) \
> > > +		return (__force uint##bits##_t)x; \
> > > +	else \
> > > +		return (__force uint##bits##_t)__SWAB##bits(x); \
> > >  }
> > > -#define cpu_to_fdt32(x) fdt32_to_cpu(x)
> > > +DEF_FDT_TO_CPU(16)
> > > +DEF_FDT_TO_CPU(32)
> > > +DEF_FDT_TO_CPU(64)
> > 
> > In fact, I really don't see why you're rewriting the byteswapper
> > functions as part of this patch.  The existing versions aren't very
> > nice, but if you want to rewrite those, please do it in a separate
> > patch.
> 
> This patchseries is about silencing sparse warnings in linux,
> u-boot, and libfdt.  Sparse is intelligent in that if you mismatch a
> native type of value 0 to a bitwise restricted type, it won't call a
> warning.  The existing short-circuiting of the byteswapper
> functions, i.e., defining cpu_to_fdt32(x) to fdt32_to_cpu(x) and
> vice versa doesn't allow for correct attribution propagation.

Ah, right, yes that will have to go.  You've also added the explicit
endianness test, though, which is a redundant change.

> Therefore I chose to allow sparse to see the actual conversion.  If
> you have any other ideas on how to silence sparse in libfdt, let me
> know.

Hrm.  So you could either rename the macros, or just duplicate the
code in the to versions of the functions.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v3 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers
@ 2012-11-19  2:30                                     ` David Gibson
  0 siblings, 0 replies; 133+ messages in thread
From: David Gibson @ 2012-11-19  2:30 UTC (permalink / raw)
  To: u-boot

On Wed, Nov 14, 2012 at 11:12:04PM -0600, Kim Phillips wrote:
> On Thu, 15 Nov 2012 15:43:40 +1100
> David Gibson <david@gibson.dropbear.id.au> wrote:
> 
> > On Wed, Nov 14, 2012 at 06:59:58PM -0600, Kim Phillips wrote:
> > > +#define EXTRACT_BYTE(x, n) ((unsigned long long)((uint8_t *)&x)[n])
> > > +#define __SWAB16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1))
> > > +#define __SWAB32(x) ((EXTRACT_BYTE(x, 0) << 24) | (EXTRACT_BYTE(x, 1) << 16) | \
> > > +		     (EXTRACT_BYTE(x, 2) << 8) | EXTRACT_BYTE(x, 3))
> > > +#define __SWAB64(x) ((EXTRACT_BYTE(x, 0) << 56) | (EXTRACT_BYTE(x, 1) << 48) | \
> > > +		     (EXTRACT_BYTE(x, 2) << 40) | (EXTRACT_BYTE(x, 3) << 32) | \
> > > +		     (EXTRACT_BYTE(x, 4) << 24) | (EXTRACT_BYTE(x, 5) << 16) | \
> > > +		     (EXTRACT_BYTE(x, 6) << 8) | EXTRACT_BYTE(x, 7))
> > 
> > This is not right, or at least very misleading.  "swab" usually refers
> > to an unconditional byteswap.  But the macros above are nops on a
> > big-endian machine.
> 
> but they don't get called on a big endian system.

Yes, which means the nop-on-bigendian is double-implemented which is
also ugly.

> This is the name
> linux uses.

I'm not sure exactly which *swab* functions in Linux you're referring
to, but I'm pretty sure most of those are unconditional swaps.

>  If you want them renamed, please suggest names - I
> can't read your mind.

Well, FDT_TO_CPU would do.

> > > -static inline uint32_t fdt32_to_cpu(uint32_t x)
> > > -{
> > > -	return (EXTRACT_BYTE(0) << 24) | (EXTRACT_BYTE(1) << 16) | (EXTRACT_BYTE(2) << 8) | EXTRACT_BYTE(3);
> > > +/*
> > > + * determine host endianness:
> > > + * *__first_byte is 0x11 on big endian systems
> > > + * *__first_byte is 0x44 on little endian systems
> > > + */
> > > +static const uint32_t __native = 0x11223344u;
> > > +static const uint8_t *__first_byte = (const uint8_t *)&__native;
> > > +
> > > +#define DEF_FDT_TO_CPU(bits) \
> > > +static inline uint##bits##_t fdt##bits##_to_cpu(fdt##bits##_t x) \
> > > +{ \
> > > +	if (*__first_byte == 0x11) \
> > > +		return (__force uint##bits##_t)x; \
> > > +	else \
> > > +		return (__force uint##bits##_t)__SWAB##bits(x); \
> > >  }
> > > -#define cpu_to_fdt32(x) fdt32_to_cpu(x)
> > > +DEF_FDT_TO_CPU(16)
> > > +DEF_FDT_TO_CPU(32)
> > > +DEF_FDT_TO_CPU(64)
> > 
> > In fact, I really don't see why you're rewriting the byteswapper
> > functions as part of this patch.  The existing versions aren't very
> > nice, but if you want to rewrite those, please do it in a separate
> > patch.
> 
> This patchseries is about silencing sparse warnings in linux,
> u-boot, and libfdt.  Sparse is intelligent in that if you mismatch a
> native type of value 0 to a bitwise restricted type, it won't call a
> warning.  The existing short-circuiting of the byteswapper
> functions, i.e., defining cpu_to_fdt32(x) to fdt32_to_cpu(x) and
> vice versa doesn't allow for correct attribution propagation.

Ah, right, yes that will have to go.  You've also added the explicit
endianness test, though, which is a redundant change.

> Therefore I chose to allow sparse to see the actual conversion.  If
> you have any other ideas on how to silence sparse in libfdt, let me
> know.

Hrm.  So you could either rename the macros, or just duplicate the
code in the to versions of the functions.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v2 13/25] lib/zlib: sparse fixes
  2012-11-09  1:06       ` Kim Phillips
@ 2012-11-21 16:37         ` Tom Rini
  0 siblings, 0 replies; 133+ messages in thread
From: Tom Rini @ 2012-11-21 16:37 UTC (permalink / raw)
  To: u-boot

On Thu, Nov 08, 2012 at 07:06:31PM -0600, Kim Phillips wrote:
> On Thu, 8 Nov 2012 12:20:51 +0100
> Wolfgang Denk <wd@denx.de> wrote:
> 
> > In message <1351553687-12469-14-git-send-email-kim.phillips@freescale.com> you wrote:
> > > define Z_NULL to (void *)0 include/u-boot/zlib.h to get rid of most of
> > > the NULL pointer warnings.
> > ...
> > > -#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
> > > +#define Z_NULL  (void *)0  /* for initializing zalloc, zfree, opaque */
> > 
> > Don't we have to put parens around such an expression?
> 
> I suppose.
> 
> > > --- a/lib/zlib/adler32.c
> > > +++ b/lib/zlib/adler32.c
> > > @@ -54,10 +54,7 @@
> > >  #endif
> > >  
> > >  /* ========================================================================= */
> > > -uLong ZEXPORT adler32(adler, buf, len)
> > > -    uLong adler;
> > > -    const Bytef *buf;
> > > -    uInt len;
> > > +uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
> > 
> > Hm... this code has been imported from another project.  This
> > modification makes updates (or even comparing what has changed in more
> > recent versions) much mor difficult, or even impossible
> > :-(
> 
> my goal is to improve u-boot code quality by eliminating as much
> sparse noise as possible - most boards use this code to decompress
> kernels, so it's widely used.  E.g., this patch removes 52 lines of
> sparse output.  But ok, we can revert this patch and turn off
> checking for these files, in the form of an #ifndef __CHECKER__ at
> the top, with an 'imported from another project' justification
> comment.  Would that be better?

My memory could be faulty here, but can't we rely on the kernel here?
That'll give us sparse-clean zlib, or hints on how they're keeping it in
sync.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121121/bfd7e4e8/attachment.pgp>

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [PATCH v4 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers
  2012-11-19  2:30                                     ` [U-Boot] " David Gibson
@ 2012-11-28 23:33                                       ` Kim Phillips
  -1 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-11-28 23:33 UTC (permalink / raw)
  To: David Gibson; +Cc: u-boot, jdl, devicetree-discuss

Projects such as linux and u-boot run sparse on libfdt.  libfdt
contains the notion of endianness via usage of endian conversion
functions such as fdt32_to_cpu.  As such, in order to pass endian
checks, libfdt has to annotate its fdt variables such that sparse
can warn when mixing bitwise and regular integers.  This patch adds
these new fdtXX_t types and, ifdef __CHECKER__ (a symbol sparse
defines), includes the bitwise annotation.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>

---
v2:
adds bitwise awareness: determine host endianness manually, and
annotate swabs with __force in fdtXX_to_cpu and cpu_to_fdtXX
conversion functions (the inline endian condition checks are
optimized out at compile time).  This allows us to be able to check
libfdt bitwise conversions with sparse by building dtc with make
CC=cgcc. v2 also moves fdt32 definitions from fdt.h to libfdt_env.h
and changes fdt32 definitions to use __bitwise instead of __be32. No
separate _FDT_SPARSE was introduced because there's no need: using
__CHECKER__ directly is valid because it only occurs once, and in
libfdt_env.h.
In addition, the libfdt sparse fixes have been moved to a subsequent
patch.

v3:  address comments from jdl:
o single set of fdt typedefs, since __bitwise is not defined if !CHECKER
o re-work EXTRACT_BYTE to take 'x' as a parameter, not a global
o SWAB function macros converted to take lowercase 'x' as a parameter,
  not a global

v4:  address comments from David Gibson
o rename byte swap routines CPU_TO_FDTXX
o properly define fdt<->cpu conversion routines
  to use CPU_TO_FDTXX macros with correct checker attributions.

 libfdt/fdt.h        | 42 +++++++++++++++++++++---------------------
 libfdt/libfdt_env.h | 53 ++++++++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 63 insertions(+), 32 deletions(-)

diff --git a/libfdt/fdt.h b/libfdt/fdt.h
index 48ccfd9..45dd134 100644
--- a/libfdt/fdt.h
+++ b/libfdt/fdt.h
@@ -4,45 +4,45 @@
 #ifndef __ASSEMBLY__
 
 struct fdt_header {
-	uint32_t magic;			 /* magic word FDT_MAGIC */
-	uint32_t totalsize;		 /* total size of DT block */
-	uint32_t off_dt_struct;		 /* offset to structure */
-	uint32_t off_dt_strings;	 /* offset to strings */
-	uint32_t off_mem_rsvmap;	 /* offset to memory reserve map */
-	uint32_t version;		 /* format version */
-	uint32_t last_comp_version;	 /* last compatible version */
+	fdt32_t magic;			 /* magic word FDT_MAGIC */
+	fdt32_t totalsize;		 /* total size of DT block */
+	fdt32_t off_dt_struct;		 /* offset to structure */
+	fdt32_t off_dt_strings;		 /* offset to strings */
+	fdt32_t off_mem_rsvmap;		 /* offset to memory reserve map */
+	fdt32_t version;		 /* format version */
+	fdt32_t last_comp_version;	 /* last compatible version */
 
 	/* version 2 fields below */
-	uint32_t boot_cpuid_phys;	 /* Which physical CPU id we're
+	fdt32_t boot_cpuid_phys;	 /* Which physical CPU id we're
 					    booting on */
 	/* version 3 fields below */
-	uint32_t size_dt_strings;	 /* size of the strings block */
+	fdt32_t size_dt_strings;	 /* size of the strings block */
 
 	/* version 17 fields below */
-	uint32_t size_dt_struct;	 /* size of the structure block */
+	fdt32_t size_dt_struct;		 /* size of the structure block */
 };
 
 struct fdt_reserve_entry {
-	uint64_t address;
-	uint64_t size;
+	fdt64_t address;
+	fdt64_t size;
 };
 
 struct fdt_node_header {
-	uint32_t tag;
+	fdt32_t tag;
 	char name[0];
 };
 
 struct fdt_property {
-	uint32_t tag;
-	uint32_t len;
-	uint32_t nameoff;
+	fdt32_t tag;
+	fdt32_t len;
+	fdt32_t nameoff;
 	char data[0];
 };
 
 #endif /* !__ASSEMBLY */
 
 #define FDT_MAGIC	0xd00dfeed	/* 4: version, 4: total size */
-#define FDT_TAGSIZE	sizeof(uint32_t)
+#define FDT_TAGSIZE	sizeof(fdt32_t)
 
 #define FDT_BEGIN_NODE	0x1		/* Start node: full name */
 #define FDT_END_NODE	0x2		/* End node */
@@ -51,10 +51,10 @@ struct fdt_property {
 #define FDT_NOP		0x4		/* nop */
 #define FDT_END		0x9
 
-#define FDT_V1_SIZE	(7*sizeof(uint32_t))
-#define FDT_V2_SIZE	(FDT_V1_SIZE + sizeof(uint32_t))
-#define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(uint32_t))
+#define FDT_V1_SIZE	(7*sizeof(fdt32_t))
+#define FDT_V2_SIZE	(FDT_V1_SIZE + sizeof(fdt32_t))
+#define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(fdt32_t))
 #define FDT_V16_SIZE	FDT_V3_SIZE
-#define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(uint32_t))
+#define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(fdt32_t))
 
 #endif /* _FDT_H */
diff --git a/libfdt/libfdt_env.h b/libfdt/libfdt_env.h
index 213d7fb..956b4ae 100644
--- a/libfdt/libfdt_env.h
+++ b/libfdt/libfdt_env.h
@@ -5,25 +5,56 @@
 #include <stdint.h>
 #include <string.h>
 
-#define EXTRACT_BYTE(n)	((unsigned long long)((uint8_t *)&x)[n])
-static inline uint16_t fdt16_to_cpu(uint16_t x)
+#ifdef __CHECKER__
+#define __force __attribute__((force))
+#define __bitwise __attribute__((bitwise))
+#else
+#define __force
+#define __bitwise
+#endif
+
+typedef uint16_t __bitwise fdt16_t;
+typedef uint32_t __bitwise fdt32_t;
+typedef uint64_t __bitwise fdt64_t;
+
+#define EXTRACT_BYTE(x, n)	((unsigned long long)((uint8_t *)&x)[n])
+#define CPU_TO_FDT16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1))
+#define CPU_TO_FDT32(x) ((EXTRACT_BYTE(x, 0) << 24) | (EXTRACT_BYTE(x, 1) << 16) | \
+			 (EXTRACT_BYTE(x, 2) << 8) | EXTRACT_BYTE(x, 3))
+#define CPU_TO_FDT64(x) ((EXTRACT_BYTE(x, 0) << 56) | (EXTRACT_BYTE(x, 1) << 48) | \
+			 (EXTRACT_BYTE(x, 2) << 40) | (EXTRACT_BYTE(x, 3) << 32) | \
+			 (EXTRACT_BYTE(x, 4) << 24) | (EXTRACT_BYTE(x, 5) << 16) | \
+			 (EXTRACT_BYTE(x, 6) << 8) | EXTRACT_BYTE(x, 7))
+
+static inline uint16_t fdt16_to_cpu(fdt16_t x)
+{
+	return (__force uint16_t)CPU_TO_FDT16(x);
+}
+static inline fdt16_t cpu_to_fdt16(uint16_t x)
 {
-	return (EXTRACT_BYTE(0) << 8) | EXTRACT_BYTE(1);
+	return (__force fdt16_t)CPU_TO_FDT16(x);
 }
-#define cpu_to_fdt16(x) fdt16_to_cpu(x)
 
-static inline uint32_t fdt32_to_cpu(uint32_t x)
+static inline uint32_t fdt32_to_cpu(fdt32_t x)
 {
-	return (EXTRACT_BYTE(0) << 24) | (EXTRACT_BYTE(1) << 16) | (EXTRACT_BYTE(2) << 8) | EXTRACT_BYTE(3);
+	return (__force uint32_t)CPU_TO_FDT32(x);
+}
+static inline fdt32_t cpu_to_fdt32(uint32_t x)
+{
+	return (__force fdt32_t)CPU_TO_FDT32(x);
 }
-#define cpu_to_fdt32(x) fdt32_to_cpu(x)
 
-static inline uint64_t fdt64_to_cpu(uint64_t x)
+static inline uint64_t fdt64_to_cpu(fdt64_t x)
+{
+	return (__force uint64_t)CPU_TO_FDT64(x);
+}
+static inline fdt64_t cpu_to_fdt64(uint64_t x)
 {
-	return (EXTRACT_BYTE(0) << 56) | (EXTRACT_BYTE(1) << 48) | (EXTRACT_BYTE(2) << 40) | (EXTRACT_BYTE(3) << 32)
-		| (EXTRACT_BYTE(4) << 24) | (EXTRACT_BYTE(5) << 16) | (EXTRACT_BYTE(6) << 8) | EXTRACT_BYTE(7);
+	return (__force fdt64_t)CPU_TO_FDT64(x);
 }
-#define cpu_to_fdt64(x) fdt64_to_cpu(x)
+#undef CPU_TO_FDT64
+#undef CPU_TO_FDT32
+#undef CPU_TO_FDT16
 #undef EXTRACT_BYTE
 
 #endif /* _LIBFDT_ENV_H */
-- 
1.8.0.1

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v4 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers
@ 2012-11-28 23:33                                       ` Kim Phillips
  0 siblings, 0 replies; 133+ messages in thread
From: Kim Phillips @ 2012-11-28 23:33 UTC (permalink / raw)
  To: u-boot

Projects such as linux and u-boot run sparse on libfdt.  libfdt
contains the notion of endianness via usage of endian conversion
functions such as fdt32_to_cpu.  As such, in order to pass endian
checks, libfdt has to annotate its fdt variables such that sparse
can warn when mixing bitwise and regular integers.  This patch adds
these new fdtXX_t types and, ifdef __CHECKER__ (a symbol sparse
defines), includes the bitwise annotation.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>

---
v2:
adds bitwise awareness: determine host endianness manually, and
annotate swabs with __force in fdtXX_to_cpu and cpu_to_fdtXX
conversion functions (the inline endian condition checks are
optimized out at compile time).  This allows us to be able to check
libfdt bitwise conversions with sparse by building dtc with make
CC=cgcc. v2 also moves fdt32 definitions from fdt.h to libfdt_env.h
and changes fdt32 definitions to use __bitwise instead of __be32. No
separate _FDT_SPARSE was introduced because there's no need: using
__CHECKER__ directly is valid because it only occurs once, and in
libfdt_env.h.
In addition, the libfdt sparse fixes have been moved to a subsequent
patch.

v3:  address comments from jdl:
o single set of fdt typedefs, since __bitwise is not defined if !CHECKER
o re-work EXTRACT_BYTE to take 'x' as a parameter, not a global
o SWAB function macros converted to take lowercase 'x' as a parameter,
  not a global

v4:  address comments from David Gibson
o rename byte swap routines CPU_TO_FDTXX
o properly define fdt<->cpu conversion routines
  to use CPU_TO_FDTXX macros with correct checker attributions.

 libfdt/fdt.h        | 42 +++++++++++++++++++++---------------------
 libfdt/libfdt_env.h | 53 ++++++++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 63 insertions(+), 32 deletions(-)

diff --git a/libfdt/fdt.h b/libfdt/fdt.h
index 48ccfd9..45dd134 100644
--- a/libfdt/fdt.h
+++ b/libfdt/fdt.h
@@ -4,45 +4,45 @@
 #ifndef __ASSEMBLY__
 
 struct fdt_header {
-	uint32_t magic;			 /* magic word FDT_MAGIC */
-	uint32_t totalsize;		 /* total size of DT block */
-	uint32_t off_dt_struct;		 /* offset to structure */
-	uint32_t off_dt_strings;	 /* offset to strings */
-	uint32_t off_mem_rsvmap;	 /* offset to memory reserve map */
-	uint32_t version;		 /* format version */
-	uint32_t last_comp_version;	 /* last compatible version */
+	fdt32_t magic;			 /* magic word FDT_MAGIC */
+	fdt32_t totalsize;		 /* total size of DT block */
+	fdt32_t off_dt_struct;		 /* offset to structure */
+	fdt32_t off_dt_strings;		 /* offset to strings */
+	fdt32_t off_mem_rsvmap;		 /* offset to memory reserve map */
+	fdt32_t version;		 /* format version */
+	fdt32_t last_comp_version;	 /* last compatible version */
 
 	/* version 2 fields below */
-	uint32_t boot_cpuid_phys;	 /* Which physical CPU id we're
+	fdt32_t boot_cpuid_phys;	 /* Which physical CPU id we're
 					    booting on */
 	/* version 3 fields below */
-	uint32_t size_dt_strings;	 /* size of the strings block */
+	fdt32_t size_dt_strings;	 /* size of the strings block */
 
 	/* version 17 fields below */
-	uint32_t size_dt_struct;	 /* size of the structure block */
+	fdt32_t size_dt_struct;		 /* size of the structure block */
 };
 
 struct fdt_reserve_entry {
-	uint64_t address;
-	uint64_t size;
+	fdt64_t address;
+	fdt64_t size;
 };
 
 struct fdt_node_header {
-	uint32_t tag;
+	fdt32_t tag;
 	char name[0];
 };
 
 struct fdt_property {
-	uint32_t tag;
-	uint32_t len;
-	uint32_t nameoff;
+	fdt32_t tag;
+	fdt32_t len;
+	fdt32_t nameoff;
 	char data[0];
 };
 
 #endif /* !__ASSEMBLY */
 
 #define FDT_MAGIC	0xd00dfeed	/* 4: version, 4: total size */
-#define FDT_TAGSIZE	sizeof(uint32_t)
+#define FDT_TAGSIZE	sizeof(fdt32_t)
 
 #define FDT_BEGIN_NODE	0x1		/* Start node: full name */
 #define FDT_END_NODE	0x2		/* End node */
@@ -51,10 +51,10 @@ struct fdt_property {
 #define FDT_NOP		0x4		/* nop */
 #define FDT_END		0x9
 
-#define FDT_V1_SIZE	(7*sizeof(uint32_t))
-#define FDT_V2_SIZE	(FDT_V1_SIZE + sizeof(uint32_t))
-#define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(uint32_t))
+#define FDT_V1_SIZE	(7*sizeof(fdt32_t))
+#define FDT_V2_SIZE	(FDT_V1_SIZE + sizeof(fdt32_t))
+#define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(fdt32_t))
 #define FDT_V16_SIZE	FDT_V3_SIZE
-#define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(uint32_t))
+#define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(fdt32_t))
 
 #endif /* _FDT_H */
diff --git a/libfdt/libfdt_env.h b/libfdt/libfdt_env.h
index 213d7fb..956b4ae 100644
--- a/libfdt/libfdt_env.h
+++ b/libfdt/libfdt_env.h
@@ -5,25 +5,56 @@
 #include <stdint.h>
 #include <string.h>
 
-#define EXTRACT_BYTE(n)	((unsigned long long)((uint8_t *)&x)[n])
-static inline uint16_t fdt16_to_cpu(uint16_t x)
+#ifdef __CHECKER__
+#define __force __attribute__((force))
+#define __bitwise __attribute__((bitwise))
+#else
+#define __force
+#define __bitwise
+#endif
+
+typedef uint16_t __bitwise fdt16_t;
+typedef uint32_t __bitwise fdt32_t;
+typedef uint64_t __bitwise fdt64_t;
+
+#define EXTRACT_BYTE(x, n)	((unsigned long long)((uint8_t *)&x)[n])
+#define CPU_TO_FDT16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1))
+#define CPU_TO_FDT32(x) ((EXTRACT_BYTE(x, 0) << 24) | (EXTRACT_BYTE(x, 1) << 16) | \
+			 (EXTRACT_BYTE(x, 2) << 8) | EXTRACT_BYTE(x, 3))
+#define CPU_TO_FDT64(x) ((EXTRACT_BYTE(x, 0) << 56) | (EXTRACT_BYTE(x, 1) << 48) | \
+			 (EXTRACT_BYTE(x, 2) << 40) | (EXTRACT_BYTE(x, 3) << 32) | \
+			 (EXTRACT_BYTE(x, 4) << 24) | (EXTRACT_BYTE(x, 5) << 16) | \
+			 (EXTRACT_BYTE(x, 6) << 8) | EXTRACT_BYTE(x, 7))
+
+static inline uint16_t fdt16_to_cpu(fdt16_t x)
+{
+	return (__force uint16_t)CPU_TO_FDT16(x);
+}
+static inline fdt16_t cpu_to_fdt16(uint16_t x)
 {
-	return (EXTRACT_BYTE(0) << 8) | EXTRACT_BYTE(1);
+	return (__force fdt16_t)CPU_TO_FDT16(x);
 }
-#define cpu_to_fdt16(x) fdt16_to_cpu(x)
 
-static inline uint32_t fdt32_to_cpu(uint32_t x)
+static inline uint32_t fdt32_to_cpu(fdt32_t x)
 {
-	return (EXTRACT_BYTE(0) << 24) | (EXTRACT_BYTE(1) << 16) | (EXTRACT_BYTE(2) << 8) | EXTRACT_BYTE(3);
+	return (__force uint32_t)CPU_TO_FDT32(x);
+}
+static inline fdt32_t cpu_to_fdt32(uint32_t x)
+{
+	return (__force fdt32_t)CPU_TO_FDT32(x);
 }
-#define cpu_to_fdt32(x) fdt32_to_cpu(x)
 
-static inline uint64_t fdt64_to_cpu(uint64_t x)
+static inline uint64_t fdt64_to_cpu(fdt64_t x)
+{
+	return (__force uint64_t)CPU_TO_FDT64(x);
+}
+static inline fdt64_t cpu_to_fdt64(uint64_t x)
 {
-	return (EXTRACT_BYTE(0) << 56) | (EXTRACT_BYTE(1) << 48) | (EXTRACT_BYTE(2) << 40) | (EXTRACT_BYTE(3) << 32)
-		| (EXTRACT_BYTE(4) << 24) | (EXTRACT_BYTE(5) << 16) | (EXTRACT_BYTE(6) << 8) | EXTRACT_BYTE(7);
+	return (__force fdt64_t)CPU_TO_FDT64(x);
 }
-#define cpu_to_fdt64(x) fdt64_to_cpu(x)
+#undef CPU_TO_FDT64
+#undef CPU_TO_FDT32
+#undef CPU_TO_FDT16
 #undef EXTRACT_BYTE
 
 #endif /* _LIBFDT_ENV_H */
-- 
1.8.0.1

^ permalink raw reply related	[flat|nested] 133+ messages in thread

* Re: [PATCH v4 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers
  2012-11-28 23:33                                       ` [U-Boot] " Kim Phillips
@ 2012-12-03  4:05                                         ` David Gibson
  -1 siblings, 0 replies; 133+ messages in thread
From: David Gibson @ 2012-12-03  4:05 UTC (permalink / raw)
  To: Kim Phillips; +Cc: u-boot, jdl, devicetree-discuss

On Wed, Nov 28, 2012 at 05:33:01PM -0600, Kim Phillips wrote:
> Projects such as linux and u-boot run sparse on libfdt.  libfdt
> contains the notion of endianness via usage of endian conversion
> functions such as fdt32_to_cpu.  As such, in order to pass endian
> checks, libfdt has to annotate its fdt variables such that sparse
> can warn when mixing bitwise and regular integers.  This patch adds
> these new fdtXX_t types and, ifdef __CHECKER__ (a symbol sparse
> defines), includes the bitwise annotation.
> 
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>

Much better, thanks

Acked-by: David Gibson <david@gibson.dropbear.id.au>

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v4 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers
@ 2012-12-03  4:05                                         ` David Gibson
  0 siblings, 0 replies; 133+ messages in thread
From: David Gibson @ 2012-12-03  4:05 UTC (permalink / raw)
  To: u-boot

On Wed, Nov 28, 2012 at 05:33:01PM -0600, Kim Phillips wrote:
> Projects such as linux and u-boot run sparse on libfdt.  libfdt
> contains the notion of endianness via usage of endian conversion
> functions such as fdt32_to_cpu.  As such, in order to pass endian
> checks, libfdt has to annotate its fdt variables such that sparse
> can warn when mixing bitwise and regular integers.  This patch adds
> these new fdtXX_t types and, ifdef __CHECKER__ (a symbol sparse
> defines), includes the bitwise annotation.
> 
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>

Much better, thanks

Acked-by: David Gibson <david@gibson.dropbear.id.au>

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH] common/command.c: revert chanches from commit 199adb60
  2012-11-10 11:41               ` Anatolij Gustschin
@ 2012-12-14  4:13                 ` Rommel Custodio
  2012-12-14  7:51                   ` Anatolij Gustschin
  0 siblings, 1 reply; 133+ messages in thread
From: Rommel Custodio @ 2012-12-14  4:13 UTC (permalink / raw)
  To: u-boot

Dear Anatolij,

Anatolij Gustschin <agust <at> denx.de> writes:

> 
> Hi Albert,
> 
> On Sat, 10 Nov 2012 12:21:55 +0100
> Albert ARIBAUD <albert.u.boot <at> aribaud.net> wrote:
> ...
> > > 
> > > Applied to u-boot-staging/agust <at> denx.de-urgent.

*bump*

This seems to be still missing in master.

All the best,
Rommel

> > 
> > Did you fix the typo in the commit summary/subject on the fly?
> 
> yes, I noticed it when applying, it wasn't worth it to resubmit the patch.
> 
> Thanks,
> Anatolij
> 

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH] common/command.c: revert chanches from commit 199adb60
  2012-12-14  4:13                 ` Rommel Custodio
@ 2012-12-14  7:51                   ` Anatolij Gustschin
  0 siblings, 0 replies; 133+ messages in thread
From: Anatolij Gustschin @ 2012-12-14  7:51 UTC (permalink / raw)
  To: u-boot

Hi Rommel,

On Fri, 14 Dec 2012 04:13:34 +0000 (UTC)
Rommel Custodio <sessyargc@gmail.com> wrote:
...
> > > > Applied to u-boot-staging/agust <at> denx.de-urgent.
> 
> *bump*
> 
> This seems to be still missing in master.

This patch is already in master, here is the commit [1].

Thanks,
Anatolij 

[1] http://git.denx.de/?p=u-boot.git;a=commit;h=22b6fcb50d06ee281a338e78f8d0a7c9ddee8629

^ permalink raw reply	[flat|nested] 133+ messages in thread

* Re: [PATCH v4 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers
  2012-11-28 23:33                                       ` [U-Boot] " Kim Phillips
@ 2013-01-06 21:52                                           ` Jon Loeliger
  -1 siblings, 0 replies; 133+ messages in thread
From: Jon Loeliger @ 2013-01-06 21:52 UTC (permalink / raw)
  To: Kim Phillips
  Cc: u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jerry Van Baren

> Projects such as linux and u-boot run sparse on libfdt.  libfdt
> contains the notion of endianness via usage of endian conversion
> functions such as fdt32_to_cpu.  As such, in order to pass endian
> checks, libfdt has to annotate its fdt variables such that sparse
> can warn when mixing bitwise and regular integers.  This patch adds
> these new fdtXX_t types and, ifdef __CHECKER__ (a symbol sparse
> defines), includes the bitwise annotation.
> 
> Signed-off-by: Kim Phillips <kim.phillips-KZfg59tc24xl57MIdRCFDg@public.gmane.org>

Applied.

Thanks,
jdl

^ permalink raw reply	[flat|nested] 133+ messages in thread

* [U-Boot] [PATCH v4 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers
@ 2013-01-06 21:52                                           ` Jon Loeliger
  0 siblings, 0 replies; 133+ messages in thread
From: Jon Loeliger @ 2013-01-06 21:52 UTC (permalink / raw)
  To: u-boot

> Projects such as linux and u-boot run sparse on libfdt.  libfdt
> contains the notion of endianness via usage of endian conversion
> functions such as fdt32_to_cpu.  As such, in order to pass endian
> checks, libfdt has to annotate its fdt variables such that sparse
> can warn when mixing bitwise and regular integers.  This patch adds
> these new fdtXX_t types and, ifdef __CHECKER__ (a symbol sparse
> defines), includes the bitwise annotation.
> 
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>

Applied.

Thanks,
jdl

^ permalink raw reply	[flat|nested] 133+ messages in thread

end of thread, other threads:[~2013-01-06 21:52 UTC | newest]

Thread overview: 133+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-17  0:28 [U-Boot] [PATCH 00/32] Initial sparse fix series Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 01/32] include/linux/byteorder: import latest endian definitions from linux Kim Phillips
2012-10-25 17:37   ` Tom Rini
2012-10-17  0:28 ` [U-Boot] [PATCH 02/32] include/linux/compat.h: fix warning: preprocessor token __iomem redefined Kim Phillips
2012-10-24 21:31   ` Tom Rini
2012-10-17  0:28 ` [U-Boot] [PATCH 03/32] include/linux/unaligned/generic.h: fix warning: preprocessor token __force redefined Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 04/32] include/linux/stddef.h: avoid 'warning: preprocessor token offsetof redefined' Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 05/32] arch/powerpc/include/asm/io.h: fix warning: preprocessor token __iomem redefined Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 06/32] arch/powerpc/lib/bootm.c: fix noinline attribute Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 07/32] arch/powerpc/lib/extable.c: sparse fix Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 08/32] arch/powerpc/lib/board.c, *traps.c: sparse fixes Kim Phillips
2012-10-18 16:55   ` Tom Rini
2012-10-17  0:28 ` [U-Boot] [PATCH 09/32] include/common.h: sparse fix Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 10/32] include/command.h: " Kim Phillips
2012-10-25 16:35   ` Tom Rini
2012-10-17  0:28 ` [U-Boot] [PATCH 11/32] include/image.h: sparse fixes Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 12/32] common/cmd_*.c: " Kim Phillips
2012-10-24 23:49   ` Tom Rini
2012-10-17  0:28 ` [U-Boot] [PATCH 13/32] common/misc: " Kim Phillips
2012-10-25 17:32   ` Tom Rini
2012-10-17  0:28 ` [U-Boot] [PATCH 14/32] common/fdt_support.c: " Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 15/32] net/: " Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 16/32] drivers/net/: " Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 17/32] lib/zlib: " Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 18/32] lib/vsprintf.c: " Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 19/32] include/fdt.h: " Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 20/32] arch/powerpc/cpu/mpc8xxx/: " Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 21/32] arch/powerpc/cpu/mpc85xx/fdt.c: " Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 22/32] powerpc/mpc85xx: " Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 23/32] powerpc/mpc83xx: " Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 24/32] drivers/block/: " Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 25/32] drivers/gpio/mpc83xx_gpio.c: " Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 26/32] drivers/input/input.c: sparse fix Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 27/32] drivers/i2c/fsl_i2c.c: " Kim Phillips
2012-10-17  3:57   ` Heiko Schocher
2012-10-26  3:29   ` [U-Boot] [U-Boot,27/32] " Tom Rini
2012-10-17  0:28 ` [U-Boot] [PATCH 28/32] drivers/mmc/mmc.c: sparse fixes Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 29/32] drivers/mmc/fsl_esdhc.c: " Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 30/32] drivers/mtd/cfi_flash.c: " Kim Phillips
2012-10-17  0:28 ` [U-Boot] [PATCH 31/32] drivers/mtd/nand: " Kim Phillips
2012-10-22 19:18   ` Scott Wood
2012-10-17  0:28 ` [U-Boot] [PATCH 32/32] drivers/serial/serial_ns16550.c: " Kim Phillips
2012-10-26  3:30   ` [U-Boot] [U-Boot, " Tom Rini
2012-10-18  0:19 ` [U-Boot] [PATCH 00/32] Initial sparse fix series Jerry Van Baren
2012-10-18 12:11   ` David Gibson
2012-10-18 22:30     ` Kim Phillips
2012-10-19  0:43       ` David Gibson
2012-10-30 21:57         ` [PATCH] libfdt: introduce fdt type annotation for use by endian checkers Kim Phillips
2012-10-30 21:57           ` [U-Boot] " Kim Phillips
2012-10-30 22:24           ` Stephen Warren
2012-10-30 22:24             ` [U-Boot] " Stephen Warren
2012-10-30 22:27             ` Kim Phillips
2012-10-30 22:27               ` [U-Boot] " Kim Phillips
     [not found]           ` <20121030165754.65b34c78cd0d3a0d6ab7d34e-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2012-11-06  7:48             ` David Gibson
2012-11-06  7:48               ` [U-Boot] " David Gibson
2012-11-14  0:34               ` [PATCH 3/4 v2] dtc/libfdt: introduce fdt types for annotation " Kim Phillips
2012-11-14  0:34                 ` [U-Boot] " Kim Phillips
     [not found]                 ` <20121113183417.7706e5c6044eb273309ef46e-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2012-11-14 14:42                   ` Jon Loeliger
2012-11-14 14:42                     ` [U-Boot] " Jon Loeliger
2012-11-15  0:59                     ` [PATCH v2 1/4] dtc/tests: don't include fdt.h prior to libfdt.h Kim Phillips
2012-11-15  0:59                       ` [U-Boot] " Kim Phillips
     [not found]                       ` <1352941199-19393-1-git-send-email-kim.phillips-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2012-11-15  0:59                         ` [PATCH v2 2/4] dtc/fdtdump: include libfdt_env.h prior to fdt.h Kim Phillips
2012-11-15  0:59                           ` [U-Boot] " Kim Phillips
2012-11-15  0:59                         ` [PATCH v3 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers Kim Phillips
2012-11-15  0:59                           ` [U-Boot] " Kim Phillips
     [not found]                           ` <1352941199-19393-3-git-send-email-kim.phillips-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2012-11-15  4:43                             ` David Gibson
2012-11-15  4:43                               ` [U-Boot] " David Gibson
2012-11-15  5:12                               ` Kim Phillips
2012-11-15  5:12                                 ` [U-Boot] " Kim Phillips
     [not found]                                 ` <20121114231204.8f19082c7acc1cea2a2d794f-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2012-11-19  2:30                                   ` David Gibson
2012-11-19  2:30                                     ` [U-Boot] " David Gibson
2012-11-28 23:33                                     ` [PATCH v4 " Kim Phillips
2012-11-28 23:33                                       ` [U-Boot] " Kim Phillips
2012-12-03  4:05                                       ` David Gibson
2012-12-03  4:05                                         ` [U-Boot] " David Gibson
     [not found]                                       ` <20121128173301.2b52b22a39fe6c3ce5a088fb-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2013-01-06 21:52                                         ` Jon Loeliger
2013-01-06 21:52                                           ` [U-Boot] " Jon Loeliger
2012-11-15  0:59                       ` [PATCH v2 4/4] dtc/libfdt: uintXX_t to fdtXX_t conversion Kim Phillips
2012-11-15  0:59                         ` [U-Boot] " Kim Phillips
2012-10-18 16:53 ` [U-Boot] [PATCH 00/32] Initial sparse fix series Tom Rini
2012-10-24 21:21   ` Tom Rini
2012-10-24 22:47     ` Kim Phillips
2012-10-25 17:46 ` Tom Rini
2012-10-25 18:59   ` Kim Phillips
2012-10-25 19:28     ` Tom Rini
2012-10-29 23:34 ` [U-Boot] [PATCH v2 " Kim Phillips
2012-10-29 23:34   ` [U-Boot] [PATCH v2 01/25] include/linux/byteorder: import latest endian definitions from linux Kim Phillips
2012-10-29 23:34   ` [U-Boot] [PATCH v2 02/25] include/linux/compat.h: fix warning: preprocessor token {__iomem, __user} redefined Kim Phillips
2012-10-29 23:34   ` [U-Boot] [PATCH v2 03/25] include/linux/unaligned/generic.h: fix warning: preprocessor token __force redefined Kim Phillips
2012-10-29 23:34   ` [U-Boot] [PATCH v2 04/25] include/linux/stddef.h: avoid 'warning: preprocessor token offsetof redefined' Kim Phillips
2012-10-29 23:34   ` [U-Boot] [PATCH v2 05/25] arch/powerpc/include/asm/io.h: fix warning: preprocessor token __iomem redefined Kim Phillips
2012-10-29 23:34   ` [U-Boot] [PATCH v2 06/25] arch/powerpc/lib/extable.c: sparse fix Kim Phillips
2012-10-29 23:34   ` [U-Boot] [PATCH v2 07/25] arch/powerpc/lib/board.c, *traps.c: sparse fixes Kim Phillips
2012-10-29 23:34   ` [U-Boot] [PATCH v2 08/25] include/image.h: " Kim Phillips
2012-10-29 23:34   ` [U-Boot] [PATCH v2 09/25] common/cmd_*.c: " Kim Phillips
2012-11-08 10:48     ` Wolfgang Denk
2012-11-09  1:04       ` Kim Phillips
2012-10-29 23:34   ` [U-Boot] [PATCH v2 10/25] common/misc: " Kim Phillips
2012-11-05 21:30     ` Henrik Nordström
2012-11-06  1:51       ` [U-Boot] [PATCH] common: fix help command breakage Kim Phillips
2012-11-06  5:44         ` Henrik Nordström
2012-11-07 21:39           ` Simon Glass
2012-11-07 22:23         ` Anatolij Gustschin
2012-11-08 11:02           ` Anatolij Gustschin
2012-11-08 11:23             ` Wolfgang Denk
2012-11-08 10:41         ` Wolfgang Denk
2012-11-08 11:52         ` [U-Boot] [PATCH] common/command.c: revert chanches from commit 199adb60 Anatolij Gustschin
2012-11-08 12:42           ` Anatolij Gustschin
2012-11-10 11:21             ` Albert ARIBAUD
2012-11-10 11:41               ` Anatolij Gustschin
2012-12-14  4:13                 ` Rommel Custodio
2012-12-14  7:51                   ` Anatolij Gustschin
2012-10-29 23:34   ` [U-Boot] [PATCH v2 11/25] net/: sparse fixes Kim Phillips
2012-10-29 23:34   ` [U-Boot] [PATCH v2 12/25] drivers/net/: " Kim Phillips
2012-10-29 23:34   ` [U-Boot] [PATCH v2 13/25] lib/zlib: " Kim Phillips
2012-11-08 11:20     ` Wolfgang Denk
2012-11-09  1:06       ` Kim Phillips
2012-11-21 16:37         ` Tom Rini
2012-10-29 23:34   ` [U-Boot] [PATCH v2 14/25] lib/vsprintf.c: " Kim Phillips
2012-10-29 23:34   ` [U-Boot] [PATCH v2 15/25] arch/powerpc/cpu/mpc8xxx/: " Kim Phillips
2012-10-29 23:34   ` [U-Boot] [PATCH v2 16/25] powerpc/mpc85xx: " Kim Phillips
2012-10-29 23:34   ` [U-Boot] [PATCH v2 17/25] powerpc/mpc83xx: " Kim Phillips
2012-10-29 23:34   ` [U-Boot] [PATCH v2 18/25] drivers/block/: " Kim Phillips
2012-10-29 23:34   ` [U-Boot] [PATCH v2 19/25] drivers/gpio/mpc83xx_gpio.c: " Kim Phillips
2012-10-29 23:34   ` [U-Boot] [PATCH v2 20/25] drivers/input/input.c: sparse fix Kim Phillips
2012-10-31  5:51     ` Simon Glass
2012-10-29 23:34   ` [U-Boot] [PATCH v2 21/25] drivers/mmc/mmc.c: sparse fixes Kim Phillips
2012-10-29 23:34   ` [U-Boot] [PATCH v2 22/25] drivers/mmc/fsl_esdhc.c: " Kim Phillips
2012-10-29 23:34   ` [U-Boot] [PATCH v2 23/25] drivers/mtd/cfi_flash.c: " Kim Phillips
2012-10-29 23:34   ` [U-Boot] [PATCH v2 24/25] drivers/mtd/nand: " Kim Phillips
2012-10-30  0:43     ` Scott Wood
2012-10-29 23:34   ` [U-Boot] [PATCH v2 25/25] drivers/serial/serial_ns16550.c: " Kim Phillips
2012-11-04 18:30   ` [U-Boot] [PATCH v2 00/32] Initial sparse fix series Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.