This patch changes some of the lm32 arch header files to use the corresponding
file from asm-generic instead of their own implementation.
The replaced files look like they were copied from other archs (mainly
microblaze) before the existence of the asm-generic header files.

This patch only contains changes which should not change the lm32 userspace
linux ABI, thus existing software images can still be used.
We could (and probably should) though replace some more files with their
asm-generic equivalent, if we change the userspace ABI.

Signed-off-by: Lars-Peter Clausen <[email protected]>
---
 arch/lm32/include/asm/auxvec.h      |    3 +-
 arch/lm32/include/asm/bitops.h      |  268 ++---------------------------------
 arch/lm32/include/asm/bugs.h        |   12 +--
 arch/lm32/include/asm/cache.h       |   33 +----
 arch/lm32/include/asm/dma.h         |   20 +---
 arch/lm32/include/asm/hw_irq.h      |   24 +---
 arch/lm32/include/asm/io.h          |    2 +
 arch/lm32/include/asm/ioctls.h      |   78 +----------
 arch/lm32/include/asm/ipcbuf.h      |   35 +-----
 arch/lm32/include/asm/kmap_types.h  |   30 +----
 arch/lm32/include/asm/linkage.h     |    8 +-
 arch/lm32/include/asm/percpu.h      |    5 -
 arch/lm32/include/asm/pgalloc.h     |    9 +-
 arch/lm32/include/asm/pgtable.h     |    2 +
 arch/lm32/include/asm/posix_types.h |   57 ++------
 arch/lm32/include/asm/segment.h     |   39 +-----
 arch/lm32/include/asm/stat.h        |   16 +--
 arch/lm32/include/asm/string.h      |    7 +-
 arch/lm32/include/asm/termios.h     |   93 +------------
 arch/lm32/include/asm/thread_info.h |   11 ++-
 arch/lm32/include/asm/types.h       |   98 +-------------
 arch/lm32/include/asm/uaccess.h     |    1 -
 arch/lm32/include/asm/user.h        |   57 +--------
 arch/lm32/kernel/process.c          |    1 +
 24 files changed, 62 insertions(+), 847 deletions(-)

diff --git a/arch/lm32/include/asm/auxvec.h b/arch/lm32/include/asm/auxvec.h
index 35c9c30..41fa68b 100644
--- a/arch/lm32/include/asm/auxvec.h
+++ b/arch/lm32/include/asm/auxvec.h
@@ -1,2 +1 @@
-/* keep me */
-
+#include <asm-generic/auxvec.h>
diff --git a/arch/lm32/include/asm/bitops.h b/arch/lm32/include/asm/bitops.h
index c9334a4..0df003d 100644
--- a/arch/lm32/include/asm/bitops.h
+++ b/arch/lm32/include/asm/bitops.h
@@ -1,258 +1,18 @@
-#ifndef _ASM_LM32_BITOPS_H
-#define _ASM_LM32_BITOPS_H
-
-/*
- *  arch/lm32/include/asm/bitops.h
- *
- *  Copyright 1992, Linus Torvalds.
- *
- *  LM32 version:
- *    Copyright (C) 2010  Takeshi MATSUYA
- */
-
-#ifndef _LINUX_BITOPS_H
-#error only <linux/bitops.h> can be included directly
+#ifndef _ASM_BITOPS_H_
+#define _ASM_BITOPS_H_
+
+#ifdef __KERNEL__
+#undef BIT
+#undef BIT_MASK
+#undef BIT_WORD
+#undef BITS_TO_LONGS
+#define BIT(nr)                        (1UL << ((unsigned int)(nr)))
+#define BIT_MASK(nr)           (1UL << (((unsigned int)(nr)) % BITS_PER_LONG))
+#define BIT_WORD(nr)           (((unsigned int)(nr)) / BITS_PER_LONG)
+#define BITS_TO_LONGS(nr)      DIV_ROUND_UP(((unsigned int)(nr)), 
BITS_PER_BYTE * sizeof(long))
 #endif
 
