Skip to content

Commit

Permalink
Merge tag 'bug-for-3.4' of git://git.kernel.org/pub/scm/linux/kernel/…
Browse files Browse the repository at this point in the history
…git/paulg/linux

Pull <linux/bug.h> cleanup from Paul Gortmaker:
 "The changes shown here are to unify linux's BUG support under the one
  <linux/bug.h> file.  Due to historical reasons, we have some BUG code
  in bug.h and some in kernel.h -- i.e.  the support for BUILD_BUG in
  linux/kernel.h predates the addition of linux/bug.h, but old code in
  kernel.h wasn't moved to bug.h at that time.  As a band-aid, kernel.h
  was including <asm/bug.h> to pseudo link them.

  This has caused confusion[1] and general yuck/WTF[2] reactions.  Here
  is an example that violates the principle of least surprise:

      CC      lib/string.o
      lib/string.c: In function 'strlcat':
      lib/string.c:225:2: error: implicit declaration of function 'BUILD_BUG_ON'
      make[2]: *** [lib/string.o] Error 1
      $
      $ grep linux/bug.h lib/string.c
      #include <linux/bug.h>
      $

  We've included <linux/bug.h> for the BUG infrastructure and yet we
  still get a compile fail! [We've not kernel.h for BUILD_BUG_ON.] Ugh -
  very confusing for someone who is new to kernel development.

  With the above in mind, the goals of this changeset are:

  1) find and fix any include/*.h files that were relying on the
     implicit presence of BUG code.
  2) find and fix any C files that were consuming kernel.h and hence
     relying on implicitly getting some/all BUG code.
  3) Move the BUG related code living in kernel.h to <linux/bug.h>
  4) remove the asm/bug.h from kernel.h to finally break the chain.

  During development, the order was more like 3-4, build-test, 1-2.  But
  to ensure that git history for bisect doesn't get needless build
  failures introduced, the commits have been reorderd to fix the problem
  areas in advance.

	[1]  https://lkml.org/lkml/2012/1/3/90
	[2]  https://lkml.org/lkml/2012/1/17/414"

Fix up conflicts (new radeon file, reiserfs header cleanups) as per Paul
and linux-next.

* tag 'bug-for-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux:
  kernel.h: doesn't explicitly use bug.h, so don't include it.
  bug: consolidate BUILD_BUG_ON with other bug code
  BUG: headers with BUG/BUG_ON etc. need linux/bug.h
  bug.h: add include of it to various implicit C users
  lib: fix implicit users of kernel.h for TAINT_WARN
  spinlock: macroize assert_spin_locked to avoid bug.h dependency
  x86: relocate get/set debugreg fcns to include/asm/debugreg.
  • Loading branch information
torvalds committed Mar 24, 2012
2 parents f1d38e4 + 6c03438 commit ed2d265
Show file tree
Hide file tree
Showing 93 changed files with 223 additions and 132 deletions.
1 change: 1 addition & 0 deletions arch/arm/mach-imx/cpu_op-mx51.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* http://www.gnu.org/copyleft/gpl.html
*/

#include <linux/bug.h>
#include <linux/types.h>
#include <mach/hardware.h>
#include <linux/kernel.h>
Expand Down
1 change: 1 addition & 0 deletions arch/arm/mach-ux500/board-mop500-pins.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/bug.h>

#include <asm/mach-types.h>
#include <plat/pincfg.h>
Expand Down
1 change: 1 addition & 0 deletions arch/avr32/include/asm/io.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef __ASM_AVR32_IO_H
#define __ASM_AVR32_IO_H

#include <linux/bug.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/types.h>
Expand Down
1 change: 1 addition & 0 deletions arch/m68k/include/asm/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <linux/linkage.h>
#include <linux/kernel.h>
#include <linux/bug.h>
#include <linux/irqflags.h>
#include <asm/segment.h>
#include <asm/entry.h>
Expand Down
1 change: 1 addition & 0 deletions arch/mips/fw/arc/cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*
* Copyright (C) 1996 David S. Miller ([email protected])
*/
#include <linux/bug.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/string.h>
Expand Down
1 change: 1 addition & 0 deletions arch/mips/fw/arc/identify.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*
* Copyright (C) 1996 David S. Miller ([email protected])
*/
#include <linux/bug.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/types.h>
Expand Down
1 change: 1 addition & 0 deletions arch/parisc/math-emu/fpudispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#define FPUDEBUG 0

#include "float.h"
#include <linux/bug.h>
#include <linux/kernel.h>
#include <asm/processor.h>
/* #include <sys/debug.h> */
Expand Down
1 change: 1 addition & 0 deletions arch/powerpc/kernel/pmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

