Skip to contentSkip to conversation

Initial sparse fix series

PATCH Superseded Kim Phillips 17 participants 117 messages Oct 17, 2012 – Jan 6, 2013 6 messages not in the archive Page 1 of 2

Subsystems (16)
lore
Share & tools
lore
#0 lore raw

cover Initial sparse fix series

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(-)
Signature · 1 line
1.7.12.3
#1 lore raw

PATCH 1/32 include/linux/byteorder: import latest endian definitions from linux

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).

---
 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(-)
include/linux/byteorder/big_endian.h +88 -47
index 19b0c86..aaf7757 100644
@@ -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 */
include/linux/byteorder/little_endian.h +87 -46

147 lines not on this page · raw message

include/linux/byteorder/swab.h +3 -3
index b1d570e..bb4a046 100644
@@ -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);
 }
Signature · 1 line
1.7.12.3
#2 lore raw

PATCH 1/32 include/linux/byteorder: import latest endian definitions from linux

Quoted 6 lines · Kim Phillips

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:

Quoted 6 lines

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).

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
Signature · 8 lines
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>
#3 lore raw

PATCH 2/32 include/linux/compat.h: fix warning: preprocessor token __iomem redefined

In reply to Kim Phillips

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".

---
 include/linux/compat.h | 3 ---
 1 file changed, 3 deletions(-)
include/linux/compat.h +0 -3
index 593b07f..e1338bf 100644
@@ -1,9 +1,6 @@
 #ifndef _LINUX_COMPAT_H_
 #define _LINUX_COMPAT_H_
 
-#define __user
-#define __iomem
-
 #define ndelay(x)	udelay(1)
 
 #define printk	printf
Signature · 1 line
1.7.12.3
#4 lore raw

PATCH 2/32 include/linux/compat.h: fix warning: preprocessor token __iomem redefined

Quoted 5 lines · Kim Phillips

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

Quoted 7 lines

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".

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.

Signature · 1 line
Tom
#5 lore raw

PATCH 3/32 include/linux/unaligned/generic.h: fix warning: preprocessor token __force redefined

In reply to Kim Phillips

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".

---
 include/linux/unaligned/generic.h | 3 ---
 1 file changed, 3 deletions(-)
include/linux/unaligned/generic.h +0 -3
index cc688e1..02d97ff 100644
@@ -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
Signature · 1 line
1.7.12.3
#6 lore raw

PATCH 4/32 include/linux/stddef.h: avoid 'warning: preprocessor token offsetof redefined'

In reply to Kim Phillips

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)

---
 include/linux/stddef.h | 2 ++
 1 file changed, 2 insertions(+)
include/linux/stddef.h +2 -0
index 81e34c2..c540f61 100644
@@ -12,7 +12,9 @@
 #include <linux/types.h>
 #endif
 
+#ifndef __CHECKER__
 #undef offsetof
 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
 
 #endif
Signature · 1 line
1.7.12.3
#7 lore raw

PATCH 5/32 arch/powerpc/include/asm/io.h: fix warning: preprocessor token __iomem redefined

In reply to Kim Phillips

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'.

---
 arch/powerpc/include/asm/io.h | 1 -
 1 file changed, 1 deletion(-)
arch/powerpc/include/asm/io.h +0 -1
index 9e20861..1f12c29 100644
@@ -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)
Signature · 1 line
1.7.12.3
#8 lore raw

PATCH 6/32 arch/powerpc/lib/bootm.c: fix noinline attribute

In reply to Kim Phillips

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

---
 arch/powerpc/lib/bootm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/lib/bootm.c +1 -1
index 53dc4df..ac5bd6d 100644
@@ -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;
Signature · 1 line
1.7.12.3
#9 lore raw

PATCH 7/32 arch/powerpc/lib/extable.c: sparse fix

In reply to Kim Phillips

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

---
 arch/powerpc/lib/extable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/lib/extable.c +1 -1
index 7408d5c..7e74a5d 100644
@@ -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)
Signature · 1 line
1.7.12.3
#10 lore raw

PATCH 8/32 arch/powerpc/lib/board.c, *traps.c: sparse fixes

In reply to Kim Phillips

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

---
 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(-)
arch/powerpc/cpu/74xx_7xx/traps.c +3 -3
index 7ae81eb..4f77202 100644
@@ -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);
arch/powerpc/cpu/mpc512x/traps.c +3 -3
index 786f4a5..3b84d57 100644
@@ -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);
arch/powerpc/cpu/mpc5xx/traps.c +3 -3
index e3ce11b..4950b65 100644
@@ -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]);
arch/powerpc/cpu/mpc5xxx/traps.c +3 -3
index 5972f34..c4d4c0b 100644
@@ -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);
arch/powerpc/cpu/mpc8220/traps.c +3 -3
index 13894c9..d8786c2 100644
@@ -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]);
arch/powerpc/cpu/mpc824x/traps.c +3 -3
index 163b983..63ab9b9 100644
@@ -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);
arch/powerpc/cpu/mpc8260/traps.c +3 -3
index c116cdf..02e287b 100644
@@ -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);
arch/powerpc/cpu/mpc83xx/traps.c +3 -3
index 9d71b8b..5cefa09 100644
@@ -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);
arch/powerpc/cpu/mpc85xx/traps.c +3 -3
index 7800717..e4bb6af 100644
@@ -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);
arch/powerpc/cpu/mpc86xx/traps.c +3 -3
index 406403e..83db97c 100644
@@ -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);
arch/powerpc/cpu/mpc8xx/traps.c +3 -3
index 343dced..3bc2312 100644
@@ -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);
arch/powerpc/cpu/ppc4xx/traps.c +3 -3
index 9baa7a1..1ed8387 100644
@@ -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);
arch/powerpc/lib/board.c +6 -6
index b860141..42bbff7 100644
@@ -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();
Signature · 1 line
1.7.12.3
#11 lore raw

PATCH 8/32 arch/powerpc/lib/board.c, *traps.c: sparse fixes

Quoted 32 lines · Kim Phillips

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

---
 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(-)
arch/powerpc/cpu/74xx_7xx/traps.c +0 -0
index 7ae81eb..4f77202 100644

arch/powerpc/cpu/74xx_7xx/traps.c extern unsigned long search_exception_table(unsigned long); · line 52

Quoted 6 lines
arch/powerpc/cpu/74xx_7xx/traps.c +1 -1
@@ -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.

Signature · 8 lines
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>
#12 lore raw

PATCH 9/32 include/common.h: sparse fix

In reply to Kim Phillips

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.'

---
 include/common.h | 4 ----
 1 file changed, 4 deletions(-)
include/common.h +0 -4
index b23e90b..5e3c5ee 100644
@@ -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>
Signature · 1 line
1.7.12.3
#13 lore raw

PATCH 10/32 include/command.h: sparse fix

In reply to Kim Phillips

__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?

---
 include/command.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/command.h +1 -1
index 1f06aa1..c051158 100644
@@ -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) \
Signature · 1 line
1.7.12.3
#14 lore raw