-#include <linux/compiler.h>
-#include <asm/system.h>
-#include <asm/byteorder.h>
-#include <asm/types.h>
-
-/*
- * These have to be done with inline assembly: that way the bit-setting
- * is guaranteed to be atomic. All bit operations return 0 if the bit
- * was cleared before the operation and != 0 if it was not.
- *
- * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
- */
-
-/**
- * set_bit - Atomically set a bit in memory
- * @nr: the bit to set
- * @addr: the address to start counting from
- *
- * This function is atomic and may not be reordered.  See __set_bit()
- * if you do not require the atomic guarantees.
- * Note that @nr may be almost arbitrarily large; this function is not
- * restricted to acting on a single-word quantity.
- */
-static __inline__ void set_bit(int nr, volatile void * addr)
-{
-       __u32 mask;
-       volatile __u32 *a = addr;
-       unsigned long flags;
-       unsigned long tmp;
-
-       a += (nr >> 5);
-       mask = (1 << (nr & 0x1F));
-
-       local_irq_save(flags);
-       __asm__ __volatile__ (
-               "lw %0, (%1+0);         \n\t"
-               "or %0, %0, %2;         \n\t"
-               "sw (%1+0),%0;          \n\t"
-               : "=&r" (tmp)
-               : "r" (a), "r" (mask)
-               : "memory"
-       );
-       local_irq_restore(flags);
-}
-
-/**
- * clear_bit - Clears a bit in memory
- * @nr: Bit to clear
- * @addr: Address to start counting from
- *
- * clear_bit() is atomic and may not be reordered.  However, it does
- * not contain a memory barrier, so if it is used for locking purposes,
- * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit()
- * in order to ensure changes are visible on other processors.
- */
-static __inline__ void clear_bit(int nr, volatile void * addr)
-{
-       __u32 mask;
-       volatile __u32 *a = addr;
-       unsigned long flags;
-       unsigned long tmp;
-
-       a += (nr >> 5);
-       mask = (1 << (nr & 0x1F));
-
-       local_irq_save(flags);
-
-       __asm__ __volatile__ (
-               "lw %0, (%1+0);         \n\t"
-               "and %0, %0, %2;        \n\t"
-               "sw (%1+0),%0;          \n\t"
-               : "=&r" (tmp)
-               : "r" (a), "r" (~mask)
-               : "memory"
-       );
-       local_irq_restore(flags);
-}
-
-#define smp_mb__before_clear_bit()     barrier()
-#define smp_mb__after_clear_bit()      barrier()
-
-/**
- * change_bit - Toggle a bit in memory
- * @nr: Bit to clear
- * @addr: Address to start counting from
- *
- * change_bit() is atomic and may not be reordered.
- * Note that @nr may be almost arbitrarily large; this function is not
- * restricted to acting on a single-word quantity.
- */
-static __inline__ void change_bit(int nr, volatile void * addr)
-{
-       __u32  mask;
-       volatile __u32  *a = addr;
-       unsigned long flags;
-       unsigned long tmp;
-
-       a += (nr >> 5);
-       mask = (1 << (nr & 0x1F));
-
-       local_irq_save(flags);
-       __asm__ __volatile__ (
-               "lw  %0, (%1+0);        \n\t"
-               "xor %0, %0, %2;        \n\t"
-               "sw (%1+0), %0;         \n\t"
-               : "=&r" (tmp)
-               : "r" (a), "r" (mask)
-               : "memory"
-       );
-       local_irq_restore(flags);
-}
-
-/**
- * test_and_set_bit - Set a bit and return its old value
- * @nr: Bit to set
- * @addr: Address to count from
- *
- * This operation is atomic and cannot be reordered.
- * It also implies a memory barrier.
- */
-static __inline__ int test_and_set_bit(int nr, volatile void * addr)
-{
-       __u32 mask, oldbit;
-       volatile __u32 *a = addr;
-       unsigned long flags;
-       unsigned long tmp;
-
-       a += (nr >> 5);
-       mask = (1 << (nr & 0x1F));
-
-       local_irq_save(flags);
-       __asm__ __volatile__ (
-               "lw %0, (%2+0);         \n\t"
-               "mv %1, %0;             \n\t"
-               "and %0, %0, %3;        \n\t"
-               "or %1, %1, %3;         \n\t"
-               "sw (%2+0), %1;         \n\t"
-               : "=&r" (oldbit), "=&r" (tmp)
-               : "r" (a), "r" (mask)
-               : "memory"
-       );
-       local_irq_restore(flags);
+#include <asm-generic/bitops.h>
 
-       return (oldbit != 0);
-}
 