#include <linux/errno.h>
#include <linux/bug.h>
#include <linux/spinlock.h>
#include <linux/export.h>

Expand Down
1 change: 1 addition & 0 deletions arch/powerpc/xmon/ppc-opc.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <linux/stddef.h>
#include <linux/kernel.h>
#include <linux/bug.h>
#include "nonstdio.h"
#include "ppc.h"

Expand Down
1 change: 1 addition & 0 deletions arch/powerpc/xmon/spu-opc.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */

#include <linux/kernel.h>
#include <linux/bug.h>
#include "spu.h"

/* This file holds the Spu opcode table */
Expand Down
1 change: 1 addition & 0 deletions arch/sparc/include/asm/vga.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#ifndef _LINUX_ASM_VGA_H_
#define _LINUX_ASM_VGA_H_

#include <linux/bug.h>
#include <asm/types.h>

#define VT_BUF_HAVE_RW
Expand Down
67 changes: 67 additions & 0 deletions arch/x86/include/asm/debugreg.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,75 @@
*/
#ifdef __KERNEL__

#include <linux/bug.h>

DECLARE_PER_CPU(unsigned long, cpu_dr7);

#ifndef CONFIG_PARAVIRT
/*
* These special macros can be used to get or set a debugging register
*/
#define get_debugreg(var, register) \
(var) = native_get_debugreg(register)
#define set_debugreg(value, register) \
native_set_debugreg(register, value)
#endif

static inline unsigned long native_get_debugreg(int regno)
{
unsigned long val = 0; /* Damn you, gcc! */

switch (regno) {
case 0:
asm("mov %%db0, %0" :"=r" (val));
break;
case 1:
asm("mov %%db1, %0" :"=r" (val));
break;
case 2:
asm("mov %%db2, %0" :"=r" (val));
break;
case 3:
asm("mov %%db3, %0" :"=r" (val));
break;
case 6:
asm("mov %%db6, %0" :"=r" (val));
break;
case 7:
asm("mov %%db7, %0" :"=r" (val));
break;
default:
BUG();
}
return val;
}

static inline void native_set_debugreg(int regno, unsigned long value)
{
switch (regno) {
case 0:
asm("mov %0, %%db0" ::"r" (value));
break;
case 1:
asm("mov %0, %%db1" ::"r" (value));
break;
case 2:
asm("mov %0, %%db2" ::"r" (value));
break;
case 3:
asm("mov %0, %%db3" ::"r" (value));
break;
case 6:
asm("mov %0, %%db6" ::"r" (value));
break;
case 7:
asm("mov %0, %%db7" ::"r" (value));
break;
default:
BUG();
}
}