PATCH 10/32 include/command.h: sparse fix

Quoted 23 lines · Kim Phillips

__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?

---
 include/command.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/command.h +0 -0
index 1f06aa1..c051158 100644

include/command.h int cmd_process(int flag, int argc, char * const argv[], · line 180

Quoted 8 lines
include/command.h +1 -1
@@ -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!

Signature · 8 lines
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>
#15 lore raw

PATCH 11/32 include/image.h: sparse fixes

In reply to Kim Phillips

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.

---
 include/image.h | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
include/image.h +8 -7
index e5f6649..ab27941 100644
@@ -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			*/
Signature · 1 line
1.7.12.3
#16 lore raw

PATCH 12/32 common/cmd_*.c: sparse fixes

In reply to Kim Phillips

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

---
 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(-)
common/cmd_boot.c +3 -2
index a799b33..ab5a6ed 100644
@@ -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;
common/cmd_bootm.c +16 -11
index 83fa5d7..92b45b4 100644
@@ -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 */
common/cmd_console.c +1 -1
index d8cad6b..07b3d8a 100644
@@ -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();
common/cmd_date.c +1 -1
index 335bc05..e645425 100644
@@ -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;
common/cmd_echo.c +1 -1
index 1e499fb..52123fe 100644
@@ -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;
common/cmd_exit.c +1 -1
index f3fc8f5..0f2ee40 100644
@@ -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;
 
common/cmd_fat.c +3 -2
index 5a5698b..e6c0437 100644
@@ -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;
common/cmd_fdt.c +10 -9
index e2225c4..ac5c488 100644
@@ -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
 );
common/cmd_flash.c +3 -3
index e55d366..687eb68 100644
@@ -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
common/cmd_help.c +1 -1
index 8c8178e..97af32c 100644
@@ -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,
common/cmd_i2c.c +10 -8
index 795814d..9a184b1 100644
@@ -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)
common/cmd_irq.c +1 -1
index 9f158ef..70447f1 100644
@@ -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)
common/cmd_itest.c +2 -2
index d5df758..ec33a93 100644
@@ -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;
 
common/cmd_load.c +23 -21

129 lines not on this page · raw message

common/cmd_mdio.c +10 -10
index 77d8df1..ff0063b 100644
@@ -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;
 
common/cmd_mem.c +14 -11
index 18f0a3f..cfaa98c 100644
@@ -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;
common/cmd_misc.c +1 -1
index 3b47a0c..5857390 100644
@@ -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;
common/cmd_mmc.c +3 -3
index 79a1088..62a1c22 100644
@@ -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);
 
common/cmd_mp.c +9 -11
index 4b27be4..0de8a5b 100644
@@ -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
 );
common/cmd_mtdparts.c +16 -12
index 2268829..c057aeb 100644
@@ -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
 );
 /***************************************************/
common/cmd_nand.c +10 -7
index e24ed7f..516d709 100644
@@ -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;
common/cmd_net.c +4 -4
index a9ade8b..fb9ef7a 100644
@@ -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;
common/cmd_nvedit.c +14 -9
index 1f9c674..94cacff 100644
@@ -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
 );
 
 /*
common/cmd_pci.c +7 -8
index a1fe519..3b032d8 100644
@@ -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
 );
common/cmd_reginfo.c +2 -1
index 908876c..61371e7 100644
@@ -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;
common/cmd_sata.c +2 -2
index 3f98235..b401bd1 100644
@@ -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;
 
common/cmd_setexpr.c +1 -1
index 1b3edb7..7b140de 100644
@@ -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];
common/cmd_source.c +7 -4
index c4cde98..7780c71 100644
@@ -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
common/cmd_test.c +3 -3
index 6da06b9..d4ec186 100644
@@ -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;
 }
common/cmd_usb.c +15 -15
index c128455..8ad0b23 100644
@@ -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;
common/cmd_version.c +1 -1
index e4b2ac1..ab4c560 100644
@@ -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
common/cmd_ximg.c +7 -4
index 0414589..9ef6048 100644
@@ -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
 );
Signature · 1 line
1.7.12.3
#17 lore raw

PATCH 12/32 common/cmd_*.c: sparse fixes

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

[snip]

Quoted 1 line

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

[snip]

common/cmd_mtdparts.c static char last_partition[PARTITION_MAXLEN]; · line 157

Quoted 5 lines

/* current active device and partition number */

common/cmd_mtdparts.c +2 -2
-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 :(

Signature · 8 lines
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>
#18 lore raw

PATCH 13/32 common/misc: sparse fixes

In reply to Kim Phillips

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.

---
 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(-)
common/command.c +8 -1
index aa0fb0a..c866ac4 100644
@@ -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 */
common/console.c +1 -1
index 1177f7d..c780ce8 100644
@@ -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;
 
common/dlmalloc.c +18 -18
index 1d7e527..b2f0a1a 100644
@@ -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
   {
common/hush.c +15 -15
index 4c84c2f..68d5f43 100644
@@ -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;
common/image.c +4 -4
index f084d2b..8b5c0d5 100644
@@ -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;
 }
common/main.c +3 -3
index 9507cec..0fd62e4 100644
@@ -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)
 
common/usb_storage.c +10 -10
index 950451e..8382006 100644
@@ -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;
common/xyzModem.c +3 -3
index a1f955b..f30b002 100644
@@ -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;
Signature · 1 line
1.7.12.3
#19 lore raw

PATCH 13/32 common/misc: sparse fixes

Quoted 58 lines · Kim Phillips

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

Quoted 3 lines

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

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
Signature · 8 lines
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>
#20 lore raw

PATCH 14/32 common/fdt_support.c: sparse fixes

In reply to Kim Phillips

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".

---
 arch/powerpc/cpu/mpc85xx/fdt.c |  2 +-
 common/fdt_support.c           | 78 +++++++++++++++++++++++-------------------
 include/fdt_support.h          |  2 +-
 3 files changed, 45 insertions(+), 37 deletions(-)
arch/powerpc/cpu/mpc85xx/fdt.c +1 -1
index a0a9b4c..e57d69c 100644
@@ -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);
 
common/fdt_support.c +43 -35

245 lines not on this page · raw message

include/fdt_support.h +1 -1
index 4b9f84a..2e18d82 100644
@@ -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);
Signature · 1 line
1.7.12.3
#21 lore raw

PATCH 15/32 net/: sparse fixes

In reply to Kim Phillips

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.

---
 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(-)
common/update.c +1 -0
index 5b1a064..94d6a82 100644
@@ -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 */
drivers/net/phy/atheros.c +1 -1
index 798473d..9b3808b 100644
@@ -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,
include/net.h +5 -4
index 3539336..970d4d1 100644
@@ -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;
 }
net/arp.c +3 -3
index 8e1d2ed..20c6b2d 100644
@@ -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)
 {
net/bootp.c +3 -3
index cd5c5dd..4300f1c 100644
@@ -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);
 