-/**
- * test_and_clear_bit - Clear a bit and return its old value
- * @nr: Bit to set
- * @addr: Address to count from
- *
- * This operation is atomic and cannot be reordered.
- * It also implies a memory barrier.
- */
-static __inline__ int test_and_clear_bit(int nr, volatile void * addr)
-{
-       __u32 mask, oldbit;
-       volatile __u32 *a = addr;
-       unsigned long flags;
-       unsigned long tmp;
-
-       a += (nr >> 5);
-       mask = (1 << (nr & 0x1F));
-
-       local_irq_save(flags);
-
-       __asm__ __volatile__ (
-               "lw %0, (%3+0);         \n\t"
-               "mv %1, %0;             \n\t"
-               "and %0, %0, %2;        \n\t"
-               "not %2, %2;            \n\t"
-               "and %1, %1, %2;        \n\t"
-               "sw (%3+0),%1;          \n\t"
-               : "=&r" (oldbit), "=&r" (tmp), "+r" (mask)
-               : "r" (a)
-               : "memory"
-       );
-       local_irq_restore(flags);
-
-       return (oldbit != 0);
-}
-
-/**
- * test_and_change_bit - Change a bit and return its old value
- * @nr: Bit to set
- * @addr: Address to count from
- *
- * This operation is atomic and cannot be reordered.
- * It also implies a memory barrier.
- */
-static __inline__ int test_and_change_bit(int nr, volatile void * addr)
-{
-       __u32 mask, oldbit;
-       volatile __u32 *a = addr;
-       unsigned long flags;
-       unsigned long tmp;
-
-       a += (nr >> 5);
-       mask = (1 << (nr & 0x1F));
-
-       local_irq_save(flags);
-       __asm__ __volatile__ (
-               "lw %0, (%2+0);         \n\t"
-               "mv %1, %0;             \n\t"
-               "and %0, %0, %3;        \n\t"
-               "xor %1, %1, %3;        \n\t"
-               "sw (%2+0), %1;         \n\t"
-               : "=&r" (oldbit), "=&r" (tmp)
-               : "r" (a), "r" (mask)
-               : "memory"
-       );
-       local_irq_restore(flags);
-
-       return (oldbit != 0);
-}
-
-#include <asm-generic/bitops/non-atomic.h>
-#include <asm-generic/bitops/ffz.h>
-#include <asm-generic/bitops/__ffs.h>
-#include <asm-generic/bitops/fls.h>
-#include <asm-generic/bitops/__fls.h>
-#include <asm-generic/bitops/fls64.h>
-
-#ifdef __KERNEL__
-
-#include <asm-generic/bitops/sched.h>
-#include <asm-generic/bitops/find.h>
-#include <asm-generic/bitops/ffs.h>
-#include <asm-generic/bitops/hweight.h>
-#include <asm-generic/bitops/lock.h>
-
-#endif /* __KERNEL__ */
-
-#ifdef __KERNEL__
-
-#include <asm-generic/bitops/ext2-non-atomic.h>
-#include <asm-generic/bitops/ext2-atomic.h>
-#include <asm-generic/bitops/minix.h>
-
-#endif /* __KERNEL__ */
-
-#endif /* _ASM_LM32_BITOPS_H */
+#endif
diff --git a/arch/lm32/include/asm/bugs.h b/arch/lm32/include/asm/bugs.h
index 142ebf4..61791e1 100644
--- a/arch/lm32/include/asm/bugs.h
+++ b/arch/lm32/include/asm/bugs.h
@@ -1,11 +1 @@
-#ifndef _LM32_ASM_BUGS_H
-#define _LM32_ASM_BUGS_H
-
-/*
- * This is included by init/main.c to check for architecture-dependent bugs.
- */
-static void check_bugs(void)
-{
-}
-
-#endif
+#include <asm-generic/bugs.h>
diff --git a/arch/lm32/include/asm/cache.h b/arch/lm32/include/asm/cache.h
index 3862855..f3e52b3 100644
--- a/arch/lm32/include/asm/cache.h
+++ b/arch/lm32/include/asm/cache.h
@@ -1,32 +1 @@
-/*
- * (C) Copyright 2007
- *     Theobroma Systems <www.theobroma-systems.com>
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#ifndef __ASM_LM32_CACHE_H
-#define __ASM_LM32_CACHE_H
-
-/* 32 byte cache lines */
-#define L1_CACHE_BYTES 32
-#define L1_CACHE_SHIFT 5
-
-#endif
-
+#include <asm-generic/cache.h>
diff --git a/arch/lm32/include/asm/dma.h b/arch/lm32/include/asm/dma.h
index 1a9818c..7ce20d9 100644
--- a/arch/lm32/include/asm/dma.h
+++ b/arch/lm32/include/asm/dma.h
@@ -1,19 +1 @@
-/*
- * Based on:
- * include/asm-m68k/dma.h
- */
-
-#ifndef _LM32_ASM_DMA_H
-#define _LM32_ASM_DMA_H
- 
-#define MAX_DMA_CHANNELS 8
-
-/* Don't define MAX_DMA_ADDRESS; it's useless on the m68k/coldfire and any
-   occurrence should be flagged as an error.  */
-#define MAX_DMA_ADDRESS PAGE_OFFSET
-
-/* These are in kernel/dma.c: */
-//extern int request_dma(unsigned int dmanr, const char *device_id);   /* 
reserve a DMA channel */
-//extern void free_dma(unsigned int dmanr);    /* release it again */
- 
-#endif /* _LM32_ASM_DMA_H */
+#include <asm-generic/dma.h>
diff --git a/arch/lm32/include/asm/hw_irq.h b/arch/lm32/include/asm/hw_irq.h
index cdf44be..1f5ef7d 100644
--- a/arch/lm32/include/asm/hw_irq.h
+++ b/arch/lm32/include/asm/hw_irq.h
@@ -1,23 +1 @@
-/*
- * (C) Copyright 2007
- *     Theobroma Systems <www.theobroma-systems.com>
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
+#include <asm-generic/hw_irq.h>
diff --git a/arch/lm32/include/asm/io.h b/arch/lm32/include/asm/io.h
index dafe3b1..e866c77 100644
--- a/arch/lm32/include/asm/io.h
+++ b/arch/lm32/include/asm/io.h
@@ -6,6 +6,8 @@
 #ifndef _LM32_ASM_IO_H
 #define _LM32_ASM_IO_H
 
+/* TODO: #include <asm-generic/io.h> */
+
 #ifdef __KERNEL__
 
 #ifndef __ASSEMBLY__
