Skip to content

Commit

Permalink
[PATCH] powerpc: sanitize header files for user space includes
Browse files Browse the repository at this point in the history
include/asm-ppc/ had #ifdef __KERNEL__ in all header files that
are not meant for use by user space, include/asm-powerpc does
not have this yet.

This patch gets us a lot closer there. There are a few cases
where I was not sure, so I left them out. I have verified
that no CONFIG_* symbols are used outside of __KERNEL__
any more and that there are no obvious compile errors when
including any of the headers in user space libraries.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
arndb authored and paulusmack committed Jan 9, 2006
1 parent e133380 commit 88ced03
Show file tree
Hide file tree
Showing 75 changed files with 183 additions and 29 deletions.
2 changes: 2 additions & 0 deletions include/asm-powerpc/abs_addr.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef _ASM_POWERPC_ABS_ADDR_H
#define _ASM_POWERPC_ABS_ADDR_H
#ifdef __KERNEL__

#include <linux/config.h>

Expand Down Expand Up @@ -70,4 +71,5 @@ static inline unsigned long phys_to_abs(unsigned long pa)
#define iseries_hv_addr(virtaddr) \
(0x8000000000000000 | virt_to_abs(virtaddr))

#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_ABS_ADDR_H */
2 changes: 2 additions & 0 deletions include/asm-powerpc/agp.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef _ASM_POWERPC_AGP_H
#define _ASM_POWERPC_AGP_H
#ifdef __KERNEL__

#include <asm/io.h>

Expand All @@ -18,4 +19,5 @@
#define free_gatt_pages(table, order) \
free_pages((unsigned long)(table), (order))

#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_AGP_H */
3 changes: 2 additions & 1 deletion include/asm-powerpc/asm-compat.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef _ASM_POWERPC_ASM_COMPAT_H
#define _ASM_POWERPC_ASM_COMPAT_H

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

#ifdef __ASSEMBLY__
Expand Down Expand Up @@ -41,6 +40,7 @@

#endif

#ifdef __KERNEL__
#ifdef CONFIG_IBM405_ERR77
/* Erratum #77 on the 405 means we need a sync or dcbt before every
* stwcx. The old ATOMIC_SYNC_FIX covered some but not all of this.
Expand All @@ -51,5 +51,6 @@
#define PPC405_ERR77(ra,rb)
#define PPC405_ERR77_SYNC
#endif
#endif

#endif /* _ASM_POWERPC_ASM_COMPAT_H */
5 changes: 5 additions & 0 deletions include/asm-powerpc/bootx.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#ifndef __ASM_BOOTX_H__
#define __ASM_BOOTX_H__

#include <asm/types.h>

#ifdef macintosh
#include <Types.h>
#include "linux_type_defs.h"
Expand Down Expand Up @@ -122,6 +124,7 @@ typedef struct boot_infos

} boot_infos_t;

#ifdef __KERNEL__
/* (*) The format of the colormap is 256 * 3 * 2 bytes. Each color index
* is represented by 3 short words containing a 16 bits (unsigned) color
* component. Later versions may contain the gamma table for direct-color
Expand Down Expand Up @@ -159,6 +162,8 @@ struct bootx_dt_node {

extern void bootx_init(unsigned long r4, unsigned long phys);

#endif /* __KERNEL__ */

#ifdef macintosh
#pragma options align=reset
#endif
Expand Down
2 changes: 2 additions & 0 deletions include/asm-powerpc/bug.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef _ASM_POWERPC_BUG_H
#define _ASM_POWERPC_BUG_H
#ifdef __KERNEL__

#include <asm/asm-compat.h>
/*
Expand Down Expand Up @@ -67,4 +68,5 @@ struct bug_entry *find_bug(unsigned long bugaddr);

#include <asm-generic/bug.h>

#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_BUG_H */
2 changes: 2 additions & 0 deletions include/asm-powerpc/checksum.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef _ASM_POWERPC_CHECKSUM_H
#define _ASM_POWERPC_CHECKSUM_H
#ifdef __KERNEL__

/*
* This program is free software; you can redistribute it and/or
Expand Down Expand Up @@ -129,4 +130,5 @@ static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
}

#endif
#endif /* __KERNEL__ */
#endif
2 changes: 2 additions & 0 deletions include/asm-powerpc/compat.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef _ASM_POWERPC_COMPAT_H
#define _ASM_POWERPC_COMPAT_H
#ifdef __KERNEL__
/*
* Architecture specific compatibility types
*/
Expand Down Expand Up @@ -202,4 +203,5 @@ struct compat_shmid64_ds {
compat_ulong_t __unused6;
};

#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_COMPAT_H */
1 change: 0 additions & 1 deletion include/asm-powerpc/cputable.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef __ASM_POWERPC_CPUTABLE_H
#define __ASM_POWERPC_CPUTABLE_H

#include <linux/config.h>
#include <asm/asm-compat.h>

#define PPC_FEATURE_32 0x80000000
Expand Down
2 changes: 2 additions & 0 deletions include/asm-powerpc/current.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef _ASM_POWERPC_CURRENT_H
#define _ASM_POWERPC_CURRENT_H
#ifdef __KERNEL__