net/net.c +1 -1
index 569fec4..82c4cc9 100644
@@ -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];
net/ping.h +0 -3
index fd8d8d9..8c71be4 100644
@@ -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
net/tftp.h +3 -0
index 18e4c9c..2b686e3 100644
@@ -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__ */
Signature · 1 line
1.7.12.3
#22 lore raw

PATCH 16/32 drivers/net/: sparse fixes

In reply to Kim Phillips

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?

---
 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(-)
drivers/net/fm/eth.c +1 -1
index 2b616ad..3560990 100644
@@ -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;
drivers/net/fm/p1023.c +1 -1
index 9765da5..387d2a3 100644
@@ -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,
 };
drivers/net/fm/p4080.c +1 -1
index 9dc6049..b04fd0f 100644
@@ -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,
drivers/net/fm/p5020.c +1 -1
index a7a6e43..5391044 100644
@@ -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,
drivers/net/fm/tgec_phy.c +5 -5
index 2d349ad..2be69d7 100644
@@ -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;
 }
drivers/net/phy/phy.c +10 -9
index baef60f..1ffa791 100644
@@ -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;
drivers/net/phy/vitesse.c +1 -1
index 0a0f40d..6c5cb99 100644
@@ -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
drivers/net/vsc7385.c +1 -0
index ada42c4..a5110e5 100644
@@ -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
Signature · 1 line
1.7.12.3
#23 lore raw

PATCH 17/32 lib/zlib: sparse fixes

In reply to Kim Phillips

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'

---
 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(-)
include/u-boot/zlib.h +1 -1
index b611fe7..e23ceb5 100644
@@ -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 */
 
lib/zlib/adler32.c +1 -4
index dc9480d..b468441 100644
@@ -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;
lib/zlib/inffast.c +2 -3
index 38f2f90..0700e04 100644
@@ -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 */
lib/zlib/inflate.c +8 -21
index 1eef609..6411c47 100644
@@ -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)
lib/zlib/inftrees.c +3 -7
index c6d4c03..7474a52 100644
@@ -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 */
lib/zlib/zutil.c +2 -8
index 65f9554..ba5742d 100644
@@ -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)
Signature · 1 line
1.7.12.3
#24 lore raw

PATCH 18/32 lib/vsprintf.c: sparse fixes

In reply to Kim Phillips

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

---
 lib/vsprintf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/vsprintf.c +2 -2
index d762763..7215531 100644
@@ -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);
Signature · 1 line
1.7.12.3
#25 lore raw

PATCH 19/32 include/fdt.h: sparse fixes

In reply to Kim Phillips

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?

---
 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(-)
include/fdt.h +17 -16
index c51212e..1b7f044 100644
@@ -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];
 };
 
include/fdt_support.h +2 -0
index 2e18d82..399b73f 100644
@@ -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);
include/libfdt.h +2 -2
index 4589c5f..ab98d23 100644
@@ -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));
 }
 
 /**
lib/libfdt/fdt.c +1 -1
index 4157b21..5a82c60 100644
@@ -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;
lib/libfdt/fdt_ro.c +1 -1
index 1933010..4e3d87a 100644
@@ -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
lib/libfdt/fdt_rw.c +2 -2
index 5ed23d6..688b817 100644
@@ -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;
lib/libfdt/fdt_sw.c +2 -2
index 55ebebf..5ce91ba 100644
@@ -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;
lib/libfdt/fdt_wip.c +1 -1
index e373677..dc1e14c 100644
@@ -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);
Signature · 1 line
1.7.12.3
#26 lore raw

PATCH 20/32 arch/powerpc/cpu/mpc8xxx/: sparse fixes

In reply to Kim Phillips

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.

---
 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(-)
arch/powerpc/cpu/mpc8xxx/cpu.c +4 -4
index 78a8f92..acd1b64 100644
@@ -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;
 
 	/*
arch/powerpc/cpu/mpc8xxx/ddr/ctrl_regs.c +1 -1
index 2592873..0e77408 100644
@@ -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;
arch/powerpc/cpu/mpc8xxx/ddr/lc_common_dimm_params.c +3 -1
index 03a784c..400b0d7 100644
@@ -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()
arch/powerpc/cpu/mpc8xxx/fsl_lbc.c +1 -1
index 023ac9a..c1fe579 100644
@@ -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 */
 }
Signature · 1 line
1.7.12.3
#27 lore raw

PATCH 21/32 arch/powerpc/cpu/mpc85xx/fdt.c: sparse fixes

In reply to Kim Phillips

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.

---
 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(-)
arch/powerpc/cpu/mpc85xx/fdt.c +30 -25
index e57d69c..0013e42 100644
@@ -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",
arch/powerpc/cpu/mpc8xxx/fdt.c +2 -1
index 32ab050..af2545d 100644
@@ -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)) {
drivers/qe/qe.h +17 -17
index faad43c..3914fab 100644
@@ -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);
Signature · 1 line
1.7.12.3
#28 lore raw

PATCH 22/32 powerpc/mpc85xx: sparse fixes

In reply to Kim Phillips

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

---
 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(-)
arch/powerpc/cpu/mpc85xx/cpu_init.c +1 -1
index afb5671..fac20db 100644
@@ -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;
arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c +1 -1
index 2a68060..0df6b54 100644
@@ -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  */
 };
board/freescale/common/ngpixis.c +6 -4
index 276ae3c..5f8421a 100644
@@ -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
 	);
board/freescale/mpc8568mds/bcsr.c +4 -4
index 30676e1..2a172cc 100644
@@ -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);
 
board/freescale/mpc8569mds/bcsr.c +4 -4
index b688e5c..37d0c5f 100644
@@ -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);
 }
Signature · 1 line
1.7.12.3
#29 lore raw

PATCH 23/32 powerpc/mpc83xx: sparse fixes

In reply to Kim Phillips

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

---
 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(-)
arch/powerpc/cpu/mpc83xx/fdt.c +2 -2
index 028c8f0..6cb096a 100644
@@ -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));
arch/powerpc/cpu/mpc83xx/speed.c +2 -2
index f78099d..195f5b4 100644
@@ -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];
 
board/freescale/mpc8313erdb/mpc8313erdb.c +12 -12
index 730ec4e..1071803 100644
@@ -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
 	}
 };
 
Signature · 1 line
1.7.12.3
#30 lore raw

PATCH 24/32 drivers/block/: sparse fixes

In reply to Kim Phillips

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>

---
 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(-)
drivers/block/fsl_sata.c +10 -69
index fda3389..7e2a22a 100644
@@ -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;
drivers/block/fsl_sata.h +6 -6
index cecff68..58cd2a4 100644
@@ -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)
drivers/block/sata_sil.c +7 -6
index 245b872..b70f04d 100644
@@ -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;
 
Signature · 1 line
1.7.12.3
#31 lore raw

PATCH 25/32 drivers/gpio/mpc83xx_gpio.c: sparse fixes

In reply to Kim Phillips

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'

