mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers
@ 2020-06-02  8:53 Ahmad Fatoum
  2020-06-02  8:53 ` [PATCH v2 01/25] scripts: import Linux Kconfig.include Ahmad Fatoum
                   ` (25 more replies)
  0 siblings, 26 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

This series adds the last few bells and whistles to COMPILE_TEST
these drivers under sandbox as well.

The five last patches address the first few issues found by
clang-analyzer. There are still hundreds more in need of triage:
http://a3f.at/up/barebox-clang-analyzer/

(Check it out; control flow visualization is pretty! j/k to navigate)

v1 -> v2:
  - Patch stack rebased
  - Added separate <asm-generic/bitio.h> (Sascha)
  - fixed Author/Signed-off-by mismatch (Roland)
  - Drop local_irq_ stubs (Sascha)

Ahmad Fatoum (25):
  scripts: import Linux Kconfig.include
  sandbox: define CONFIG_64BIT as appropriate
  sandbox: asm: bitsperlong.h: detect bitness according to 64BIT symbol
  sandbox: support forcing 32-bit x86
  include: asm-generic: provide (in|out)_(le|be)(16|32) helpers for all
    archs
  ARM: asm/io.h: fall back to <asm-generic/bitio.h> out_be32 and friends
  sandbox: <asm/io.h>: include bitio accessors
  clocksource: arm_global_timer.c: remove unused asm/ header
  mtd: nand: orion: depend on ARM
  ddr: fsl: depend on ARM
  net: fec_imx: depend on HAS_DMA
  net: macb: depend on HAS_DMA
  sandbox: implement stub physical virtual translation
  sandbox: asm: implement stub DMA functions
  sandbox: select HAS_DMA
  ARM: atomic.h: move generic implementation to asm-generic
  include: <asm-generic/atomic.h>: remove stub IRQ save/restore
  sandbox: asm: implement <asm/atomic.h>
  usb: xhci-hcd: remove unused #include <asm/cache.h>
  usb: xhci-hcd: replace opencoded non-atomic 64-bit MMIO with lo_hi
    helper
  include: bitops: fix dead increment in fls() and ffs()
  commands: tftp: drop unused variable
  commands: test: drop dead assignment
  sandbox: os: add_image: fix memory leak
  mtd: nand: base: fix use of uninitialized struct member

 arch/arm/include/asm/atomic.h          | 108 +-----------------
 arch/arm/include/asm/io.h              |  58 +---------
 arch/sandbox/Kconfig                   |  17 +++
 arch/sandbox/Makefile                  |  12 +-
 arch/sandbox/include/asm/atomic.h      |   2 +
 arch/sandbox/include/asm/bitsperlong.h |  11 +-
 arch/sandbox/include/asm/dma.h         |  53 ++++++++-
 arch/sandbox/include/asm/io.h          |  11 ++
 arch/sandbox/os/Makefile               |   2 +-
 arch/sandbox/os/common.c               |   2 +-
 commands/test.c                        |   1 -
 commands/tftp.c                        |   8 +-
 drivers/clocksource/arm_global_timer.c |   1 -
 drivers/ddr/fsl/Kconfig                |   1 +
 drivers/mtd/nand/Kconfig               |   2 +-
 drivers/mtd/nand/nand_base.c           |   1 +
 drivers/net/Kconfig                    |   2 +
 drivers/usb/host/xhci.h                |  14 +--
 include/asm-generic/atomic.h           |  73 +++++++++++++
 include/asm-generic/bitio.h            | 145 +++++++++++++++++++++++++
 include/asm-generic/bitops/ffs.h       |   4 +-
 include/asm-generic/bitops/fls.h       |   4 +-
 scripts/Kconfig.include                |  53 +++++++++
 scripts/gcc-64bitptr.sh                |   9 ++
 scripts/gcc-version.sh                 |  20 ++++
 25 files changed, 412 insertions(+), 202 deletions(-)
 create mode 100644 arch/sandbox/include/asm/atomic.h
 create mode 100644 include/asm-generic/atomic.h
 create mode 100644 include/asm-generic/bitio.h
 create mode 100644 scripts/Kconfig.include
 create mode 100755 scripts/gcc-64bitptr.sh
 create mode 100755 scripts/gcc-version.sh

-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 01/25] scripts: import Linux Kconfig.include
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
@ 2020-06-02  8:53 ` Ahmad Fatoum
  2020-06-02  8:53 ` [PATCH v2 02/25] sandbox: define CONFIG_64BIT as appropriate Ahmad Fatoum
                   ` (24 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

With this include, we can have goodies like $(cc-option ...) and
$(success ...) inside our Kconfig files.

gcc-version also now becomes available. While unused for now, it can
allow us to selectively turn on warnings on new GCC versions, which
were previously disabled because of their too high false positive rate.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 scripts/Kconfig.include | 53 +++++++++++++++++++++++++++++++++++++++++
 scripts/gcc-version.sh  | 20 ++++++++++++++++
 2 files changed, 73 insertions(+)
 create mode 100644 scripts/Kconfig.include
 create mode 100755 scripts/gcc-version.sh

diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include
new file mode 100644
index 000000000000..496d11c92c97
--- /dev/null
+++ b/scripts/Kconfig.include
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: GPL-2.0-only
+# Kconfig helper macros
+
+# Convenient variables
+comma       := ,
+quote       := "
+squote      := '
+empty       :=
+space       := $(empty) $(empty)
+dollar      := $
+right_paren := )
+left_paren  := (
+
+# $(if-success,<command>,<then>,<else>)
+# Return <then> if <command> exits with 0, <else> otherwise.
+if-success = $(shell,{ $(1); } >/dev/null 2>&1 && echo "$(2)" || echo "$(3)")
+
+# $(success,<command>)
+# Return y if <command> exits with 0, n otherwise
+success = $(if-success,$(1),y,n)
+
+# $(failure,<command>)
+# Return n if <command> exits with 0, y otherwise
+failure = $(if-success,$(1),n,y)
+
+# $(cc-option,<flag>)
+# Return y if the compiler supports <flag>, n otherwise
+cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -S -x c /dev/null -o /dev/null)
+
+# $(ld-option,<flag>)
+# Return y if the linker supports <flag>, n otherwise
+ld-option = $(success,$(LD) -v $(1))
+
+# $(as-instr,<instr>)
+# Return y if the assembler supports <instr>, n otherwise
+as-instr = $(success,printf "%b\n" "$(1)" | $(CC) $(CLANG_FLAGS) -c -x assembler -o /dev/null -)
+
+# check if $(CC) and $(LD) exist
+$(error-if,$(failure,command -v $(CC)),compiler '$(CC)' not found)
+$(error-if,$(failure,command -v $(LD)),linker '$(LD)' not found)
+
+# Fail if the linker is gold as it's not capable of linking the kernel proper
+$(error-if,$(success, $(LD) -v | grep -q gold), gold linker '$(LD)' not supported)
+
+# gcc version including patch level
+gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh $(CC))
+
+# machine bit flags
+#  $(m32-flag): -m32 if the compiler supports it, or an empty string otherwise.
+#  $(m64-flag): -m64 if the compiler supports it, or an empty string otherwise.
+cc-option-bit = $(if-success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null,$(1))
+m32-flag := $(cc-option-bit,-m32)
+m64-flag := $(cc-option-bit,-m64)
diff --git a/scripts/gcc-version.sh b/scripts/gcc-version.sh
new file mode 100755
index 000000000000..ae353432539b
--- /dev/null
+++ b/scripts/gcc-version.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# gcc-version gcc-command
+#
+# Print the gcc version of `gcc-command' in a 5 or 6-digit form
+# such as `29503' for gcc-2.95.3, `30301' for gcc-3.3.1, etc.
+
+compiler="$*"
+
+if [ ${#compiler} -eq 0 ]; then
+	echo "Error: No compiler specified." >&2
+	printf "Usage:\n\t$0 <gcc-command>\n" >&2
+	exit 1
+fi
+
+MAJOR=$(echo __GNUC__ | $compiler -E -x c - | tail -n 1)
+MINOR=$(echo __GNUC_MINOR__ | $compiler -E -x c - | tail -n 1)
+PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -x c - | tail -n 1)
+printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 02/25] sandbox: define CONFIG_64BIT as appropriate
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
  2020-06-02  8:53 ` [PATCH v2 01/25] scripts: import Linux Kconfig.include Ahmad Fatoum
@ 2020-06-02  8:53 ` Ahmad Fatoum
  2020-06-02  8:53 ` [PATCH v2 03/25] sandbox: asm: bitsperlong.h: detect bitness according to 64BIT symbol Ahmad Fatoum
                   ` (23 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

All 64-bit architectures are supposed to define CONFIG_64BIT to support
the relevant 64-bit MMIO accessors. The sandbox architecture is a bit
of a special case, because barebox uses the toolchain default and
doesn't force a bitness. Add 64BIT as promptless symbol, which reflects
the pointer size of the target platform.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/sandbox/Kconfig    | 9 +++++++++
 scripts/gcc-64bitptr.sh | 9 +++++++++
 2 files changed, 18 insertions(+)
 create mode 100755 scripts/gcc-64bitptr.sh

diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index 6ec71a99e53f..46cfe8b4b1c8 100644
--- a/arch/sandbox/Kconfig
+++ b/arch/sandbox/Kconfig
@@ -1,3 +1,5 @@
+source "scripts/Kconfig.include"
+
 config SANDBOX
 	bool
 	select OFTREE
@@ -20,3 +22,10 @@ config SANDBOX_UNWIND
 	default y
 	select ARCH_HAS_STACK_DUMP
 	depends on UBSAN || KASAN
+
+config CC_IS_64BIT
+	def_bool $(success,$(srctree)/scripts/gcc-64bitptr.sh $(CC))
+
+config 64BIT
+	bool
+	default CC_IS_64BIT
diff --git a/scripts/gcc-64bitptr.sh b/scripts/gcc-64bitptr.sh
new file mode 100755
index 000000000000..7fb05703b813
--- /dev/null
+++ b/scripts/gcc-64bitptr.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-only
+
+cat << "END" | $@ -x c - -c -o /dev/null
+int main(void)
+{
+	return sizeof(struct { int:-!(sizeof(void *) == 8); });
+}
+END
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 03/25] sandbox: asm: bitsperlong.h: detect bitness according to 64BIT symbol
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
  2020-06-02  8:53 ` [PATCH v2 01/25] scripts: import Linux Kconfig.include Ahmad Fatoum
  2020-06-02  8:53 ` [PATCH v2 02/25] sandbox: define CONFIG_64BIT as appropriate Ahmad Fatoum