diff --git a/arch/lm32/include/asm/ioctls.h b/arch/lm32/include/asm/ioctls.h
index cf323f0..8d82496 100644
--- a/arch/lm32/include/asm/ioctls.h
+++ b/arch/lm32/include/asm/ioctls.h
@@ -6,83 +6,9 @@
 #ifndef _ASM_LM32_IOCTLS_H
 #define _ASM_LM32_IOCTLS_H
 
-#include <asm/ioctl.h>
-
-/* 0x54 is just a magic number to make these relatively unique ('T') */
-
-#define TCGETS         0x5401
-#define TCSETS         0x5402
-#define TCSETSW                0x5403
-#define TCSETSF                0x5404
-#define TCGETA         0x5405
-#define TCSETA         0x5406
-#define TCSETAW                0x5407
-#define TCSETAF                0x5408
-#define TCSBRK         0x5409
-#define TCXONC         0x540A
-#define TCFLSH         0x540B
-#define TIOCEXCL       0x540C
-#define TIOCNXCL       0x540D
-#define TIOCSCTTY      0x540E
-#define TIOCGPGRP      0x540F
-#define TIOCSPGRP      0x5410
-#define TIOCOUTQ       0x5411
-#define TIOCSTI                0x5412
-#define TIOCGWINSZ     0x5413
-#define TIOCSWINSZ     0x5414
-#define TIOCMGET       0x5415
-#define TIOCMBIS       0x5416
-#define TIOCMBIC       0x5417
-#define TIOCMSET       0x5418
-#define TIOCGSOFTCAR   0x5419
-#define TIOCSSOFTCAR   0x541A
-#define FIONREAD       0x541B
-#define TIOCINQ                FIONREAD
-#define TIOCLINUX      0x541C
-#define TIOCCONS       0x541D
-#define TIOCGSERIAL    0x541E
-#define TIOCSSERIAL    0x541F
-#define TIOCPKT                0x5420
-#define FIONBIO                0x5421
-#define TIOCNOTTY      0x5422
-#define TIOCSETD       0x5423
-#define TIOCGETD       0x5424
-#define TCSBRKP                0x5425  /* Needed for POSIX tcsendbreak() */
-#define TIOCSBRK       0x5427  /* BSD compatibility */
-#define TIOCCBRK       0x5428  /* BSD compatibility */
-#define TIOCGSID       0x5429  /* Return the session ID of FD */
-#define TIOCGPTN       _IOR('T',0x30, unsigned int) /* Get Pty Number (of 
pty-mux device) */
-#define TIOCSPTLCK     _IOW('T',0x31, int)  /* Lock/unlock Pty */
-#define TIOCGDEV       _IOR('T',0x32, unsigned int) /* Get primary device node 
of /dev/console */
-#define TIOCSIG                _IOW('T',0x36, int)  /* Generate signal on Pty 
slave */
-
-#define FIONCLEX       0x5450  /* these numbers need to be adjusted. */
-#define FIOCLEX                0x5451
-#define FIOASYNC       0x5452
-#define TIOCSERCONFIG  0x5453
-#define TIOCSERGWILD   0x5454
-#define TIOCSERSWILD   0x5455
-#define TIOCGLCKTRMIOS 0x5456
-#define TIOCSLCKTRMIOS 0x5457
-#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
-#define TIOCSERGETLSR   0x5459 /* Get line status register */
-#define TIOCSERGETMULTI 0x545A /* Get multiport config  */
-#define TIOCSERSETMULTI 0x545B /* Set multiport config */
-
-#define TIOCMIWAIT     0x545C  /* wait for a change on serial input line(s) */
-#define TIOCGICOUNT    0x545D  /* read serial port inline interrupt counts */
+/* TODO: This define can be dropped when the ABI is changed */
 #define FIOQSIZE       0x545E
 
-/* Used for packet mode */
-#define TIOCPKT_DATA            0
-#define TIOCPKT_FLUSHREAD       1
-#define TIOCPKT_FLUSHWRITE      2
-#define TIOCPKT_STOP            4
-#define TIOCPKT_START           8
-#define TIOCPKT_NOSTOP         16
-#define TIOCPKT_DOSTOP         32
-#define TIOCPKT_IOCTL          64
-
-#define TIOCSER_TEMT   0x01    /* Transmitter physically empty */
+#include <asm-generic/ioctls.h>
 
 #endif