---
 drivers/gpio/mpc83xx_gpio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/mpc83xx_gpio.c +2 -2
index a9afcb2..e167852 100644
@@ -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;
Signature · 1 line
1.7.12.3
#32 lore raw

PATCH 26/32 drivers/input/input.c: sparse fix

In reply to Kim Phillips

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

---
 drivers/input/input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/input.c +1 -1
index 5b2b4b0..5a4c76d 100644
@@ -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)
Signature · 1 line
1.7.12.3
#33 lore raw

PATCH 27/32 drivers/i2c/fsl_i2c.c: sparse fix

In reply to Kim Phillips

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

---
 drivers/i2c/fsl_i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/fsl_i2c.c +1 -1
index 5b017a9..3cb232f 100644
@@ -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 */
Signature · 1 line
1.7.12.3
#34 lore raw

PATCH 27/32 drivers/i2c/fsl_i2c.c: sparse fix

Helo Kim,

Quoted 6 lines · Kim Phillips

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

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

Thanks!

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#35 lore raw

PATCH 27/32 drivers/i2c/fsl_i2c.c: sparse fix

In reply to Kim Phillips
Quoted 4 lines · Kim Phillips

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

Applied to u-boot/master, thanks!

Signature · 8 lines
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>
#36 lore raw

PATCH 28/32 drivers/mmc/mmc.c: sparse fixes

In reply to Kim Phillips

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

---
 drivers/mmc/mmc.c | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)
drivers/mmc/mmc.c +19 -18
index a60cfe1..b1b6a07 100644
@@ -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;
Signature · 1 line
1.7.12.3
#37 lore raw

PATCH 29/32 drivers/mmc/fsl_esdhc.c: sparse fixes

In reply to Kim Phillips

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

---
 drivers/mmc/fsl_esdhc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/fsl_esdhc.c +2 -2
index 3f8d30d..301dd8c 100644
@@ -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;
Signature · 1 line
1.7.12.3
#38 lore raw

PATCH 30/32 drivers/mtd/cfi_flash.c: sparse fixes

In reply to Kim Phillips

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?

---
 drivers/mtd/cfi_flash.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/mtd/cfi_flash.c +12 -8
index 43140f3..8a90f32 100644
@@ -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
Signature · 1 line
1.7.12.3
#39 lore raw

PATCH 31/32 drivers/mtd/nand: sparse fixes

In reply to Kim Phillips

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

---
 drivers/mtd/nand/nand_base.c | 9 +++++----
 drivers/mtd/nand/nand_ecc.c  | 1 +
 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/mtd/nand/nand_base.c +5 -4
index 71f5027..110cebd 100644
@@ -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;
drivers/mtd/nand/nand_ecc.c +1 -0
index 81f0e08..097cf62 100644
@@ -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
Signature · 1 line
1.7.12.3
#40 lore raw

PATCH 31/32 drivers/mtd/nand: sparse fixes

Quoted 25 lines · Kim Phillips

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

---
 drivers/mtd/nand/nand_base.c | 9 +++++----
 drivers/mtd/nand/nand_ecc.c  | 1 +
 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/mtd/nand/nand_base.c +1 -2
index 71f5027..110cebd 100644
@@ -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,

drivers/mtd/nand/nand_base.c ident_done: · line 2860

Quoted 10 lines
drivers/mtd/nand/nand_base.c +4 -2
+		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

#41 lore raw

PATCH 32/32 drivers/serial/serial_ns16550.c: sparse fixes

In reply to Kim Phillips

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?

---
 drivers/serial/serial_ns16550.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/serial/serial_ns16550.c +6 -6
index b5d1248..4176e25 100644
@@ -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 */
Signature · 1 line
1.7.12.3
#42 lore raw

PATCH 32/32 drivers/serial/serial_ns16550.c: sparse fixes

Quoted 25 lines · Kim Phillips

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?

Quoted 1 line

Applied to u-boot/master, thanks!

Signature · 8 lines
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>
#43 lore raw

cover Initial sparse fix series

In reply to Kim Phillips

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*.

Quoted 7 lines · Kim Phillips

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]

Quoted 1 line

Note that there are two libfdt dependencies:

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

Quoted 4 lines

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]

Quoted 5 lines

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

Quoted 184 lines
 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(-)
include/fdt.h +17 -16
index c51212e..1b7f044 100644
@@ -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];
 };
 