static inline void hw_breakpoint_disable(void)
{
/* Zero the control register for HW Breakpoint */
Expand Down
1 change: 1 addition & 0 deletions arch/x86/include/asm/paravirt.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <asm/paravirt_types.h>

#ifndef __ASSEMBLY__
#include <linux/bug.h>
#include <linux/types.h>
#include <linux/cpumask.h>

Expand Down
63 changes: 0 additions & 63 deletions arch/x86/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,61 +475,6 @@ struct thread_struct {
unsigned io_bitmap_max;
};

static inline unsigned long native_get_debugreg(int regno)
{
unsigned long val = 0; /* Damn you, gcc! */

switch (regno) {
case 0:
asm("mov %%db0, %0" :"=r" (val));
break;
case 1:
asm("mov %%db1, %0" :"=r" (val));
break;
case 2:
asm("mov %%db2, %0" :"=r" (val));
break;
case 3:
asm("mov %%db3, %0" :"=r" (val));
break;
case 6:
asm("mov %%db6, %0" :"=r" (val));
break;
case 7:
asm("mov %%db7, %0" :"=r" (val));
break;
default:
BUG();
}
return val;
}

static inline void native_set_debugreg(int regno, unsigned long value)
{
switch (regno) {
case 0:
asm("mov %0, %%db0" ::"r" (value));
break;
case 1:
asm("mov %0, %%db1" ::"r" (value));
break;
case 2:
asm("mov %0, %%db2" ::"r" (value));
break;
case 3:
asm("mov %0, %%db3" ::"r" (value));
break;
case 6:
asm("mov %0, %%db6" ::"r" (value));
break;
case 7:
asm("mov %0, %%db7" ::"r" (value));
break;
default:
BUG();
}
}

/*
* Set IOPL bits in EFLAGS from given mask
*/
Expand Down Expand Up @@ -575,14 +520,6 @@ static inline void native_swapgs(void)
#define __cpuid native_cpuid
#define paravirt_enabled() 0

/*
* These special macros can be used to get or set a debugging register
*/
#define get_debugreg(var, register) \
(var) = native_get_debugreg(register)
#define set_debugreg(value, register) \
native_set_debugreg(register, value)

static inline void load_sp0(struct tss_struct *tss,
struct thread_struct *thread)
{
Expand Down
1 change: 1 addition & 0 deletions arch/x86/kernel/cpu/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <asm/archrandom.h>
#include <asm/hypervisor.h>
#include <asm/processor.h>
#include <asm/debugreg.h>
#include <asm/sections.h>
#include <linux/topology.h>
#include <linux/cpumask.h>
Expand Down
1 change: 1 addition & 0 deletions arch/x86/kernel/paravirt.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <asm/bug.h>
#include <asm/paravirt.h>
#include <asm/debugreg.h>
#include <asm/desc.h>
#include <asm/setup.h>
#include <asm/pgtable.h>
Expand Down
1 change: 1 addition & 0 deletions arch/x86/mm/kmemcheck/selftest.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <linux/bug.h>
#include <linux/kernel.h>

#include "opcode.h"
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/radeon/cayman_blit_shaders.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* Alex Deucher <[email protected]>
*/

#include <linux/bug.h>
#include <linux/types.h>
#include <linux/kernel.h>

Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/radeon/evergreen_blit_shaders.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* Alex Deucher <[email protected]>
*/

#include <linux/bug.h>
#include <linux/types.h>
#include <linux/kernel.h>

Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/radeon/r600_blit_shaders.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* Alex Deucher <[email protected]>
*/

#include <linux/bug.h>
#include <linux/types.h>
#include <linux/kernel.h>

Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/radeon/si_blit_shaders.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/

#include <linux/types.h>
#include <linux/bug.h>
#include <linux/kernel.h>

const u32 si_default_state[] =
Expand Down
1 change: 1 addition & 0 deletions drivers/staging/wlags49_h2/hcf.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
#include "hcf.h" // HCF and MSF common include file
#include "hcfdef.h" // HCF specific include file
#include "mmd.h" // MoreModularDriver common include file
#include <linux/bug.h>
#include <linux/kernel.h>

#if ! defined offsetof
Expand Down
1 change: 1 addition & 0 deletions fs/reiserfs/reiserfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/sched.h>
#include <linux/bug.h>
#include <linux/workqueue.h>
#include <asm/unaligned.h>
#include <linux/bitops.h>
Expand Down
1 change: 1 addition & 0 deletions include/asm-generic/dma-mapping-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define _ASM_GENERIC_DMA_MAPPING_H

#include <linux/kmemcheck.h>
#include <linux/bug.h>
#include <linux/scatterlist.h>
#include <linux/dma-debug.h>
#include <linux/dma-attrs.h>
Expand Down
1 change: 1 addition & 0 deletions include/asm-generic/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifdef CONFIG_MMU

#include <linux/mm_types.h>
#include <linux/bug.h>

#ifndef __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
extern int ptep_set_access_flags(struct vm_area_struct *vma,
Expand Down
2 changes: 2 additions & 0 deletions include/asm-generic/tlbflush.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#error need to implement an architecture specific asm/tlbflush.h
#endif

#include <linux/bug.h>

static inline void flush_tlb_mm(struct mm_struct *mm)
{
BUG();
Expand Down
1 change: 1 addition & 0 deletions include/drm/ttm/ttm_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <linux/workqueue.h>
#include <linux/spinlock.h>
#include <linux/bug.h>
#include <linux/wait.h>
#include <linux/errno.h>
#include <linux/kobject.h>
Expand Down
1 change: 1 addition & 0 deletions include/linux/atmdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ struct atm_cirange {
#include <linux/wait.h> /* wait_queue_head_t */
#include <linux/time.h> /* struct timeval */
#include <linux/net.h>
#include <linux/bug.h>
#include <linux/skbuff.h> /* struct sk_buff */
#include <linux/uio.h>
#include <net/sock.h>
Expand Down
1 change: 1 addition & 0 deletions include/linux/bio.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/highmem.h>
#include <linux/mempool.h>
#include <linux/ioprio.h>
#include <linux/bug.h>

#ifdef CONFIG_BLOCK

Expand Down
1 change: 1 addition & 0 deletions include/linux/bit_spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <linux/kernel.h>
#include <linux/preempt.h>
#include <linux/atomic.h>
#include <linux/bug.h>

/*
* bit-based spin_lock()
Expand Down
Loading

0 comments on commit ed2d265

Please sign in to comment.