diff --git a/arch/lm32/include/asm/ipcbuf.h b/arch/lm32/include/asm/ipcbuf.h
index b1efffe..84c7e51 100644
--- a/arch/lm32/include/asm/ipcbuf.h
+++ b/arch/lm32/include/asm/ipcbuf.h
@@ -1,34 +1 @@
-/*
- * Based on:
- * include/asm-arm/ipcbuf.h
- */
-
-#ifndef __ASM_LM32_IPCBUF_H
-#define __ASM_LM32_IPCBUF_H
-
-/*
- * The ipc64_perm structure for arm architecture.
- * Note extra padding because this structure is passed back and forth
- * between kernel and user space.
- *
- * Pad space is left for:
- * - 32-bit mode_t and seq
- * - 2 miscellaneous 32-bit values
- */
-
-struct ipc64_perm
-{
-       __kernel_key_t          key;
-       __kernel_uid32_t        uid;
-       __kernel_gid32_t        gid;
-       __kernel_uid32_t        cuid;
-       __kernel_gid32_t        cgid;
-       __kernel_mode_t         mode;
-       unsigned short          __pad1;
-       unsigned short          seq;
-       unsigned short          __pad2;
-       unsigned long           __unused1;
-       unsigned long           __unused2;
-};
-
-#endif
+#include <asm-generic/ipcbuf.h>
diff --git a/arch/lm32/include/asm/kmap_types.h 
b/arch/lm32/include/asm/kmap_types.h
index 5ddad12..3575c64 100644
--- a/arch/lm32/include/asm/kmap_types.h
+++ b/arch/lm32/include/asm/kmap_types.h
@@ -1,29 +1 @@
-/*
- * Based on:
- * include/asm-arm/kmap_types.h
- */
-
-#ifndef _LM32_ASM_KMAP_TYPES_H
-#define _LM32_ASM_KMAP_TYPES_H
-
-/*
- * This is the "bare minimum".  AIO seems to require this.
- */
-enum km_type {
-       KM_BOUNCE_READ,
-       KM_SKB_SUNRPC_DATA,
-       KM_SKB_DATA_SOFTIRQ,
-       KM_USER0,
-       KM_USER1,
-       KM_BIO_SRC_IRQ,
-       KM_BIO_DST_IRQ,
-       KM_PTE0,
-       KM_PTE1,
-       KM_IRQ0,
-       KM_IRQ1,
-       KM_SOFTIRQ0,
-       KM_SOFTIRQ1,
-       KM_TYPE_NR
-};
-
-#endif
+#include <asm-generic/kmap_types.h>
diff --git a/arch/lm32/include/asm/linkage.h b/arch/lm32/include/asm/linkage.h
index 8e7aece..0540bba 100644
--- a/arch/lm32/include/asm/linkage.h
+++ b/arch/lm32/include/asm/linkage.h
@@ -1,7 +1 @@
-#ifndef _LM32_ASM_LINKAGE_H
-#define _LM32_ASM_LINKAGE_H
-
-#define __ALIGN .align 4
-#define __ALIGN_STR ".align 4"
-
-#endif
+#include <asm-generic/linkage.h>
diff --git a/arch/lm32/include/asm/percpu.h b/arch/lm32/include/asm/percpu.h
index 2c68a01..06a959d 100644
--- a/arch/lm32/include/asm/percpu.h
+++ b/arch/lm32/include/asm/percpu.h
@@ -1,6 +1 @@
-#ifndef __ARCH_LM32_PERCPU__
-#define __ARCH_LM32_PERCPU__
-
 #include <asm-generic/percpu.h>
-
-#endif /* __ARCH_LM32_PERCPU__ */
diff --git a/arch/lm32/include/asm/pgalloc.h b/arch/lm32/include/asm/pgalloc.h
index 883c994..f261cb7 100644
--- a/arch/lm32/include/asm/pgalloc.h
+++ b/arch/lm32/include/asm/pgalloc.h
@@ -1,8 +1 @@
-#ifndef _LM32_ASM_PGALLOC_H
-#define _LM32_ASM_PGALLOC_H
-
-#include <asm/setup.h>
-
-#define check_pgt_cache()      do { } while (0)
-
-#endif
+#include <asm-generic/pgalloc.h>
diff --git a/arch/lm32/include/asm/pgtable.h b/arch/lm32/include/asm/pgtable.h
index 4477556..d7dde12 100644
--- a/arch/lm32/include/asm/pgtable.h
+++ b/arch/lm32/include/asm/pgtable.h
@@ -6,6 +6,8 @@
 #ifndef _LM32_ASM_PGTABLE_H
 #define _LM32_ASM_PGTABLE_H
 
+/* TODO: #include <asm-generic/pgtable.h> */
+
 #include <asm-generic/4level-fixup.h>
 
 #include <asm/page.h>
diff --git a/arch/lm32/include/asm/posix_types.h 
b/arch/lm32/include/asm/posix_types.h
index 75bb000..305d013 100644
--- a/arch/lm32/include/asm/posix_types.h
+++ b/arch/lm32/include/asm/posix_types.h
@@ -6,32 +6,14 @@
 #ifndef __ARCH_LM32_ASM_POSIX_TYPES_H
 #define __ARCH_LM32_ASM_POSIX_TYPES_H
 
-/*
- * This file is generally used by user-level software, so you need to
- * be a little careful about namespace pollution etc.  Also, we cannot
- * assume GCC is being used.
- */
+/* TODO: Change ABI? */
 
-typedef unsigned long  __kernel_ino_t;
 typedef unsigned short __kernel_mode_t;
 typedef unsigned short __kernel_nlink_t;
-typedef long           __kernel_off_t;
-typedef int            __kernel_pid_t;
 typedef unsigned short __kernel_ipc_pid_t;
 typedef unsigned short __kernel_uid_t;
 typedef unsigned short __kernel_gid_t;