include/fdt_support.h +2 -0
index 2e18d82..399b73f 100644
@@ -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);
include/libfdt.h +2 -2
index 4589c5f..ab98d23 100644
@@ -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));
 }
 
 /**
lib/libfdt/fdt.c +1 -1
index 4157b21..5a82c60 100644
@@ -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;
lib/libfdt/fdt_ro.c +1 -1
index 1933010..4e3d87a 100644
@@ -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
lib/libfdt/fdt_rw.c +2 -2
index 5ed23d6..688b817 100644
@@ -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;
lib/libfdt/fdt_sw.c +2 -2
index 55ebebf..5ce91ba 100644
@@ -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;
lib/libfdt/fdt_wip.c +1 -1
index e373677..dc1e14c 100644
@@ -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);
#44 lore raw

cover Initial sparse fix series

Quoted 6 lines · Jerry Van Baren

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.

Quoted 11 lines · Kim Phillips
Quoted 7 lines

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.

Quoted 26 lines

What are your thoughts on this quest?

[snip]

Quoted 1 line

Note that there are two libfdt dependencies:

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

Quoted 4 lines

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]

Quoted 5 lines

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.

Quoted 6 lines

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.

Quoted 17 lines
Quoted 17 lines
 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(-)
include/fdt.h +0 -0
index c51212e..1b7f044 100644
@@ -2,40 +2,41 @@
 #define _FDT_H
 
Quoted 2 lines

include/fdt.h line 5

Quoted 2 lines
include/fdt.h +1 -0
 #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.

Signature · 4 lines
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
#45 lore raw

cover Initial sparse fix series

Quoted 10 lines · On Thu, 18 Oct 2012 23:11:12 +1100 David Gibson <[email protected]>…
Quoted 6 lines · Jerry Van Baren

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.

Quoted 12 lines
Quoted 11 lines · Kim Phillips
Quoted 7 lines

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.

Quoted 8 lines

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.

Quoted 28 lines
Quoted 28 lines

What are your thoughts on this quest?

[snip]

Quoted 1 line

Note that there are two libfdt dependencies:

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

Quoted 4 lines

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]

Quoted 5 lines

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:

Quoted 7 lines
Quoted 4 lines

#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.

Quoted 40 lines
Quoted 17 lines
Quoted 17 lines
 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(-)
include/fdt.h +0 -0
index c51212e..1b7f044 100644
@@ -2,40 +2,41 @@
 #define _FDT_H
 
Quoted 2 lines

include/fdt.h line 5

Quoted 2 lines
include/fdt.h +1 -0
 #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".

Quoted 2 lines

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.

Quoted 14 lines

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.

Quoted 4 lines

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

#46 lore raw

cover Initial sparse fix series

Quoted 72 lines · Kim Phillips
Quoted 10 lines · On Thu, 18 Oct 2012 23:11:12 +1100 David Gibson <[email protected]>…
Quoted 6 lines · Jerry Van Baren

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.

Quoted 12 lines
Quoted 11 lines · Kim Phillips
Quoted 7 lines

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.

Quoted 8 lines

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.

Quoted 33 lines
Quoted 32 lines

What are your thoughts on this quest?

[snip]

Quoted 1 line

Note that there are two libfdt dependencies:

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

Quoted 4 lines

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]

Quoted 5 lines

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

Quoted 6 lines
Quoted 2 lines

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.

Quoted 40 lines
Quoted 40 lines
Quoted 17 lines
Quoted 17 lines
 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(-)
include/fdt.h +0 -0
index c51212e..1b7f044 100644
@@ -2,40 +2,41 @@
 #define _FDT_H
 
Quoted 2 lines

include/fdt.h line 5

Quoted 2 lines
include/fdt.h +1 -0
 #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".

Quoted 5 lines
Quoted 2 lines

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.

Quoted 14 lines
Quoted 14 lines

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.

Quoted 8 lines
Quoted 4 lines

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.

Signature · 4 lines
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
#47 lore raw

PATCH 1/1 libfdt: introduce fdt type annotation for use by endian checkers

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.

---
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(-)
libfdt/fdt.c +1 -1
index e56833a..57faba3 100644
@@ -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;
libfdt/fdt.h +29 -21

85 lines not on this page · raw message

libfdt/fdt_ro.c +1 -1
index 02b6d68..42da2bd 100644
@@ -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
libfdt/fdt_rw.c +2 -2
index 24437df..fdba618 100644
@@ -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;
libfdt/fdt_sw.c +2 -2
index 55ebebf..f422754 100644
@@ -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;
libfdt/fdt_wip.c +1 -1
index 6025fa1..c5bbb68 100644
@@ -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);
libfdt/libfdt.h +16 -16
index 73f4975..8e57a06 100644
@@ -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));
 }
 
 /**
Signature · 1 line
1.8.0
#48 lore raw

Re: [PATCH] libfdt: introduce fdt type annotation for use by endian checkers

Quoted 7 lines · Kim Phillips

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.

#49 lore raw

Re: [PATCH] libfdt: introduce fdt type annotation for use by endian checkers

Quoted 11 lines · On Tue, 30 Oct 2012 16:24:05 -0600 Stephen Warren <[email protected]> wrote:
Quoted 7 lines · Kim Phillips

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

Quoted 2 lines

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

A message that is not in the archive (sent off-list or not yet received): 20121030165754.65b34c78cd0d3a0d6ab7d34e-KZfg59tc24xl57MIdRCFDg@public.gmane.org

#51 lore raw

Re: [PATCH] libfdt: introduce fdt type annotation for use by endian checkers

Quoted 8 lines · Kim Phillips

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.

Quoted 4 lines

---
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]

libfdt/fdt.h line 6

Quoted 9 lines
libfdt/fdt.h +1 -0
index 48ccfd9..0d9c856 100644
@@ -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..

libfdt/fdt.h line 8

Quoted 2 lines
libfdt/fdt.h +2 -0
+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.

Signature · 4 lines
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
#52 lore raw

PATCH v2 3/4 dtc/libfdt: introduce fdt types for annotation by endian checkers

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.

---
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(-)
libfdt/fdt.h +21 -21
index 48ccfd9..45dd134 100644
@@ -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 */
libfdt/libfdt_env.h +52 -14

77 lines not on this page · raw message

Signature · 1 line
1.8.0

A message that is not in the archive (sent off-list or not yet received): 20121113183417.7706e5c6044eb273309ef46e-KZfg59tc24xl57MIdRCFDg@public.gmane.org

#54 lore raw

Re: [PATCH 3/4 v2] dtc/libfdt: introduce fdt types for annotation by endian checkers

Hi Kim,

Quoted 2 lines

I hope this addresses all your comments, David.

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

Quoted 10 lines

index 213d7fb..302d5cb 100644

libfdt/libfdt_env.h +3 -0
@@ -5,25 +5,63 @@
 #include <stdint.h>
 #include <string.h>
 
+#ifdef __CHECKER__
+#define __force __attribute__((force))
+#define __bitwise __attribute__((bitwise))

libfdt/libfdt_env.h line 20

Quoted 10 lines
libfdt/libfdt_env.h +10 -0
+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;

libfdt/libfdt_env.h

Quoted 13 lines
libfdt/libfdt_env.h +4 -5
 #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:

libfdt/libfdt_env.h line 43

Quoted 11 lines
libfdt/libfdt_env.h +7 -0
 #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...

Quoted 4 lines
libfdt/libfdt_env.h +0 -3
-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)

libfdt/libfdt_env.h line 55