@ 2020-06-02  8:53 ` Ahmad Fatoum
  2020-06-02  8:53 ` [PATCH v2 04/25] sandbox: support forcing 32-bit x86 Ahmad Fatoum
                   ` (22 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Now that we have an accurate CONFIG_64BIT describing sandbox bitness,
we don't need to assume everything except __x86_64__ as 32-bit.

This assumes that sizeof(long) == sizeof(void *), which is assumed
anyway throughout the code base.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/sandbox/include/asm/bitsperlong.h | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/arch/sandbox/include/asm/bitsperlong.h b/arch/sandbox/include/asm/bitsperlong.h
index 00c1fc2625b2..6dc0bb0c13b2 100644
--- a/arch/sandbox/include/asm/bitsperlong.h
+++ b/arch/sandbox/include/asm/bitsperlong.h
@@ -1,10 +1 @@
-#ifndef __ASM_BITSPERLONG_H
-#define __ASM_BITSPERLONG_H
-
-#ifdef __x86_64__
-#define BITS_PER_LONG 64
-#else
-#define BITS_PER_LONG 32
-#endif
-
-#endif /* __ASM_BITSPERLONG_H */
+#include <asm-generic/bitsperlong.h>
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 04/25] sandbox: support forcing 32-bit x86
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (2 preceding siblings ...)
  2020-06-02  8:53 ` [PATCH v2 03/25] sandbox: asm: bitsperlong.h: detect bitness according to 64BIT symbol Ahmad Fatoum
@ 2020-06-02  8:53 ` Ahmad Fatoum
  2020-06-02  8:53 ` [PATCH v2 05/25] include: asm-generic: provide (in|out)_(le|be)(16|32) helpers for all archs Ahmad Fatoum
                   ` (21 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

If gcc supports multiple architectures, barebox uses only the default
when compiling for ARCH=sandbox, this is e.g. the case with compilers
that generate both 32- and 64-bit x86 executables.

There can be good reasons to force 32-bit though, e.g. to reduce memory
consumption while fuzzing or to temporarily avoid 32-to-64-bit warnings,
while running the static analyzer. Add an option for this.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/sandbox/Kconfig     |  7 +++++++
 arch/sandbox/Makefile    | 12 +++++++++++-
 arch/sandbox/os/Makefile |  2 +-
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index 46cfe8b4b1c8..789938941dcd 100644
--- a/arch/sandbox/Kconfig
+++ b/arch/sandbox/Kconfig
@@ -26,6 +26,13 @@ config SANDBOX_UNWIND
 config CC_IS_64BIT
 	def_bool $(success,$(srctree)/scripts/gcc-64bitptr.sh $(CC))
 
+config CC_HAS_LINUX_I386_SUPPORT
+	def_bool $(cc-option,-m32) && $(ld-option,-m elf_i386)
+
 config 64BIT
 	bool
+	default n if SANDBOX_LINUX_I386
 	default CC_IS_64BIT
+
+config SANDBOX_LINUX_I386
+	bool "32-bit x86 barebox" if CC_HAS_LINUX_I386_SUPPORT
diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
index 3917cade94eb..c08ea0cf83e0 100644
--- a/arch/sandbox/Makefile
+++ b/arch/sandbox/Makefile
@@ -52,11 +52,21 @@ ifeq ($(CONFIG_UBSAN),y)
 SANITIZER_LIBS += -fsanitize=undefined
 endif
 
-cmd_barebox__ = $(CC) -o $@ -Wl,-T,$(BAREBOX_LDS) \
+ifeq ($(CONFIG_SANDBOX_LINUX_I386),y)
+KBUILD_CFLAGS += -m32
+KBUILD_LDFLAGS += -m elf_i386
+KBUILD_AFLAGS += -m32
+BAREBOX_LDFLAGS += -m32
+endif
+
+BAREBOX_LDFLAGS += \
+	-Wl,-T,$(BAREBOX_LDS) \
 	-Wl,--whole-archive $(BAREBOX_OBJS) -Wl,--no-whole-archive \
 	-lrt -lpthread $(SDL_LIBS) $(FTDI1_LIBS) \
 	$(SANITIZER_LIBS)
 
+cmd_barebox__ = $(CC) -o $@ $(BAREBOX_LDFLAGS)
+
 common-y += $(BOARD) arch/sandbox/os/ arch/sandbox/lib/
 
 common-$(CONFIG_OFTREE) += arch/sandbox/dts/
diff --git a/arch/sandbox/os/Makefile b/arch/sandbox/os/Makefile
index c012c9cf0155..ed921443e0fd 100644
--- a/arch/sandbox/os/Makefile
+++ b/arch/sandbox/os/Makefile
@@ -6,7 +6,7 @@ KBUILD_CPPFLAGS = $(patsubst %,-I$(srctree)/%include,$(machdirs))
 
 KBUILD_CPPFLAGS += -DCONFIG_MALLOC_SIZE=$(CONFIG_MALLOC_SIZE)
 
-KBUILD_CFLAGS := -Wall
+KBUILD_CFLAGS += -Wall
 NOSTDINC_FLAGS :=
 
 obj-y = common.o tap.o
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 05/25] include: asm-generic: provide (in|out)_(le|be)(16|32) helpers for all archs
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (3 preceding siblings ...)
  2020-06-02  8:53 ` [PATCH v2 04/25] sandbox: support forcing 32-bit x86 Ahmad Fatoum
