2015-07-13 16:14:47

by Paul Burton

[permalink] [raw]
Subject: [PATCH 1/2] MIPS: PCI: ops-emma2rh: drop nonsensical db_assert

The db_assert call checks whether the bus_num pointer is non-NULL, but
does so after said pointer has been dereferenced by the assignment on
the previous line. Thus the check is pointless & likely to have been
optimised out by the compiler anyway. The check_args function is static
& only ever called from the local file with bus_num being a pointer to
an on-stack variable, so the check seems somewhat overzealous anyway.
Simply remove it.

Signed-off-by: Paul Burton <[email protected]>
---

arch/mips/pci/ops-emma2rh.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/mips/pci/ops-emma2rh.c b/arch/mips/pci/ops-emma2rh.c
index 710aef5..2dc97c4 100644
--- a/arch/mips/pci/ops-emma2rh.c
+++ b/arch/mips/pci/ops-emma2rh.c
@@ -25,7 +25,6 @@
#include <linux/types.h>

#include <asm/addrspace.h>
-#include <asm/debug.h>

#include <asm/emma/emma2rh.h>

@@ -40,10 +39,9 @@
static int check_args(struct pci_bus *bus, u32 devfn, u32 * bus_num)
{
/* check if the bus is top-level */
- if (bus->parent != NULL) {
+ if (bus->parent != NULL)
*bus_num = bus->number;
- db_assert(bus_num != NULL);
- } else
+ else
*bus_num = 0;

if (*bus_num == 0) {
--
2.4.5


2015-07-13 16:15:10

by Paul Burton

[permalink] [raw]
Subject: [PATCH 2/2] MIPS: drop CONFIG_RUNTIME_DEBUG & debug.h

The debug.h header provided some MIPS-specific debug macros, which are
no longer used at all. Remove them.

Signed-off-by: Paul Burton <[email protected]>
---

arch/mips/Kconfig.debug | 9 --------
arch/mips/include/asm/debug.h | 48 -------------------------------------------
2 files changed, 57 deletions(-)
delete mode 100644 arch/mips/include/asm/debug.h

diff --git a/arch/mips/Kconfig.debug b/arch/mips/Kconfig.debug
index 3a2b775..e250524 100644
--- a/arch/mips/Kconfig.debug
+++ b/arch/mips/Kconfig.debug
@@ -87,15 +87,6 @@ config SB1XXX_CORELIS
Select compile flags that produce code that can be processed by the
Corelis mksym utility and UDB Emulator.

-config RUNTIME_DEBUG
- bool "Enable run-time debugging"
- depends on DEBUG_KERNEL
- help
- If you say Y here, some debugging macros will do run-time checking.
- If you say N here, those macros will mostly turn to no-ops. See
- arch/mips/include/asm/debug.h for debugging macros.
- If unsure, say N.
-
config DEBUG_ZBOOT
bool "Enable compressed kernel support debugging"
depends on DEBUG_KERNEL && SYS_SUPPORTS_ZBOOT
diff --git a/arch/mips/include/asm/debug.h b/arch/mips/include/asm/debug.h
deleted file mode 100644
index 1fd5a2b..0000000
--- a/arch/mips/include/asm/debug.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Debug macros for run-time debugging.
- * Turned on/off with CONFIG_RUNTIME_DEBUG option.
- *
- * Copyright (C) 2001 MontaVista Software Inc.
- * Author: Jun Sun, [email protected] or [email protected]
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- */
-
-#ifndef _ASM_DEBUG_H
-#define _ASM_DEBUG_H
-
-
-/*
- * run-time macros for catching spurious errors. Eable CONFIG_RUNTIME_DEBUG in
- * kernel hacking config menu to use them.
- *
- * Use them as run-time debugging aid. NEVER USE THEM AS ERROR HANDLING CODE!!!
- */
-
-#ifdef CONFIG_RUNTIME_DEBUG
-
-#include <linux/kernel.h>
-
-#define db_assert(x) if (!(x)) { \
- panic("assertion failed at %s:%d: %s", __FILE__, __LINE__, #x); }
-#define db_warn(x) if (!(x)) { \
- printk(KERN_WARNING "warning at %s:%d: %s", __FILE__, __LINE__, #x); }
-#define db_verify(x, y) db_assert(x y)
-#define db_verify_warn(x, y) db_warn(x y)
-#define db_run(x) do { x; } while (0)
-
-#else
-
-#define db_assert(x)
-#define db_warn(x)
-#define db_verify(x, y) x
-#define db_verify_warn(x, y) x
-#define db_run(x)
-
-#endif
-
-#endif /* _ASM_DEBUG_H */
--
2.4.5

2015-07-14 08:30:40

by Ralf Baechle

[permalink] [raw]
Subject: Re: [PATCH 1/2] MIPS: PCI: ops-emma2rh: drop nonsensical db_assert

On Mon, Jul 13, 2015 at 05:14:21PM +0100, Paul Burton wrote:

> The db_assert call checks whether the bus_num pointer is non-NULL, but
> does so after said pointer has been dereferenced by the assignment on
> the previous line. Thus the check is pointless & likely to have been
> optimised out by the compiler anyway. The check_args function is static
> & only ever called from the local file with bus_num being a pointer to
> an on-stack variable, so the check seems somewhat overzealous anyway.
> Simply remove it.

Thanks, applied.

Your patch btw. leaves the db_verify() macro as the sole caller of
db_assert() and db_verify() itself is unused and in fact, nothing
includes <asm/debug.h> anymore. Removing <asm/debug.h> leaves
CONFIG_RUNTIME_DEBUG unused, so I'm removing that one, too.

Ralf

2015-07-14 08:32:56

by Paul Burton

[permalink] [raw]
Subject: Re: [PATCH 1/2] MIPS: PCI: ops-emma2rh: drop nonsensical db_assert

On Tue, Jul 14, 2015 at 10:30:30AM +0200, Ralf Baechle wrote:
> On Mon, Jul 13, 2015 at 05:14:21PM +0100, Paul Burton wrote:
>
> > The db_assert call checks whether the bus_num pointer is non-NULL, but
> > does so after said pointer has been dereferenced by the assignment on
> > the previous line. Thus the check is pointless & likely to have been
> > optimised out by the compiler anyway. The check_args function is static
> > & only ever called from the local file with bus_num being a pointer to
> > an on-stack variable, so the check seems somewhat overzealous anyway.
> > Simply remove it.
>
> Thanks, applied.
>
> Your patch btw. leaves the db_verify() macro as the sole caller of
> db_assert() and db_verify() itself is unused and in fact, nothing
> includes <asm/debug.h> anymore. Removing <asm/debug.h> leaves
> CONFIG_RUNTIME_DEBUG unused, so I'm removing that one, too.
>
> Ralf

Hi Ralf,

That's precisely what led me to write this patch, and precisely what the
following patch I submitted (MIPS: drop CONFIG_RUNTIME_DEBUG & debug.h)
does:

http://patchwork.linux-mips.org/patch/10693/

Thanks,
Paul