Quoted 10 lines
libfdt/libfdt_env.h +7 -1
-		| (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

#55 lore raw

PATCH v2 1/4 dtc/tests: don't include fdt.h prior to libfdt.h

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.

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

A message that is not in the archive (sent off-list or not yet received): 1352941199-19393-1-git-send-email-kim.phillips-KZfg59tc24xl57MIdRCFDg@public.gmane.org

#57 lore raw

PATCH v2 2/4 dtc/fdtdump: include libfdt_env.h prior to fdt.h

in order to get the upcoming fdt type definitions.

---
v2: added David's Acked-by.

 fdtdump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fdtdump.c +1 -1
index 207a46d..8a7ae72 100644
@@ -8,8 +8,8 @@
 #include <string.h>
 #include <ctype.h>
 
-#include <fdt.h>
 #include <libfdt_env.h>
+#include <fdt.h>
 
 #include "util.h"
 
Signature · 1 line
1.8.0
#58 lore raw

PATCH v3 3/4 dtc/libfdt: introduce fdt types for annotation by endian checkers

In reply to a message not in the archive

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.

---
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(-)
libfdt/fdt.h +21 -21
index 48ccfd9..45dd134 100644
@@ -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 */
libfdt/libfdt_env.h +54 -15

79 lines not on this page · raw message

Signature · 1 line
1.8.0

A message that is not in the archive (sent off-list or not yet received): 1352941199-19393-3-git-send-email-kim.phillips-KZfg59tc24xl57MIdRCFDg@public.gmane.org

#60 lore raw

Re: [PATCH v3 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers

Quoted 38 lines · Kim Phillips

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.

---
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(-)
libfdt/fdt.h +0 -0
index 48ccfd9..45dd134 100644

[snip]

Quoted 15 lines
libfdt/libfdt_env.h +1 -6
index 213d7fb..f0d97b9 100644
@@ -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__

libfdt/libfdt_env.h line 18

Quoted 10 lines
libfdt/libfdt_env.h +10 -0
+#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.

libfdt/libfdt_env.h line 27

Quoted 8 lines
libfdt/libfdt_env.h +8 -0
+#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.

Quoted 13 lines
libfdt/libfdt_env.h +10 -3
-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) \

libfdt/libfdt_env.h line 47

Quoted 10 lines
libfdt/libfdt_env.h +8 -1
+{ \
+	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.

Signature · 4 lines
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
#61 lore raw

Re: [PATCH v3 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers

Quoted 13 lines · On Thu, 15 Nov 2012 15:43:40 +1100 David Gibson <[email protected]>…

libfdt/libfdt_env.h line 27

Quoted 8 lines · Kim Phillips
libfdt/libfdt_env.h +8 -0
+#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.

Quoted 20 lines
Quoted 20 lines
libfdt/libfdt_env.h +15 -4
-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)
Quoted 8 lines

libfdt/libfdt_env.h line 47

Quoted 3 lines
libfdt/libfdt_env.h +3 -0
+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

A message that is not in the archive (sent off-list or not yet received): 20121114231204.8f19082c7acc1cea2a2d794f-KZfg59tc24xl57MIdRCFDg@public.gmane.org

#63 lore raw

Re: [PATCH v3 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers

Quoted 17 lines · Kim Phillips
Quoted 13 lines · On Thu, 15 Nov 2012 15:43:40 +1100 David Gibson…

libfdt/libfdt_env.h line 27

Quoted 8 lines · Kim Phillips
libfdt/libfdt_env.h +8 -0
+#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.

Quoted 1 line

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.

Quoted 2 lines

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.

Quoted 2 lines

If you want them renamed, please suggest names - I
can't read your mind.

Well, FDT_TO_CPU would do.

Quoted 29 lines
Quoted 20 lines
Quoted 20 lines
libfdt/libfdt_env.h +15 -4
-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)
Quoted 8 lines

libfdt/libfdt_env.h line 47

Quoted 3 lines
libfdt/libfdt_env.h +3 -0
+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.

Quoted 6 lines

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.

Quoted 3 lines

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.

Signature · 4 lines
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
#64 lore raw

Re: [PATCH v4 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers

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.

---
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(-)
libfdt/fdt.h +21 -21
index 48ccfd9..45dd134 100644
@@ -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 */
libfdt/libfdt_env.h +42 -11

67 lines not on this page · raw message

Signature · 1 line
1.8.0.1
Acked-by
#65 lore raw

Re: [PATCH v4 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers

Quoted 9 lines · Kim Phillips

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.

Much better, thanks

Signature · 4 lines
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

A message that is not in the archive (sent off-list or not yet received): 20121128173301.2b52b22a39fe6c3ce5a088fb-KZfg59tc24xl57MIdRCFDg@public.gmane.org

Applied
#67 lore raw

Re: [PATCH v4 3/4] dtc/libfdt: introduce fdt types for annotation by endian checkers

Quoted 9 lines

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.

Applied.

Thanks,
jdl

#68 lore raw

PATCH v2 4/4 dtc/libfdt: uintXX_t to fdtXX_t conversion

In reply to Kim Phillips

Now that fdt types are defined and annotated, use them to make sparse happy.

---
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(-)
libfdt/fdt.c +1 -1
index e56833a..57faba3 100644
@@ -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;
libfdt/fdt_ro.c +1 -1
index 02b6d68..42da2bd 100644
@@ -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
libfdt/fdt_rw.c +2 -2
index 24437df..fdba618 100644
@@ -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;
libfdt/fdt_sw.c +2 -2
index 55ebebf..f422754 100644
@@ -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;
libfdt/fdt_wip.c +1 -1
index 6025fa1..c5bbb68 100644
@@ -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);
libfdt/libfdt.h +16 -16
index 73f4975..8e57a06 100644
@@ -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));
 }
 
 /**
Signature · 1 line
1.8.0
#69 lore raw

cover Initial sparse fix series

In reply to Kim Phillips
Quoted 23 lines · Kim Phillips

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/.

Quoted 7 lines

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.

Signature · 8 lines
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>
#70 lore raw

cover Initial sparse fix series

Quoted 29 lines · Tom Rini
Quoted 27 lines · Kim Phillips

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/.

Quoted 7 lines
Quoted 3 lines

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.

Signature · 8 lines
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>
#71 lore raw

cover Initial sparse fix series

Quoted 34 lines · On Wed, 24 Oct 2012 14:21:20 -0700 Tom Rini <[email protected]> wrote:
Quoted 33 lines · Tom Rini
Quoted 30 lines · Kim Phillips

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.

Quoted 8 lines
Quoted 3 lines

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

#72 lore raw

cover Initial sparse fix series

In reply to Kim Phillips
Quoted 7 lines · Kim Phillips

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).

Signature · 8 lines
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>
#73 lore raw

cover Initial sparse fix series

Quoted 10 lines · On Thu, 25 Oct 2012 10:46:54 -0700 Tom Rini <[email protected]> wrote:
Quoted 7 lines · Kim Phillips

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.

Quoted 3 lines

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.

Quoted 3 lines

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.

Quoted 2 lines

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

#74 lore raw

cover Initial sparse fix series

Quoted 13 lines · Kim Phillips
Quoted 10 lines · On Thu, 25 Oct 2012 10:46:54 -0700 Tom Rini <[email protected]> wrote:
Quoted 7 lines · Kim Phillips

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.

Quoted 5 lines
Quoted 3 lines

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.

Quoted 5 lines
Quoted 3 lines

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.

Signature · 8 lines
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>
#75 lore raw

v2 cover Initial sparse fix series

In reply to Kim Phillips

[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(-)
Signature · 1 line
1.8.0
#76 lore raw

PATCH v2 1/25 include/linux/byteorder: import latest endian definitions from linux

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]')

---
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(-)
arch/arm/cpu/arm1176/tnetv107x/clock.c +0 -4
index e26fec1..16876ae 100644
@@ -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,
arch/powerpc/include/asm/ppc4xx-sdram.h +1 -1
index d570d79..e35d9b6 100644
@@ -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);
arch/powerpc/lib/bootm.c +1 -1
index 53dc4df..ac5bd6d 100644
@@ -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;
drivers/mtd/ubi/crc32.c +2 -10
index a7e26b0..ab439b3 100644
@@ -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)
drivers/net/macb.c +0 -2
index 0e1ced7..8bacbda 100644
@@ -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
drivers/net/smc91111.c +0 -2
index 6dc7ad5..1357ede 100644
@@ -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;
drivers/serial/s3c64xx.c +0 -2
index ea8d734..f53c2bf 100644
@@ -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
fs/yaffs2/ydirectenv.h +0 -2
index c912b09..c2ffbfd 100644
@@ -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)
include/common.h +0 -4
index b23e90b..5e3c5ee 100644
@@ -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>
include/linux/byteorder/big_endian.h +88 -47

151 lines not on this page · raw message

include/linux/byteorder/little_endian.h +87 -46

147 lines not on this page · raw message

include/linux/byteorder/swab.h +3 -3
index b1d570e..bb4a046 100644
@@ -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);
 }
Signature · 1 line
1.8.0
#77 lore raw

PATCH v2 2/25 include/linux/compat.h: fix warning: preprocessor token {__iomem, __user} redefined

In reply to Kim Phillips

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".

---
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(-)
include/linux/compat.h +0 -3
index 593b07f..e1338bf 100644
@@ -1,9 +1,6 @@
 #ifndef _LINUX_COMPAT_H_
 #define _LINUX_COMPAT_H_
 
-#define __user
-#define __iomem
-
 #define ndelay(x)	udelay(1)
 
 #define printk	printf
include/linux/mtd/mtd-abi.h +2 -0
index 5991157..8bdd231 100644
@@ -11,6 +11,8 @@
 #include <linux/compat.h>
 #endif
 
+#include <linux/compiler.h>
+
 struct erase_info_user {
 	uint32_t start;
 	uint32_t length;
Signature · 1 line
1.8.0
#78 lore raw

PATCH v2 3/25 include/linux/unaligned/generic.h: fix warning: preprocessor token __force redefined

In reply to Kim Phillips

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".

---
v2: no change

 include/linux/unaligned/generic.h | 3 ---
 1 file changed, 3 deletions(-)
include/linux/unaligned/generic.h +0 -3
index cc688e1..02d97ff 100644
@@ -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
Signature · 1 line
1.8.0
#79 lore raw

PATCH v2 4/25 include/linux/stddef.h: avoid 'warning: preprocessor token offsetof redefined'

In reply to Kim Phillips

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)

---
v2: no change

 include/linux/stddef.h | 2 ++
 1 file changed, 2 insertions(+)
include/linux/stddef.h +2 -0
index 81e34c2..c540f61 100644
@@ -12,7 +12,9 @@
 #include <linux/types.h>
 #endif
 
+#ifndef __CHECKER__
 #undef offsetof
 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
 
 #endif
Signature · 1 line
1.8.0
#80 lore raw

PATCH v2 5/25 arch/powerpc/include/asm/io.h: fix warning: preprocessor token __iomem redefined

In reply to Kim Phillips

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'.

---
v2: no change

 arch/powerpc/include/asm/io.h | 1 -
 1 file changed, 1 deletion(-)
arch/powerpc/include/asm/io.h +0 -1
index 9e20861..1f12c29 100644
@@ -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)
Signature · 1 line
1.8.0
#81 lore raw

PATCH v2 6/25 arch/powerpc/lib/extable.c: sparse fix

In reply to Kim Phillips

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.

---
v2: doesn't make it static, it just deletes it

 arch/powerpc/lib/extable.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
arch/powerpc/lib/extable.c +1 -4
index 7408d5c..60983ae 100644
@@ -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;
 
Signature · 1 line
1.8.0
#82 lore raw

PATCH v2 7/25 arch/powerpc/lib/board.c, *traps.c: sparse fixes

In reply to Kim Phillips

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

---
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(-)
arch/powerpc/cpu/74xx_7xx/traps.c +9 -19
index 7ae81eb..a33e283 100644
@@ -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;
arch/powerpc/cpu/mpc512x/traps.c +51 -59

214 lines not on this page · raw message

arch/powerpc/cpu/mpc5xx/traps.c +3 -3
index e3ce11b..90da73b 100644
@@ -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]);
arch/powerpc/cpu/mpc5xxx/traps.c +10 -19
index 5972f34..438f8d3 100644
@@ -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;
arch/powerpc/cpu/mpc8220/traps.c +57 -62

235 lines not on this page · raw message

arch/powerpc/cpu/mpc824x/traps.c +10 -19
index 163b983..9bcdd8f 100644
@@ -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;
arch/powerpc/cpu/mpc8260/traps.c +10 -19
index c116cdf..e1e6845 100644
@@ -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;
arch/powerpc/cpu/mpc83xx/traps.c +10 -19
index 9d71b8b..53a1062 100644
@@ -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;
arch/powerpc/cpu/mpc85xx/traps.c +12 -24
index 7800717..476ae93 100644
@@ -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;
 }
arch/powerpc/cpu/mpc86xx/traps.c +9 -18
index 406403e..50069d5 100644
@@ -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;
 }
arch/powerpc/cpu/mpc8xx/traps.c +10 -19
index 343dced..f0ab78d 100644
@@ -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;
arch/powerpc/cpu/ppc4xx/traps.c +9 -17
index 9baa7a1..dae19cb 100644
@@ -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);
arch/powerpc/lib/board.c +6 -6
index ebf4008..1b051e1 100644
@@ -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();
Signature · 1 line
1.8.0
#83 lore raw

PATCH v2 8/25 include/image.h: sparse fixes

In reply to Kim Phillips

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.

---
v2: no changes

 include/image.h | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
include/image.h +8 -7
index 4e5863f..0a895f2 100644
@@ -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			*/
Signature · 1 line
1.8.0
#84 lore raw