@ 2020-06-02  8:53 ` Ahmad Fatoum
  2020-06-02  8:53 ` [PATCH v2 06/25] ARM: asm/io.h: fall back to <asm-generic/bitio.h> out_be32 and friends Ahmad Fatoum
                   ` (20 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

These U-Boot style bitwise operations macros will be needed for
COMPILE_TEST-compiled drivers on platforms except for ARM. Add fallback
definitions there, based on the ARM ones.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/asm-generic/bitio.h | 145 ++++++++++++++++++++++++++++++++++++
 1 file changed, 145 insertions(+)
 create mode 100644 include/asm-generic/bitio.h

diff --git a/include/asm-generic/bitio.h b/include/asm-generic/bitio.h
new file mode 100644
index 000000000000..e88dbd7b8527
--- /dev/null
+++ b/include/asm-generic/bitio.h
@@ -0,0 +1,145 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#ifndef __ASM_GENERIC_BITIO_H
+#define __ASM_GENERIC_BITIO_H
+
+#include <asm-generic/io.h>
+
+/*
+ * Clear and set bits in one shot. These macros can be used to clear and
+ * set multiple bits in a register using a single call. These macros can
+ * also be used to set a multiple-bit bit pattern using a mask, by
+ * specifying the mask in the 'clear' parameter and the new bit pattern
+ * in the 'set' parameter.
+ */
+
+#ifndef out_arch
+#define out_arch(type,endian,a,v)	__raw_write##type(cpu_to_##endian(v),a)
+#endif
+
+#ifndef in_arch
+#define in_arch(type,endian,a)		endian##_to_cpu(__raw_read##type(a))
+#endif
+
+#ifndef out_le64
+#define out_le64(a,v)	out_arch(q,le64,a,v)
+#endif
+
+#ifndef out_le32
+#define out_le32(a,v)	out_arch(l,le32,a,v)
+#endif
+
+#ifndef out_le16
+#define out_le16(a,v)	out_arch(w,le16,a,v)
+#endif
+
+#ifndef in_le64
+#define in_le64(a)	in_arch(q,le64,a)
+#endif
+
+#ifndef in_le32
+#define in_le32(a)	in_arch(l,le32,a)
+#endif
+
+#ifndef in_le16
+#define in_le16(a)	in_arch(w,le16,a)
+#endif
+
+#ifndef out_be32
+#define out_be32(a,v)	out_arch(l,be32,a,v)
+#endif
+
+#ifndef out_be16
+#define out_be16(a,v)	out_arch(w,be16,a,v)
+#endif
+
+#ifndef in_be32
+#define in_be32(a)	in_arch(l,be32,a)
+#endif
+
+#ifndef in_be16
+#define in_be16(a)	in_arch(w,be16,a)
+#endif
+
+#ifndef out_8
+#define out_8(a,v)	__raw_writeb(v,a)
+#endif
+
+#ifndef in_8
+#define in_8(a)		__raw_readb(a)
+#endif
+
+#ifndef clrbits
+#define clrbits(type, addr, clear) \
+	out_##type((addr), in_##type(addr) & ~(clear))
+#endif
+
+#ifndef setbits
+#define setbits(type, addr, set) \
+	out_##type((addr), in_##type(addr) | (set))
+#endif
+
+#define clrsetbits(type, addr, clear, set) \
+	out_##type((addr), (in_##type(addr) & ~(clear)) | (set))
+
+#ifndef clrbits_be32
+#define clrbits_be32(addr, clear) clrbits(be32, addr, clear)
+#endif
+
+#ifndef setbits_be32
+#define setbits_be32(addr, set) setbits(be32, addr, set)
+#endif
+
+#ifndef clrsetbits_be32
+#define clrsetbits_be32(addr, clear, set) clrsetbits(be32, addr, clear, set)
+#endif
+
+#ifndef clrbits_le32
+#define clrbits_le32(addr, clear) clrbits(le32, addr, clear)
+#endif
+
+#ifndef setbits_le32
+#define setbits_le32(addr, set) setbits(le32, addr, set)
+#endif
+
+#ifndef clrsetbits_le32
+#define clrsetbits_le32(addr, clear, set) clrsetbits(le32, addr, clear, set)
+#endif
+
+#ifndef clrbits_be16
+#define clrbits_be16(addr, clear) clrbits(be16, addr, clear)
+#endif
+
+#ifndef setbits_be16
+#define setbits_be16(addr, set) setbits(be16, addr, set)
+#endif
+
+#ifndef clrsetbits_be16
+#define clrsetbits_be16(addr, clear, set) clrsetbits(be16, addr, clear, set)
+#endif
+
+#ifndef clrbits_le16
+#define clrbits_le16(addr, clear) clrbits(le16, addr, clear)
+#endif
+
+#ifndef setbits_le16
+#define setbits_le16(addr, set) setbits(le16, addr, set)
+#endif
+
+#ifndef clrsetbits_le16
+#define clrsetbits_le16(addr, clear, set) clrsetbits(le16, addr, clear, set)
+#endif
+
+#ifndef clrbits_8
+#define clrbits_8(addr, clear) clrbits(8, addr, clear)
+#endif
+
+#ifndef setbits_8
+#define setbits_8(addr, set) setbits(8, addr, set)
+#endif
+
+#ifndef clrsetbits_8
+#define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
+#endif
+
+#endif /* __ASM_GENERIC_IO_H */
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 06/25] ARM: asm/io.h: fall back to <asm-generic/bitio.h> out_be32 and friends
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (4 preceding siblings ...)
  2020-06-02  8:53 ` [PATCH v2 05/25] include: asm-generic: provide (in|out)_(le|be)(16|32) helpers for all archs Ahmad Fatoum