-typedef unsigned int   __kernel_size_t;
-typedef int            __kernel_ssize_t;
-typedef int            __kernel_ptrdiff_t;
-typedef long           __kernel_time_t;
-typedef long           __kernel_suseconds_t;
-typedef long           __kernel_clock_t;
-typedef int            __kernel_timer_t;
-typedef int            __kernel_clockid_t;
-typedef int            __kernel_daddr_t;
-typedef char *         __kernel_caddr_t;
-typedef unsigned short __kernel_uid16_t;
-typedef unsigned short __kernel_gid16_t;
+
 typedef unsigned int   __kernel_uid32_t;
 typedef unsigned int   __kernel_gid32_t;
 
@@ -39,32 +21,23 @@ typedef unsigned short      __kernel_old_uid_t;
 typedef unsigned short __kernel_old_gid_t;
 typedef unsigned short __kernel_old_dev_t;
 
-#ifdef __GNUC__
-typedef long long      __kernel_loff_t;
-#endif
-
-typedef struct {
-#if defined(__KERNEL__) || defined(__USE_ALL)
-       int     val[2];
-#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */
-       int     __val[2];
-#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */
-} __kernel_fsid_t;
-
-#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
+/* Those defines are to prevent asm-generic/posix_types.h from adding these
+ * types */
+#define __kernel_mode_t                __kernel_mode_t
+#define __kernel_nlink_t       __kernel_nlink_t
+#define __kernel_ipc_pid_t     __kernel_ipc_pid_t
+#define __kernel_uid_t         __kernel_uid_t
+#define __kernel_gid_t         __kernel_gid_t
 
-#undef __FD_SET
-#define        __FD_SET(d, set)        ((set)->fds_bits[__FDELT(d)] |= 
__FDMASK(d))
+#define __kernel_uid32_t       __kernel_uid32_t
+#define __kernel_gid32_t       __kernel_gid32_t
 
-#undef __FD_CLR
-#define        __FD_CLR(d, set)        ((set)->fds_bits[__FDELT(d)] &= 
~__FDMASK(d))
+#define __kernel_old_uid_t     __kernel_old_uid_t
+#define __kernel_old_gid_t     __kernel_old_gid_t
+#define __kernel_old_dev_t     __kernel_old_dev_t
 
-#undef __FD_ISSET
-#define        __FD_ISSET(d, set)      ((set)->fds_bits[__FDELT(d)] & 
__FDMASK(d))
 
-#undef __FD_ZERO
-#define __FD_ZERO(fdsetp) (memset (fdsetp, 0, sizeof(*(fd_set *)fdsetp)))
+#include <asm-generic/posix_types.h>
 
-#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */
 
 #endif
diff --git a/arch/lm32/include/asm/segment.h b/arch/lm32/include/asm/segment.h
index 96c4f0e..f1b81e5 100644
--- a/arch/lm32/include/asm/segment.h
+++ b/arch/lm32/include/asm/segment.h
@@ -1,38 +1 @@
-/*
- * (C) Copyright 2007
- *     Theobroma Systems <www.theobroma-systems.com>
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#ifndef _LM32_ASM_SEGMENT_H
-#define _LM32_ASM_SEGMENT_H
-
-#ifndef __ASSEMBLY__
-
-typedef unsigned long mm_segment_t;
-
-#define USER_DS                (0x5)
-#define KERNEL_DS      (0xA)
-
-#define segment_eq(a,b)        ((a) == (b))
-
-#endif /* __ASSEMBLY__ */
-
-#endif /* _LM32_ASM_SEGMENT_H */
+#include <asm-generic/segment.h>
diff --git a/arch/lm32/include/asm/stat.h b/arch/lm32/include/asm/stat.h
index 1121416..8aa73a98 100644
--- a/arch/lm32/include/asm/stat.h
+++ b/arch/lm32/include/asm/stat.h
@@ -6,19 +6,9 @@
 #ifndef _LM32_ASM_STAT_H
 #define _LM32_ASM_STAT_H
 