PATCH v2 9/25 common/cmd_*.c: sparse fixes

In reply to Kim Phillips

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

---
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(-)
common/cmd_boot.c +3 -2
index a799b33..d3836fd 100644
@@ -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;
common/cmd_bootm.c +20 -11
index 83fa5d7..d256ddf 100644
@@ -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 */
common/cmd_console.c +1 -1
index d8cad6b..e8d9f11 100644
@@ -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();
common/cmd_date.c +1 -1
index 335bc05..0ac032c 100644
@@ -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;
common/cmd_echo.c +1 -1
index 1e499fb..52123fe 100644
@@ -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;
common/cmd_exit.c +1 -1
index f3fc8f5..0f2ee40 100644
@@ -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;
 
common/cmd_fat.c +3 -2
index c38302d..3219b54 100644
@@ -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;
common/cmd_fdt.c +12 -9
index a5e2cfc..a67a103 100644
@@ -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
 );
common/cmd_flash.c +3 -3
index e55d366..687eb68 100644
@@ -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
common/cmd_help.c +1 -1
index 3178a1a..f832a96 100644
@@ -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);
common/cmd_i2c.c +12 -8
index 82e63e1..4438db5 100644
@@ -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)
common/cmd_irq.c +2 -1
index 9f158ef..1e82883 100644
@@ -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)
common/cmd_itest.c +2 -2
index d5df758..2c8e5d0 100644
@@ -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;
 
common/cmd_load.c +151 -152

766 lines not on this page · raw message

common/cmd_mdio.c +10 -10
index 77d8df1..ff0063b 100644
@@ -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;
 
common/cmd_mem.c +14 -11
index 18f0a3f..4d64cff 100644
@@ -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;
common/cmd_misc.c +3 -3
index 3b47a0c..dc2772e 100644
@@ -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;
common/cmd_mmc.c +3 -3
index 79a1088..62a1c22 100644
@@ -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);
 
common/cmd_mp.c +11 -11
index 4b27be4..2143814 100644
@@ -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
 );