@ 2020-06-02  8:53 ` Ahmad Fatoum
  2020-06-02  8:53 ` [PATCH v2 07/25] sandbox: <asm/io.h>: include bitio accessors Ahmad Fatoum
                   ` (19 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

With the generic implementations in place in <asm-generic/bitio.h>, we can
drop the now-duplicate ARM definitions.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/include/asm/io.h | 58 +--------------------------------------
 1 file changed, 1 insertion(+), 57 deletions(-)

diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index 56db5463410e..072b47317c03 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -4,6 +4,7 @@
 #define	IO_SPACE_LIMIT	0
 
 #include <asm-generic/io.h>
+#include <asm-generic/bitio.h>
 
 /*
  * String version of IO memory access ops:
@@ -12,63 +13,6 @@ extern void memcpy_fromio(void *, const volatile void __iomem *, size_t);
 extern void memcpy_toio(volatile void __iomem *, const void *, size_t);
 extern void memset_io(volatile void __iomem *, int, size_t);
 
-/*
- * Clear and set bits in one shot. These macros can be used to clear and
- * set multiple bits in a register using a single call. These macros can
- * also be used to set a multiple-bit bit pattern using a mask, by
- * specifying the mask in the 'clear' parameter and the new bit pattern
- * in the 'set' parameter.
- */
-
-#define out_arch(type,endian,a,v)	__raw_write##type(cpu_to_##endian(v),a)
-#define in_arch(type,endian,a)		endian##_to_cpu(__raw_read##type(a))
-
-#define out_le64(a,v)	out_arch(q,le64,a,v)
-#define out_le32(a,v)	out_arch(l,le32,a,v)
-#define out_le16(a,v)	out_arch(w,le16,a,v)
-
-#define in_le64(a)	in_arch(q,le64,a)
-#define in_le32(a)	in_arch(l,le32,a)
-#define in_le16(a)	in_arch(w,le16,a)
-
-#define out_be32(a,v)	out_arch(l,be32,a,v)
-#define out_be16(a,v)	out_arch(w,be16,a,v)
-
-#define in_be32(a)	in_arch(l,be32,a)
-#define in_be16(a)	in_arch(w,be16,a)
-
-#define out_8(a,v)	__raw_writeb(v,a)
-#define in_8(a)		__raw_readb(a)
-
-#define clrbits(type, addr, clear) \
-	out_##type((addr), in_##type(addr) & ~(clear))
-
-#define setbits(type, addr, set) \
-	out_##type((addr), in_##type(addr) | (set))
-
-#define clrsetbits(type, addr, clear, set) \
-	out_##type((addr), (in_##type(addr) & ~(clear)) | (set))
-
-#define clrbits_be32(addr, clear) clrbits(be32, addr, clear)
-#define setbits_be32(addr, set) setbits(be32, addr, set)
-#define clrsetbits_be32(addr, clear, set) clrsetbits(be32, addr, clear, set)
-
-#define clrbits_le32(addr, clear) clrbits(le32, addr, clear)
-#define setbits_le32(addr, set) setbits(le32, addr, set)
-#define clrsetbits_le32(addr, clear, set) clrsetbits(le32, addr, clear, set)
-
-#define clrbits_be16(addr, clear) clrbits(be16, addr, clear)
-#define setbits_be16(addr, set) setbits(be16, addr, set)
-#define clrsetbits_be16(addr, clear, set) clrsetbits(be16, addr, clear, set)
-
-#define clrbits_le16(addr, clear) clrbits(le16, addr, clear)
-#define setbits_le16(addr, set) setbits(le16, addr, set)
-#define clrsetbits_le16(addr, clear, set) clrsetbits(le16, addr, clear, set)
-
-#define clrbits_8(addr, clear) clrbits(8, addr, clear)
-#define setbits_8(addr, set) setbits(8, addr, set)
-#define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
-
 static inline void *phys_to_virt(unsigned long phys)
 {
 	return (void *)phys;
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 07/25] sandbox: <asm/io.h>: include bitio accessors
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (5 preceding siblings ...)
  2020-06-02  8:53 ` [PATCH v2 06/25] ARM: asm/io.h: fall back to <asm-generic/bitio.h> out_be32 and friends Ahmad Fatoum
@ 2020-06-02  8:53 ` Ahmad Fatoum
  2020-06-02  8:53 ` [PATCH v2 08/25] clocksource: arm_global_timer.c: remove unused asm/ header Ahmad Fatoum
                   ` (18 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

ARM <asm/io.h> defines the U-Boot style setbits/clrbits helpers.
Have sandbox follow suit to allow more drivers to be compile tested
there.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/sandbox/include/asm/io.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h
index cb891df5c8c8..0a07627a893d 100644
--- a/arch/sandbox/include/asm/io.h
+++ b/arch/sandbox/include/asm/io.h
@@ -4,5 +4,6 @@
 #define	IO_SPACE_LIMIT 0
 
 #include <asm-generic/io.h>
+#include <asm-generic/bitio.h>
 
 #endif /* __ASM_SANDBOX_IO_H */
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 08/25] clocksource: arm_global_timer.c: remove unused asm/ header
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (6 preceding siblings ...)
  2020-06-02  8:53 ` [PATCH v2 07/25] sandbox: <asm/io.h>: include bitio accessors Ahmad Fatoum
@ 2020-06-02  8:53 ` Ahmad Fatoum
  2020-06-02  8:53 ` [PATCH v2 09/25] mtd: nand: orion: depend on ARM Ahmad Fatoum
                   ` (17 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

We don't use the header and dropping it allows us to compile-test the
driver under non-ARM architectures. Do so.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/clocksource/arm_global_timer.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/clocksource/arm_global_timer.c b/drivers/clocksource/arm_global_timer.c
index 44e3a3c762fb..78cd72d3eb45 100644
--- a/drivers/clocksource/arm_global_timer.c
+++ b/drivers/clocksource/arm_global_timer.c
@@ -20,7 +20,6 @@
 #include <clock.h>
 #include <linux/clk.h>
 #include <io.h>
-#include <asm/system.h>
 
 #define GT_COUNTER0	0x00
 #define GT_COUNTER1	0x04
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 09/25] mtd: nand: orion: depend on ARM
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (7 preceding siblings ...)
  2020-06-02  8:53 ` [PATCH v2 08/25] clocksource: arm_global_timer.c: remove unused asm/ header Ahmad Fatoum
@ 2020-06-02  8:53 ` Ahmad Fatoum
  2020-06-02  8:53 ` [PATCH v2 10/25] ddr: fsl: " Ahmad Fatoum
                   ` (16 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

We have inline assembly in the driver, so we can't compile-test it
unmodified on non-ARM. Indicate so in the Kconfig.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/mtd/nand/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index fff9903d1d35..b81e72d6b773 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -98,7 +98,7 @@ config MTD_NAND_OMAP_ELM
 config NAND_ORION
 	bool
 	prompt "Marvell Orion NAND driver"
-	depends on ARCH_KIRKWOOD || COMPILE_TEST
+	depends on ARM && (ARCH_KIRKWOOD || COMPILE_TEST)
 	help
 	  Support for the Orion NAND controller, present in Kirkwood SoCs.
 
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 10/25] ddr: fsl: depend on ARM
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (8 preceding siblings ...)
  2020-06-02  8:53 ` [PATCH v2 09/25] mtd: nand: orion: depend on ARM Ahmad Fatoum
@ 2020-06-02  8:53 ` Ahmad Fatoum
  2020-06-02  8:53 ` [PATCH v2 11/25] net: fec_imx: depend on HAS_DMA Ahmad Fatoum
                   ` (15 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

We have inline assembly in the driver, so we can't compile-test it
unmodified on non-ARM. Indicate so in the Kconfig.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/ddr/fsl/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/ddr/fsl/Kconfig b/drivers/ddr/fsl/Kconfig
index 09920bb8632e..b12bf8f7776f 100644
--- a/drivers/ddr/fsl/Kconfig
+++ b/drivers/ddr/fsl/Kconfig
@@ -1,5 +1,6 @@
 config DDR_FSL
 	bool "Freescale DDR support" if COMPILE_TEST
+	depends on ARM
 
 if DDR_FSL
 
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 11/25] net: fec_imx: depend on HAS_DMA
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (9 preceding siblings ...)
  2020-06-02  8:53 ` [PATCH v2 10/25] ddr: fsl: " Ahmad Fatoum
@ 2020-06-02  8:53 ` Ahmad Fatoum
  2020-06-02  8:53 ` [PATCH v2 12/25] net: macb: " Ahmad Fatoum
                   ` (14 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The driver makes use of dma_alloc_coherent and brethren. Depend on
HAS_DMA to be sure, we don't run into link errors when compile-testing.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/net/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 9bb498527557..ee8a716d9a3d 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -155,6 +155,7 @@ config DRIVER_NET_ETHOC
 config DRIVER_NET_FEC_IMX
 	bool "i.MX FEC Ethernet driver"
 	depends on ARCH_HAS_FEC_IMX || COMPILE_TEST
+	depends on HAS_DMA
 	select PHYLIB
 
 config DRIVER_NET_FSL_FMAN
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 12/25] net: macb: depend on HAS_DMA
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (10 preceding siblings ...)
  2020-06-02  8:53 ` [PATCH v2 11/25] net: fec_imx: depend on HAS_DMA Ahmad Fatoum