/*
* This program is free software; you can redistribute it and/or
Expand All @@ -24,4 +25,5 @@ register struct task_struct *current asm ("r2");

#endif

#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_CURRENT_H */
2 changes: 2 additions & 0 deletions include/asm-powerpc/delay.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef _ASM_POWERPC_DELAY_H
#define _ASM_POWERPC_DELAY_H
#ifdef __KERNEL__

/*
* Copyright 1996, Paul Mackerras.
Expand All @@ -16,4 +17,5 @@
extern void __delay(unsigned long loops);
extern void udelay(unsigned long usecs);

#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_DELAY_H */
2 changes: 2 additions & 0 deletions include/asm-powerpc/dma-mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
#ifndef _ASM_DMA_MAPPING_H
#define _ASM_DMA_MAPPING_H
#ifdef __KERNEL__

#include <linux/config.h>
#include <linux/types.h>
Expand Down Expand Up @@ -282,4 +283,5 @@ struct dma_mapping_ops {
int (*dac_dma_supported)(struct device *dev, u64 mask);
};

#endif /* __KERNEL__ */
#endif /* _ASM_DMA_MAPPING_H */
2 changes: 2 additions & 0 deletions include/asm-powerpc/dma.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef _ASM_POWERPC_DMA_H
#define _ASM_POWERPC_DMA_H
#ifdef __KERNEL__

/*
* Defines for using and allocating dma channels.
Expand Down Expand Up @@ -387,4 +388,5 @@ extern int isa_dma_bridge_buggy;

#endif /* !defined(CONFIG_PPC_ISERIES) || defined(CONFIG_PCI) */

#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_DMA_H */
2 changes: 2 additions & 0 deletions include/asm-powerpc/eeh.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#ifndef _PPC64_EEH_H
#define _PPC64_EEH_H
#ifdef __KERNEL__

#include <linux/config.h>
#include <linux/init.h>
Expand Down Expand Up @@ -373,4 +374,5 @@ static inline void eeh_insl_ns(unsigned long port, void * buf, int nl)
eeh_check_failure((void __iomem *)(port), *(u32*)buf);
}

#endif /* __KERNEL__ */
#endif /* _PPC64_EEH_H */
2 changes: 2 additions & 0 deletions include/asm-powerpc/eeh_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#ifndef ASM_PPC64_EEH_EVENT_H
#define ASM_PPC64_EEH_EVENT_H
#ifdef __KERNEL__

/** EEH event -- structure holding pci controller data that describes
* a change in the isolation status of a PCI slot. A pointer
Expand Down Expand Up @@ -49,4 +50,5 @@ int eeh_send_failure_event (struct device_node *dn,
int reset_state,
int time_unavail);

#endif /* __KERNEL__ */
#endif /* ASM_PPC64_EEH_EVENT_H */
3 changes: 3 additions & 0 deletions include/asm-powerpc/elf.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#ifndef _ASM_POWERPC_ELF_H
#define _ASM_POWERPC_ELF_H

#ifdef __KERNEL__
#include <linux/sched.h> /* for task_struct */
#endif

#include <asm/types.h>
#include <asm/ptrace.h>
#include <asm/cputable.h>
Expand Down
2 changes: 2 additions & 0 deletions include/asm-powerpc/floppy.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
#ifndef __ASM_POWERPC_FLOPPY_H
#define __ASM_POWERPC_FLOPPY_H
#ifdef __KERNEL__

#include <linux/config.h>
#include <asm/machdep.h>
Expand Down Expand Up @@ -102,4 +103,5 @@ static int FDC2 = -1;

#define EXTRA_FLOPPY_PARAMS

#endif /* __KERNEL__ */
#endif /* __ASM_POWERPC_FLOPPY_H */
5 changes: 5 additions & 0 deletions include/asm-powerpc/grackle.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#ifndef _ASM_POWERPC_GRACKLE_H
#define _ASM_POWERPC_GRACKLE_H
#ifdef __KERNEL__
/*
* Functions for setting up and using a MPC106 northbridge
*/

#include <asm/pci-bridge.h>

extern void setup_grackle(struct pci_controller *hose);
#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_GRACKLE_H */
2 changes: 2 additions & 0 deletions include/asm-powerpc/hardirq.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef _ASM_POWERPC_HARDIRQ_H
#define _ASM_POWERPC_HARDIRQ_H
#ifdef __KERNEL__

#include <asm/irq.h>
#include <asm/bug.h>
Expand All @@ -24,4 +25,5 @@ static inline void ack_bad_irq(int irq)
BUG();
}

#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_HARDIRQ_H */
5 changes: 5 additions & 0 deletions include/asm-powerpc/heathrow.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef _ASM_POWERPC_HEATHROW_H
#define _ASM_POWERPC_HEATHROW_H
#ifndef __KERNEL__
/*
* heathrow.h: definitions for using the "Heathrow" I/O controller chip.
*
Expand Down Expand Up @@ -60,3 +63,5 @@
/* Looks like Heathrow has some sort of GPIOs as well... */
#define HRW_GPIO_MODEM_RESET 0x6d