common/cmd_mtdparts.c +16 -10
index 2268829..06fc171 100644
@@ -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
 );
 /***************************************************/
common/cmd_nand.c +12 -7
index e24ed7f..4b16069 100644
@@ -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;
common/cmd_net.c +39 -37

190 lines not on this page · raw message

common/cmd_nvedit.c +16 -9
index 68c38f4..006131f 100644
@@ -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
 );
 
 /*
common/cmd_pci.c +9 -8
index a1fe519..8550b64 100644
@@ -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
 );
common/cmd_reginfo.c +2 -1
index 908876c..08a6563 100644
@@ -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;
common/cmd_sata.c +2 -2
index 3f98235..b401bd1 100644
@@ -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;
 
common/cmd_setexpr.c +1 -1
index 1b3edb7..7b140de 100644
@@ -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];
common/cmd_source.c +8 -3
index c4cde98..02a862c 100644
@@ -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
common/cmd_test.c +3 -3
index 6da06b9..d4ec186 100644
@@ -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;
 }
common/cmd_usb.c +15 -15
index c128455..8ad0b23 100644
@@ -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;
common/cmd_version.c +1 -1
index e4b2ac1..ab4c560 100644
@@ -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
common/cmd_ximg.c +9 -4
index 0414589..42a7eba 100644
@@ -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
 );
Signature · 1 line
1.8.0
#85 lore raw

PATCH v2 9/25 common/cmd_*.c: sparse fixes

Dear Kim Phillips,

Quoted 1 line · In message <[email protected]> you…

...

Quoted 1 line

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

Signature · 5 lines
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
#86 lore raw

PATCH v2 9/25 common/cmd_*.c: sparse fixes

Quoted 7 lines · On Thu, 8 Nov 2012 11:48:54 +0100 Wolfgang Denk <[email protected]> wrote:
Quoted 1 line · In message <[email protected]> you…

...

Quoted 1 line

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).

Quoted 7 lines

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.

Quoted 2 lines

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

#87 lore raw

PATCH v2 10/25 common/misc: sparse fixes

In reply to Kim Phillips

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.

---
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(-)
common/command.c +8 -1
index 50c8429..f51df26 100644
@@ -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 */
common/dlmalloc.c +18 -18
index 1d7e527..b2f0a1a 100644
@@ -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
   {
common/hush.c +16 -15
index 4c84c2f..eb6c879 100644
@@ -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;
common/image.c +4 -4
index 750a98b..df642e6 100644
@@ -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;
 }
common/main.c +5 -5
index 9507cec..592ce07 100644
@@ -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)
 
common/usb_storage.c +10 -10
index 0c2a4c7..2d92ee1 100644
@@ -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;
common/xyzModem.c +3 -3
index a1f955b..f30b002 100644
@@ -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;
Signature · 1 line
1.8.0
#88 lore raw

PATCH v2 10/25 common/misc: sparse fixes

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

Quoted 10 lines
common/command.c +2 -0
index 50c8429..f51df26 100644
@@ -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."

common/command.c int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int · line 53

Quoted 10 lines
common/command.c +6 -1
+		       " 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

#89 lore raw

PATCH 1/1 common: fix help command breakage

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.

---
tested on an 8572ds board

 common/command.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
common/command.c +12 -9
index f51df26..991a7ee 100644
@@ -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;
 	}
 	/*
Signature · 1 line
1.8.0
#90 lore raw

PATCH 1/1 common: fix help command breakage

m?n 2012-11-05 klockan 19:51 -0600 skrev Kim Phillips:

Quoted 4 lines

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

Quoted 8 lines

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.

#91 lore raw

PATCH 1/1 common: fix help command breakage

Quoted 13 lines · Henrik Nordstr?m

m?n 2012-11-05 klockan 19:51 -0600 skrev Kim Phillips:

Quoted 12 lines

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.

Quoted 9 lines

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#92 lore raw

PATCH 1/1 common: fix help command breakage

In reply to Kim Phillips

Hi,

Quoted 10 lines · On Mon, 5 Nov 2012 19:51:11 -0600 Kim Phillips <[email protected]>…

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.

Quoted 7 lines

---
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

#93 lore raw

PATCH 1/1 common: fix help command breakage

On Wed, 7 Nov 2012 23:23:50 +0100
Anatolij Gustschin <[email protected]> wrote:
...

Quoted 1 line

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

I'll drop this patch as requested by Wolfgang.

Thanks,
Anatolij

#94 lore raw

PATCH 1/1 common: fix help command breakage

Dear Anatolij,

Quoted 6 lines · In message <20121108120224.3b377929@wker> you wrote:

On Wed, 7 Nov 2012 23:23:50 +0100
Anatolij Gustschin <[email protected]> wrote:
...

Quoted 1 line

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

Signature · 4 lines
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?
#95 lore raw

PATCH 1/1 common: fix help command breakage

In reply to Kim Phillips

Dear Kim Phillips,

Quoted 10 lines · In message <[email protected]> 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.

Quoted 7 lines

---
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

Signature · 5 lines
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
#96 lore raw

PATCH 1/1 common/command.c: revert chanches from commit 199adb60

In reply to 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).

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

---
 common/command.c |    9 +--------
 1 files changed, 1 insertions(+), 8 deletions(-)
common/command.c +1 -8
index f51df26..50c8429 100644
@@ -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 */
Signature · 1 line
1.7.1
#97 lore raw

PATCH 1/1 common/command.c: revert chanches from commit 199adb60

Quoted 8 lines · On Thu, 8 Nov 2012 12:52:13 +0100 Anatolij Gustschin <[email protected]> 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).

Quoted 7 lines

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

---
 common/command.c |    9 +--------
 1 files changed, 1 insertions(+), 8 deletions(-)

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

Anatolij

#98 lore raw

PATCH 1/1 common/command.c: revert chanches from commit 199adb60

Hi Anatolij,

Quoted 13 lines · Anatolij Gustschin
Quoted 10 lines · On Thu, 8 Nov 2012 12:52:13 +0100 Anatolij Gustschin <[email protected]> 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.

Quoted 7 lines
Quoted 5 lines
---
 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,

Signature · 1 line
Albert.
#99 lore raw

PATCH 1/1 common/command.c: revert chanches from commit 199adb60

Hi Albert,

On Sat, 10 Nov 2012 12:21:55 +0100
Albert ARIBAUD <[email protected]> wrote:
...

Quoted 4 lines
Quoted 2 lines

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

#100 lore raw

PATCH 1/1 common/command.c: revert chanches from commit 199adb60

Dear Anatolij,

Quoted 8 lines · 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:
...

Quoted 2 lines
Quoted 2 lines

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

*bump*

This seems to be still missing in master.

All the best,
Rommel

Quoted 8 lines
Quoted 2 lines

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

#101 lore raw

PATCH 1/1 common/command.c: revert chanches from commit 199adb60

Hi Rommel,

On Fri, 14 Dec 2012 04:13:34 +0000 (UTC)
Rommel Custodio <[email protected]> wrote:
...

Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

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