@ 2020-06-02  8:53 ` Ahmad Fatoum
  2020-06-02  8:54 ` [PATCH v2 13/25] sandbox: implement stub physical virtual translation Ahmad Fatoum
                   ` (13 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The driver makes use of dma_alloc_coherent and brethren. Depend on
HAS_DMA to be sure, we don't run into link errors when compile-testing.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/net/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index ee8a716d9a3d..76509a52a1c7 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -181,6 +181,7 @@ config DRIVER_NET_KS8851_MLL
 config DRIVER_NET_MACB
 	bool "macb Ethernet driver"
 	depends on HAS_MACB || COMPILE_TEST
+	depends on HAS_DMA
 	select PHYLIB
 
 config DRIVER_NET_MICREL
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 13/25] sandbox: implement stub physical virtual translation
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (11 preceding siblings ...)
  2020-06-02  8:53 ` [PATCH v2 12/25] net: macb: " Ahmad Fatoum
@ 2020-06-02  8:54 ` Ahmad Fatoum
  2020-06-02  8:54 ` [PATCH v2 14/25] sandbox: asm: implement stub DMA functions Ahmad Fatoum
                   ` (12 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:54 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

For compile-testing drivers that use DMA operations under sandbox,
we want stub implementations of these. Provide them.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/sandbox/include/asm/io.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h
index 0a07627a893d..6a0e77aead42 100644
--- a/arch/sandbox/include/asm/io.h
+++ b/arch/sandbox/include/asm/io.h
@@ -6,4 +6,14 @@
 #include <asm-generic/io.h>
 #include <asm-generic/bitio.h>
 
+static inline void *phys_to_virt(unsigned long phys)
+{
+       return (void *)phys;
+}
+
+static inline unsigned long virt_to_phys(volatile void *mem)
+{
+       return (unsigned long)mem;
+}
+
 #endif /* __ASM_SANDBOX_IO_H */
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 14/25] sandbox: asm: implement stub DMA functions
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (12 preceding siblings ...)
  2020-06-02  8:54 ` [PATCH v2 13/25] sandbox: implement stub physical virtual translation Ahmad Fatoum
@ 2020-06-02  8:54 ` Ahmad Fatoum
  2020-06-02  8:54 ` [PATCH v2 15/25] sandbox: select HAS_DMA Ahmad Fatoum
                   ` (11 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:54 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

For compile-testing drivers that use DMA operations under sandbox,
we want stub implementations of these. Provide them.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/sandbox/include/asm/dma.h | 53 +++++++++++++++++++++++++++++++++-
 1 file changed, 52 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/include/asm/dma.h b/arch/sandbox/include/asm/dma.h
index 459536779e0a..5e72d8e7df2d 100644
--- a/arch/sandbox/include/asm/dma.h
+++ b/arch/sandbox/include/asm/dma.h
@@ -8,6 +8,57 @@
 #ifndef __ASM_DMA_H
 #define __ASM_DMA_H
 
-/* empty*/
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <driver.h>
+
+#define dma_alloc dma_alloc
+static inline void *dma_alloc(size_t size)
+{
+	return xmemalign(64, ALIGN(size, 64));
+}
+
+static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
+{
+	void *ret = xmemalign(4096, size);
+	if (dma_handle)
+		*dma_handle = (dma_addr_t)ret;
+
+	memset(ret, 0, size);
+
+	return ret;
+}
+
+static inline void *dma_alloc_writecombine(size_t size, dma_addr_t *dma_handle)
+{
+	return dma_alloc_coherent(size, dma_handle);
+}
+
+static inline void dma_free_coherent(void *mem, dma_addr_t dma_handle,
+				     size_t size)
+{
+	free(mem);
+}
+
+static inline dma_addr_t dma_map_single(struct device_d *dev, void *ptr, size_t size,
+					enum dma_data_direction dir)
+{
+	return (dma_addr_t)ptr;
+}
+
+static inline void dma_unmap_single(struct device_d *dev, dma_addr_t addr, size_t size,
+				    enum dma_data_direction dir)
+{
+}
+
+static inline void dma_sync_single_for_cpu(dma_addr_t address, size_t size,
+					   enum dma_data_direction dir)
+{
+}
+
+static inline void dma_sync_single_for_device(dma_addr_t address, size_t size,
+					      enum dma_data_direction dir)
+{
+}
 
 #endif /* __ASM_DMA_H */
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 15/25] sandbox: select HAS_DMA
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (13 preceding siblings ...)
  2020-06-02  8:54 ` [PATCH v2 14/25] sandbox: asm: implement stub DMA functions Ahmad Fatoum
@ 2020-06-02  8:54 ` Ahmad Fatoum
  2020-06-02  8:54 ` [PATCH v2 16/25] ARM: atomic.h: move generic implementation to asm-generic Ahmad Fatoum
                   ` (10 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:54 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

With the DMA stubs in place, we can indicate HAS_DMA in good conscience.
Do so.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/sandbox/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index 789938941dcd..3f10709021a7 100644
--- a/arch/sandbox/Kconfig
+++ b/arch/sandbox/Kconfig
@@ -6,6 +6,7 @@ config SANDBOX
 	select GPIOLIB
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
 	select HAVE_ARCH_KASAN
+	select HAS_DMA
 	default y
 
 config ARCH_TEXT_BASE
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 16/25] ARM: atomic.h: move generic implementation to asm-generic
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (14 preceding siblings ...)
  2020-06-02  8:54 ` [PATCH v2 15/25] sandbox: select HAS_DMA Ahmad Fatoum