#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_HEATHROW_H */
2 changes: 2 additions & 0 deletions include/asm-powerpc/hvcall.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef _ASM_POWERPC_HVCALL_H
#define _ASM_POWERPC_HVCALL_H
#ifdef __KERNEL__

#define HVSC .long 0x44000022

Expand Down Expand Up @@ -170,4 +171,5 @@ long plpar_hcall_4out(unsigned long opcode,
unsigned long *out4);

#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_HVCALL_H */
2 changes: 2 additions & 0 deletions include/asm-powerpc/hvconsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#ifndef _PPC64_HVCONSOLE_H
#define _PPC64_HVCONSOLE_H
#ifdef __KERNEL__

/*
* This is the max number of console adapters that can/will be found as
Expand All @@ -46,4 +47,5 @@ extern struct hvc_struct * __devinit hvc_alloc(uint32_t vtermno, int irq,
struct hv_ops *ops);
/* remove a vterm from hvc tty operation (modele_exit or hotplug remove) */
extern int __devexit hvc_remove(struct hvc_struct *hp);
#endif /* __KERNEL__ */
#endif /* _PPC64_HVCONSOLE_H */
2 changes: 2 additions & 0 deletions include/asm-powerpc/hvcserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#ifndef _PPC64_HVCSERVER_H
#define _PPC64_HVCSERVER_H
#ifdef __KERNEL__

#include <linux/list.h>

Expand Down Expand Up @@ -54,4 +55,5 @@ extern int hvcs_register_connection(uint32_t unit_address,
uint32_t p_partition_ID, uint32_t p_unit_address);
extern int hvcs_free_connection(uint32_t unit_address);

#endif /* __KERNEL__ */
#endif /* _PPC64_HVCSERVER_H */
2 changes: 2 additions & 0 deletions include/asm-powerpc/i8259.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef _ASM_POWERPC_I8259_H
#define _ASM_POWERPC_I8259_H
#ifdef __KERNEL__

#include <linux/irq.h>

Expand All @@ -9,4 +10,5 @@ extern void i8259_init(unsigned long intack_addr, int offset);
extern int i8259_irq(struct pt_regs *regs);
extern int i8259_irq_cascade(struct pt_regs *regs, void *unused);

#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_I8259_H */
2 changes: 2 additions & 0 deletions include/asm-powerpc/ibmebus.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#ifndef _ASM_EBUS_H
#define _ASM_EBUS_H
#ifdef __KERNEL__

#include <linux/device.h>
#include <linux/interrupt.h>
Expand Down Expand Up @@ -80,4 +81,5 @@ static inline struct ibmebus_dev *to_ibmebus_dev(struct device *dev)
}


#endif /* __KERNEL__ */
#endif /* _ASM_IBMEBUS_H */
6 changes: 1 addition & 5 deletions include/asm-powerpc/io.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef _ASM_POWERPC_IO_H
#define _ASM_POWERPC_IO_H
#ifdef __KERNEL__

/*
* This program is free software; you can redistribute it and/or
Expand Down Expand Up @@ -186,7 +187,6 @@ extern void _outsl_ns(volatile u32 __iomem *port, const void *buf, int nl);
#define IO_SPACE_LIMIT ~(0UL)


#ifdef __KERNEL__
extern int __ioremap_explicit(unsigned long p_addr, unsigned long v_addr,
unsigned long size, unsigned long flags);
extern void __iomem *__ioremap(unsigned long address, unsigned long size,
Expand Down Expand Up @@ -256,8 +256,6 @@ static inline void * phys_to_virt(unsigned long address)
*/
#define BIO_VMERGE_BOUNDARY 0

#endif /* __KERNEL__ */

static inline void iosync(void)
{
__asm__ __volatile__ ("sync" : : : "memory");
Expand Down Expand Up @@ -405,8 +403,6 @@ static inline void out_be64(volatile unsigned long __iomem *addr, unsigned long
#include <asm/eeh.h>
#endif

#ifdef __KERNEL__

/**
* check_signature - find BIOS signatures
* @io_addr: mmio address to check
Expand Down
2 changes: 2 additions & 0 deletions include/asm-powerpc/iommu.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#ifndef _ASM_IOMMU_H
#define _ASM_IOMMU_H
#ifdef __KERNEL__

#include <linux/config.h>
#include <asm/types.h>
Expand Down Expand Up @@ -115,4 +116,5 @@ static inline void pci_iommu_init(void) { }

extern void alloc_dart_table(void);

#endif /* __KERNEL__ */
#endif /* _ASM_IOMMU_H */
2 changes: 2 additions & 0 deletions include/asm-powerpc/kdebug.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef _ASM_POWERPC_KDEBUG_H
#define _ASM_POWERPC_KDEBUG_H
#ifdef __KERNEL__

/* nearly identical to x86_64/i386 code */

Expand Down Expand Up @@ -39,4 +40,5 @@ static inline int notify_die(enum die_val val,char *str,struct pt_regs *regs,lon
return notifier_call_chain(&powerpc_die_chain, val, &args);
}

#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_KDEBUG_H */
Loading

0 comments on commit 88ced03

Please sign in to comment.