assert() is almost used in the same way as BUG_ON(), except:
Subsystems (27)
v3 cover assert() is almost used in the same way as BUG_ON(), except:
- the logic is opposite
- currently, assert() is compiled only when DEBUG is defined
Coccinelle can easily convert assert() to BUG_ON().
A problem is it would grow the image size.
In v2, I introduced a new CONFIG option to allow to disable it.
In v3, it is default 'y'. I disabled it only for openrd boards.
Masahiro Yamada (6):
Enable CONFIG_PANIC_HANG for boards without do_reset()
usb: xhci: return ERR_PTR(-ETIMEDOUT) at the end of
xhci_wait_for_event()
Introduce CONFIG_BUG_CHECKS to allow to disable BUG{_ON} and WARN_ON
ARM: openrd: disable CONFIG_BUG_CHECKS
treewide: convert assert() to BUG_ON()
Remove assert()
arch/arm/mach-exynos/clock.c | 4 +- arch/arm/mach-tegra/clock.c | 10 ++-- arch/arm/mach-tegra/pinmux-common.c | 80 +++++++++++++-------------- arch/arm/mach-tegra/tegra114/clock.c | 10 ++-- arch/arm/mach-tegra/tegra124/clock.c | 10 ++-- arch/arm/mach-tegra/tegra20/clock.c | 14 ++--- arch/arm/mach-tegra/tegra210/clock.c | 10 ++-- arch/arm/mach-tegra/tegra30/clock.c | 10 ++-- arch/sandbox/cpu/state.c | 4 +- arch/x86/cpu/intel_common/mrc.c | 2 +- arch/x86/lib/efi/efi.c | 2 +- arch/x86/lib/fsp/fsp_support.c | 6 +- arch/x86/lib/physmem.c | 5 +- board/freescale/qemu-ppce500/qemu-ppce500.c | 8 +-- cmd/bootefi.c | 2 +- cmd/mtdparts.c | 2 +- cmd/tpm_test.c | 28 +++++----- common/dlmalloc.c | 86 ++++++++++++++--------------- common/fdt_support.c | 2 +- common/hwconfig.c | 36 ++++++------ configs/cl-som-imx7_defconfig | 1 + configs/evb-rk3229_defconfig | 1 + configs/mccmon6_sd_defconfig | 1 + configs/openrd_base_defconfig | 1 + configs/openrd_client_defconfig | 1 + configs/openrd_ultimate_defconfig | 1 + configs/opos6uldev_defconfig | 1 + drivers/clk/clk-uclass.c | 2 +- drivers/clk/rockchip/clk_rk3036.c | 23 ++++---- drivers/clk/rockchip/clk_rk3128.c | 27 ++++----- drivers/clk/rockchip/clk_rk3188.c | 28 ++++------ drivers/clk/rockchip/clk_rk322x.c | 23 ++++---- drivers/clk/rockchip/clk_rk3288.c | 36 +++++------- drivers/clk/rockchip/clk_rk3328.c | 8 +-- drivers/clk/rockchip/clk_rk3368.c | 4 +- drivers/clk/rockchip/clk_rk3399.c | 51 +++++++---------- drivers/clk/rockchip/clk_rv1108.c | 2 +- drivers/core/device-remove.c | 8 +-- drivers/core/device.c | 2 +- drivers/core/ofnode.c | 24 ++++---- drivers/core/uclass.c | 4 +- drivers/gpio/gpio-uclass.c | 2 +- drivers/i2c/i2c-uclass.c | 2 +- drivers/input/input.c | 4 +- drivers/input/key_matrix.c | 2 +- drivers/misc/cros_ec.c | 10 ++-- drivers/misc/cros_ec_i2c.c | 4 +- drivers/mtd/nand/tegra_nand.c | 2 +- drivers/mtd/spi/sandbox.c | 4 +- drivers/net/fsl-mc/mc.c | 2 +- drivers/phy/phy-uclass.c | 2 +- drivers/power/tps6586x.c | 4 +- drivers/rtc/rtc-uclass.c | 10 ++-- drivers/sound/sound.c | 2 +- drivers/spi/exynos_spi.c | 6 +- drivers/usb/emul/sandbox_flash.c | 2 +- drivers/usb/host/usb-uclass.c | 4 +- drivers/usb/host/xhci-ring.c | 7 +++ drivers/video/stb_truetype.h | 2 +- fs/ext4/dev.c | 2 +- fs/ext4/ext4_common.c | 2 +- fs/ext4/ext4_journal.c | 2 +- fs/fat/fat.c | 2 +- include/dm/ofnode.h | 4 +- include/efi_loader.h | 12 ++-- include/linux/bug.h | 9 ++- include/log.h | 15 ----- lib/Kconfig | 9 +++ lib/circbuf.c | 16 +++--- lib/efi_loader/efi_boottime.c | 2 +- lib/efi_loader/efi_device_path.c | 2 +- lib/efi_loader/efi_file.c | 2 +- lib/efi_loader/efi_memory.c | 2 +- lib/fdtdec.c | 8 +-- lib/membuff.c | 4 +- lib/physmem.c | 4 +- lib/qsort.c | 2 +- lib/slre.c | 8 +-- lib/tiny-printf.c | 9 --- lib/vsprintf.c | 9 --- net/eth-uclass.c | 2 +- net/eth_legacy.c | 2 +- net/net.c | 2 +- test/command_ut.c | 30 +++++----- test/print_ut.c | 42 +++++++------- 85 files changed, 406 insertions(+), 448 deletions(-)
Signature · 1 line
2.7.4
PATCH v3 1/6 Enable CONFIG_PANIC_HANG for boards without do_reset()
Calling panic() for these boards causes build error:
undefined reference to `do_reset'
They must compile do_reset(), or define CONFIG_PANIC_HANG.
---
Changes in v3: None
Changes in v2: None
configs/cl-som-imx7_defconfig | 1 + configs/evb-rk3229_defconfig | 1 + configs/mccmon6_sd_defconfig | 1 + configs/opos6uldev_defconfig | 1 + 4 files changed, 4 insertions(+)
configs/cl-som-imx7_defconfig +1 -0
@@ -51,3 +51,4 @@ CONFIG_USB_STORAGE=y CONFIG_USB_GADGET=y CONFIG_CI_UDC=y CONFIG_OF_LIBFDT=y +CONFIG_PANIC_HANG=y
configs/evb-rk3229_defconfig +1 -0
@@ -48,3 +48,4 @@ CONFIG_USB_GADGET_VENDOR_NUM=0x2207 CONFIG_USB_GADGET_PRODUCT_NUM=0x320a CONFIG_USB_GADGET_DWC2_OTG=y CONFIG_ERRNO_STR=y +CONFIG_PANIC_HANG=y
configs/mccmon6_sd_defconfig +1 -0
@@ -44,3 +44,4 @@ CONFIG_DM_THERMAL=y CONFIG_USB=y CONFIG_USB_STORAGE=y CONFIG_OF_LIBFDT=y +CONFIG_PANIC_HANG=y
configs/opos6uldev_defconfig +1 -0
@@ -84,3 +84,4 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_VIDEO=y CONFIG_OF_LIBFDT_OVERLAY=y # CONFIG_EFI_LOADER is not set +CONFIG_PANIC_HANG=y
Signature · 1 line
2.7.4
PATCH v3 2/6 usb: xhci: return ERR_PTR(-ETIMEDOUT) at the end of xhci_wait_for_event()
In reply to Masahiro Yamadaxhci_wait_for_event() is supposed to return a pointer to union xhci_trb, but it does not return anything at the end of the function.
This relies on that the end of the function is unreachable due to BUG().
We are planning to make BUG() no-op for platforms with strong image size constraint. Doing so would cause compiler warning:
drivers/usb/host/xhci-ring.c:475:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
So, this function must return something. From the error message just above, ERR_PTR(-ETIMEDOUT) seems a good choice.
The use of BUG() looks suspicious here in the first place; no response from hardware is not a bug. It should be treated as a normal error. So, this function must return an error pointer instead of BUG(), then the caller must handle it properly.
I am not fixing the code because this is not the only place that stops the system. Just one failure of xHCI halts the system, here and there.
I left a comment block, hoping somebody will take a look.
---
Changes in v3:
- newly added
Changes in v2: None
drivers/usb/host/xhci-ring.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/host/xhci-ring.c +7 -0
@@ -471,7 +471,14 @@ union xhci_trb *xhci_wait_for_event(struct xhci_ctrl *ctrl, trb_type expected)return NULL ;printf ("XHCI timeout on event type %d... cannot recover.\n" , expected); + +/* +* CHECK: +* Is this software bug? Is this a good reason to halt the system? +*/ BUG (); + +return ERR_PTR (-ETIMEDOUT ); }/*
Signature · 1 line
2.7.4
PATCH v3 2/6 usb: xhci: return ERR_PTR(-ETIMEDOUT) at the end of xhci_wait_for_event()
Bin, Marek,
Would you take a look at xHCI code?
Lots of xHCI code invokes BUG_ON()/BUG() when the hardware access fails, then halts the system completely. This is not a software bug.
2018-01-10 10:45 GMT+09:00 Masahiro Yamada <[email protected]>:
Quoted 62 lines
xhci_wait_for_event()is supposed to return a pointer to unionxhci_trb, but it does not return anything at the end of the function.This relies on that the end of the function is unreachable due to
BUG().We are planning to make
BUG()no-op for platforms with strong image size constraint. Doing so would cause compiler warning:
drivers/usb/host/xhci-ring.c:475:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^So, this function must return something. From the error message just above,
ERR_PTR(-ETIMEDOUT)seems a good choice.The use of
BUG()looks suspicious here in the first place; no response from hardware is not a bug. It should be treated as a normal error. So, this function must return an error pointer instead ofBUG(), then the caller must handle it properly.I am not fixing the code because this is not the only place that stops the system. Just one failure of xHCI halts the system, here and there.
I left a comment block, hoping somebody will take a look.
Signed-off-by Masahiro Yamada <[email protected]>---
Changes in v3:
- newly addedChanges in v2: None
drivers/usb/host/xhci-ring.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/usb/host/xhci-ring.c +7
-1@@ -471,7 +471,14 @@ union xhci_trb *xhci_wait_for_event(struct xhci_ctrl *ctrl, trb_type expected)return NULL ;printf ("XHCI timeout on event type %d... cannot recover.\n" , expected); + +/* +* CHECK: +* Is this software bug? Is this a good reason to halt the system? +*/ BUG (); + +return ERR_PTR (-ETIMEDOUT ); }/* -- 2.7.4
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
Signature · 2 lines
Best Regards Masahiro Yamada
PATCH v3 2/6 usb: xhci: return ERR_PTR(-ETIMEDOUT) at the end of xhci_wait_for_event()
Quoted 1 line · Masahiro Yamada
Bin, Marek,
Hi,
Quoted 1 line
Would you take a look at xHCI code?
I was kinda hoping Bin would, oh well ...
Quoted 6 lines
Lots of xHCI code invokes BUG_ON()/BUG() when the hardware access fails, then halts the system completely. This is not a software bug.
Quoted 8 lines
2018-01-10 10:45 GMT+09:00 Masahiro Yamada <[email protected]>:
Quoted 7 lines
xhci_wait_for_event()is supposed to return a pointer to unionxhci_trb, but it does not return anything at the end of the function.This relies on that the end of the function is unreachable due to
BUG().We are planning to make
BUG()no-op for platforms with strong image size constraint.
But BUG() should hang the system because it means an unrecoverable issue happened. Changing it to nop would cause a lot of weird misbehavior, so that is IMO a bad idea. Just change it to hang(), that should be present even on size-constrained systems.
Quoted 8 lines
Quoted 8 lines
Doing so would cause compiler warning:
drivers/usb/host/xhci-ring.c:475:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^So, this function must return something. From the error message just above,
ERR_PTR(-ETIMEDOUT)seems a good choice.
This is an imported code from Linux, so you might want to check what they do/did there.
Quoted 50 lines
Quoted 47 lines
The use of
BUG()looks suspicious here in the first place; no response from hardware is not a bug. It should be treated as a normal error. So, this function must return an error pointer instead ofBUG(), then the caller must handle it properly.I am not fixing the code because this is not the only place that stops the system. Just one failure of xHCI halts the system, here and there.
I left a comment block, hoping somebody will take a look.
Signed-off-by Masahiro Yamada <[email protected]>---
Changes in v3:
- newly addedChanges in v2: None
drivers/usb/host/xhci-ring.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/usb/host/xhci-ring.c +7
-1@@ -471,7 +471,14 @@ union xhci_trb *xhci_wait_for_event(struct xhci_ctrl *ctrl, trb_type expected)return NULL ;printf ("XHCI timeout on event type %d... cannot recover.\n" , expected); + +/* +* CHECK: +* Is this software bug? Is this a good reason to halt the system? +*/ BUG (); + +return ERR_PTR (-ETIMEDOUT ); }/* -- 2.7.4
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
Signature · 2 lines
Best regards, Marek Vasut
PATCH v3 2/6 usb: xhci: return ERR_PTR(-ETIMEDOUT) at the end of xhci_wait_for_event()
Hi Marek,
2018-01-28 21:43 GMT+09:00 Marek Vasut <[email protected]>:
Quoted 21 lines · Masahiro Yamada
Quoted 1 line
Bin, Marek,
Hi,
Quoted 1 line
Would you take a look at xHCI code?
I was kinda hoping Bin would, oh well ...
Quoted 12 lines
Lots of xHCI code invokes BUG_ON()/BUG() when the hardware access fails, then halts the system completely. This is not a software bug.
2018-01-10 10:45 GMT+09:00 Masahiro Yamada <[email protected]>:
Quoted 5 lines
xhci_wait_for_event()is supposed to return a pointer to unionxhci_trb, but it does not return anything at the end of the function.This relies on that the end of the function is unreachable due to
BUG().
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
We are planning to make
BUG()no-op for platforms with strong image size constraint.But
BUG()should hang the system because it means an unrecoverable issue happened. Changing it to nop would cause a lot of weird misbehavior, so that is IMO a bad idea. Just change it tohang(), that should be present even on size-constrained systems.
In my opinion, BUG_ON(!x) and assert(x) are equivalent.
Both check software bugs that should never happen (but useful for debugging).
When releasing software, we can turn them into no-op.
Actually, assert() works like that in user-space programs. (assert() is no-op if NDEBUG is defined)
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Doing so would cause compiler warning:
drivers/usb/host/xhci-ring.c:475:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
So, this function must return something. From the error message just above,
ERR_PTR(-ETIMEDOUT)seems a good choice.This is an imported code from Linux, so you might want to check what they do/did there.
I grepped xhci_wait_for_event in the kernel source, but did not get any hit.
Signature · 2 lines
Best Regards Masahiro Yamada
PATCH v3 2/6 usb: xhci: return ERR_PTR(-ETIMEDOUT) at the end of xhci_wait_for_event()
Quoted 35 lines · Masahiro Yamada
Hi Marek,
2018-01-28 21:43 GMT+09:00 Marek Vasut <[email protected]>:
Quoted 21 lines · Masahiro Yamada
Quoted 1 line
Bin, Marek,
Hi,
Quoted 1 line
Would you take a look at xHCI code?
I was kinda hoping Bin would, oh well ...
Quoted 12 lines
Lots of xHCI code invokes BUG_ON()/BUG() when the hardware access fails, then halts the system completely. This is not a software bug.
2018-01-10 10:45 GMT+09:00 Masahiro Yamada <[email protected]>:
Quoted 5 lines
xhci_wait_for_event()is supposed to return a pointer to unionxhci_trb, but it does not return anything at the end of the function.This relies on that the end of the function is unreachable due to
BUG().Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
We are planning to make
BUG()no-op for platforms with strong image size constraint.But
BUG()should hang the system because it means an unrecoverable issue happened. Changing it to nop would cause a lot of weird misbehavior, so that is IMO a bad idea. Just change it tohang(), that should be present even on size-constrained systems.In my opinion,
BUG_ON(!x)and assert(x) are equivalent.
Quoted 8 lines
Both check software bugs that should never happen
(but useful for debugging).When releasing software, we can turn them into no-op.
Actually,
assert()works like that in user-space programs. (assert()is no-op if NDEBUG is defined)
Except in kernel, BUG() means something really bad happened and is not optimized away, ever.
Signature · 2 lines
Best regards, Marek Vasut
PATCH v3 2/6 usb: xhci: return ERR_PTR(-ETIMEDOUT) at the end of xhci_wait_for_event()
In reply to Masahiro YamadaHi Masahiro,
Quoted 4 lines · Masahiro Yamada
Bin, Marek,
Would you take a look at xHCI code?
Sorry I missed this before.
Quoted 4 lines
Lots of xHCI code invokes BUG_ON()/BUG() when the hardware access fails, then halts the system completely. This is not a software bug.
Given xHCI codes were originally from Linux where BUG_ON()/BUG() was once there but now disappears, I agree let's do it to clear the compiler warnings for now.
Something needs to be done in the U-Boot xHCI codes to handle the error path properly.
Regards,
Bin
PATCH v3 3/6 Introduce CONFIG_BUG_CHECKS to allow to disable BUG{_ON} and WARN_ON
In reply to Masahiro YamadaBUG(), BUG_ON(), WARN_ON(), etc. are generally used to test a condition that should never happen. If it does, it is a bug, then they print noisy messages.
They are useful to catch bugs, and Linux always enables them, but doing so in U-Boot causes image size problems on some platforms.
Introduce CONFIG_BUG_CHECKS to switch this feature. It is enabled by default since it is the current behavior. Disable it if your platform needs to save memory footprint.
---
Changes in v3:
- Flip the default to 'y'
- Rename CONFIG_ENABLE_BUG_CHECKS to CONFIG_BUG_CHECKS because I thought "ENABLE" was not a necessary word
- define to "do {} while (0)"
Changes in v2:
- Newly added
include/linux/bug.h | 9 ++++++++- lib/Kconfig | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-)
include/linux/bug.h +8 -1
@@ -6,17 +6,24 @@#include <linux/compiler.h> #include <linux/printk.h> +#ifdef CONFIG_BUG_CHECKS #define BUG () do { \ printk("BUG at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \ panic("BUG!"); \ } while (0) +#define __WARN () \ + printk("WARNING at %s:%d/%s()!\n", __FILE__, __LINE__, __func__) +#else +#define BUG () do {} while (0) +#define __WARN () do {} while (0) +#endif #define BUG_ON (condition) do { if (unlikely(condition)) BUG(); } while (0)#define WARN_ON (condition) ({ \ int __ret_warn_on = !!(condition); \ if (unlikely(__ret_warn_on)) \ - printk("WARNING at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \ + __WARN(); \ unlikely(__ret_warn_on); \ })
lib/Kconfig +9 -0
@@ -45,6 +45,15 @@ config USE_TINY_PRINTF The supported format specifiers are %c, %s, %u/%d and %x. +config BUG_CHECKS + bool "Enable BUG/BUG_ON() checks and WARN_ON() logs" + default y + help + BUG(), BUG_ON(), and WARN_ON() print noisy messages. BUG() and + BUG_ON() also reboot or halt the system. + + Disable this if your platform needs to save memory footprint. + config PANIC_HANG bool "Do not reset the system on fatal error" help
Signature · 1 line
2.7.4
PATCH v3 4/6 ARM: openrd: disable CONFIG_BUG_CHECKS
In reply to Masahiro YamadaThese boards are always on the boundary of "u-boot-nodtb.bin exceeds file size limit" error.
Commit ab5502bf561b ("ARM: openrd: set CONFIG_LOGLEVEL to 2") reduced the loglevel to save memory footprint.
They are hitting the size limit, again. Disable CONFIG_BUG_CHECKS.
---
Changes in v3:
- newly added
Changes in v2: None
configs/openrd_base_defconfig | 1 + configs/openrd_client_defconfig | 1 + configs/openrd_ultimate_defconfig | 1 + 3 files changed, 3 insertions(+)
configs/openrd_base_defconfig +1 -0
@@ -29,4 +29,5 @@ CONFIG_SYS_NS16550=y CONFIG_USB=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_STORAGE=y +# CONFIG_BUG_CHECKS is not set CONFIG_OF_LIBFDT=y
configs/openrd_client_defconfig +1 -0
@@ -29,4 +29,5 @@ CONFIG_SYS_NS16550=y CONFIG_USB=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_STORAGE=y +# CONFIG_BUG_CHECKS is not set CONFIG_OF_LIBFDT=y
configs/openrd_ultimate_defconfig +1 -0
@@ -29,4 +29,5 @@ CONFIG_SYS_NS16550=y CONFIG_USB=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_STORAGE=y +# CONFIG_BUG_CHECKS is not set CONFIG_OF_LIBFDT=y
Signature · 1 line
2.7.4
PATCH v3 5/6 treewide: convert assert() to BUG_ON()
In reply to Masahiro YamadaWe do not need multiple ways to do the same thing. Instead of assert(), use BUG_ON() from Linux. The logic is opposite, but Coccinelle is of great help for such a conversion. We could simply convert assert(x) to BUG_ON(!x) for all expressions "x", but I did a bit better job by converting assert(a == b) to BUG_ON(a != b), etc.
The semantic patch I used is as follows:
// <smpl>
@@@@
-assert(0)
+BUG()
@@
expression a;
@@
-assert((a))
+assert(a)
@@
expression a;
@@
-assert(a == 0)
+BUG_ON(a)
@@
expression a;
@@
-assert(a == NULL)
+BUG_ON(a)
@@
expression a;
@@
-assert(a != 0)
+BUG_ON(!a)
@@
expression a;
@@
-assert(a != NULL)
+BUG_ON(!a)
@@
expression a, b;
@@
-assert(a == b)
+BUG_ON(a != b)
@@
expression a, b;
@@
-assert(a != b)
+BUG_ON(a == b)
@@
expression a, b;
@@
-assert(a < b)
+BUG_ON(a >= b)
@@
expression a, b;
@@
-assert(a <= b)
+BUG_ON(a > b)
@@
expression a;
@@
-assert(!a)
+BUG_ON(a)
@@
expression a;
@@
-assert(a)
+BUG_ON(!a)
// </smpl>
---
Changes in v3:
- Re-run coccinelle based on v2017.01
Changes in v2:
- Improve semantic patch and re-run coccinelle based on commit 02907004294d98
arch/arm/mach-exynos/clock.c | 4 +- arch/arm/mach-tegra/clock.c | 10 ++-- arch/arm/mach-tegra/pinmux-common.c | 80 +++++++++++++-------------- arch/arm/mach-tegra/tegra114/clock.c | 10 ++-- arch/arm/mach-tegra/tegra124/clock.c | 10 ++-- arch/arm/mach-tegra/tegra20/clock.c | 14 ++--- arch/arm/mach-tegra/tegra210/clock.c | 10 ++-- arch/arm/mach-tegra/tegra30/clock.c | 10 ++-- arch/sandbox/cpu/state.c | 4 +- arch/x86/cpu/intel_common/mrc.c | 2 +- arch/x86/lib/efi/efi.c | 2 +- arch/x86/lib/fsp/fsp_support.c | 6 +- arch/x86/lib/physmem.c | 5 +- board/freescale/qemu-ppce500/qemu-ppce500.c | 8 +-- cmd/bootefi.c | 2 +- cmd/mtdparts.c | 2 +- cmd/tpm_test.c | 28 +++++----- common/dlmalloc.c | 86 ++++++++++++++--------------- common/fdt_support.c | 2 +- common/hwconfig.c | 36 ++++++------ drivers/clk/clk-uclass.c | 2 +- drivers/clk/rockchip/clk_rk3036.c | 23 ++++---- drivers/clk/rockchip/clk_rk3128.c | 27 ++++----- drivers/clk/rockchip/clk_rk3188.c | 28 ++++------ drivers/clk/rockchip/clk_rk322x.c | 23 ++++---- drivers/clk/rockchip/clk_rk3288.c | 36 +++++------- drivers/clk/rockchip/clk_rk3328.c | 8 +-- drivers/clk/rockchip/clk_rk3368.c | 4 +- drivers/clk/rockchip/clk_rk3399.c | 51 +++++++---------- drivers/clk/rockchip/clk_rv1108.c | 2 +- drivers/core/device-remove.c | 8 +-- drivers/core/device.c | 2 +- drivers/core/ofnode.c | 24 ++++---- drivers/core/uclass.c | 4 +- drivers/gpio/gpio-uclass.c | 2 +- drivers/i2c/i2c-uclass.c | 2 +- drivers/input/input.c | 4 +- drivers/input/key_matrix.c | 2 +- drivers/misc/cros_ec.c | 10 ++-- drivers/misc/cros_ec_i2c.c | 4 +- drivers/mtd/nand/tegra_nand.c | 2 +- drivers/mtd/spi/sandbox.c | 4 +- drivers/net/fsl-mc/mc.c | 2 +- drivers/phy/phy-uclass.c | 2 +- drivers/power/tps6586x.c | 4 +- drivers/rtc/rtc-uclass.c | 10 ++-- drivers/sound/sound.c | 2 +- drivers/spi/exynos_spi.c | 6 +- drivers/usb/emul/sandbox_flash.c | 2 +- drivers/usb/host/usb-uclass.c | 4 +- drivers/video/stb_truetype.h | 2 +- fs/ext4/dev.c | 2 +- fs/ext4/ext4_common.c | 2 +- fs/ext4/ext4_journal.c | 2 +- fs/fat/fat.c | 2 +- include/dm/ofnode.h | 4 +- include/efi_loader.h | 12 ++-- lib/circbuf.c | 16 +++--- lib/efi_loader/efi_boottime.c | 2 +- lib/efi_loader/efi_device_path.c | 2 +- lib/efi_loader/efi_file.c | 2 +- lib/efi_loader/efi_memory.c | 2 +- lib/fdtdec.c | 8 +-- lib/membuff.c | 4 +- lib/physmem.c | 4 +- lib/qsort.c | 2 +- lib/slre.c | 8 +-- net/eth-uclass.c | 2 +- net/eth_legacy.c | 2 +- net/net.c | 2 +- test/command_ut.c | 30 +++++----- test/print_ut.c | 42 +++++++------- 72 files changed, 375 insertions(+), 414 deletions(-)
arch/arm/mach-exynos/clock.c +2 -2
@@ -1405,8 +1405,8 @@ static int clock_calc_best_scalar(unsigned int main_scaler_bits,debug ("Input Rate is %u, Target is %u, Cap is %u\n" , input_rate, target_rate, cap); -assert (best_fine_scalar !=NULL ); -assert (main_scaler_bits <= fine_scalar_bits); +BUG_ON (!best_fine_scalar); +BUG_ON (main_scaler_bits > fine_scalar_bits); *best_fine_scalar =1 ;
arch/arm/mach-tegra/clock.c +5 -5
@@ -74,7 +74,7 @@ static struct clk_pll *get_pll(enum clock_id clkid)struct clk_rst_ctlr *clkrst = (struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE ; -assert (clock_id_is_pll (clkid)); +BUG_ON (!clock_id_is_pll (clkid));if (clkid >= (enum clock_id )TEGRA_CLK_PLLS ) {debug ("%s: Invalid PLL %d\n" , __func__, clkid);return NULL ;
@@ -94,7 +94,7 @@ int clock_ll_read_pll(enum clock_id clkid, u32 *divm, u32 *divn,struct clk_pll_info *pllinfo = &tegra_pll_info_table[clkid];u32 data; -assert (clkid !=CLOCK_ID_USB ); +BUG_ON (clkid ==CLOCK_ID_USB );/* Safety check, adds to code size but is small */ if (!clock_id_is_pll (clkid) || clkid ==CLOCK_ID_USB )
@@ -454,7 +454,7 @@ unsigned clock_adjust_periph_pll_div(enum periph_id periph_id,if (extra_div) *extra_div = xdiv; -assert (divider >=0 ); +BUG_ON (0 > divider);if (adjust_periph_pll (periph_id, source, mux_bits, divider))return -1U ; debug("periph %d, rate=%d, reg=%p = %x\n", periph_id, rate,
@@ -515,7 +515,7 @@ void reset_cmplx_set_enable(int cpu, int which, int reset)u32 mask;/* Form the mask, which depends on the cpu chosen (2 or 4) */ -assert (cpu >=0 && cpu <MAX_NUM_CPU ); +BUG_ON (!(cpu >=0 && cpu <MAX_NUM_CPU )); mask = which << cpu;/* either enable or disable those reset for that CPU */
@@ -665,7 +665,7 @@ int clock_decode_periph_id(struct udevice *dev)if (err)return -1 ; id =clk_id_to_periph_id (cell[1 ]); -assert (clock_periph_id_isvalid (id)); +BUG_ON (!clock_periph_id_isvalid (id)); return id; }#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
arch/arm/mach-tegra/pinmux-common.c +40 -40
206 lines not on this page · raw message
arch/arm/mach-tegra/tegra114/clock.c +5 -5
@@ -486,9 +486,9 @@ u32 *get_periph_source_reg(enum periph_id periph_id)if (periph_id ==PERIPH_ID_CSI )return &clkrst->crc_clk_src[PERIPH_ID_CSI +1 ]; -assert (periph_id >=PERIPH_ID_FIRST && periph_id <PERIPH_ID_COUNT ); +BUG_ON (!(periph_id >=PERIPH_ID_FIRST && periph_id <PERIPH_ID_COUNT )); internal_id = periph_id_to_internal_id[periph_id]; -assert (internal_id !=-1 ); +BUG_ON (internal_id ==-1 );if (internal_id >=PERIPHC_VW_FIRST ) { internal_id -=PERIPHC_VW_FIRST ;return &clkrst->crc_clk_src_vw[internal_id];
@@ -560,7 +560,7 @@ int get_periph_clock_source(enum periph_id periph_id,int mux, err; err =get_periph_clock_info (periph_id, mux_bits, divider_bits, &type); -assert (!err); +BUG_ON (err);for (mux =0 ; mux <CLOCK_MAX_MUX ; mux++)if (clock_source[type][mux] == parent)
@@ -580,7 +580,7 @@ void clock_set_enable(enum periph_id periph_id, int enable)u32 reg;/* Enable/disable the clock to this peripheral */ -assert (clock_periph_id_isvalid (periph_id)); +BUG_ON (!clock_periph_id_isvalid (periph_id));if ((int )periph_id < (int )PERIPH_ID_VW_FIRST ) clk = &clkrst->crc_clk_out_enb[PERIPH_REG (periph_id)];else
@@ -601,7 +601,7 @@ void reset_set_enable(enum periph_id periph_id, int enable)u32 reg;/* Enable/disable reset to the peripheral */ -assert (clock_periph_id_isvalid (periph_id)); +BUG_ON (!clock_periph_id_isvalid (periph_id));if (periph_id <PERIPH_ID_VW_FIRST ) reset = &clkrst->crc_rst_dev[PERIPH_REG (periph_id)];else
arch/arm/mach-tegra/tegra124/clock.c +5 -5
@@ -628,9 +628,9 @@ u32 *get_periph_source_reg(enum periph_id periph_id)if (periph_id ==PERIPH_ID_CSI )return &clkrst->crc_clk_src[PERIPH_ID_CSI +1 ]; -assert (periph_id >=PERIPH_ID_FIRST && periph_id <PERIPH_ID_COUNT ); +BUG_ON (!(periph_id >=PERIPH_ID_FIRST && periph_id <PERIPH_ID_COUNT )); internal_id = periph_id_to_internal_id[periph_id]; -assert (internal_id !=-1 ); +BUG_ON (internal_id ==-1 );if (internal_id >=PERIPHC_X_FIRST ) { internal_id -=PERIPHC_X_FIRST ;return &clkrst->crc_clk_src_x[internal_id];
@@ -706,7 +706,7 @@ int get_periph_clock_source(enum periph_id periph_id,int mux, err; err =get_periph_clock_info (periph_id, mux_bits, divider_bits, &type); -assert (!err); +BUG_ON (err);for (mux =0 ; mux <CLOCK_MAX_MUX ; mux++)if (clock_source[type][mux] == parent)
@@ -726,7 +726,7 @@ void clock_set_enable(enum periph_id periph_id, int enable)u32 reg;/* Enable/disable the clock to this peripheral */ -assert (clock_periph_id_isvalid (periph_id)); +BUG_ON (!clock_periph_id_isvalid (periph_id));if ((int )periph_id < (int )PERIPH_ID_VW_FIRST ) clk = &clkrst->crc_clk_out_enb[PERIPH_REG (periph_id)];else if ((int )periph_id <PERIPH_ID_X_FIRST )
@@ -749,7 +749,7 @@ void reset_set_enable(enum periph_id periph_id, int enable)u32 reg;/* Enable/disable reset to the peripheral */ -assert (clock_periph_id_isvalid (periph_id)); +BUG_ON (!clock_periph_id_isvalid (periph_id));if (periph_id <PERIPH_ID_VW_FIRST ) reset = &clkrst->crc_rst_dev[PERIPH_REG (periph_id)];else if ((int )periph_id <PERIPH_ID_X_FIRST )
arch/arm/mach-tegra/tegra20/clock.c +7 -7
@@ -407,9 +407,9 @@ u32 *get_periph_source_reg(enum periph_id periph_id) (struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE ;enum periphc_internal_id internal_id; -assert (clock_periph_id_isvalid (periph_id)); +BUG_ON (!clock_periph_id_isvalid (periph_id)); internal_id = periph_id_to_internal_id[periph_id]; -assert (internal_id !=-1 ); +BUG_ON (internal_id ==-1 );return &clkrst->crc_clk_src[internal_id]; }
@@ -483,7 +483,7 @@ int get_periph_clock_source(enum periph_id periph_id,int mux, err; err =get_periph_clock_info (periph_id, mux_bits, divider_bits, &type); -assert (!err); +BUG_ON (err);for (mux =0 ; mux <CLOCK_MAX_MUX ; mux++)if (clock_source[type][mux] == parent)
@@ -494,8 +494,8 @@ int get_periph_clock_source(enum periph_id periph_id,* which is not in our table. If not, then they are asking for a * source which this peripheral can't access through its mux. */ -assert (type ==CLOCK_TYPE_PCXTS ); -assert (parent ==CLOCK_ID_SFROM32KHZ ); +BUG_ON (type !=CLOCK_TYPE_PCXTS ); +BUG_ON (parent !=CLOCK_ID_SFROM32KHZ );if (type ==CLOCK_TYPE_PCXTS && parent ==CLOCK_ID_SFROM32KHZ )return 4 ;/* mux value for this clock */
@@ -513,7 +513,7 @@ void clock_set_enable(enum periph_id periph_id, int enable)u32 reg;/* Enable/disable the clock to this peripheral */ -assert (clock_periph_id_isvalid (periph_id)); +BUG_ON (!clock_periph_id_isvalid (periph_id)); reg =readl (clk);if (enable) reg |=PERIPH_MASK (periph_id);
@@ -530,7 +530,7 @@ void reset_set_enable(enum periph_id periph_id, int enable)u32 reg;/* Enable/disable reset to the peripheral */ -assert (clock_periph_id_isvalid (periph_id)); +BUG_ON (!clock_periph_id_isvalid (periph_id)); reg =readl (reset);if (enable) reg |=PERIPH_MASK (periph_id);
arch/arm/mach-tegra/tegra210/clock.c +5 -5
@@ -707,9 +707,9 @@ u32 *get_periph_source_reg(enum periph_id periph_id)if (periph_id ==PERIPH_ID_CSI )return &clkrst->crc_clk_src[PERIPH_ID_CSI +1 ]; -assert (periph_id >=PERIPH_ID_FIRST && periph_id <PERIPH_ID_COUNT ); +BUG_ON (!(periph_id >=PERIPH_ID_FIRST && periph_id <PERIPH_ID_COUNT )); internal_id =INTERNAL_ID (periph_id_to_internal_id[periph_id]); -assert (internal_id !=-1 ); +BUG_ON (internal_id ==-1 );if (internal_id <PERIPHC_VW_FIRST )/* L, H, U */
@@ -796,7 +796,7 @@ int get_periph_clock_source(enum periph_id periph_id,int mux, err; err =get_periph_clock_info (periph_id, mux_bits, divider_bits, &type); -assert (!err); +BUG_ON (err);for (mux =0 ; mux <CLOCK_MAX_MUX ; mux++)if (clock_source[type][mux] == parent)
@@ -816,7 +816,7 @@ void clock_set_enable(enum periph_id periph_id, int enable)u32 reg;/* Enable/disable the clock to this peripheral */ -assert (clock_periph_id_isvalid (periph_id)); +BUG_ON (!clock_periph_id_isvalid (periph_id));if ((int )periph_id < (int )PERIPH_ID_VW_FIRST ) clk = &clkrst->crc_clk_out_enb[PERIPH_REG (periph_id)];else if ((int )periph_id < (int )PERIPH_ID_X_FIRST )
@@ -842,7 +842,7 @@ void reset_set_enable(enum periph_id periph_id, int enable)u32 reg;/* Enable/disable reset to the peripheral */ -assert (clock_periph_id_isvalid (periph_id)); +BUG_ON (!clock_periph_id_isvalid (periph_id));if (periph_id <PERIPH_ID_VW_FIRST ) reset = &clkrst->crc_rst_dev[PERIPH_REG (periph_id)];else if ((int )periph_id < (int )PERIPH_ID_X_FIRST )
arch/arm/mach-tegra/tegra30/clock.c +5 -5
@@ -466,9 +466,9 @@ u32 *get_periph_source_reg(enum periph_id periph_id)if (periph_id ==PERIPH_ID_CSI )return &clkrst->crc_clk_src[PERIPH_ID_CSI +1 ]; -assert (periph_id >=PERIPH_ID_FIRST && periph_id <PERIPH_ID_COUNT ); +BUG_ON (!(periph_id >=PERIPH_ID_FIRST && periph_id <PERIPH_ID_COUNT )); internal_id = periph_id_to_internal_id[periph_id]; -assert (internal_id !=-1 ); +BUG_ON (internal_id ==-1 );if (internal_id >=PERIPHC_VW_FIRST ) { internal_id -=PERIPHC_VW_FIRST ;return &clkrst->crc_clk_src_vw[internal_id];
@@ -540,7 +540,7 @@ int get_periph_clock_source(enum periph_id periph_id,int mux, err; err =get_periph_clock_info (periph_id, mux_bits, divider_bits, &type); -assert (!err); +BUG_ON (err);for (mux =0 ; mux <CLOCK_MAX_MUX ; mux++)if (clock_source[type][mux] == parent)
@@ -560,7 +560,7 @@ void clock_set_enable(enum periph_id periph_id, int enable)u32 reg;/* Enable/disable the clock to this peripheral */ -assert (clock_periph_id_isvalid (periph_id)); +BUG_ON (!clock_periph_id_isvalid (periph_id));if ((int )periph_id < (int )PERIPH_ID_VW_FIRST ) clk = &clkrst->crc_clk_out_enb[PERIPH_REG (periph_id)];else
@@ -581,7 +581,7 @@ void reset_set_enable(enum periph_id periph_id, int enable)u32 reg;/* Enable/disable reset to the peripheral */ -assert (clock_periph_id_isvalid (periph_id)); +BUG_ON (!clock_periph_id_isvalid (periph_id));if (periph_id <PERIPH_ID_VW_FIRST ) reset = &clkrst->crc_rst_dev[PERIPH_REG (periph_id)];else
arch/sandbox/cpu/state.c +2 -2
@@ -333,7 +333,7 @@ int state_setprop(int node, const char *prop_name, const void *data, int size)struct sandbox_state *state_get_current (void ) { -assert (state); +BUG_ON (!state);return state; }
@@ -367,7 +367,7 @@ int state_init(void) state->ram_size =CONFIG_SYS_SDRAM_SIZE ; state->ram_buf =os_malloc (state->ram_size); -assert (state->ram_buf); +BUG_ON (!state->ram_buf);state_reset_for_test (state);/*
arch/x86/cpu/intel_common/mrc.c +1 -1
@@ -42,7 +42,7 @@ ulong mrc_common_board_get_usable_ram_top(ulong total_size) }/* If no suitable area was found, return an error. */ -assert (largest); +BUG_ON (!largest);if (!largest || largest->size < (2 <<20 ))panic ("No available memory found for relocation" );
arch/x86/lib/efi/efi.c +1 -1
@@ -55,7 +55,7 @@ ulong board_get_usable_ram_top(ulong total_size) }/* If no suitable area was found, return an error. */ -assert (largest); +BUG_ON (!largest);if (!largest || (largest->num_pages <<EFI_PAGE_SHIFT ) < (2 <<20 )) goto err;
arch/x86/lib/fsp/fsp_support.c +3 -3
@@ -91,7 +91,7 @@ void fsp_continue(u32 status, void *hob_list) {post_code (POST_MRC ); -assert (status ==0 ); +BUG_ON (status);/* The boot loader main function entry */ fsp_init_done (hob_list);
@@ -126,7 +126,7 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf) fsp_hdr->cfg_region_off);/* Verify the VPD data region is valid */ -assert (fsp_vpd->sign ==VPD_IMAGE_ID ); +BUG_ON (fsp_vpd->sign !=VPD_IMAGE_ID ); fsp_upd = &config_data.fsp_upd;
@@ -135,7 +135,7 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf) sizeof(struct upd_region));/* Verify the UPD data region is valid */ -assert (fsp_upd->terminator ==UPD_TERMINATOR ); +BUG_ON (fsp_upd->terminator !=UPD_TERMINATOR );#endif memset (&rt_buf,0 ,sizeof (struct fspinit_rtbuf ));
arch/x86/lib/physmem.c +2 -3
@@ -141,8 +141,7 @@ static void x86_phys_memset_page(phys_addr_t map_addr, uintptr_t offset, int c,const uintptr_t window =LARGE_PAGE_SIZE ;/* Make sure the window is below U-Boot. */ -assert (window +LARGE_PAGE_SIZE < - gd->relocaddr -CONFIG_SYS_MALLOC_LEN -CONFIG_SYS_STACK_SIZE ); +BUG_ON (window +LARGE_PAGE_SIZE >= gd->relocaddr -CONFIG_SYS_MALLOC_LEN -CONFIG_SYS_STACK_SIZE );/* Map the page into the window and then memset the appropriate part. */ x86_phys_map_page (window, map_addr,1 );memset ((void *)(window + offset), c, size);
@@ -165,7 +164,7 @@ phys_addr_t arch_phys_memset(phys_addr_t start, int c, phys_size_t size)phys_size_t low_size =min (max_addr +1 - start, size);void *start_ptr = (void *)(uintptr_t )start; -assert (((phys_addr_t )(uintptr_t )start) == start); +BUG_ON (((phys_addr_t )(uintptr_t )start) != start);memset (start_ptr, c, low_size); start += low_size; size -= low_size;
board/freescale/qemu-ppce500/qemu-ppce500.c +3 -5
@@ -109,7 +109,7 @@ static int pci_map_region(void *fdt, int pci_node, int range_id,return -1 ;/* Map virtual memory for range */ -assert (!tlb_map_range (map_addr, addr, size,TLB_MAP_IO )); +BUG_ON (tlb_map_range (map_addr, addr, size,TLB_MAP_IO )); *pmap_addr = map_addr + size;if (pvaddr)
@@ -286,15 +286,13 @@ void init_tlbs(void)init_used_tlb_cams ();/* Create a dynamic AS=0 CCSRBAR mapping */ -assert (!tlb_map_range (CONFIG_SYS_CCSRBAR ,CONFIG_SYS_CCSRBAR_PHYS , -1024 *1024 ,TLB_MAP_IO )); +BUG_ON (tlb_map_range (CONFIG_SYS_CCSRBAR ,CONFIG_SYS_CCSRBAR_PHYS ,1024 *1024 ,TLB_MAP_IO ));/* Create a RAM map that spans all accessible RAM */ setup_ddr_tlbs (ram_size >>20 );/* Create a map for the TLB */ -assert (!tlb_map_range ((ulong )get_fdt_virt (),get_fdt_phys (), -1024 *1024 ,TLB_MAP_RAM )); +BUG_ON (tlb_map_range ((ulong )get_fdt_virt (),get_fdt_phys (),1024 *1024 ,TLB_MAP_RAM )); }void init_laws (void )
cmd/bootefi.c +1 -1
@@ -176,7 +176,7 @@ static efi_status_t do_bootefi_exec(void *efi, void *fdt, memdp =efi_dp_from_mem (0 ,0 ,0 ); device_path = image_path = memdp; }else { -assert (device_path && image_path); +BUG_ON (!(device_path && image_path)); }/* Initialize and populate EFI object list */
cmd/mtdparts.c +1 -1
@@ -852,7 +852,7 @@ static int device_parse(const char *const mtd_dev, const char **ret, struct mtd_debug ("===device_parse===\n" ); -assert (retdev); +BUG_ON (!retdev); *retdev =NULL ;if (ret)
cmd/tpm_test.c +14 -14
@@ -180,13 +180,13 @@ static int test_fast_enable(void)TPM_CHECK (tpm_get_flags (&disable, &deactivated,NULL ));printf ("\tdisable is %d, deactivated is %d\n" , disable, deactivated); -assert (disable ==1 && deactivated ==1 ); +BUG_ON (!(disable ==1 && deactivated ==1 ));TPM_CHECK (tpm_physical_enable ());TPM_CHECK (tpm_physical_set_deactivated (0 ));TPM_CHECK (tpm_get_flags (&disable, &deactivated,NULL ));printf ("\tdisable is %d, deactivated is %d\n" , disable, deactivated); -assert (disable ==0 && deactivated ==0 ); +BUG_ON (!(disable ==0 && deactivated ==0 )); }printf ("\tdone\n" );return 0 ;
@@ -213,22 +213,22 @@ static int test_global_lock(void)/* Verifies that write to index0 fails */ x =1 ; result =tpm_nv_write_value (INDEX0 , (uint8_t *)&x,sizeof (x)); -assert (result ==TPM_AREA_LOCKED ); +BUG_ON (result !=TPM_AREA_LOCKED );TPM_CHECK (tpm_nv_read_value (INDEX0 , (uint8_t *)&x,sizeof (x))); -assert (x ==0 ); +BUG_ON (x);/* Verifies that write to index1 is still possible */ x =2 ;TPM_CHECK (tpm_nv_write_value (INDEX1 , (uint8_t *)&x,sizeof (x)));TPM_CHECK (tpm_nv_read_value (INDEX1 , (uint8_t *)&x,sizeof (x))); -assert (x ==2 ); +BUG_ON (x !=2 );/* Turns off PP */ tpm_tsc_physical_presence (PHYS_PRESENCE );/* Verifies that write to index1 fails */ x =3 ; result =tpm_nv_write_value (INDEX1 , (uint8_t *)&x,sizeof (x)); -assert (result ==TPM_BAD_PRESENCE ); +BUG_ON (result !=TPM_BAD_PRESENCE );TPM_CHECK (tpm_nv_read_value (INDEX1 , (uint8_t *)&x,sizeof (x))); -assert (x ==2 ); +BUG_ON (x !=2 );printf ("\tdone\n" );return 0 ; }
@@ -325,7 +325,7 @@ static int test_redefine_unowned(void)TPM_CHECK (TlclStartupIfNeeded ());TPM_CHECK (tpm_self_test_full ());TPM_CHECK (tpm_tsc_physical_presence (PRESENCE )); -assert (!tpm_is_owned ()); +BUG_ON (tpm_is_owned ());/* Ensures spaces exist. */ TPM_CHECK (tpm_nv_read_value (INDEX0 , (uint8_t *)&x,sizeof (x)));
@@ -344,7 +344,7 @@ static int test_redefine_unowned(void)/* Verifies that index0 cannot be redefined */ result =tpm_nv_define_space (INDEX0 , perm,sizeof (uint32_t )); -assert (result ==TPM_AREA_LOCKED ); +BUG_ON (result !=TPM_AREA_LOCKED );/* Checks that index1 can */ TPM_CHECK (tpm_nv_define_space (INDEX1 , perm,2 *sizeof (uint32_t )));
@@ -355,9 +355,9 @@ static int test_redefine_unowned(void)/* Verifies that neither index0 nor index1 can be redefined */ result =tpm_nv_define_space (INDEX0 , perm,sizeof (uint32_t )); -assert (result ==TPM_BAD_PRESENCE ); +BUG_ON (result !=TPM_BAD_PRESENCE ); result =tpm_nv_define_space (INDEX1 , perm,sizeof (uint32_t )); -assert (result ==TPM_BAD_PRESENCE ); +BUG_ON (result !=TPM_BAD_PRESENCE );printf ("done\n" );return 0 ;
@@ -376,9 +376,9 @@ static int test_space_perm(void)TPM_CHECK (tpm_continue_self_test ());TPM_CHECK (tpm_tsc_physical_presence (PRESENCE ));TPM_CHECK (tpm_get_permissions (INDEX0 , &perm)); -assert ((perm &PERMPPGL ) ==PERMPPGL ); +BUG_ON ((perm &PERMPPGL ) !=PERMPPGL );TPM_CHECK (tpm_get_permissions (INDEX1 , &perm)); -assert ((perm &PERMPP ) ==PERMPP ); +BUG_ON ((perm &PERMPP ) !=PERMPP );printf ("done\n" );return 0 ; }
@@ -469,7 +469,7 @@ static int test_write_limit(void)case TPM_SUCCESS :break ;case TPM_MAXNVWRITES : -assert (i >=TPM_MAX_NV_WRITES_NOOWNER ); +BUG_ON (TPM_MAX_NV_WRITES_NOOWNER > i);default :pr_err ("\tunexpected error code %d (0x%x)\n" , result, result);
common/dlmalloc.c +43 -43
216 lines not on this page · raw message
common/fdt_support.c +1 -1
@@ -1124,7 +1124,7 @@ static struct of_bus *of_match_bus(const void *blob, int parentoffset)* in the of_busses array or something equally catastrophic has * gone wrong. */ -assert (0 ); +BUG ();return NULL ; }
common/hwconfig.c +18 -18
@@ -248,37 +248,37 @@ int main() ret =hwconfig_arg ("key1" , &len);printf ("%zd %.*s\n" , len, (int )len, ret); -assert (len ==29 ); -assert (hwconfig_arg_cmp ("key1" ,"subkey1=value1,subkey2=value2" )); -assert (!strncmp (ret,"subkey1=value1,subkey2=value2" , len)); +BUG_ON (len !=29 ); +BUG_ON (!hwconfig_arg_cmp ("key1" ,"subkey1=value1,subkey2=value2" )); +BUG_ON (strncmp (ret,"subkey1=value1,subkey2=value2" , len)); ret =hwconfig_subarg ("key1" ,"subkey1" , &len);printf ("%zd %.*s\n" , len, (int )len, ret); -assert (len ==6 ); -assert (hwconfig_subarg_cmp ("key1" ,"subkey1" ,"value1" )); -assert (!strncmp (ret,"value1" , len)); +BUG_ON (len !=6 ); +BUG_ON (!hwconfig_subarg_cmp ("key1" ,"subkey1" ,"value1" )); +BUG_ON (strncmp (ret,"value1" , len)); ret =hwconfig_subarg ("key1" ,"subkey2" , &len);printf ("%zd %.*s\n" , len, (int )len, ret); -assert (len ==6 ); -assert (hwconfig_subarg_cmp ("key1" ,"subkey2" ,"value2" )); -assert (!strncmp (ret,"value2" , len)); +BUG_ON (len !=6 ); +BUG_ON (!hwconfig_subarg_cmp ("key1" ,"subkey2" ,"value2" )); +BUG_ON (strncmp (ret,"value2" , len)); ret =hwconfig_arg ("key2" , &len);printf ("%zd %.*s\n" , len, (int )len, ret); -assert (len ==6 ); -assert (hwconfig_arg_cmp ("key2" ,"value3" )); -assert (!strncmp (ret,"value3" , len)); +BUG_ON (len !=6 ); +BUG_ON (!hwconfig_arg_cmp ("key2" ,"value3" )); +BUG_ON (strncmp (ret,"value3" , len)); -assert (hwconfig ("key3" )); -assert (hwconfig_arg ("key4" , &len) ==NULL ); -assert (hwconfig_arg ("bogus" , &len) ==NULL ); +BUG_ON (!hwconfig ("key3" )); +BUG_ON (hwconfig_arg ("key4" , &len)); +BUG_ON (hwconfig_arg ("bogus" , &len));unenv_set ("hwconfig" ); -assert (hwconfig (NULL ) ==0 ); -assert (hwconfig ("" ) ==0 ); -assert (hwconfig ("key3" ) ==0 ); +BUG_ON (hwconfig (NULL )); +BUG_ON (hwconfig ("" )); +BUG_ON (hwconfig ("key3" ));return 0 ; }
drivers/clk/clk-uclass.c +1 -1
@@ -64,7 +64,7 @@ int clk_get_by_index(struct udevice *dev, int index, struct clk *clk)debug ("%s(dev=%p, index=%d, clk=%p)\n" , __func__, dev, index, clk); -assert (clk); +BUG_ON (!clk); clk->dev =NULL ; ret = dev_read_phandle_with_args(dev, "clocks", "#clock-cells", 0,
drivers/clk/rockchip/clk_rk3036.c +10 -13
@@ -58,8 +58,7 @@ static int rkclk_set_pll(struct rk3036_cru *cru, enum rk_clk_id clk_id, vco=%u Hz, output=%u Hz\n", pll, div->fbdiv, div->refdiv, div->postdiv1, div->postdiv2, vco_hz, output_hz); -assert (vco_hz >=VCO_MIN_HZ && vco_hz <=VCO_MAX_HZ && - output_hz >=OUTPUT_MIN_HZ && output_hz <=OUTPUT_MAX_HZ ); +BUG_ON (!(vco_hz >=VCO_MIN_HZ && vco_hz <=VCO_MAX_HZ && output_hz >=OUTPUT_MIN_HZ && output_hz <=OUTPUT_MAX_HZ ));/* use integer mode */ rk_setreg (&pll->con1,1 <<PLL_DSMPD_SHIFT );
@@ -100,10 +99,10 @@ static void rkclk_init(struct rk3036_cru *cru)* core hz : apll = 1:1 */ aclk_div =APLL_HZ /CORE_ACLK_HZ -1 ; -assert ((aclk_div +1 ) *CORE_ACLK_HZ ==APLL_HZ && aclk_div <0x7 ); +BUG_ON (!((aclk_div +1 ) *CORE_ACLK_HZ ==APLL_HZ && aclk_div <0x7 )); pclk_div =APLL_HZ /CORE_PERI_HZ -1 ; -assert ((pclk_div +1 ) *CORE_PERI_HZ ==APLL_HZ && pclk_div <0xf ); +BUG_ON (!((pclk_div +1 ) *CORE_PERI_HZ ==APLL_HZ && pclk_div <0xf )); rk_clrsetreg(&cru->cru_clksel_con[0], CORE_CLK_PLL_SEL_MASK | CORE_DIV_CON_MASK,
@@ -120,13 +119,13 @@ static void rkclk_init(struct rk3036_cru *cru)* set up dependent divisors for PCLK/HCLK and ACLK clocks. */ aclk_div =GPLL_HZ /BUS_ACLK_HZ -1 ; -assert ((aclk_div +1 ) *BUS_ACLK_HZ ==GPLL_HZ && aclk_div <=0x1f ); +BUG_ON (!((aclk_div +1 ) *BUS_ACLK_HZ ==GPLL_HZ && aclk_div <=0x1f )); pclk_div =GPLL_HZ /BUS_PCLK_HZ -1 ; -assert ((pclk_div +1 ) *BUS_PCLK_HZ ==GPLL_HZ && pclk_div <=0x7 ); +BUG_ON (!((pclk_div +1 ) *BUS_PCLK_HZ ==GPLL_HZ && pclk_div <=0x7 )); hclk_div =GPLL_HZ /BUS_HCLK_HZ -1 ; -assert ((hclk_div +1 ) *BUS_HCLK_HZ ==GPLL_HZ && hclk_div <=0x3 ); +BUG_ON (!((hclk_div +1 ) *BUS_HCLK_HZ ==GPLL_HZ && hclk_div <=0x3 )); rk_clrsetreg(&cru->cru_clksel_con[0], BUS_ACLK_PLL_SEL_MASK | BUS_ACLK_DIV_MASK,
@@ -143,15 +142,13 @@ static void rkclk_init(struct rk3036_cru *cru)* set up dependent divisors for PCLK/HCLK and ACLK clocks. */ aclk_div =GPLL_HZ /PERI_ACLK_HZ -1 ; -assert ((aclk_div +1 ) *PERI_ACLK_HZ ==GPLL_HZ && aclk_div <0x1f ); +BUG_ON (!((aclk_div +1 ) *PERI_ACLK_HZ ==GPLL_HZ && aclk_div <0x1f )); hclk_div =ilog2 (PERI_ACLK_HZ /PERI_HCLK_HZ ); -assert ((1 << hclk_div) *PERI_HCLK_HZ == -PERI_ACLK_HZ && (hclk_div <0x4 )); +BUG_ON (!((1 << hclk_div) *PERI_HCLK_HZ ==PERI_ACLK_HZ && (hclk_div <0x4 ))); pclk_div =ilog2 (PERI_ACLK_HZ /PERI_PCLK_HZ ); -assert ((1 << pclk_div) *PERI_PCLK_HZ == -PERI_ACLK_HZ && pclk_div <0x8 ); +BUG_ON (!((1 << pclk_div) *PERI_PCLK_HZ ==PERI_ACLK_HZ && pclk_div <0x8 )); rk_clrsetreg(&cru->cru_clksel_con[10], PERI_PLL_SEL_MASK | PERI_PCLK_DIV_MASK |
@@ -251,7 +248,7 @@ static ulong rockchip_mmc_set_clk(struct rk3036_cru *cru, uint clk_general_rate,if (src_clk_div >128 ) { src_clk_div =DIV_ROUND_UP (OSC_HZ /2 , freq); -assert (src_clk_div -1 <128 ); +BUG_ON (src_clk_div -1 >=128 ); mux =EMMC_SEL_24M ; }else { mux =EMMC_SEL_GPLL ;
drivers/clk/rockchip/clk_rk3128.c +12 -15
@@ -51,8 +51,7 @@ static int rkclk_set_pll(struct rk3128_cru *cru, enum rk_clk_id clk_id,debug ("PLL at %p:fd=%d,rd=%d,pd1=%d,pd2=%d,vco=%uHz,output=%uHz\n" , pll, div->fbdiv, div->refdiv, div->postdiv1, div->postdiv2, vco_hz, output_hz); -assert (vco_hz >=VCO_MIN_HZ && vco_hz <=VCO_MAX_HZ && - output_hz >=OUTPUT_MIN_HZ && output_hz <=OUTPUT_MAX_HZ ); +BUG_ON (!(vco_hz >=VCO_MIN_HZ && vco_hz <=VCO_MAX_HZ && output_hz >=OUTPUT_MIN_HZ && output_hz <=OUTPUT_MAX_HZ ));/* use integer mode */ rk_setreg (&pll->con1,1 <<PLL_DSMPD_SHIFT );
@@ -162,10 +161,10 @@ static void rkclk_init(struct rk3128_cru *cru)* core hz : apll = 1:1 */ aclk_div =APLL_HZ /CORE_ACLK_HZ -1 ; -assert ((aclk_div +1 ) *CORE_ACLK_HZ ==APLL_HZ && aclk_div <0x7 ); +BUG_ON (!((aclk_div +1 ) *CORE_ACLK_HZ ==APLL_HZ && aclk_div <0x7 )); pclk_div =APLL_HZ /CORE_PERI_HZ -1 ; -assert ((pclk_div +1 ) *CORE_PERI_HZ ==APLL_HZ && pclk_div <0xf ); +BUG_ON (!((pclk_div +1 ) *CORE_PERI_HZ ==APLL_HZ && pclk_div <0xf )); rk_clrsetreg(&cru->cru_clksel_con[0], CORE_CLK_PLL_SEL_MASK | CORE_DIV_CON_MASK,
@@ -182,13 +181,13 @@ static void rkclk_init(struct rk3128_cru *cru)* set up dependent divisors for PCLK/HCLK and ACLK clocks. */ aclk_div =GPLL_HZ /BUS_ACLK_HZ -1 ; -assert ((aclk_div +1 ) *BUS_ACLK_HZ ==GPLL_HZ && aclk_div <=0x1f ); +BUG_ON (!((aclk_div +1 ) *BUS_ACLK_HZ ==GPLL_HZ && aclk_div <=0x1f )); pclk_div =BUS_ACLK_HZ /BUS_PCLK_HZ -1 ; -assert ((pclk_div +1 ) *BUS_PCLK_HZ ==BUS_ACLK_HZ && pclk_div <=0x7 ); +BUG_ON (!((pclk_div +1 ) *BUS_PCLK_HZ ==BUS_ACLK_HZ && pclk_div <=0x7 )); hclk_div =BUS_ACLK_HZ /BUS_HCLK_HZ -1 ; -assert ((hclk_div +1 ) *BUS_HCLK_HZ ==BUS_ACLK_HZ && hclk_div <=0x3 ); +BUG_ON (!((hclk_div +1 ) *BUS_HCLK_HZ ==BUS_ACLK_HZ && hclk_div <=0x3 )); rk_clrsetreg(&cru->cru_clksel_con[0], BUS_ACLK_PLL_SEL_MASK | BUS_ACLK_DIV_MASK,
@@ -205,15 +204,13 @@ static void rkclk_init(struct rk3128_cru *cru)* set up dependent divisors for PCLK/HCLK and ACLK clocks. */ aclk_div =GPLL_HZ /PERI_ACLK_HZ -1 ; -assert ((aclk_div +1 ) *PERI_ACLK_HZ ==GPLL_HZ && aclk_div <0x1f ); +BUG_ON (!((aclk_div +1 ) *PERI_ACLK_HZ ==GPLL_HZ && aclk_div <0x1f )); hclk_div =ilog2 (PERI_ACLK_HZ /PERI_HCLK_HZ ); -assert ((1 << hclk_div) *PERI_HCLK_HZ == -PERI_ACLK_HZ && (hclk_div <0x4 )); +BUG_ON (!((1 << hclk_div) *PERI_HCLK_HZ ==PERI_ACLK_HZ && (hclk_div <0x4 ))); pclk_div =ilog2 (PERI_ACLK_HZ /PERI_PCLK_HZ ); -assert ((1 << pclk_div) *PERI_PCLK_HZ == -PERI_ACLK_HZ && pclk_div <0x8 ); +BUG_ON (!((1 << pclk_div) *PERI_PCLK_HZ ==PERI_ACLK_HZ && pclk_div <0x8 )); rk_clrsetreg(&cru->cru_clksel_con[10], PERI_PLL_SEL_MASK | PERI_PCLK_DIV_MASK |
@@ -372,7 +369,7 @@ static ulong rk3128_peri_set_pclk(struct rk3128_cru *cru, ulong clk_id, uint hz)int src_clk_div; src_clk_div =PERI_ACLK_HZ / hz; -assert (src_clk_div -1 <4 ); +BUG_ON (src_clk_div -1 >=4 );switch (clk_id) {case PCLK_I2C0 :
@@ -407,7 +404,7 @@ static ulong rk3128_saradc_set_clk(struct rk3128_cru *cru, uint hz)int src_clk_div; src_clk_div =DIV_ROUND_UP (OSC_HZ , hz) -1 ; -assert (src_clk_div <128 ); +BUG_ON (src_clk_div >=128 ); rk_clrsetreg(&cru->cru_clksel_con[24], SARADC_DIV_CON_MASK,
@@ -422,7 +419,7 @@ static ulong rk3128_vop_set_clk(struct rk3128_cru *cru, ulong clk_id, uint hz)struct pll_div cpll_config = {0 }; src_clk_div =GPLL_HZ / hz; -assert (src_clk_div -1 <31 ); +BUG_ON (src_clk_div -1 >=31 );switch (clk_id) {case ACLK_VIO0 :
drivers/clk/rockchip/clk_rk3188.c +12 -16
@@ -96,9 +96,7 @@ static int rkclk_set_pll(struct rk3188_cru *cru, enum rk_clk_id clk_id,debug ("PLL at %x: nf=%d, nr=%d, no=%d, vco=%u Hz, output=%u Hz\n" , (uint )pll, div->nf, div->nr, div->no, vco_hz, output_hz); -assert (vco_hz >=VCO_MIN_HZ && vco_hz <=VCO_MAX_HZ && - output_hz >=OUTPUT_MIN_HZ && output_hz <=OUTPUT_MAX_HZ && - (div->no ==1 || !(div->no %2 ))); +BUG_ON (!(vco_hz >=VCO_MIN_HZ && vco_hz <=VCO_MAX_HZ && output_hz >=OUTPUT_MIN_HZ && output_hz <=OUTPUT_MAX_HZ && (div->no ==1 || !(div->no %2 ))));/* enter reset */ rk_setreg (&pll->con3,1 <<PLL_RESET_SHIFT );
@@ -295,7 +293,7 @@ static ulong rockchip_mmc_set_clk(struct rk3188_cru *cru, uint gclk_rate,debug ("%s: gclk_rate=%u\n" , __func__, gclk_rate);/* mmc clock defaulg div 2 internal, need provide double in cru */ src_clk_div =DIV_ROUND_UP (gclk_rate /2 , freq) -1 ; -assert (src_clk_div <=0x3f ); +BUG_ON (src_clk_div >0x3f );switch (periph) {case HCLK_EMMC :
@@ -350,16 +348,16 @@ static ulong rockchip_spi_set_clk(struct rk3188_cru *cru, uint gclk_rate, {int src_clk_div =DIV_ROUND_UP (gclk_rate, freq) -1 ; -assert (src_clk_div <128 ); +BUG_ON (src_clk_div >=128 );switch (periph) {case SCLK_SPI0 : -assert (src_clk_div <=SPI0_DIV_MASK ); +BUG_ON (src_clk_div >SPI0_DIV_MASK );rk_clrsetreg (&cru->cru_clksel_con[25 ],SPI0_DIV_MASK <<SPI0_DIV_SHIFT , src_clk_div <<SPI0_DIV_SHIFT );break ;case SCLK_SPI1 : -assert (src_clk_div <=SPI1_DIV_MASK ); +BUG_ON (src_clk_div >SPI1_DIV_MASK );rk_clrsetreg (&cru->cru_clksel_con[25 ],SPI1_DIV_MASK <<SPI1_DIV_SHIFT , src_clk_div <<SPI1_DIV_SHIFT );
@@ -400,7 +398,7 @@ static void rkclk_init(struct rk3188_cru *cru, struct rk3188_grf *grf,* set up dependent divisors for PCLK/HCLK and ACLK clocks. */ aclk_div =DIV_ROUND_UP (GPLL_HZ ,CPU_ACLK_HZ ) -1 ; -assert ((aclk_div +1 ) *CPU_ACLK_HZ ==GPLL_HZ && aclk_div <=0x1f ); +BUG_ON (!((aclk_div +1 ) *CPU_ACLK_HZ ==GPLL_HZ && aclk_div <=0x1f )); rk_clrsetreg(&cru->cru_clksel_con[0], CPU_ACLK_PLL_MASK << CPU_ACLK_PLL_SHIFT |
@@ -409,11 +407,11 @@ static void rkclk_init(struct rk3188_cru *cru, struct rk3188_grf *grf, aclk_div << A9_CPU_DIV_SHIFT); hclk_div =ilog2 (CPU_ACLK_HZ /CPU_HCLK_HZ ); -assert ((1 << hclk_div) *CPU_HCLK_HZ ==CPU_ACLK_HZ && hclk_div <0x3 ); +BUG_ON (!((1 << hclk_div) *CPU_HCLK_HZ ==CPU_ACLK_HZ && hclk_div <0x3 )); pclk_div =ilog2 (CPU_ACLK_HZ /CPU_PCLK_HZ ); -assert ((1 << pclk_div) *CPU_PCLK_HZ ==CPU_ACLK_HZ && pclk_div <0x4 ); +BUG_ON (!((1 << pclk_div) *CPU_PCLK_HZ ==CPU_ACLK_HZ && pclk_div <0x4 )); h2p_div =ilog2 (CPU_HCLK_HZ /CPU_H2P_HZ ); -assert ((1 << h2p_div) *CPU_H2P_HZ ==CPU_HCLK_HZ && pclk_div <0x3 ); +BUG_ON (!((1 << h2p_div) *CPU_H2P_HZ ==CPU_HCLK_HZ && pclk_div <0x3 )); rk_clrsetreg(&cru->cru_clksel_con[1], AHB2APB_DIV_MASK << AHB2APB_DIV_SHIFT |
@@ -428,15 +426,13 @@ static void rkclk_init(struct rk3188_cru *cru, struct rk3188_grf *grf,* set up dependent divisors for PCLK/HCLK and ACLK clocks. */ aclk_div =GPLL_HZ /PERI_ACLK_HZ -1 ; -assert ((aclk_div +1 ) *PERI_ACLK_HZ ==GPLL_HZ && aclk_div <0x1f ); +BUG_ON (!((aclk_div +1 ) *PERI_ACLK_HZ ==GPLL_HZ && aclk_div <0x1f )); hclk_div =ilog2 (PERI_ACLK_HZ /PERI_HCLK_HZ ); -assert ((1 << hclk_div) *PERI_HCLK_HZ == -PERI_ACLK_HZ && (hclk_div <0x4 )); +BUG_ON (!((1 << hclk_div) *PERI_HCLK_HZ ==PERI_ACLK_HZ && (hclk_div <0x4 ))); pclk_div =ilog2 (PERI_ACLK_HZ /PERI_PCLK_HZ ); -assert ((1 << pclk_div) *PERI_PCLK_HZ == -PERI_ACLK_HZ && (pclk_div <0x4 )); +BUG_ON (!((1 << pclk_div) *PERI_PCLK_HZ ==PERI_ACLK_HZ && (pclk_div <0x4 ))); rk_clrsetreg(&cru->cru_clksel_con[10], PERI_PCLK_DIV_MASK << PERI_PCLK_DIV_SHIFT |
drivers/clk/rockchip/clk_rk322x.c +10 -13
@@ -54,8 +54,7 @@ static int rkclk_set_pll(struct rk322x_cru *cru, enum rk_clk_id clk_id,debug ("PLL@%p: fb=%d, ref=%d, pst1=%d, pst2=%d, vco=%u Hz, output=%u Hz\n" , pll, div->fbdiv, div->refdiv, div->postdiv1, div->postdiv2, vco_hz, output_hz); -assert (vco_hz >=VCO_MIN_HZ && vco_hz <=VCO_MAX_HZ && - output_hz >=OUTPUT_MIN_HZ && output_hz <=OUTPUT_MAX_HZ ); +BUG_ON (!(vco_hz >=VCO_MIN_HZ && vco_hz <=VCO_MAX_HZ && output_hz >=OUTPUT_MIN_HZ && output_hz <=OUTPUT_MAX_HZ ));/* use integer mode */ rk_setreg (&pll->con1,1 <<PLL_DSMPD_SHIFT );
@@ -101,10 +100,10 @@ static void rkclk_init(struct rk322x_cru *cru)* core hz : apll = 1:1 */ aclk_div =APLL_HZ /CORE_ACLK_HZ -1 ; -assert ((aclk_div +1 ) *CORE_ACLK_HZ ==APLL_HZ && aclk_div <0x7 ); +BUG_ON (!((aclk_div +1 ) *CORE_ACLK_HZ ==APLL_HZ && aclk_div <0x7 )); pclk_div =APLL_HZ /CORE_PERI_HZ -1 ; -assert ((pclk_div +1 ) *CORE_PERI_HZ ==APLL_HZ && pclk_div <0xf ); +BUG_ON (!((pclk_div +1 ) *CORE_PERI_HZ ==APLL_HZ && pclk_div <0xf )); rk_clrsetreg(&cru->cru_clksel_con[0], CORE_CLK_PLL_SEL_MASK | CORE_DIV_CON_MASK,
@@ -121,13 +120,13 @@ static void rkclk_init(struct rk322x_cru *cru)* set up dependent divisors for PCLK/HCLK and ACLK clocks. */ aclk_div =GPLL_HZ /BUS_ACLK_HZ -1 ; -assert ((aclk_div +1 ) *BUS_ACLK_HZ ==GPLL_HZ && aclk_div <=0x1f ); +BUG_ON (!((aclk_div +1 ) *BUS_ACLK_HZ ==GPLL_HZ && aclk_div <=0x1f )); pclk_div =BUS_ACLK_HZ /BUS_PCLK_HZ -1 ; -assert ((pclk_div +1 ) *BUS_PCLK_HZ ==GPLL_HZ && pclk_div <=0x7 ); +BUG_ON (!((pclk_div +1 ) *BUS_PCLK_HZ ==GPLL_HZ && pclk_div <=0x7 )); hclk_div =BUS_ACLK_HZ /BUS_HCLK_HZ -1 ; -assert ((hclk_div +1 ) *BUS_HCLK_HZ ==GPLL_HZ && hclk_div <=0x3 ); +BUG_ON (!((hclk_div +1 ) *BUS_HCLK_HZ ==GPLL_HZ && hclk_div <=0x3 )); rk_clrsetreg(&cru->cru_clksel_con[0], BUS_ACLK_PLL_SEL_MASK | BUS_ACLK_DIV_MASK,
@@ -144,15 +143,13 @@ static void rkclk_init(struct rk322x_cru *cru)* set up dependent divisors for PCLK/HCLK and ACLK clocks. */ aclk_div =GPLL_HZ /PERI_ACLK_HZ -1 ; -assert ((aclk_div +1 ) *PERI_ACLK_HZ ==GPLL_HZ && aclk_div <0x1f ); +BUG_ON (!((aclk_div +1 ) *PERI_ACLK_HZ ==GPLL_HZ && aclk_div <0x1f )); hclk_div =ilog2 (PERI_ACLK_HZ /PERI_HCLK_HZ ); -assert ((1 << hclk_div) *PERI_HCLK_HZ == -PERI_ACLK_HZ && (hclk_div <0x4 )); +BUG_ON (!((1 << hclk_div) *PERI_HCLK_HZ ==PERI_ACLK_HZ && (hclk_div <0x4 ))); pclk_div =ilog2 (PERI_ACLK_HZ /PERI_PCLK_HZ ); -assert ((1 << pclk_div) *PERI_PCLK_HZ == -PERI_ACLK_HZ && pclk_div <0x8 ); +BUG_ON (!((1 << pclk_div) *PERI_PCLK_HZ ==PERI_ACLK_HZ && pclk_div <0x8 )); rk_clrsetreg(&cru->cru_clksel_con[10], PERI_PLL_SEL_MASK | PERI_PCLK_DIV_MASK |
@@ -252,7 +249,7 @@ static ulong rockchip_mmc_set_clk(struct rk322x_cru *cru, uint clk_general_rate,if (src_clk_div >128 ) { src_clk_div =DIV_ROUND_UP (OSC_HZ /2 , freq); -assert (src_clk_div -1 <128 ); +BUG_ON (src_clk_div -1 >=128 ); mux =EMMC_SEL_24M ; }else { mux =EMMC_SEL_GPLL ;
drivers/clk/rockchip/clk_rk3288.c +14 -22
@@ -152,9 +152,7 @@ static int rkclk_set_pll(struct rk3288_cru *cru, enum rk_clk_id clk_id,debug ("PLL at %x: nf=%d, nr=%d, no=%d, vco=%u Hz, output=%u Hz\n" , (uint )pll, div->nf, div->nr, div->no, vco_hz, output_hz); -assert (vco_hz >=VCO_MIN_HZ && vco_hz <=VCO_MAX_HZ && - output_hz >=OUTPUT_MIN_HZ && output_hz <=OUTPUT_MAX_HZ && - (div->no ==1 || !(div->no %2 ))); +BUG_ON (!(vco_hz >=VCO_MIN_HZ && vco_hz <=VCO_MAX_HZ && output_hz >=OUTPUT_MIN_HZ && output_hz <=OUTPUT_MAX_HZ && (div->no ==1 || !(div->no %2 ))));/* enter reset */ rk_setreg (&pll->con3,1 <<PLL_RESET_SHIFT );
@@ -374,14 +372,12 @@ static void rkclk_init(struct rk3288_cru *cru, struct rk3288_grf *grf)* set up dependent divisors for PCLK/HCLK and ACLK clocks. */ aclk_div =GPLL_HZ /PD_BUS_ACLK_HZ -1 ; -assert ((aclk_div +1 ) *PD_BUS_ACLK_HZ ==GPLL_HZ && aclk_div <0x1f ); +BUG_ON (!((aclk_div +1 ) *PD_BUS_ACLK_HZ ==GPLL_HZ && aclk_div <0x1f )); hclk_div =PD_BUS_ACLK_HZ /PD_BUS_HCLK_HZ -1 ; -assert ((hclk_div +1 ) *PD_BUS_HCLK_HZ == -PD_BUS_ACLK_HZ && (hclk_div <0x4 ) && (hclk_div !=0x2 )); +BUG_ON (!((hclk_div +1 ) *PD_BUS_HCLK_HZ ==PD_BUS_ACLK_HZ && (hclk_div <0x4 ) && (hclk_div !=0x2 ))); pclk_div =PD_BUS_ACLK_HZ /PD_BUS_PCLK_HZ -1 ; -assert ((pclk_div +1 ) *PD_BUS_PCLK_HZ == -PD_BUS_ACLK_HZ && pclk_div <0x7 ); +BUG_ON (!((pclk_div +1 ) *PD_BUS_PCLK_HZ ==PD_BUS_ACLK_HZ && pclk_div <0x7 )); rk_clrsetreg(&cru->cru_clksel_con[1], PD_BUS_PCLK_DIV_MASK | PD_BUS_HCLK_DIV_MASK |
@@ -396,15 +392,13 @@ static void rkclk_init(struct rk3288_cru *cru, struct rk3288_grf *grf)* set up dependent divisors for PCLK/HCLK and ACLK clocks. */ aclk_div =GPLL_HZ /PERI_ACLK_HZ -1 ; -assert ((aclk_div +1 ) *PERI_ACLK_HZ ==GPLL_HZ && aclk_div <0x1f ); +BUG_ON (!((aclk_div +1 ) *PERI_ACLK_HZ ==GPLL_HZ && aclk_div <0x1f )); hclk_div =ilog2 (PERI_ACLK_HZ /PERI_HCLK_HZ ); -assert ((1 << hclk_div) *PERI_HCLK_HZ == -PERI_ACLK_HZ && (hclk_div <0x4 )); +BUG_ON (!((1 << hclk_div) *PERI_HCLK_HZ ==PERI_ACLK_HZ && (hclk_div <0x4 ))); pclk_div =ilog2 (PERI_ACLK_HZ /PERI_PCLK_HZ ); -assert ((1 << pclk_div) *PERI_PCLK_HZ == -PERI_ACLK_HZ && (pclk_div <0x4 )); +BUG_ON (!((1 << pclk_div) *PERI_PCLK_HZ ==PERI_ACLK_HZ && (pclk_div <0x4 ))); rk_clrsetreg(&cru->cru_clksel_con[10], PERI_PCLK_DIV_MASK | PERI_HCLK_DIV_MASK |
@@ -542,14 +536,12 @@ static ulong rockchip_mmc_set_clk(struct rk3288_cru *cru, uint gclk_rate,if (src_clk_div >0x3f ) { src_clk_div =DIV_ROUND_UP (OSC_HZ /2 , freq); -assert (src_clk_div <0x40 ); +BUG_ON (src_clk_div >=0x40 ); mux =EMMC_PLL_SELECT_24MHZ ; -assert ((int )EMMC_PLL_SELECT_24MHZ == - (int )MMC0_PLL_SELECT_24MHZ ); +BUG_ON ((int )EMMC_PLL_SELECT_24MHZ != (int )MMC0_PLL_SELECT_24MHZ ); }else { mux =EMMC_PLL_SELECT_GENERAL ; -assert ((int )EMMC_PLL_SELECT_GENERAL == - (int )MMC0_PLL_SELECT_GENERAL ); +BUG_ON ((int )EMMC_PLL_SELECT_GENERAL != (int )MMC0_PLL_SELECT_GENERAL ); }switch (periph) {case HCLK_EMMC :
@@ -605,7 +597,7 @@ static ulong rockchip_spi_get_clk(struct rk3288_cru *cru, uint gclk_rate,default :return -EINVAL ; } -assert (mux ==SPI0_PLL_SELECT_GENERAL ); +BUG_ON (mux !=SPI0_PLL_SELECT_GENERAL );return DIV_TO_RATE (gclk_rate, div); }
@@ -617,7 +609,7 @@ static ulong rockchip_spi_set_clk(struct rk3288_cru *cru, uint gclk_rate,debug ("%s: clk_general_rate=%u\n" , __func__, gclk_rate); src_clk_div =DIV_ROUND_UP (gclk_rate, freq) -1 ; -assert (src_clk_div <128 ); +BUG_ON (src_clk_div >=128 );switch (periph) {case SCLK_SPI0 : rk_clrsetreg(&cru->cru_clksel_con[25],
@@ -660,7 +652,7 @@ static ulong rockchip_saradc_set_clk(struct rk3288_cru *cru, uint hz)int src_clk_div; src_clk_div =DIV_ROUND_UP (OSC_HZ , hz) -1 ; -assert (src_clk_div <128 ); +BUG_ON (src_clk_div >=128 ); rk_clrsetreg(&cru->cru_clksel_con[24], CLK_SARADC_DIV_CON_MASK,
@@ -766,7 +758,7 @@ static ulong rk3288_clk_set_rate(struct clk *clk, ulong rate)/* vop aclk source clk: cpll */ div =CPLL_HZ / rate; -assert ((div -1 <64 ) && (div * rate ==CPLL_HZ )); +BUG_ON (!((div -1 <64 ) && (div * rate ==CPLL_HZ )));switch (clk->id) {case ACLK_VOP0 :
drivers/clk/rockchip/clk_rk3328.c +3 -5
@@ -239,9 +239,7 @@ static void rkclk_set_pll(struct rk3328_cru *cru, enum rk_clk_id clk_id, postdiv2=%d, vco=%u khz, output=%u khz\n", pll_con, div->fbdiv, div->refdiv, div->postdiv1, div->postdiv2, vco_khz, output_khz); -assert (vco_khz >=VCO_MIN_KHZ && vco_khz <=VCO_MAX_KHZ && - output_khz >=OUTPUT_MIN_KHZ && output_khz <=OUTPUT_MAX_KHZ && - div->fbdiv >=PLL_DIV_MIN && div->fbdiv <=PLL_DIV_MAX ); +BUG_ON (!(vco_khz >=VCO_MIN_KHZ && vco_khz <=VCO_MAX_KHZ && output_khz >=OUTPUT_MIN_KHZ && output_khz <=OUTPUT_MAX_KHZ && div->fbdiv >=PLL_DIV_MIN && div->fbdiv <=PLL_DIV_MAX ));/* * When power on or changing PLL setting,
@@ -354,7 +352,7 @@ static ulong rk3328_i2c_set_clk(struct rk3328_cru *cru, ulong clk_id, uint hz)int src_clk_div; src_clk_div =GPLL_HZ / hz; -assert (src_clk_div -1 <127 ); +BUG_ON (src_clk_div -1 >=127 );switch (clk_id) {case SCLK_I2C0 :
@@ -496,7 +494,7 @@ static ulong rk3328_saradc_set_clk(struct rk3328_cru *cru, uint hz)int src_clk_div; src_clk_div =DIV_ROUND_UP (OSC_HZ , hz) -1 ; -assert (src_clk_div <128 ); +BUG_ON (src_clk_div >=128 ); rk_clrsetreg(&cru->clksel_con[23], CLK_SARADC_DIV_CON_MASK,
drivers/clk/rockchip/clk_rk3368.c +2 -2
@@ -377,7 +377,7 @@ static ulong rk3368_spi_set_clk(struct rk3368_cru *cru, ulong clk_id, uint hz)int src_clk_div; src_clk_div =DIV_ROUND_UP (GPLL_HZ , hz); -assert (src_clk_div <127 ); +BUG_ON (src_clk_div >=127 );switch (clk_id) { case SCLK_SPI0 ... SCLK_SPI2:
@@ -414,7 +414,7 @@ static ulong rk3368_saradc_set_clk(struct rk3368_cru *cru, uint hz)int src_clk_div; src_clk_div =DIV_ROUND_UP (OSC_HZ , hz) -1 ; -assert (src_clk_div <128 ); +BUG_ON (src_clk_div >=128 ); rk_clrsetreg(&cru->clksel_con[25], CLK_SARADC_DIV_CON_MASK,
drivers/clk/rockchip/clk_rk3399.c +20 -31
143 lines not on this page · raw message
drivers/clk/rockchip/clk_rv1108.c +1 -1
@@ -147,7 +147,7 @@ static ulong rv1108_saradc_set_clk(struct rv1108_cru *cru, uint hz)int src_clk_div; src_clk_div =DIV_ROUND_UP (OSC_HZ , hz) -1 ; -assert (src_clk_div <128 ); +BUG_ON (src_clk_div >=128 ); rk_clrsetreg(&cru->clksel_con[22], CLK_SARADC_DIV_CON_MASK,
drivers/core/device-remove.c +4 -4
@@ -32,7 +32,7 @@ static int device_chld_unbind(struct udevice *dev)struct udevice *pos, *n;int ret, saved_ret =0 ; -assert (dev); +BUG_ON (!dev);list_for_each_entry_safe (pos, n, &dev->child_head, sibling_node) { ret =device_unbind (pos);
@@ -54,7 +54,7 @@ static int device_chld_remove(struct udevice *dev, uint flags)struct udevice *pos, *n;int ret; -assert (dev); +BUG_ON (!dev);list_for_each_entry_safe (pos, n, &dev->child_head, sibling_node) { ret =device_remove (pos, flags);
@@ -80,7 +80,7 @@ int device_unbind(struct udevice *dev)return -EINVAL ; drv = dev->driver; -assert (drv); +BUG_ON (!drv);if (drv->unbind) { ret = drv->unbind (dev);
@@ -173,7 +173,7 @@ int device_remove(struct udevice *dev, uint flags)return 0 ; drv = dev->driver; -assert (drv); +BUG_ON (!drv); ret =uclass_pre_remove_device (dev);if (ret)
drivers/core/device.c +1 -1
@@ -307,7 +307,7 @@ int device_probe(struct udevice *dev)return 0 ; drv = dev->driver; -assert (drv); +BUG_ON (!drv);/* Allocate private data if requested and not reentered */ if (drv->priv_auto_alloc_size && !dev->priv) {
drivers/core/ofnode.c +12 -12
@@ -18,7 +18,7 @@int ofnode_read_u32 (ofnode node,const char *propname,u32 *outp) { -assert (ofnode_valid (node)); +BUG_ON (!ofnode_valid (node));debug ("%s: %s: " , __func__, propname);if (ofnode_is_np (node)) {
@@ -42,7 +42,7 @@ int ofnode_read_u32(ofnode node, const char *propname, u32 *outp)int ofnode_read_u32_default (ofnode node,const char *propname,u32 def) { -assert (ofnode_valid (node)); +BUG_ON (!ofnode_valid (node));ofnode_read_u32 (node, propname, &def);return def;
@@ -50,7 +50,7 @@ int ofnode_read_u32_default(ofnode node, const char *propname, u32 def)int ofnode_read_s32_default (ofnode node,const char *propname,s32 def) { -assert (ofnode_valid (node)); +BUG_ON (!ofnode_valid (node));ofnode_read_u32 (node, propname, (u32 *)&def);return def;
@@ -60,7 +60,7 @@ bool ofnode_read_bool(ofnode node, const char *propname) {const void *prop; -assert (ofnode_valid (node)); +BUG_ON (!ofnode_valid (node));debug ("%s: %s: " , __func__, propname); prop =ofnode_get_property (node, propname,NULL );
@@ -75,7 +75,7 @@ const char *ofnode_read_string(ofnode node, const char *propname)const char *str =NULL ;int len =-1 ; -assert (ofnode_valid (node)); +BUG_ON (!ofnode_valid (node));debug ("%s: %s: " , __func__, propname);if (ofnode_is_np (node)) {
@@ -107,7 +107,7 @@ ofnode ofnode_find_subnode(ofnode node, const char *subnode_name) {ofnode subnode; -assert (ofnode_valid (node)); +BUG_ON (!ofnode_valid (node));debug ("%s: %s: " , __func__, subnode_name);if (ofnode_is_np (node)) {
@@ -132,7 +132,7 @@ ofnode ofnode_find_subnode(ofnode node, const char *subnode_name)int ofnode_read_u32_array (ofnode node,const char *propname,u32 *out_values,size_t sz) { -assert (ofnode_valid (node)); +BUG_ON (!ofnode_valid (node));debug ("%s: %s: " , __func__, propname);if (ofnode_is_np (node)) {
@@ -147,7 +147,7 @@ int ofnode_read_u32_array(ofnode node, const char *propname,ofnode ofnode_first_subnode (ofnode node) { -assert (ofnode_valid (node)); +BUG_ON (!ofnode_valid (node));if (ofnode_is_np (node))return np_to_ofnode (node.np->child);
@@ -157,7 +157,7 @@ ofnode ofnode_first_subnode(ofnode node)ofnode ofnode_next_subnode (ofnode node) { -assert (ofnode_valid (node)); +BUG_ON (!ofnode_valid (node));if (ofnode_is_np (node))return np_to_ofnode (node.np->sibling);
@@ -167,7 +167,7 @@ ofnode ofnode_next_subnode(ofnode node)const char *ofnode_get_name (ofnode node) { -assert (ofnode_valid (node)); +BUG_ON (!ofnode_valid (node));if (ofnode_is_np (node))return strrchr (node.np->full_name,'/' ) +1 ;
@@ -271,7 +271,7 @@ int ofnode_read_string_count(ofnode node, const char *property)static void ofnode_from_fdtdec_phandle_args (struct fdtdec_phandle_args *in,struct ofnode_phandle_args *out) { -assert (OF_MAX_PHANDLE_ARGS ==MAX_PHANDLE_ARGS ); +BUG_ON (OF_MAX_PHANDLE_ARGS !=MAX_PHANDLE_ARGS ); out->node =offset_to_ofnode (in->node); out->args_count = in->args_count;memcpy (out->args, in->args,sizeof (out->args));
@@ -280,7 +280,7 @@ static void ofnode_from_fdtdec_phandle_args(struct fdtdec_phandle_args *in,static void ofnode_from_of_phandle_args (struct of_phandle_args *in,struct ofnode_phandle_args *out) { -assert (OF_MAX_PHANDLE_ARGS ==MAX_PHANDLE_ARGS ); +BUG_ON (OF_MAX_PHANDLE_ARGS !=MAX_PHANDLE_ARGS ); out->node =np_to_ofnode (in->np); out->args_count = in->args_count;memcpy (out->args, in->args,sizeof (out->args));
drivers/core/uclass.c +2 -2
@@ -371,7 +371,7 @@ int uclass_get_device_tail(struct udevice *dev, int ret, struct udevice **devp)if (ret)return ret; -assert (dev); +BUG_ON (!dev); ret =device_probe (dev);if (ret)return ret;
@@ -569,7 +569,7 @@ int uclass_resolve_seq(struct udevice *dev)int seq;int ret; -assert (dev->seq ==-1 ); +BUG_ON (dev->seq !=-1 ); ret =uclass_find_device_by_seq (dev->uclass->uc_drv->id, dev->req_seq, false, &dup);if (!ret) {
drivers/gpio/gpio-uclass.c +1 -1
@@ -480,7 +480,7 @@ const char *gpio_get_bank_info(struct udevice *dev, int *bit_count)/* Must be called on an active device */ priv =dev_get_uclass_priv (dev); -assert (priv); +BUG_ON (!priv); *bit_count = priv->gpio_count;return priv->bank_name;
drivers/i2c/i2c-uclass.c +1 -1
@@ -51,7 +51,7 @@ static int i2c_setup_offset(struct dm_i2c_chip *chip, uint offset, msg->buf = offset_buf;if (!chip->offset_len)return -EADDRNOTAVAIL ; -assert (chip->offset_len <=I2C_MAX_OFFSET_LEN ); +BUG_ON (chip->offset_len >I2C_MAX_OFFSET_LEN ); offset_len = chip->offset_len;while (offset_len--) *offset_buf++ = offset >> (8 * offset_len);
drivers/input/input.c +2 -2
@@ -248,7 +248,7 @@ static struct input_key_xlate *process_modifier(struct input_config *config,int i;/* Start with the main table, and see what modifiers change it */ -assert (config->num_tables >0 ); +BUG_ON (0 >= config->num_tables); table = &config->table[0 ];for (i =1 ; i < config->num_tables; i++) {struct input_key_xlate *tab = &config->table[i];
@@ -356,7 +356,7 @@ static int sort_array_by_ordering(int *dest, int count, int *order,if (array_search (order, ocount, temp[i]) ==-1 ) dest[dest_count++] = temp[i]; } -assert (dest_count == count); +BUG_ON (dest_count != count);return same; }
drivers/input/key_matrix.c +1 -1
@@ -184,7 +184,7 @@ int key_matrix_init(struct key_matrix *config, int rows, int cols, config->num_cols = cols; config->key_count = rows * cols; config->ghost_filter = ghost_filter; -assert (config->key_count >0 ); +BUG_ON (0 >= config->key_count);return 0 ; }
drivers/misc/cros_ec.c +5 -5
@@ -308,7 +308,7 @@ static int ec_command_inptr(struct cros_ec_dev *dev, uint8_t cmd,debug ("%s: len=%d, din=%p\n" , __func__, len, din);if (dinp) {/* If we have any data to return, it must be 64bit-aligned */ -assert (len <=0 || !((uintptr_t )din &7 )); +BUG_ON (!(len <=0 || !((uintptr_t )din &7 ))); *dinp = din; }
@@ -338,7 +338,7 @@ static int ec_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,uint8_t *in_buffer;int len; -assert ((din_len ==0 ) || din); +BUG_ON (!((din_len ==0 ) || din)); len =ec_command_inptr (dev, cmd, cmd_version, dout, dout_len, &in_buffer, din_len);if (len >0 ) {
@@ -347,7 +347,7 @@ static int ec_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,* disregard the result. */ if (din && in_buffer) { -assert (len <= din_len); +BUG_ON (len > din_len);memmove (din, in_buffer, len); } }
@@ -756,7 +756,7 @@ static int cros_ec_flash_write_block(struct cros_ec_dev *dev, p->offset = offset; p->size = size; -assert (data && p->size <=EC_FLASH_WRITE_VER0_SIZE ); +BUG_ON (!(data && p->size <=EC_FLASH_WRITE_VER0_SIZE ));memcpy (p +1 , data, p->size); ret = ec_command_inptr(dev, EC_CMD_FLASH_WRITE, 0,
@@ -787,7 +787,7 @@ static int cros_ec_flash_write_burst_size(struct cros_ec_dev *dev)*/ static int cros_ec_data_is_erased (const uint32_t *data,int size) { -assert (!(size &3 )); +BUG_ON ((size &3 )); size /=sizeof (uint32_t );for (; size >0 ; size -=4 , data++)if (*data !=-1U )
drivers/misc/cros_ec_i2c.c +2 -2
@@ -135,8 +135,8 @@ static int cros_ec_i2c_command(struct udevice *udev, uint8_t cmd,debug ("%s: Cannot receive %d bytes\n" , __func__, din_len);return -1 ; } -assert (dout_len >=0 ); -assert (dinp); +BUG_ON (0 > dout_len); +BUG_ON (!dinp); i2c_msg[0 ].addr = chip->chip_addr; i2c_msg[0 ].len = out_bytes;
drivers/mtd/nand/tegra_nand.c +1 -1
@@ -259,7 +259,7 @@ static void nand_command(struct mtd_info *mtd, unsigned int command,/* Emulate NAND_CMD_READOOB */ if (command ==NAND_CMD_READOOB ) { -assert (mtd->writesize !=0 ); +BUG_ON (!mtd->writesize); column += mtd->writesize; command =NAND_CMD_READ0 ; }
drivers/mtd/spi/sandbox.c +2 -2
@@ -138,7 +138,7 @@ static int sandbox_sf_probe(struct udevice *dev)if (!pdata->filename) {struct sandbox_state *state =state_get_current (); -assert (bus->seq !=-1 ); +BUG_ON (bus->seq ==-1 );if (bus->seq <CONFIG_SANDBOX_SPI_MAX_BUS ) spec = state->spi[bus->seq][cs].spec;if (!spec) {
@@ -416,7 +416,7 @@ static int sandbox_sf_xfer(struct udevice *dev, unsigned int bitlen, cnt = bytes - pos;debug (" tx: read(%u)\n" , cnt); -assert (tx); +BUG_ON (!tx); ret =os_read (sbsf->fd, tx + pos, cnt);if (ret <0 ) {puts ("sandbox_sf: os_read() failed\n" );
drivers/net/fsl-mc/mc.c +1 -1
@@ -591,7 +591,7 @@ static int wait_for_mc(bool booting_mc, u32 *final_reg_gsr)struct mc_ccsr_registers __iomem *mc_ccsr_regs =MC_CCSR_BASE_ADDR ;dmb (); -assert (timeout_ms >0 ); +BUG_ON (0 >= timeout_ms);for (;;) {udelay (1000 );/* throttle polling */ reg_gsr =in_le32 (&mc_ccsr_regs->reg_gsr);
drivers/phy/phy-uclass.c +1 -1
@@ -44,7 +44,7 @@ int generic_phy_get_by_index(struct udevice *dev, int index,debug ("%s(dev=%p, index=%d, phy=%p)\n" , __func__, dev, index, phy); -assert (phy); +BUG_ON (!phy); phy->dev =NULL ; ret =dev_read_phandle_with_args (dev,"phys" ,"#phy-cells" ,0 , index, &args);
drivers/power/tps6586x.c +2 -2
@@ -151,7 +151,7 @@ int tps6586x_set_pwm_mode(int mask)uchar val;int ret; -assert (tps6586x_dev); +BUG_ON (!tps6586x_dev); ret =tps6586x_read (PFM_MODE );if (ret !=-1 ) { val = (uchar )ret;
@@ -172,7 +172,7 @@ int tps6586x_adjust_sm0_sm1(int sm0_target, int sm1_target, int step, int rate,int sm0, sm1;int bad; -assert (tps6586x_dev); +BUG_ON (!tps6586x_dev);/* get current voltage settings */ if (read_voltages (&sm0, &sm1)) {
drivers/rtc/rtc-uclass.c +5 -5
@@ -14,7 +14,7 @@ int dm_rtc_get(struct udevice *dev, struct rtc_time *time) {struct rtc_ops *ops =rtc_get_ops (dev); -assert (ops); +BUG_ON (!ops);if (!ops->get)return -ENOSYS ;return ops->get (dev, time);
@@ -24,7 +24,7 @@ int dm_rtc_set(struct udevice *dev, struct rtc_time *time) {struct rtc_ops *ops =rtc_get_ops (dev); -assert (ops); +BUG_ON (!ops);if (!ops->set)return -ENOSYS ;return ops->set (dev, time);
@@ -34,7 +34,7 @@ int dm_rtc_reset(struct udevice *dev) {struct rtc_ops *ops =rtc_get_ops (dev); -assert (ops); +BUG_ON (!ops);if (!ops->reset)return -ENOSYS ;return ops->reset (dev);
@@ -44,7 +44,7 @@ int rtc_read8(struct udevice *dev, unsigned int reg) {struct rtc_ops *ops =rtc_get_ops (dev); -assert (ops); +BUG_ON (!ops);if (!ops->read8)return -ENOSYS ;return ops->read8 (dev, reg);
@@ -54,7 +54,7 @@ int rtc_write8(struct udevice *dev, unsigned int reg, int val) {struct rtc_ops *ops =rtc_get_ops (dev); -assert (ops); +BUG_ON (!ops);if (!ops->write8)return -ENOSYS ;return ops->write8 (dev, reg, val);
drivers/sound/sound.c +1 -1
@@ -15,7 +15,7 @@ void sound_create_square_wave(unsigned short *data, int size, uint32_t freq)const int period = freq ? sample / freq :0 ;const int half = period /2 ; -assert (freq); +BUG_ON (!freq);/* Make sure we don't overflow our buffer */ if (size %2 )
drivers/spi/exynos_spi.c +3 -3
@@ -86,7 +86,7 @@ static void spi_request_bytes(struct exynos_spi *regs, int count, int step)writel (0 , ®s->swap_cfg); } -assert (count && count < (1 <<16 )); +BUG_ON (!(count && count < (1 <<16 )));setbits_le32 (®s->ch_cfg,SPI_CH_RST );clrbits_le32 (®s->ch_cfg,SPI_CH_RST );
@@ -183,7 +183,7 @@ static int spi_rx_tx(struct exynos_spi_priv *priv, int todo,* and make sure that we transmit dummy bytes too, to * keep things going. */ -assert (!out_bytes); +BUG_ON (out_bytes); out_bytes = in_bytes; toread = in_bytes; txp =NULL ;
@@ -355,7 +355,7 @@ static int exynos_spi_xfer(struct udevice *dev, unsigned int bitlen,if ((flags &SPI_XFER_END ) && !(priv->mode &SPI_SLAVE )) {spi_cs_deactivate (dev);if (priv->skip_preamble) { -assert (!priv->skip_preamble); +BUG_ON (priv->skip_preamble);debug ("Failed to complete premable transaction\n" ); ret =-1 ; }
drivers/usb/emul/sandbox_flash.c +1 -1
@@ -222,7 +222,7 @@ static void setup_response(struct sandbox_flash_priv *priv, void *resp, csw->dCSWDataResidue =0 ; csw->bCSWStatus =CSWSTATUS_GOOD ; -assert (!resp || resp == priv->buff); +BUG_ON (!(!resp || resp == priv->buff)); priv->buff_used = size; }
drivers/usb/host/usb-uclass.c +2 -2
@@ -211,7 +211,7 @@ static void usb_scan_bus(struct udevice *bus, bool recurse) priv =dev_get_uclass_priv (bus); -assert (recurse);/* TODO: Support non-recusive */ +BUG_ON (!recurse);/* TODO: Support non-recusive */ printf ("scanning bus %d for devices... " , bus->seq);debug ("\n" );
@@ -744,7 +744,7 @@ struct udevice *usb_get_bus(struct udevice *dev) bus = bus->parent;if (!bus) {/* By design this cannot happen */ -assert (bus); +BUG_ON (!bus);debug ("USB HUB '%s' does not have a controller\n" , dev->name); }
drivers/video/stb_truetype.h +1 -1
@@ -417,7 +417,7 @@ int main(int arg, char **argv)#ifndef STBTT_assert#include <assert.h> -#define STBTT_assert (x) assert(x) +#define STBTT_assert (x) BUG_ON(!x)#endif #ifndef STBTT_strlen
fs/ext4/dev.c +1 -1
@@ -38,7 +38,7 @@ static disk_partition_t *part_info;void ext4fs_set_blk_dev (struct blk_desc *rbdd,disk_partition_t *info) { -assert (rbdd->blksz == (1 << rbdd->log2blksz)); +BUG_ON (rbdd->blksz != (1 << rbdd->log2blksz)); ext4fs_blk_desc = rbdd;get_fs ()->dev_desc = rbdd; part_info = info;
fs/ext4/ext4_common.c +1 -1
@@ -431,7 +431,7 @@ uint16_t ext4fs_checksum_update(uint32_t i) crc =ext2fs_crc16 (crc, &le32_i,sizeof (le32_i)); crc =ext2fs_crc16 (crc, desc, offset); offset +=sizeof (desc->bg_checksum);/* skip checksum */ -assert (offset ==sizeof (*desc)); +BUG_ON (offset !=sizeof (*desc));if (offset < fs->gdsize) { crc =ext2fs_crc16 (crc, (__u8 *)desc + offset, fs->gdsize - offset);
fs/ext4/ext4_journal.c +1 -1
@@ -191,7 +191,7 @@ int ext4fs_put_metadata(char *metadata_buffer, uint32_t blknr)return -EINVAL ; }if (dirty_block_ptr[gd_index]->buf) -assert (dirty_block_ptr[gd_index]->blknr == blknr); +BUG_ON (dirty_block_ptr[gd_index]->blknr != blknr);else dirty_block_ptr[gd_index]->buf =zalloc (fs->blksz);
fs/fat/fat.c +1 -1
@@ -705,7 +705,7 @@ static void fat_itr_child(fat_itr *itr, fat_itr *parent)fsdata *mydata = parent->fsdata;/* for silly macros */ unsigned clustnum =START (parent->dent); -assert (fat_itr_isdir (parent)); +BUG_ON (!fat_itr_isdir (parent)); itr->fsdata = parent->fsdata;if (clustnum >0 ) {
include/dm/ofnode.h +1 -3
@@ -157,9 +157,7 @@ static inline bool ofnode_is_np(ofnode node)* Check our assumption that flat tree offsets are not used when a * live tree is in use. */ -assert (!ofnode_valid (node) || - (of_live_active () ?_ofnode_to_np (node) - :_ofnode_to_np (node))); +BUG_ON (!(!ofnode_valid (node) || (of_live_active () ?_ofnode_to_np (node) :_ofnode_to_np (node))));#endif return of_live_active () &&ofnode_valid (node); }
include/efi_loader.h +6 -6
@@ -28,7 +28,7 @@ const char *__efi_nesting_dec(void);* Enter the u-boot world from UEFI: */ #define EFI_ENTRY (format, ...) do { \ - assert(__efi_entry_check()); \ + BUG_ON(!__efi_entry_check()); \ debug("%sEFI: Entry %s(" format ")\n", __efi_nesting_inc(), \ __func__, ##__VA_ARGS__); \ } while(0)
@@ -40,7 +40,7 @@ const char *__efi_nesting_dec(void);typeof (ret) _r = ret; \debug ("%sEFI: Exit: %s: %u\n" ,__efi_nesting_dec (), \ __func__, (u32)((uintptr_t ) _r & ~EFI_ERROR_MASK )); \ -assert (__efi_exit_check ()); \ +BUG_ON (!__efi_exit_check ()); \ _r; \ })
@@ -49,9 +49,9 @@ const char *__efi_nesting_dec(void);*/ #define EFI_CALL (exp) ({ \ debug("%sEFI: Call: %s\n", __efi_nesting_inc(), #exp); \ - assert(__efi_exit_check()); \ + BUG_ON(!__efi_exit_check()); \ typeof(exp) _r = exp; \ - assert(__efi_entry_check()); \ + BUG_ON(!__efi_entry_check()); \ debug("%sEFI: %lu returned by %s\n", __efi_nesting_dec(), \ (unsigned long)((uintptr_t)_r & ~EFI_ERROR_MASK), #exp); \ _r; \
@@ -62,9 +62,9 @@ const char *__efi_nesting_dec(void);*/ #define EFI_CALL_VOID (exp) do { \ debug("%sEFI: Call: %s\n", __efi_nesting_inc(), #exp); \ - assert(__efi_exit_check()); \ + BUG_ON(!__efi_exit_check()); \ exp; \ - assert(__efi_entry_check()); \ + BUG_ON(!__efi_entry_check()); \ debug("%sEFI: Return From: %s\n", __efi_nesting_dec(), #exp); \ } while(0)
lib/circbuf.c +8 -8
@@ -13,12 +13,12 @@int buf_init (circbuf_t * buf,unsigned int size) { -assert (buf !=NULL ); +BUG_ON (!buf); buf->size =0 ; buf->totalsize = size; buf->data = (char *)malloc (sizeof (char ) * size); -assert (buf->data !=NULL ); +BUG_ON (!buf->data); buf->top = buf->data; buf->tail = buf->data;
@@ -29,8 +29,8 @@ int buf_init (circbuf_t * buf, unsigned int size)int buf_free (circbuf_t * buf) { -assert (buf !=NULL ); -assert (buf->data !=NULL ); +BUG_ON (!buf); +BUG_ON (!buf->data);free (buf->data);memset (buf,0 ,sizeof (circbuf_t));
@@ -43,8 +43,8 @@ int buf_pop (circbuf_t * buf, char *dest, unsigned int len)unsigned int i;char *p; -assert (buf !=NULL ); -assert (dest !=NULL ); +BUG_ON (!buf); +BUG_ON (!dest); p = buf->top;
@@ -73,8 +73,8 @@ int buf_push (circbuf_t * buf, const char *src, unsigned int len)unsigned int i;char *p; -assert (buf !=NULL ); -assert (src !=NULL ); +BUG_ON (!buf); +BUG_ON (!src); p = buf->tail;
lib/efi_loader/efi_boottime.c +1 -1
@@ -62,7 +62,7 @@ int __efi_entry_check(void) {int ret = entry_count++ ==0 ;#ifdef CONFIG_ARM -assert (efi_gd); +BUG_ON (!efi_gd); app_gd = gd; gd = efi_gd;#endif
lib/efi_loader/efi_device_path.c +1 -1
@@ -560,7 +560,7 @@ struct efi_device_path *efi_dp_from_eth(void)void *buf, *start;unsigned dpsize =0 ; -assert (eth_get_dev ()); +BUG_ON (!eth_get_dev ());#ifdef CONFIG_DM_ETH dpsize +=dp_size (eth_get_dev ());
lib/efi_loader/efi_file.c +1 -1
@@ -249,7 +249,7 @@ static efi_status_t dir_read(struct file_handle *fh, u64 *buffer_size,unsigned int required_size;if (!fh->dirs) { -assert (fh->offset ==0 ); +BUG_ON (fh->offset); fh->dirs =fs_opendir (fh->path);if (!fh->dirs)return EFI_DEVICE_ERROR ;
lib/efi_loader/efi_memory.c +1 -1
@@ -385,7 +385,7 @@ efi_status_t efi_free_pool(void *buffer) alloc = container_of(buffer, struct efi_pool_allocation, data);/* Sanity check, was the supplied address returned by allocate_pool */ -assert (((uintptr_t )alloc &EFI_PAGE_MASK ) ==0 ); +BUG_ON (((uintptr_t )alloc &EFI_PAGE_MASK )); r =efi_free_pages ((uintptr_t )alloc, alloc->num_pages);
lib/fdtdec.c +4 -4
@@ -78,7 +78,7 @@ static const char * const compat_names[COMPAT_COUNT] = {const char *fdtdec_get_compatible (enum fdt_compat_id id) {/* We allow reading of the 'unknown' ID for testing purposes */ -assert (id >=0 && id <COMPAT_COUNT ); +BUG_ON (!(id >=0 && id <COMPAT_COUNT ));return compat_names[id]; }
@@ -378,7 +378,7 @@ int fdtdec_next_alias(const void *blob, const char *name,int node, err;/* snprintf() is not available */ -assert (strlen (name) <MAX_STR_LEN ); +BUG_ON (strlen (name) >=MAX_STR_LEN );sprintf (str,"%.*s%d" ,MAX_STR_LEN , name, *upto); node =fdt_path_offset (blob, str);if (node <0 )
@@ -505,7 +505,7 @@ int fdtdec_add_aliases_for_id(const void *blob, const char *name,if (j == maxcount)break ; -assert (!node_list[i]); +BUG_ON (node_list[i]); node_list[i] = nodes[j++];if (i >= num_found) num_found = i +1 ;
@@ -585,7 +585,7 @@ int fdtdec_check_fdt(void)* FDT (prior to console ready) will need to make their own * arrangements and do their own checks. */ -assert (!fdtdec_prepare_fdt ()); +BUG_ON (fdtdec_prepare_fdt ());return 0 ; }
lib/membuff.c +2 -2
@@ -25,7 +25,7 @@ static int membuff_putrawflex(struct membuff *mb, int maxlen, bool update,int len;/* always write to 'mb->head' */ -assert (data && offsetp); +BUG_ON (!(data && offsetp)); *data = &mb->start; *offsetp = mb->head - mb->start;
@@ -330,7 +330,7 @@ int membuff_extend_by(struct membuff *mb, int by, int max)char *ptr;/* double the buffer size until it is big enough */ -assert (by >=0 ); +BUG_ON (0 > by);for (orig = mb->end - mb->start, size = orig; size < orig + by;) size *=2 ;if (max !=-1 )
lib/physmem.c +2 -2
@@ -16,7 +16,7 @@ phys_addr_t __weak arch_phys_memset(phys_addr_t s, int c, phys_size_t n) {void *s_ptr = (void *)(uintptr_t )s; -assert (((phys_addr_t )(uintptr_t )s) == s); -assert (((phys_addr_t)(uintptr_t)(s + n)) == s + n); +BUG_ON (((phys_addr_t )(uintptr_t )s) != s); +BUG_ON (((phys_addr_t)(uintptr_t)(s + n)) != s + n);return (phys_addr_t )(uintptr_t )memset (s_ptr, c, n); }
lib/qsort.c +1 -1
@@ -28,7 +28,7 @@ void qsort(void *base,char tmp;if ((nel >1 ) && (width >0 )) { -assert (nel <= ((size_t )(-1 )) / width);/* check for overflow */ +BUG_ON (nel > ((size_t )(-1 )) / width);/* check for overflow */ wgap =0 ; do { wgap = 3 * wgap + 1;
lib/slre.c +4 -4
@@ -165,7 +165,7 @@ slre_dump(const struct slre *r, FILE *fp)static void set_jump_offset (struct slre *r,int pc,int offset) { -assert (offset < r->code_size); +BUG_ON (offset >= r->code_size);if (r->code_size - offset >0xff ) r->err_str ="Jump offset is too big" ;
@@ -507,8 +507,8 @@ match(const struct slre *r, int pc, const char *s, int len,while (res && r->code[pc] !=END ) { -assert (pc < r->code_size); -assert (pc < (int ) (sizeof (r->code) /sizeof (r->code[0 ]))); +BUG_ON (pc >= r->code_size); +BUG_ON (pc >= (int )(sizeof (r->code) /sizeof (r->code[0 ])));switch (r->code[pc]) {case BRANCH :
@@ -635,7 +635,7 @@ match(const struct slre *r, int pc, const char *s, int len,break ;default :printf ("unknown cmd (%d) at %d\n" , r->code[pc], pc); -assert (0 ); +BUG ();break ; } }
net/eth-uclass.c +1 -1
@@ -42,7 +42,7 @@ static struct eth_uclass_priv *eth_get_uclass_priv(void)struct uclass *uc;uclass_get (UCLASS_ETH , &uc); -assert (uc); +BUG_ON (!uc);return uc->priv; }
net/eth_legacy.c +1 -1
@@ -187,7 +187,7 @@ int eth_register(struct eth_device *dev)struct eth_device *d;static int index; -assert (strlen (dev->name) <sizeof (dev->name)); +BUG_ON (strlen (dev->name) >=sizeof (dev->name));if (!eth_devices) { eth_devices = dev;
net/net.c +1 -1
@@ -784,7 +784,7 @@ int net_send_udp_packet(uchar *ether, struct in_addr dest, int dport, int sport,int pkt_hdr_size;/* make sure the net_tx_packet is initialized (net_init() was called) */ -assert (net_tx_packet !=NULL ); +BUG_ON (!net_tx_packet);if (net_tx_packet ==NULL )return -1 ;
test/command_ut.c +15 -15
@@ -19,16 +19,16 @@ static int do_ut_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])/* commands separated by \n */ run_command_list ("setenv list 1\n setenv list ${list}1" ,-1 ,0 ); -assert (!strcmp ("11" ,env_get ("list" ))); +BUG_ON (strcmp ("11" ,env_get ("list" )));/* command followed by \n and nothing else */ run_command_list ("setenv list 1${list}\n" ,-1 ,0 ); -assert (!strcmp ("111" ,env_get ("list" ))); +BUG_ON (strcmp ("111" ,env_get ("list" )));/* a command string with \0 in it. Stuff after \0 should be ignored */ run_command ("setenv list" ,0 );run_command_list (test_cmd,sizeof (test_cmd),0 ); -assert (!strcmp ("123" ,env_get ("list" ))); +BUG_ON (strcmp ("123" ,env_get ("list" )));/* * a command list where we limit execution to only the first command
@@ -36,26 +36,26 @@ static int do_ut_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])*/ run_command_list ("setenv list 1\n setenv list ${list}2; " "setenv list ${list}3" ,strlen ("setenv list 1" ),0 ); -assert (!strcmp ("1" ,env_get ("list" ))); +BUG_ON (strcmp ("1" ,env_get ("list" ))); -assert (run_command ("false" ,0 ) ==1 ); -assert (run_command ("echo" ,0 ) ==0 ); -assert (run_command_list ("false" ,-1 ,0 ) ==1 ); -assert (run_command_list ("echo" ,-1 ,0 ) ==0 ); +BUG_ON (run_command ("false" ,0 ) !=1 ); +BUG_ON (run_command ("echo" ,0 )); +BUG_ON (run_command_list ("false" ,-1 ,0 ) !=1 ); +BUG_ON (run_command_list ("echo" ,-1 ,0 ));#ifdef CONFIG_HUSH_PARSER run_command ("setenv foo 'setenv black 1\nsetenv adder 2'" ,0 );run_command ("run foo" ,0 ); -assert (env_get ("black" ) !=NULL ); -assert (!strcmp ("1" ,env_get ("black" ))); -assert (env_get ("adder" ) !=NULL ); -assert (!strcmp ("2" ,env_get ("adder" ))); +BUG_ON (!env_get ("black" )); +BUG_ON (strcmp ("1" ,env_get ("black" ))); +BUG_ON (!env_get ("adder" )); +BUG_ON (strcmp ("2" ,env_get ("adder" )));#endif -assert (run_command ("" ,0 ) ==0 ); -assert (run_command (" " ,0 ) ==0 ); +BUG_ON (run_command ("" ,0 )); +BUG_ON (run_command (" " ,0 )); -assert (run_command ("'" ,0 ) ==1 ); +BUG_ON (run_command ("'" ,0 ) !=1 );printf ("%s: Everything went swimmingly\n" , __func__);return 0 ;
test/print_ut.c +21 -21
77 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v3 6/6 Remove assert()
In reply to Masahiro YamadaNo more users of assert() except host tools. Remove.
---
Changes in v3:
- Rebase on v2017.01
Changes in v2: None
include/log.h | 15 --------------- lib/tiny-printf.c | 9 --------- lib/vsprintf.c | 9 --------- 3 files changed, 33 deletions(-)
include/log.h +0 -15
@@ -141,21 +141,6 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file, #define warn_non_spl(fmt, args...) \ debug_cond(!_SPL_BUILD, fmt, ##args) -/* -* An assertion is run-time check done in debug mode only. If DEBUG is not -* defined then it is skipped. If DEBUG is defined and the assertion fails, -* then it calls panic*( which may or may not reset/halt U-Boot (see -* CONFIG_PANIC_HANG), It is hoped that all failing assertions are found -* before release, and after release it is hoped that they don't matter. But -* in any case these failing assertions cannot be fixed with a reset (which -* may just do the same assertion again). -*/ -void __assert_fail (const char *assertion,const char *file,unsigned int line, -const char *function); -#define assert (x) \ - ({ if (!(x) && _DEBUG) \ - __assert_fail(#x, __FILE__, __LINE__, __func__); }) -/** * struct log_rec - a single log record *
lib/tiny-printf.c +0 -9
@@ -381,12 +381,3 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)return ret; } - -void __assert_fail (const char *assertion,const char *file,unsigned line, -const char *function) -{ -/* This will not return */ -printf ("%s:%u: %s: Assertion `%s' failed." , file, line, function, - assertion); -hang (); -}
lib/vsprintf.c +0 -9
@@ -789,15 +789,6 @@ int vprintf(const char *fmt, va_list args)return i; } - -void __assert_fail (const char *assertion,const char *file,unsigned line, -const char *function) -{ -/* This will not return */ -panic ("%s:%u: %s: Assertion `%s' failed." , file, line, function, - assertion); -} -char *simple_itoa (ulong i) {/* 21 digits plus null terminator, good for 64-bit or smaller ints */
Signature · 1 line
2.7.4
v3 cover assert() is almost used in the same way as BUG_ON(), except:
In reply to Masahiro YamadaQuoted 11 lines · Masahiro Yamada
- the logic is opposite
- currently,assert()is compiled only when DEBUG is definedCoccinelle can easily convert
assert()toBUG_ON().A problem is it would grow the image size.
In v2, I introduced a new CONFIG option to allow to disable it.In v3, it is default 'y'. I disabled it only for openrd boards.
Quoted 8 lines
Masahiro Yamada (6):
EnableCONFIG_PANIC_HANGfor boards withoutdo_reset()
usb: xhci: returnERR_PTR(-ETIMEDOUT)at the end of
xhci_wait_for_event()
IntroduceCONFIG_BUG_CHECKSto allow to disable BUG{_ON} andWARN_ON
ARM: openrd: disableCONFIG_BUG_CHECKS
treewide: convertassert()toBUG_ON()
Removeassert()
So, as much as I want this change in theory, I'm not sure what to do with this series. First, there's the USB side (and other I'm sure less visible cases) where this does change behavior a bit. But second, and harder to deal with, is that this totally breaks all of our test/py code (make tests hangs) and I haven't come up with a good fix. I think some of these changes can certainly be brought in.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/fc23c871/attachment.sig>