@ 2020-06-02  8:54 ` Ahmad Fatoum
  2020-06-02  8:54 ` [PATCH v2 17/25] include: <asm-generic/atomic.h>: remove stub IRQ save/restore Ahmad Fatoum
                   ` (9 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:54 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

For easier code-sharing, the UBIFS code still uses the Linux atomic
accessors.  Make porting it to sandbox easier, by providing these
functions for all platforms.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/include/asm/atomic.h | 108 +---------------------------------
 include/asm-generic/atomic.h  |  99 +++++++++++++++++++++++++++++++
 2 files changed, 102 insertions(+), 105 deletions(-)
 create mode 100644 include/asm-generic/atomic.h

diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
index 9b79506b594b..cfc359a5ce59 100644
--- a/arch/arm/include/asm/atomic.h
+++ b/arch/arm/include/asm/atomic.h
@@ -1,111 +1,9 @@
-/*
- *  linux/include/asm-arm/atomic.h
- *
- *  Copyright (c) 1996 Russell King.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- *  Changelog:
- *   27-06-1996	RMK	Created
- *   13-04-1997	RMK	Made functions atomic!
- *   07-12-1997	RMK	Upgraded for v2.1.
- *   26-08-1998	PJB	Added #ifdef __KERNEL__
- */
+// SPDX-License-Identifier: GPL-2.0-only
+
 #ifndef __ASM_ARM_ATOMIC_H
 #define __ASM_ARM_ATOMIC_H
 
-#ifdef CONFIG_SMP
-#error SMP not supported
-#endif
-
-typedef struct { volatile int counter; } atomic_t;
-
-#define ATOMIC_INIT(i)	{ (i) }
-
-#ifdef __KERNEL__
 #include <asm/proc-armv/system.h>
+#include <asm-generic/atomic.h>
 
-#define atomic_read(v)	((v)->counter)
-#define atomic_set(v,i)	(((v)->counter) = (i))
-
-static inline void atomic_add(int i, volatile atomic_t *v)
-{
-	unsigned long flags = 0;
-
-	local_irq_save(flags);
-	v->counter += i;
-	local_irq_restore(flags);
-}
-
-static inline void atomic_sub(int i, volatile atomic_t *v)
-{
-	unsigned long flags = 0;
-
-	local_irq_save(flags);
-	v->counter -= i;
-	local_irq_restore(flags);
-}
-
-static inline void atomic_inc(volatile atomic_t *v)
-{
-	unsigned long flags = 0;
-
-	local_irq_save(flags);
-	v->counter += 1;
-	local_irq_restore(flags);
-}
-
-static inline void atomic_dec(volatile atomic_t *v)
-{
-	unsigned long flags = 0;
-
-	local_irq_save(flags);
-	v->counter -= 1;
-	local_irq_restore(flags);
-}
-
-static inline int atomic_dec_and_test(volatile atomic_t *v)
-{
-	unsigned long flags = 0;
-	int val;
-
-	local_irq_save(flags);
-	val = v->counter;
-	v->counter = val -= 1;
-	local_irq_restore(flags);
-
-	return val == 0;
-}
-
-static inline int atomic_add_negative(int i, volatile atomic_t *v)
-{
-	unsigned long flags = 0;
-	int val;
-
-	local_irq_save(flags);
-	val = v->counter;
-	v->counter = val += i;
-	local_irq_restore(flags);
-
-	return val < 0;
-}
-
-static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
-{
-	unsigned long flags = 0;
-
-	local_irq_save(flags);
-	*addr &= ~mask;
-	local_irq_restore(flags);
-}
-
-/* Atomic operations are already serializing on ARM */
-#define smp_mb__before_atomic_dec()	barrier()
-#define smp_mb__after_atomic_dec()	barrier()
-#define smp_mb__before_atomic_inc()	barrier()
-#define smp_mb__after_atomic_inc()	barrier()
-
-#endif
 #endif
diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
new file mode 100644
index 000000000000..6357b66a5304
--- /dev/null
+++ b/include/asm-generic/atomic.h
@@ -0,0 +1,99 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ *  based on linux/include/asm-arm/atomic.h
+ *
+ *  Copyright (c) 1996 Russell King.
+ */
+
+#ifndef __ASM_GENERIC_ATOMIC_H
+#define __ASM_GENERIC_ATOMIC_H
+
+#ifdef CONFIG_SMP
+#error SMP not supported
+#endif
+
+typedef struct { volatile int counter; } atomic_t;
+
+#define ATOMIC_INIT(i)	{ (i) }
+
+#define atomic_read(v)	((v)->counter)
+#define atomic_set(v,i)	(((v)->counter) = (i))
+
+static inline void atomic_add(int i, volatile atomic_t *v)
+{
+	unsigned long flags = 0;
+
+	local_irq_save(flags);
+	v->counter += i;
+	local_irq_restore(flags);
+}
+
+static inline void atomic_sub(int i, volatile atomic_t *v)
+{
+	unsigned long flags = 0;
+
+	local_irq_save(flags);
+	v->counter -= i;
+	local_irq_restore(flags);
+}
+
+static inline void atomic_inc(volatile atomic_t *v)
+{
+	unsigned long flags = 0;
+
+	local_irq_save(flags);
+	v->counter += 1;
+	local_irq_restore(flags);
+}
+
+static inline void atomic_dec(volatile atomic_t *v)
+{
+	unsigned long flags = 0;
+
+	local_irq_save(flags);
+	v->counter -= 1;
+	local_irq_restore(flags);
+}
+
+static inline int atomic_dec_and_test(volatile atomic_t *v)
+{
+	unsigned long flags = 0;
+	int val;
+
+	local_irq_save(flags);
+	val = v->counter;
+	v->counter = val -= 1;
+	local_irq_restore(flags);
+
+	return val == 0;
+}
+
+static inline int atomic_add_negative(int i, volatile atomic_t *v)
+{
+	unsigned long flags = 0;
+	int val;
+
+	local_irq_save(flags);
+	val = v->counter;
+	v->counter = val += i;
+	local_irq_restore(flags);
+
+	return val < 0;
+}
+
+static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
+{
+	unsigned long flags = 0;
+
+	local_irq_save(flags);
+	*addr &= ~mask;
+	local_irq_restore(flags);
+}
+
+/* Atomic operations are already serializing on ARM */
+#define smp_mb__before_atomic_dec()	barrier()
+#define smp_mb__after_atomic_dec()	barrier()
+#define smp_mb__before_atomic_inc()	barrier()
+#define smp_mb__after_atomic_inc()	barrier()
+
+#endif
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 17/25] include: <asm-generic/atomic.h>: remove stub IRQ save/restore
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (15 preceding siblings ...)
  2020-06-02  8:54 ` [PATCH v2 16/25] ARM: atomic.h: move generic implementation to asm-generic Ahmad Fatoum
@ 2020-06-02  8:54 ` Ahmad Fatoum
  2020-06-02  8:54 ` [PATCH v2 18/25] sandbox: asm: implement <asm/atomic.h> Ahmad Fatoum
                   ` (8 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:54 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

For an architecture to use <asm-generic/atomic.h>, it must define
local_irq_save() and local_irq_restore(). Instead of having every
platform define duplicate their stub definition, just drop them
altogether, so <asm-generic/atomic.h> can be used freestanding.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/asm-generic/atomic.h | 26 --------------------------
 1 file changed, 26 deletions(-)

diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
index 6357b66a5304..449cecaabc74 100644
--- a/include/asm-generic/atomic.h
+++ b/include/asm-generic/atomic.h
@@ -21,73 +21,47 @@ typedef struct { volatile int counter; } atomic_t;
 
 static inline void atomic_add(int i, volatile atomic_t *v)
 {
-	unsigned long flags = 0;
-
-	local_irq_save(flags);
 	v->counter += i;
-	local_irq_restore(flags);
 }
 
 static inline void atomic_sub(int i, volatile atomic_t *v)
 {
-	unsigned long flags = 0;
-
-	local_irq_save(flags);
 	v->counter -= i;
-	local_irq_restore(flags);
 }
 
 static inline void atomic_inc(volatile atomic_t *v)
 {
-	unsigned long flags = 0;
-
-	local_irq_save(flags);
 	v->counter += 1;
-	local_irq_restore(flags);
 }
 
 static inline void atomic_dec(volatile atomic_t *v)
 {
-	unsigned long flags = 0;
-
-	local_irq_save(flags);
 	v->counter -= 1;
-	local_irq_restore(flags);
 }
 
 static inline int atomic_dec_and_test(volatile atomic_t *v)
 {
-	unsigned long flags = 0;
 	int val;
 
-	local_irq_save(flags);
 	val = v->counter;
 	v->counter = val -= 1;
-	local_irq_restore(flags);
 
 	return val == 0;
 }
 
 static inline int atomic_add_negative(int i, volatile atomic_t *v)
 {
-	unsigned long flags = 0;
 	int val;
 
-	local_irq_save(flags);
 	val = v->counter;
 	v->counter = val += i;
-	local_irq_restore(flags);
 
 	return val < 0;
 }
 
 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
 {
-	unsigned long flags = 0;
-
-	local_irq_save(flags);
 	*addr &= ~mask;
-	local_irq_restore(flags);
 }
 
 /* Atomic operations are already serializing on ARM */
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 18/25] sandbox: asm: implement <asm/atomic.h>
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (16 preceding siblings ...)
  2020-06-02  8:54 ` [PATCH v2 17/25] include: <asm-generic/atomic.h>: remove stub IRQ save/restore Ahmad Fatoum