-struct __old_kernel_stat {
-       unsigned short st_dev;
-       unsigned short st_ino;
-       unsigned short st_mode;
-       unsigned short st_nlink;
-       unsigned short st_uid;
-       unsigned short st_gid;
-       unsigned short st_rdev;
-       unsigned long  st_size;
-       unsigned long  st_atime;
-       unsigned long  st_mtime;
-       unsigned long  st_ctime;
-};
+;
+
+/* TODO: Change ABI and use asm-generic */
 
 struct stat {
        unsigned short st_dev;
diff --git a/arch/lm32/include/asm/string.h b/arch/lm32/include/asm/string.h
index 2e29682..8b02454 100644
--- a/arch/lm32/include/asm/string.h
+++ b/arch/lm32/include/asm/string.h
@@ -1,6 +1 @@
-#ifndef _LM32_ASM_STRING_H
-#define _LM32_ASM_STRING_H
-
-//#include <asm/setup.h>
-
-#endif /* _LM32_ASM_STRING_H */
+#include <asm-generic/string.h>
diff --git a/arch/lm32/include/asm/termios.h b/arch/lm32/include/asm/termios.h
index c7296de..280d78a 100644
--- a/arch/lm32/include/asm/termios.h
+++ b/arch/lm32/include/asm/termios.h
@@ -1,92 +1 @@
-/*
- * Based on:
- * include/asm-m68k/termios.h
- */
-
-#ifndef _LM32_ASM_TERMIOS_H
-#define _LM32_ASM_TERMIOS_H
-
-#include <asm/termbits.h>
-#include <asm/ioctls.h>
-
-struct winsize {
-       unsigned short ws_row;
-       unsigned short ws_col;
-       unsigned short ws_xpixel;
-       unsigned short ws_ypixel;
-};
-
-#define NCC 8
-struct termio {
-       unsigned short c_iflag;         /* input mode flags */
-       unsigned short c_oflag;         /* output mode flags */
-       unsigned short c_cflag;         /* control mode flags */
-       unsigned short c_lflag;         /* local mode flags */
-       unsigned char c_line;           /* line discipline */
-       unsigned char c_cc[NCC];        /* control characters */
-};
-
-/* modem lines */
-#define TIOCM_LE       0x001
-#define TIOCM_DTR      0x002
-#define TIOCM_RTS      0x004
-#define TIOCM_ST       0x008
-#define TIOCM_SR       0x010
-#define TIOCM_CTS      0x020
-#define TIOCM_CAR      0x040
-#define TIOCM_RNG      0x080
-#define TIOCM_DSR      0x100
-#define TIOCM_CD       TIOCM_CAR
-#define TIOCM_RI       TIOCM_RNG
-#define TIOCM_OUT1     0x2000
-#define TIOCM_OUT2     0x4000
-#define TIOCM_LOOP     0x8000
-
-/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
-
-#ifdef __KERNEL__
-/*     intr=^C         quit=^\         erase=del       kill=^U
-       eof=^D          vtime=\0        vmin=\1         sxtc=\0
-       start=^Q        stop=^S         susp=^Z         eol=\0
-       reprint=^R      discard=^U      werase=^W       lnext=^V
-       eol2=\0
-*/
-#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
-
-/*
- * Translate a "termio" structure into a "termios". Ugh.
- */
-#define user_termio_to_kernel_termios(termios, termio) \
-({ \
-       unsigned short tmp; \
-       get_user(tmp, &(termio)->c_iflag); \
-       (termios)->c_iflag = (0xffff0000 & ((termios)->c_iflag)) | tmp; \
-       get_user(tmp, &(termio)->c_oflag); \
-       (termios)->c_oflag = (0xffff0000 & ((termios)->c_oflag)) | tmp; \
-       get_user(tmp, &(termio)->c_cflag); \
-       (termios)->c_cflag = (0xffff0000 & ((termios)->c_cflag)) | tmp; \
-       get_user(tmp, &(termio)->c_lflag); \
-       (termios)->c_lflag = (0xffff0000 & ((termios)->c_lflag)) | tmp; \
-       get_user((termios)->c_line, &(termio)->c_line); \
-       copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
-})
-
-/*
- * Translate a "termios" structure into a "termio". Ugh.
- */
-#define kernel_termios_to_user_termio(termio, termios) \
-({ \
-       put_user((termios)->c_iflag, &(termio)->c_iflag); \
-       put_user((termios)->c_oflag, &(termio)->c_oflag); \
-       put_user((termios)->c_cflag, &(termio)->c_cflag); \
-       put_user((termios)->c_lflag, &(termio)->c_lflag); \
-       put_user((termios)->c_line,  &(termio)->c_line); \
-       copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
-})
-
-#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, 
sizeof(struct termios))
-#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct 
termios))
-
-#endif /* __KERNEL__ */
-
-#endif /* _LM32_ASM_TERMIOS_H */
+#include <asm-generic/termios.h>
diff --git a/arch/lm32/include/asm/thread_info.h 
b/arch/lm32/include/asm/thread_info.h
index 9cbfe45..7f09a18 100644
--- a/arch/lm32/include/asm/thread_info.h
+++ b/arch/lm32/include/asm/thread_info.h
@@ -9,7 +9,6 @@
 #define _ASM_LM32_THREAD_INFO_H
 
 #include <asm/page.h>
-#include <asm/segment.h>
 
 #ifdef __KERNEL__
 
@@ -21,6 +20,14 @@
 
 #ifndef __ASSEMBLY__
 
+typedef unsigned long mm_segment_t;
+
+#define USER_DS                (0x5)
+#define KERNEL_DS      (0xA)
+
+#define segment_eq(a,b)        ((a) == (b))
+
+
 /*
  * low level task data.
  * If you change this, change the TI_* offsets below to match.
@@ -32,7 +39,7 @@ struct thread_info {
        int                cpu;                 /* cpu we're on */
        int                preempt_count;       /* 0 => preemptable, <0 => BUG 
*/
        struct restart_block restart_block;
-       mm_segment_t    mem_seg; /* USER_DS if user mode thread, KERNEL_DS if 
kernel mode thread */
+       mm_segment_t mem_seg;
 };
 
 /*
diff --git a/arch/lm32/include/asm/types.h b/arch/lm32/include/asm/types.h
index d9e4eda..b9e79bc 100644
--- a/arch/lm32/include/asm/types.h
+++ b/arch/lm32/include/asm/types.h
@@ -1,97 +1 @@
-/*
- * (C) Copyright 2007
- *     Theobroma Systems <www.theobroma-systems.com>
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-/*
- * Based on:
- * include/asm-m68k/types.h
- */
-
-#ifndef _LM32_ASM_TYPES_H
-#define _LM32_ASM_TYPES_H
-
-#include <asm/param.h>
-
-/*
- * This file is never included by application software unless
- * explicitly requested (e.g., via linux/types.h) in which case the
- * application is Linux specific so (user-) name space pollution is
- * not a major issue.  However, for interoperability, libraries still
- * need to be careful to avoid a name clashes.
- */
-
-#ifndef __ASSEMBLY__
-
-typedef unsigned short umode_t;
-
-/*
- * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
- * header files exported to user space
- */
-
-typedef __signed__ char __s8;
-typedef unsigned char __u8;
-
-typedef __signed__ short __s16;
-typedef unsigned short __u16;
-
-typedef __signed__ int __s32;
-typedef unsigned int __u32;
-
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
-typedef __signed__ long long __s64;
-typedef unsigned long long __u64;
-#endif
-
-#endif /* __ASSEMBLY__ */
-
-/*
- * These aren't exported outside the kernel to avoid name space clashes
- */
-#ifdef __KERNEL__
-
-#define BITS_PER_LONG 32
-
-#ifndef __ASSEMBLY__
-
-typedef signed char s8;
-typedef unsigned char u8;
-
-typedef signed short s16;
-typedef unsigned short u16;
-
-typedef signed int s32;
-typedef unsigned int u32;
-
-typedef signed long long s64;
-typedef unsigned long long u64;
-
-/* DMA addresses are always 32-bits wide */
-
-// TODO ensure this is correct once dma is implemented
-typedef u32 dma_addr_t;
-typedef u32 dma64_addr_t;
-
-#endif /* __ASSEMBLY__ */
-
-#endif /* __KERNEL__ */
-
-#endif /* _LM32_ASM_TYPES_H */
+#include <asm-generic/types.h>
diff --git a/arch/lm32/include/asm/uaccess.h b/arch/lm32/include/asm/uaccess.h
index ec0ec74..8b7bd3f 100644
--- a/arch/lm32/include/asm/uaccess.h
+++ b/arch/lm32/include/asm/uaccess.h
@@ -32,7 +32,6 @@
 #include <linux/string.h>
 
 #include <asm/thread_info.h>
-#include <asm/segment.h>
 //#include <asm-generic/uaccess.h>
 //#include <asm-generic/sections.h>
 
diff --git a/arch/lm32/include/asm/user.h b/arch/lm32/include/asm/user.h
index b33141b..4792a60 100644
--- a/arch/lm32/include/asm/user.h
+++ b/arch/lm32/include/asm/user.h
@@ -1,56 +1 @@
-/*
- * (C) Copyright 2007
- *     Theobroma Systems <www.theobroma-systems.com>
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#ifndef _LM32_ASM_USER_H
-#define _LM32_ASM_USER_H
-
-#include <asm/page.h>
-#include <asm/registers.h>
-
-/* When the kernel dumps core, it starts by dumping the user struct -
-   this will be used by gdb to figure out where the data and stack segments
-   are within the file, and what virtual addresses to use. */
-struct user{
-       /* We start with the registers, to mimic the way that "memory" is 
returned
-   from the ptrace(3,...) function.  */
-  struct user_context context; /* Where the registers are actually stored */
-       /* The rest of this junk is to help gdb figure out what goes where */
-  unsigned long int u_tsize;   /* Text segment size (pages). */
-  unsigned long int u_dsize;   /* Data segment size (pages). */
-  unsigned long int u_ssize;   /* Stack segment size (pages). */
-  unsigned long start_code;     /* Starting virtual address of text. */
-  unsigned long start_stack;   /* Starting virtual address of stack area.
-                                  This is actually the bottom of the stack,
-                                  the top of the stack is always found in the
-                                  esp register.  */
-  long int signal;                     /* Signal that caused the core dump. */
-  unsigned long magic;         /* To uniquely identify a core file */
-  char u_comm[32];             /* User command that was responsible */
-};
-
-#define NBPG PAGE_SIZE
-#define UPAGES 1
-#define HOST_TEXT_START_ADDR (u.start_code)
-#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
-
-#endif
+#include <asm-generic/user.h>
diff --git a/arch/lm32/kernel/process.c b/arch/lm32/kernel/process.c
index 6ad94cc9..4de69bf 100644
--- a/arch/lm32/kernel/process.c
+++ b/arch/lm32/kernel/process.c
@@ -41,6 +41,7 @@
 #include <linux/interrupt.h>
 #include <linux/reboot.h>
 #include <linux/fs.h>
+#include <linux/io.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
-- 
1.7.2.3

_______________________________________________
http://lists.milkymist.org/listinfo.cgi/devel-milkymist.org
IRC: #milkymist@Freenode
Twitter: www.twitter.com/milkymistvj
Ideas? http://milkymist.uservoice.com

Reply via email to