@ 2020-06-02  8:54 ` Ahmad Fatoum
  2020-06-02  8:54 ` [PATCH v2 19/25] usb: xhci-hcd: remove unused #include <asm/cache.h> Ahmad Fatoum
                   ` (7 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:54 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

For easier code-sharing, the UBIFS code still uses the Kernel's
atomic accessors. Provide a sandbox <asm/atomic.h> header, so we
can compile-test UBI under sandbox.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/sandbox/include/asm/atomic.h | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 arch/sandbox/include/asm/atomic.h

diff --git a/arch/sandbox/include/asm/atomic.h b/arch/sandbox/include/asm/atomic.h
new file mode 100644
index 000000000000..af12dee13089
--- /dev/null
+++ b/arch/sandbox/include/asm/atomic.h
@@ -0,0 +1,2 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include <asm-generic/atomic.h>
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 19/25] usb: xhci-hcd: remove unused #include <asm/cache.h>
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (17 preceding siblings ...)
  2020-06-02  8:54 ` [PATCH v2 18/25] sandbox: asm: implement <asm/atomic.h> Ahmad Fatoum
@ 2020-06-02  8:54 ` Ahmad Fatoum
  2020-06-02  8:54 ` [PATCH v2 20/25] usb: xhci-hcd: replace opencoded non-atomic 64-bit MMIO with lo_hi helper Ahmad Fatoum
                   ` (6 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:54 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

We don't use anything defined within, so drop it.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/usb/host/xhci.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 886cbef14c3a..1a3f7e7642bc 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -17,7 +17,6 @@
 #define HOST_XHCI_H_
 
 #include <asm/types.h>
-#include <asm/cache.h>
 #include <io.h>
 #include <linux/list.h>
 
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 20/25] usb: xhci-hcd: replace opencoded non-atomic 64-bit MMIO with lo_hi helper
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (18 preceding siblings ...)
  2020-06-02  8:54 ` [PATCH v2 19/25] usb: xhci-hcd: remove unused #include <asm/cache.h> Ahmad Fatoum
@ 2020-06-02  8:54 ` Ahmad Fatoum
  2020-06-02  8:54 ` [PATCH v2 21/25] include: bitops: fix dead increment in fls() and ffs() Ahmad Fatoum
                   ` (5 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:54 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Commit 3c5317e9046 ("usb: xhci-hcd: Make use of lo_hi_readq/writeq()")
had made use of lo_hi_readq/writeq() to implement xhci_read/write_64(),
like Linux does, but this was removed in commit fddd1c7c51a8
("usb: host: remove xhci driver"). Reinstate it to make code clearer.

No functional change.

[Note: Linux doesn't use any readq/writeq, but does two 32-bit access
 always, even on 64-bit systems]

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/usb/host/xhci.h | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 1a3f7e7642bc..9ffbb103d562 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -18,6 +18,7 @@
 
 #include <asm/types.h>
 #include <io.h>
+#include <io-64-nonatomic-lo-hi.h>
 #include <linux/list.h>
 
 #define MAX_EP_CTX_NUM		31
@@ -1112,10 +1113,7 @@ static inline u64 xhci_readq(__le64 volatile *regs)
 #if BITS_PER_LONG == 64
 	return readq(regs);
 #else
-	__u32 *ptr = (__u32 *)regs;
-	u64 val_lo = readl(ptr);
-	u64 val_hi = readl(ptr + 1);
-	return val_lo + (val_hi << 32);
+	return lo_hi_readq(regs);
 #endif
 }
 
@@ -1124,12 +1122,7 @@ static inline void xhci_writeq(__le64 volatile *regs, const u64 val)
 #if BITS_PER_LONG == 64
 	writeq(val, regs);
 #else
-	__u32 *ptr = (__u32 *)regs;
-	u32 val_lo = lower_32_bits(val);
-	/* FIXME */
-	u32 val_hi = upper_32_bits(val);
-	writel(val_lo, ptr);
-	writel(val_hi, ptr + 1);
+	lo_hi_writeq(val, regs);
 #endif
 }
 
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 21/25] include: bitops: fix dead increment in fls() and ffs()
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (19 preceding siblings ...)
  2020-06-02  8:54 ` [PATCH v2 20/25] usb: xhci-hcd: replace opencoded non-atomic 64-bit MMIO with lo_hi helper Ahmad Fatoum
@ 2020-06-02  8:54 ` Ahmad Fatoum
  2020-06-02  8:54 ` [PATCH v2 22/25] commands: tftp: drop unused variable Ahmad Fatoum
                   ` (4 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:54 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Static analyzers trip over this dead increment. It arguably
doesn't improve readability, so just drop the dead code.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/asm-generic/bitops/ffs.h | 4 +---
 include/asm-generic/bitops/fls.h | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/include/asm-generic/bitops/ffs.h b/include/asm-generic/bitops/ffs.h
index fbbb43af7dc0..0ff1b8b7c79a 100644
--- a/include/asm-generic/bitops/ffs.h
+++ b/include/asm-generic/bitops/ffs.h
@@ -31,10 +31,8 @@ static inline int ffs(int x)
 		x >>= 2;
 		r += 2;
 	}
-	if (!(x & 1)) {
-		x >>= 1;
+	if (!(x & 1))
 		r += 1;
-	}
 	return r;
 }
 
diff --git a/include/asm-generic/bitops/fls.h b/include/asm-generic/bitops/fls.h
index 850859bc5069..cc0d3ca95aaa 100644
--- a/include/asm-generic/bitops/fls.h
+++ b/include/asm-generic/bitops/fls.h
@@ -31,10 +31,8 @@ static inline int fls(int x)
 		x <<= 2;
 		r -= 2;
 	}
-	if (!(x & 0x80000000u)) {
-		x <<= 1;
+	if (!(x & 0x80000000u))
 		r -= 1;
-	}
 	return r;
 }
 
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 22/25] commands: tftp: drop unused variable
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (20 preceding siblings ...)
  2020-06-02  8:54 ` [PATCH v2 21/25] include: bitops: fix dead increment in fls() and ffs() Ahmad Fatoum
@ 2020-06-02  8:54 ` Ahmad Fatoum
  2020-06-02  8:54 ` [PATCH v2 23/25] commands: test: drop dead assignment Ahmad Fatoum
                   ` (3 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:54 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The flags variables is not used. Drop it.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 commands/tftp.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/commands/tftp.c b/commands/tftp.c
index 1569819844bf..48ff00c6217c 100644
--- a/commands/tftp.c
+++ b/commands/tftp.c
@@ -20,7 +20,6 @@ static int do_tftpb(int argc, char *argv[])
 {
 	char *source, *dest, *freep;
 	int opt;
-	unsigned long flags;
 	int tftp_push = 0;
 	int ret;
 	IPaddr_t ip;
@@ -46,13 +45,10 @@ static int do_tftpb(int argc, char *argv[])
 	else
 		dest = argv[optind];
 
-	if (tftp_push) {
+	if (tftp_push)
 		dest = freep = basprintf("%s/%s", TFTP_MOUNT_PATH, dest);
-		flags = O_RDONLY;
-	} else {
+	else
 		source = freep = basprintf("%s/%s", TFTP_MOUNT_PATH, source);
-		flags = O_WRONLY | O_CREAT;
-	}
 
 	if (!freep)
 		return -ENOMEM;
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 23/25] commands: test: drop dead assignment
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (21 preceding siblings ...)
  2020-06-02  8:54 ` [PATCH v2 22/25] commands: tftp: drop unused variable Ahmad Fatoum
@ 2020-06-02  8:54 ` Ahmad Fatoum
  2020-06-02  8:54 ` [PATCH v2 24/25] sandbox: os: add_image: fix memory leak Ahmad Fatoum
                   ` (2 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:54 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

last_expr is set to a different value few lines later. Drop the dead
assignment.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 commands/test.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/commands/test.c b/commands/test.c
index 505b7c56b1a4..c845cec01789 100644
--- a/commands/test.c
+++ b/commands/test.c
@@ -86,7 +86,6 @@ static int do_test(int argc, char *argv[])
 	if (argc < 2)
 		return 1;
 
-	last_expr = 0;
 	left = argc - 1;
 	ap = argv + 1;
 
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 24/25] sandbox: os: add_image: fix memory leak
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (22 preceding siblings ...)
  2020-06-02  8:54 ` [PATCH v2 23/25] commands: test: drop dead assignment Ahmad Fatoum
@ 2020-06-02  8:54 ` Ahmad Fatoum
  2020-06-02  8:54 ` [PATCH v2 25/25] mtd: nand: base: fix use of uninitialized struct member Ahmad Fatoum
  2020-06-03  8:04 ` [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Sascha Hauer
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:54 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

devname is strdup'd few lines later, so remove the earlier strdup.
The pointer isn't stored anywhere persistent in between.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/sandbox/os/common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index e67ea14138c0..382a92304020 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -236,7 +236,7 @@ static int add_image(char *str, char *devname_template, int *devname_number)
 		filename = devname;
 		snprintf(tmp, sizeof(tmp),
 			 devname_template, (*devname_number)++);
-		devname = strdup(tmp);
+		devname = tmp;
 	}
 
 	printf("add %s backed by file %s%s\n", devname,
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 25/25] mtd: nand: base: fix use of uninitialized struct member
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (23 preceding siblings ...)
  2020-06-02  8:54 ` [PATCH v2 24/25] sandbox: os: add_image: fix memory leak Ahmad Fatoum
@ 2020-06-02  8:54 ` Ahmad Fatoum
  2020-06-03  8:04 ` [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Sascha Hauer
  25 siblings, 0 replies; 27+ messages in thread
From: Ahmad Fatoum @ 2020-06-02  8:54 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

ooblen is read in nand_do_read_ops, despite never having been assigned a
value. Because ooblen is used to indicate how many bytes of oobbuf are
usable and oobbuf is NULL, use 0 as initial value.

Found on ARCH=sandbox using clang-analyzer.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/mtd/nand/nand_base.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 00f0f7588434..3f4c787f49da 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1688,6 +1688,7 @@ static int nand_read(struct mtd_info *mtd, loff_t from, size_t len,
 	nand_get_device(mtd, FL_READING);
 	ops.len = len;
 	ops.datbuf = buf;
+	ops.ooblen = 0;
 	ops.oobbuf = NULL;
 	ops.mode = MTD_OPS_PLACE_OOB;
 	ret = nand_do_read_ops(mtd, from, &ops);
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers
  2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
                   ` (24 preceding siblings ...)
  2020-06-02  8:54 ` [PATCH v2 25/25] mtd: nand: base: fix use of uninitialized struct member Ahmad Fatoum
@ 2020-06-03  8:04 ` Sascha Hauer
  25 siblings, 0 replies; 27+ messages in thread
From: Sascha Hauer @ 2020-06-03  8:04 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Tue, Jun 02, 2020 at 10:53:47AM +0200, Ahmad Fatoum wrote:
> This series adds the last few bells and whistles to COMPILE_TEST
> these drivers under sandbox as well.
> 
> The five last patches address the first few issues found by
> clang-analyzer. There are still hundreds more in need of triage:
> http://a3f.at/up/barebox-clang-analyzer/
> 
> (Check it out; control flow visualization is pretty! j/k to navigate)
> 
> v1 -> v2:
>   - Patch stack rebased
>   - Added separate <asm-generic/bitio.h> (Sascha)
>   - fixed Author/Signed-off-by mismatch (Roland)
>   - Drop local_irq_ stubs (Sascha)

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2020-06-03  8:04 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-02  8:53 [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
2020-06-02  8:53 ` [PATCH v2 01/25] scripts: import Linux Kconfig.include Ahmad Fatoum
2020-06-02  8:53 ` [PATCH v2 02/25] sandbox: define CONFIG_64BIT as appropriate Ahmad Fatoum
2020-06-02  8:53 ` [PATCH v2 03/25] sandbox: asm: bitsperlong.h: detect bitness according to 64BIT symbol Ahmad Fatoum
2020-06-02  8:53 ` [PATCH v2 04/25] sandbox: support forcing 32-bit x86 Ahmad Fatoum
2020-06-02  8:53 ` [PATCH v2 05/25] include: asm-generic: provide (in|out)_(le|be)(16|32) helpers for all archs Ahmad Fatoum
2020-06-02  8:53 ` [PATCH v2 06/25] ARM: asm/io.h: fall back to <asm-generic/bitio.h> out_be32 and friends Ahmad Fatoum
2020-06-02  8:53 ` [PATCH v2 07/25] sandbox: <asm/io.h>: include bitio accessors Ahmad Fatoum
2020-06-02  8:53 ` [PATCH v2 08/25] clocksource: arm_global_timer.c: remove unused asm/ header Ahmad Fatoum
2020-06-02  8:53 ` [PATCH v2 09/25] mtd: nand: orion: depend on ARM Ahmad Fatoum
2020-06-02  8:53 ` [PATCH v2 10/25] ddr: fsl: " Ahmad Fatoum
2020-06-02  8:53 ` [PATCH v2 11/25] net: fec_imx: depend on HAS_DMA Ahmad Fatoum
2020-06-02  8:53 ` [PATCH v2 12/25] net: macb: " Ahmad Fatoum
2020-06-02  8:54 ` [PATCH v2 13/25] sandbox: implement stub physical virtual translation Ahmad Fatoum
2020-06-02  8:54 ` [PATCH v2 14/25] sandbox: asm: implement stub DMA functions Ahmad Fatoum
2020-06-02  8:54 ` [PATCH v2 15/25] sandbox: select HAS_DMA Ahmad Fatoum
2020-06-02  8:54 ` [PATCH v2 16/25] ARM: atomic.h: move generic implementation to asm-generic Ahmad Fatoum
2020-06-02  8:54 ` [PATCH v2 17/25] include: <asm-generic/atomic.h>: remove stub IRQ save/restore Ahmad Fatoum
2020-06-02  8:54 ` [PATCH v2 18/25] sandbox: asm: implement <asm/atomic.h> Ahmad Fatoum
2020-06-02  8:54 ` [PATCH v2 19/25] usb: xhci-hcd: remove unused #include <asm/cache.h> Ahmad Fatoum
2020-06-02  8:54 ` [PATCH v2 20/25] usb: xhci-hcd: replace opencoded non-atomic 64-bit MMIO with lo_hi helper Ahmad Fatoum
2020-06-02  8:54 ` [PATCH v2 21/25] include: bitops: fix dead increment in fls() and ffs() Ahmad Fatoum
2020-06-02  8:54 ` [PATCH v2 22/25] commands: tftp: drop unused variable Ahmad Fatoum
2020-06-02  8:54 ` [PATCH v2 23/25] commands: test: drop dead assignment Ahmad Fatoum
2020-06-02  8:54 ` [PATCH v2 24/25] sandbox: os: add_image: fix memory leak Ahmad Fatoum
2020-06-02  8:54 ` [PATCH v2 25/25] mtd: nand: base: fix use of uninitialized struct member Ahmad Fatoum
2020-06-03  8:04 ` [PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox