Skip to contentSkip to conversation

arm: use generic header files where possible

PATCH New Arnd Bergmann 1 participant 9 messages Oct 6, 2010 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

cover arm: use generic header files where possible

Many header files in the arm architecture already use the common asm-generic implementation, but I found a number that don't yet.

A signficant amount of code can be saved by either directly falling back to the common implementation, where it has no effect on compilation, or by using a combination of the common file with arm-specific additions in the other cases.

In order to make this more appropriate for both review and bisection in case of problems, I first change the headers to be identical to the common version, aside from the introductory copyright statement and include guard, and in the second step replace the common parts with an #include.

Arnd Bergmann (8):
arm: generalize IPC header files
arm: trivial changes to make headers more generic
arm: remove unused asm/segment.h contents
arm: make asm/ioctls.h mostly generic
arm: generalize asm/posix_types.h
arm: generalize asm/signal.h
arm: generalize asm/termios.h
arm: remove generic asm header file contents

 arch/arm/include/asm/ioctls.h      |   84 +---------------
 arch/arm/include/asm/ipcbuf.h      |   30 +-----
 arch/arm/include/asm/msgbuf.h      |   32 +------
 arch/arm/include/asm/param.h       |   32 +------
 arch/arm/include/asm/parport.h     |   19 +----
 arch/arm/include/asm/posix_types.h |   68 ++++--------
 arch/arm/include/asm/segment.h     |   12 +--
 arch/arm/include/asm/sembuf.h      |   26 +-----
 arch/arm/include/asm/serial.h      |   20 +----
 arch/arm/include/asm/shmbuf.h      |   43 +--------
 arch/arm/include/asm/signal.h      |  147 +-------------------------
 arch/arm/include/asm/socket.h      |   66 +------------
 arch/arm/include/asm/sockios.h     |   14 +---
 arch/arm/include/asm/termbits.h    |  199 +-----------------------------------
 arch/arm/include/asm/termios.h     |   93 +-----------------
 arch/arm/include/asm/timex.h       |    8 +--
 arch/arm/include/asm/types.h       |   32 +------
 17 files changed, 44 insertions(+), 881 deletions(-)
#1 lore raw

PATCH 1/8 arm: generalize IPC header files

The IPC structure definitions in ARM are all compatible with the generic definitions. Make them look identical as a preparation for actually using the files in include/asm-generic.

---
 arch/arm/include/asm/ipcbuf.h |   15 ++++++++++-----
 arch/arm/include/asm/msgbuf.h |   20 ++++++++++++++++++--
 arch/arm/include/asm/sembuf.h |   27 ++++++++++++++++++++-------
 arch/arm/include/asm/shmbuf.h |   21 +++++++++++++++++++--
 4 files changed, 67 insertions(+), 16 deletions(-)
arch/arm/include/asm/ipcbuf.h +10 -5
index 9768397..40e492d 100644
@@ -2,24 +2,29 @@
 #define __ASMARM_IPCBUF_H
 
 /*
- * The ipc64_perm structure for arm architecture.
+ * The generic ipc64_perm structure:
  * Note extra padding because this structure is passed back and forth
  * between kernel and user space.
  *
+ * ipc64_perm was originally meant to be architecture specific, but
+ * everyone just ended up making identical copies without specific
+ * optimizations, so we may just as well all use the same one.
+ *
  * Pad space is left for:
- * - 32-bit mode_t and seq
+ * - 32-bit mode_t on architectures that only had 16 bit
+ * - 32-bit seq
  * - 2 miscellaneous 32-bit values
  */
 
-struct ipc64_perm
-{
+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;
+				/* pad if mode_t is u16: */
+	unsigned char		__pad1[4 - sizeof(__kernel_mode_t)];
 	unsigned short		seq;
 	unsigned short		__pad2;
 	unsigned long		__unused1;
arch/arm/include/asm/msgbuf.h +18 -2
index 33b35b9..ca4e383 100644
@@ -1,11 +1,21 @@
 #ifndef _ASMARM_MSGBUF_H
 #define _ASMARM_MSGBUF_H
 
-/* 
- * The msqid64_ds structure for arm architecture.
+#include <asm/bitsperlong.h>
+/*
+ * generic msqid64_ds structure.
+ *
  * Note extra padding because this structure is passed back and forth
  * between kernel and user space.
  *
+ * msqid64_ds was originally meant to be architecture specific, but
+ * everyone just ended up making identical copies without specific
+ * optimizations, so we may just as well all use the same one.
+ *
+ * 64 bit architectures typically define a 64 bit __kernel_time_t,
+ * so they do not need the first three padding words.
+ * On big-endian systems, the padding is in the wrong place.
+ *
  * Pad space is left for:
  * - 64-bit time_t to solve y2038 problem
  * - 2 miscellaneous 32-bit values
@@ -14,11 +24,17 @@
 struct msqid64_ds {
 	struct ipc64_perm msg_perm;
 	__kernel_time_t msg_stime;	/* last msgsnd time */
+#if __BITS_PER_LONG != 64
 	unsigned long	__unused1;
+#endif
 	__kernel_time_t msg_rtime;	/* last msgrcv time */
+#if __BITS_PER_LONG != 64
 	unsigned long	__unused2;
+#endif
 	__kernel_time_t msg_ctime;	/* last change time */
+#if __BITS_PER_LONG != 64
 	unsigned long	__unused3;
+#endif
 	unsigned long  msg_cbytes;	/* current number of bytes on queue */
 	unsigned long  msg_qnum;	/* number of messages in queue */
 	unsigned long  msg_qbytes;	/* max number of bytes on queue */
arch/arm/include/asm/sembuf.h +20 -7
index 1c02839..f7131b7 100644
@@ -1,23 +1,36 @@
 #ifndef _ASMARM_SEMBUF_H
 #define _ASMARM_SEMBUF_H
 
-/* 
- * The semid64_ds structure for arm architecture.
+#include <asm/bitsperlong.h>
+
+/*
+ * The semid64_ds structure for x86 architecture.
  * Note extra padding because this structure is passed back and forth
  * between kernel and user space.
  *
+ * semid64_ds was originally meant to be architecture specific, but
+ * everyone just ended up making identical copies without specific
+ * optimizations, so we may just as well all use the same one.
+ *
+ * 64 bit architectures typically define a 64 bit __kernel_time_t,
+ * so they do not need the first two padding words.
+ * On big-endian systems, the padding is in the wrong place.
+ *
  * Pad space is left for:
  * - 64-bit time_t to solve y2038 problem
  * - 2 miscellaneous 32-bit values
  */
-
 struct semid64_ds {
-	struct ipc64_perm sem_perm;		/* permissions .. see ipc.h */
-	__kernel_time_t	sem_otime;		/* last semop time */
+	struct ipc64_perm sem_perm;	/* permissions .. see ipc.h */
+	__kernel_time_t	sem_otime;	/* last semop time */
+#if __BITS_PER_LONG != 64
 	unsigned long	__unused1;
-	__kernel_time_t	sem_ctime;		/* last change time */
+#endif
+	__kernel_time_t	sem_ctime;	/* last change time */
+#if __BITS_PER_LONG != 64
 	unsigned long	__unused2;
-	unsigned long	sem_nsems;		/* no. of semaphores in array */
+#endif
+	unsigned long	sem_nsems;	/* no. of semaphores in array */
 	unsigned long	__unused3;
 	unsigned long	__unused4;
 };
arch/arm/include/asm/shmbuf.h +19 -2
index 2e5c67b..39b1ab0 100644
@@ -1,11 +1,22 @@
 #ifndef _ASMARM_SHMBUF_H
 #define _ASMARM_SHMBUF_H
 
-/* 
- * The shmid64_ds structure for arm architecture.
+#include <asm/bitsperlong.h>
+
+/*
+ * The shmid64_ds structure for x86 architecture.
  * Note extra padding because this structure is passed back and forth
  * between kernel and user space.
  *
+ * shmid64_ds was originally meant to be architecture specific, but
+ * everyone just ended up making identical copies without specific
+ * optimizations, so we may just as well all use the same one.
+ *
+ * 64 bit architectures typically define a 64 bit __kernel_time_t,
+ * so they do not need the first two padding words.
+ * On big-endian systems, the padding is in the wrong place.
+ *
+ *
  * Pad space is left for:
  * - 64-bit time_t to solve y2038 problem
  * - 2 miscellaneous 32-bit values
@@ -15,11 +26,17 @@ struct shmid64_ds {
 	struct ipc64_perm	shm_perm;	/* operation perms */
 	size_t			shm_segsz;	/* size of segment (bytes) */
 	__kernel_time_t		shm_atime;	/* last attach time */
+#if __BITS_PER_LONG != 64
 	unsigned long		__unused1;
+#endif
 	__kernel_time_t		shm_dtime;	/* last detach time */
+#if __BITS_PER_LONG != 64
 	unsigned long		__unused2;
+#endif
 	__kernel_time_t		shm_ctime;	/* last change time */
+#if __BITS_PER_LONG != 64
 	unsigned long		__unused3;
+#endif
 	__kernel_pid_t		shm_cpid;	/* pid of creator */
 	__kernel_pid_t		shm_lpid;	/* pid of last operator */
 	unsigned long		shm_nattch;	/* no. of current attaches */
Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/8 arm: trivial changes to make headers more generic

In reply to Arnd Bergmann

A number of header files differ from the asm-generic version only in whitespace, comments or other minor things. Make them identical to the generic version as a preparation to actually using the implementation from include/asm-generic.

---
 arch/arm/include/asm/param.h    |   19 +++++++++++--------
 arch/arm/include/asm/parport.h  |   19 ++++++++++++++++---
 arch/arm/include/asm/serial.h   |    9 ++++++++-
 arch/arm/include/asm/socket.h   |   12 +++++++-----
 arch/arm/include/asm/sockios.h  |    2 +-
 arch/arm/include/asm/termbits.h |   11 ++++++-----
 arch/arm/include/asm/timex.h    |   12 ++++++++++--
 arch/arm/include/asm/types.h    |   29 ++++++++++++++++++++---------
 8 files changed, 79 insertions(+), 34 deletions(-)
arch/arm/include/asm/param.h +11 -8
index 8b24bf9..eaca062 100644
@@ -10,22 +10,25 @@
 #ifndef __ASM_PARAM_H
 #define __ASM_PARAM_H
 
+
 #ifdef __KERNEL__
 # define HZ		CONFIG_HZ	/* Internal kernel timer frequency */
-# define USER_HZ	100		/* User interfaces are in "ticks" */
-# define CLOCKS_PER_SEC	(USER_HZ)	/* like times() */
-#else
-# define HZ		100
+# define USER_HZ	100		/* some user interfaces are */
+# define CLOCKS_PER_SEC	(USER_HZ)       /* in "ticks" like times() */
+#endif
+
+#ifndef HZ
+#define HZ 100
 #endif
 
+#ifndef EXEC_PAGESIZE
 #define EXEC_PAGESIZE	4096
+#endif
 
 #ifndef NOGROUP
-#define NOGROUP         (-1)
+#define NOGROUP		(-1)
 #endif
 
-/* max length of hostname */
-#define MAXHOSTNAMELEN  64
+#define MAXHOSTNAMELEN	64	/* max length of hostname */
 
 #endif
-
arch/arm/include/asm/parport.h +16 -3
index 26e94b0..b4c19a8 100644
@@ -9,10 +9,23 @@
 #ifndef __ASMARM_PARPORT_H
 #define __ASMARM_PARPORT_H
 
-static int __devinit parport_pc_find_isa_ports (int autoirq, int autodma);
-static int __devinit parport_pc_find_nonpci_ports (int autoirq, int autodma)
+/*
+ * An ISA bus may have i8255 parallel ports at well-known
+ * locations in the I/O space, which are scanned by
+ * parport_pc_find_isa_ports.
+ *
+ * Without ISA support, the driver will only attach
+ * to devices on the PCI bus.
+ */
+
+static int __devinit parport_pc_find_isa_ports(int autoirq, int autodma);
+static int __devinit parport_pc_find_nonpci_ports(int autoirq, int autodma)
 {
-	return parport_pc_find_isa_ports (autoirq, autodma);
+#ifdef CONFIG_ISA
+	return parport_pc_find_isa_ports(autoirq, autodma);
+#else
+	return 0;
+#endif
 }
 
 #endif /* !(_ASMARM_PARPORT_H) */
arch/arm/include/asm/serial.h +8 -1
index ebb0490..560f625 100644
@@ -14,6 +14,13 @@
 #ifndef __ASM_SERIAL_H
 #define __ASM_SERIAL_H
 
-#define BASE_BAUD	(1843200 / 16)
+/*
+ * This should not be an architecture specific #define, oh well.
+ *
+ * Traditionally, it just describes i8250 and related serial ports
+ * that have this clock rate.
+ */
+
+#define BASE_BAUD (1843200 / 16)
 
 #endif
arch/arm/include/asm/socket.h +7 -5
index 90ffd04..5a0fbcc 100644
@@ -23,25 +23,28 @@
 #define SO_LINGER	13
 #define SO_BSDCOMPAT	14
 /* To add :#define SO_REUSEPORT 15 */
+
+#ifndef SO_PASSCRED /* powerpc only differs in these */
 #define SO_PASSCRED	16
 #define SO_PEERCRED	17
 #define SO_RCVLOWAT	18
 #define SO_SNDLOWAT	19
 #define SO_RCVTIMEO	20
 #define SO_SNDTIMEO	21
+#endif
 
 /* Security levels - as per NRL IPv6 - don't actually do anything */
 #define SO_SECURITY_AUTHENTICATION		22
 #define SO_SECURITY_ENCRYPTION_TRANSPORT	23
 #define SO_SECURITY_ENCRYPTION_NETWORK		24
 
-#define SO_BINDTODEVICE 25
+#define SO_BINDTODEVICE	25
 
 /* Socket filtering */
-#define SO_ATTACH_FILTER        26
-#define SO_DETACH_FILTER        27
+#define SO_ATTACH_FILTER	26
+#define SO_DETACH_FILTER	27
 
-#define SO_PEERNAME             28
+#define SO_PEERNAME		28
 #define SO_TIMESTAMP		29
 #define SCM_TIMESTAMP		SO_TIMESTAMP
 
@@ -61,5 +64,4 @@
 #define SO_DOMAIN		39
 
 #define SO_RXQ_OVFL             40
-
 #endif /* _ASM_SOCKET_H */
arch/arm/include/asm/sockios.h +1 -1
index a2588a2..42b3d72 100644
@@ -2,7 +2,7 @@
 #define __ARCH_ARM_SOCKIOS_H
 
 /* Socket-level I/O control calls. */
-#define FIOSETOWN 	0x8901
+#define FIOSETOWN	0x8901
 #define SIOCSPGRP	0x8902
 #define FIOGETOWN	0x8903
 #define SIOCGPGRP	0x8904
arch/arm/include/asm/termbits.h +6 -5
index 704135d..b2e61b9 100644
@@ -1,6 +1,8 @@
 #ifndef __ASM_ARM_TERMBITS_H
 #define __ASM_ARM_TERMBITS_H
 
+#include <linux/posix_types.h>
+
 typedef unsigned char	cc_t;
 typedef unsigned int	speed_t;
 typedef unsigned int	tcflag_t;
@@ -37,7 +39,6 @@ struct ktermios {
 	speed_t c_ospeed;		/* output speed */
 };
 
-
 /* c_cc characters */
 #define VINTR 0
 #define VQUIT 1
@@ -155,11 +156,11 @@ struct ktermios {
 #define  B3000000 0010015
 #define  B3500000 0010016
 #define  B4000000 0010017
-#define CIBAUD	  002003600000		/* input baud rate */
-#define CMSPAR    010000000000		/* mark or space (stick) parity */
-#define CRTSCTS	  020000000000		/* flow control */
+#define CIBAUD	  002003600000	/* input baud rate */
+#define CMSPAR	  010000000000	/* mark or space (stick) parity */
+#define CRTSCTS	  020000000000	/* flow control */
 
-#define IBSHIFT	   16
+#define IBSHIFT	  16		/* Shift from CBAUD to CIBAUD */
 
 /* c_lflag bits */
 #define ISIG	0000001
arch/arm/include/asm/timex.h +10 -2
index 3be8de3..55a01f1 100644
@@ -15,10 +15,18 @@
 #include <mach/timex.h>
 
 typedef unsigned long cycles_t;
-
-static inline cycles_t get_cycles (void)
+#ifndef get_cycles
+static inline cycles_t get_cycles(void)
 {
 	return 0;
 }
+#endif
+
+/*
+ * Architectures are encouraged to implement read_current_timer
+ * and define this in order to avoid the expensive delay loop
+ * calibration during boot.
+ */
+#undef ARCH_HAS_READ_CURRENT_TIMER
 
 #endif
arch/arm/include/asm/types.h +20 -9
index 345df01..b7389db 100644
@@ -1,6 +1,9 @@
 #ifndef __ASM_ARM_TYPES_H
 #define __ASM_ARM_TYPES_H
-
+/*
+ * int-ll64 is used practically everywhere now,
+ * so use it as a reasonable default.
+ */
 #include <asm-generic/int-ll64.h>
 
 #ifndef __ASSEMBLY__
@@ -13,19 +16,27 @@ typedef unsigned short umode_t;
  * These aren't exported outside the kernel to avoid name space clashes
  */
 #ifdef __KERNEL__
-
-#define BITS_PER_LONG 32
-
 #ifndef __ASSEMBLY__
-
-/* Dma addresses are 32-bits wide.  */
-
+/*
+ * DMA addresses may be very different from physical addresses
+ * and pointers. i386 and powerpc may have 64 bit DMA on 32 bit
+ * systems, while sparc64 uses 32 bit DMA addresses for 64 bit
+ * physical addresses.
+ * This default defines dma_addr_t to have the same size as
+ * phys_addr_t, which is the most common way.
+ * Do not define the dma64_addr_t type, which never really
+ * worked.
+ */
+#ifndef dma_addr_t
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
+typedef u64 dma_addr_t;
+#else
 typedef u32 dma_addr_t;
-typedef u32 dma64_addr_t;
+#endif /* CONFIG_PHYS_ADDR_T_64BIT */
+#endif /* dma_addr_t */
 
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
 
 #endif
-
Signature · 1 line
1.7.1
#3 lore raw

PATCH 3/8 arm: remove unused asm/segment.h contents

In reply to Arnd Bergmann

The constants defined in asm/segment.h are not used anywhere in Linux, so we can make the file look like the practically empty asm-generic/segment.h.

---
 arch/arm/include/asm/segment.h |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)
arch/arm/include/asm/segment.h +5 -7
index 9e24c21..b8b7291 100644
@@ -1,11 +1,9 @@
 #ifndef __ASM_ARM_SEGMENT_H
 #define __ASM_ARM_SEGMENT_H
-
-#define __KERNEL_CS   0x0
-#define __KERNEL_DS   0x0
-
-#define __USER_CS     0x1
-#define __USER_DS     0x1
+/*
+ * Only here because we have some old header files that expect it...
+ *
+ * New architectures probably don't want to have their own version.
+ */
 
 #endif /* __ASM_ARM_SEGMENT_H */
-
Signature · 1 line
1.7.1
#4 lore raw

PATCH 4/8 arm: make asm/ioctls.h mostly generic

In reply to Arnd Bergmann

This makes the arm version of asm/ioctls.h almost identical to the asm-generic version, the only difference being the definition of FIOQSIZE.

The only user-visible change is the addition of the TCGETX/TCSETX/TCSETXF/TCSETXW ioctl family, which was not defined on ARM previously.

---
 arch/arm/include/asm/ioctls.h |   39 ++++++++++++++++++++++++++-------------
 1 files changed, 26 insertions(+), 13 deletions(-)
arch/arm/include/asm/ioctls.h +26 -13
index 0b30894..0040d08 100644
@@ -1,7 +1,10 @@
 #ifndef __ASM_ARM_IOCTLS_H
 #define __ASM_ARM_IOCTLS_H
 
-#include <asm/ioctl.h>
+/* ARM uses a different value from the asm-generic definition for this */
+#define FIOQSIZE	0x545E
+
+#include <linux/ioctl.h>
 
 /* 0x54 is just a magic number to make these relatively unique ('T') */
 
@@ -46,18 +49,21 @@
 #define TIOCSBRK	0x5427  /* BSD compatibility */
 #define TIOCCBRK	0x5428  /* BSD compatibility */
 #define TIOCGSID	0x5429  /* Return the session ID of FD */
-#define TCGETS2		_IOR('T',0x2A, struct termios2)
-#define TCSETS2		_IOW('T',0x2B, struct termios2)
-#define TCSETSW2	_IOW('T',0x2C, struct termios2)
-#define TCSETSF2	_IOW('T',0x2D, struct termios2)
-#define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
-#define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
-#define TIOCSIG		_IOW('T',0x36, int)  /* Generate signal on Pty slave */
-
-#define TIOCGRS485      0x542E
-#define TIOCSRS485      0x542F
+#define TCGETS2		_IOR('T', 0x2A, struct termios2)
+#define TCSETS2		_IOW('T', 0x2B, struct termios2)
+#define TCSETSW2	_IOW('T', 0x2C, struct termios2)
+#define TCSETSF2	_IOW('T', 0x2D, struct termios2)
+#define TIOCGRS485	0x542E
+#define TIOCSRS485	0x542F
+#define TIOCGPTN	_IOR('T', 0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
+#define TIOCSPTLCK	_IOW('T', 0x31, int)  /* Lock/unlock Pty */
+#define TCGETX		0x5432 /* SYS5 TCGETX compatibility */
+#define TCSETX		0x5433
+#define TCSETXF		0x5434
+#define TCSETXW		0x5435
+#define TIOCSIG		_IOW('T', 0x36, int)  /* pty: generate signal */
 
-#define FIONCLEX	0x5450  /* these numbers need to be adjusted. */
+#define FIONCLEX	0x5450
 #define FIOCLEX		0x5451
 #define FIOASYNC	0x5452
 #define TIOCSERCONFIG	0x5453
@@ -72,7 +78,14 @@
 
 #define TIOCMIWAIT	0x545C	/* wait for a change on serial input line(s) */
 #define TIOCGICOUNT	0x545D	/* read serial port inline interrupt counts */
-#define FIOQSIZE	0x545E
+
+/*
+ * Some arches already define FIOQSIZE due to a historical
+ * conflict with a Hayes modem-specific ioctl value.
+ */
+#ifndef FIOQSIZE
+# define FIOQSIZE	0x5460
+#endif
 
 /* Used for packet mode */
 #define TIOCPKT_DATA		 0
Signature · 1 line
1.7.1
#5 lore raw

PATCH 5/8 arm: generalize asm/posix_types.h

In reply to Arnd Bergmann

This makes the arm version of asm/posix_types.h a variant of the asm-generic version, which allows overriding parts of the type definitions while using the common parts.

The definitions that still need to differ to maintain the user space ABI are:

__kernel_mode_t
__kernel_nlink_t
__kernel_ipc_pid_t
__kernel_uid_t
__kernel_gid_t
__kernel_uid32_t
__kernel_gid32_t
__kernel_old_uid_t
__kernel_old_gid_t
__kernel_old_dev_t

These get defined to their traditional values before the common code.

The definitions of __FD_SET/__FD_CLR__FD_ISSET/__FD_ZERO all get replaced by the slightly different definitions from the asm-generic file, which are more type safe.

---
 arch/arm/include/asm/posix_types.h |  207 ++++++++++++++++++++++++++++++------
 1 files changed, 172 insertions(+), 35 deletions(-)
arch/arm/include/asm/posix_types.h +172 -35
index 2446d23..558cf4b 100644
@@ -14,64 +14,201 @@
 #define __ARCH_ARM_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.
+ * These are ARM specific overrides for types that
+ * we traditionally define differently from the
+ * generic types.
  */
-
-typedef unsigned long		__kernel_ino_t;
 typedef unsigned short		__kernel_mode_t;
+#define __kernel_mode_t		__kernel_mode_t
+
 typedef unsigned short		__kernel_nlink_t;
-typedef long			__kernel_off_t;
-typedef int			__kernel_pid_t;
+#define __kernel_nlink_t	__kernel_nlink_t
+
 typedef unsigned short		__kernel_ipc_pid_t;
+#define __kernel_ipc_pid_t	__kernel_ipc_pid_t
+
 typedef unsigned short		__kernel_uid_t;
+#define __kernel_uid_t		__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;
+#define __kernel_gid_t		__kernel_gid_t
+
 typedef unsigned int		__kernel_uid32_t;
+#define __kernel_uid32_t	__kernel_uid32_t
+
 typedef unsigned int		__kernel_gid32_t;
+#define __kernel_gid32_t	__kernel_gid32_t
 
 typedef unsigned short		__kernel_old_uid_t;
+#define __kernel_old_uid_t	__kernel_old_uid_t
+
 typedef unsigned short		__kernel_old_gid_t;
+#define __kernel_old_gid_t	__kernel_old_gid_t
+
 typedef unsigned short		__kernel_old_dev_t;
+#define __kernel_old_dev_t	__kernel_old_dev_t
+
+/* generic contents from here */
+
+#include <asm/bitsperlong.h>
+/*
+ * This file is generally used by user-level software, so you need to
+ * be a little careful about namespace pollution etc.
+ *
+ * First the types that are often defined in different ways across
+ * architectures, so that you can override them.
+ */
+
+#ifndef __kernel_ino_t
+typedef unsigned long	__kernel_ino_t;
+#endif
+
+#ifndef __kernel_mode_t
+typedef unsigned int	__kernel_mode_t;
+#endif
+
+#ifndef __kernel_nlink_t
+typedef unsigned long	__kernel_nlink_t;
+#endif
+
+#ifndef __kernel_pid_t
+typedef int		__kernel_pid_t;
+#endif
+
+#ifndef __kernel_ipc_pid_t
+typedef int		__kernel_ipc_pid_t;
+#endif
+
+#ifndef __kernel_uid_t
+typedef unsigned int	__kernel_uid_t;
+typedef unsigned int	__kernel_gid_t;
+#endif
+
+#ifndef __kernel_suseconds_t
+typedef long		__kernel_suseconds_t;
+#endif
+
+#ifndef __kernel_daddr_t
+typedef int		__kernel_daddr_t;
+#endif
 
-#ifdef __GNUC__
-typedef long long		__kernel_loff_t;
+#ifndef __kernel_uid32_t
+typedef __kernel_uid_t	__kernel_uid32_t;
+typedef __kernel_gid_t	__kernel_gid32_t;
 #endif
 
+#ifndef __kernel_old_uid_t
+typedef __kernel_uid_t	__kernel_old_uid_t;
+typedef __kernel_gid_t	__kernel_old_gid_t;
+#endif
+
+#ifndef __kernel_old_dev_t
+typedef unsigned int	__kernel_old_dev_t;
+#endif
+
+/*
+ * Most 32 bit architectures use "unsigned int" size_t,
+ * and all 64 bit architectures use "unsigned long" size_t.
+ */
+#ifndef __kernel_size_t
+#if __BITS_PER_LONG != 64
+typedef unsigned int	__kernel_size_t;
+typedef int		__kernel_ssize_t;
+typedef int		__kernel_ptrdiff_t;
+#else
+typedef unsigned long	__kernel_size_t;
+typedef long		__kernel_ssize_t;
+typedef long		__kernel_ptrdiff_t;
+#endif
+#endif
+
+/*
+ * anything below here should be completely generic
+ */
+typedef long		__kernel_off_t;
+typedef long long	__kernel_loff_t;
+typedef long		__kernel_time_t;
+typedef long		__kernel_clock_t;
+typedef int		__kernel_timer_t;
+typedef int		__kernel_clockid_t;
+typedef char *		__kernel_caddr_t;
+typedef unsigned short	__kernel_uid16_t;
+typedef unsigned short	__kernel_gid16_t;
+
 typedef struct {
 	int	val[2];
 } __kernel_fsid_t;
 
-#if defined(__KERNEL__)
+#ifdef __KERNEL__
 
-#undef	__FD_SET
-#define __FD_SET(fd, fdsetp) \
-		(((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] |= (1<<((fd) & 31)))
+#undef __FD_SET
+static inline void __FD_SET(unsigned long __fd, __kernel_fd_set *__fdsetp)
+{
+	unsigned long __tmp = __fd / __NFDBITS;
+	unsigned long __rem = __fd % __NFDBITS;
+	__fdsetp->fds_bits[__tmp] |= (1UL<<__rem);
+}
 
-#undef	__FD_CLR
-#define __FD_CLR(fd, fdsetp) \
-		(((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] &= ~(1<<((fd) & 31)))
+#undef __FD_CLR
+static inline void __FD_CLR(unsigned long __fd, __kernel_fd_set *__fdsetp)
+{
+	unsigned long __tmp = __fd / __NFDBITS;
+	unsigned long __rem = __fd % __NFDBITS;
+	__fdsetp->fds_bits[__tmp] &= ~(1UL<<__rem);
+}
 
-#undef	__FD_ISSET
-#define __FD_ISSET(fd, fdsetp) \
-		((((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] & (1<<((fd) & 31))) != 0)
+#undef __FD_ISSET
+static inline int __FD_ISSET(unsigned long __fd, const __kernel_fd_set *__p)
+{
+	unsigned long __tmp = __fd / __NFDBITS;
+	unsigned long __rem = __fd % __NFDBITS;
+	return (__p->fds_bits[__tmp] & (1UL<<__rem)) != 0;
+}
 
-#undef	__FD_ZERO
-#define __FD_ZERO(fdsetp) \
-		(memset (fdsetp, 0, sizeof (*(fd_set *)(fdsetp))))
+/*
+ * This will unroll the loop for the normal constant case (8 ints,
+ * for a 256-bit fd_set)
+ */
+#undef __FD_ZERO
+static inline void __FD_ZERO(__kernel_fd_set *__p)
+{
+	unsigned long *__tmp = __p->fds_bits;
+	int __i;
 
-#endif
+	if (__builtin_constant_p(__FDSET_LONGS)) {
+		switch (__FDSET_LONGS) {
+		case 16:
+			__tmp[ 0] = 0; __tmp[ 1] = 0;
+			__tmp[ 2] = 0; __tmp[ 3] = 0;
+			__tmp[ 4] = 0; __tmp[ 5] = 0;
+			__tmp[ 6] = 0; __tmp[ 7] = 0;
+			__tmp[ 8] = 0; __tmp[ 9] = 0;
+			__tmp[10] = 0; __tmp[11] = 0;
+			__tmp[12] = 0; __tmp[13] = 0;
+			__tmp[14] = 0; __tmp[15] = 0;
+			return;
+
+		case 8:
+			__tmp[ 0] = 0; __tmp[ 1] = 0;
+			__tmp[ 2] = 0; __tmp[ 3] = 0;
+			__tmp[ 4] = 0; __tmp[ 5] = 0;
+			__tmp[ 6] = 0; __tmp[ 7] = 0;
+			return;
+
+		case 4:
+			__tmp[ 0] = 0; __tmp[ 1] = 0;
+			__tmp[ 2] = 0; __tmp[ 3] = 0;
+			return;
+		}
+	}
+	__i = __FDSET_LONGS;
+	while (__i) {
+		__i--;
+		*__tmp = 0;
+		__tmp++;
+	}
+}
+
+#endif /* __KERNEL__ */
 
 #endif
Signature · 1 line
1.7.1
#6 lore raw

PATCH 6/8 arm: generalize asm/signal.h

In reply to Arnd Bergmann

The signal.h implementation in arm is mostly generic, this makes it look like the version in include/asm-generic/.

In addition to the definitions from the generic file, arm needs two SA_FLAGS values (SA_THIRTYTWO and SA_RESTORER) and a nonstandard signal (SIGSWI) as well as the definition of the legacy struct old_sigaction.

We do however drop support for libc5 and older using the header in user space. This was done on other architectures before because libc5 header compatibility has been broken elsewhere for a long time already.

---
 arch/arm/include/asm/signal.h |  119 +++++++++++++++++++----------------------
 1 files changed, 56 insertions(+), 63 deletions(-)
arch/arm/include/asm/signal.h +56 -63
index 43ba0fb..6c67030 100644
@@ -1,33 +1,27 @@
 #ifndef _ASMARM_SIGNAL_H
 #define _ASMARM_SIGNAL_H
 
-#include <linux/types.h>
+/*
+ * ARM specific SA_FLAGS values:
+ * SA_THIRTYTWO		delivers the signal in 32-bit mode, even if the task 
+ *			is running in 26-bit.
+ * SA_RESTART		flag to get restarting signals (which were the default long ago)
+ */
+#define SA_THIRTYTWO	0x02000000
+#define SA_RESTORER	0x04000000
 
-/* Avoid too many header ordering problems.  */
-struct siginfo;
+/*
+ * ARM specific signals
+ */
+#define SIGSWI		32
 
-#ifdef __KERNEL__
-/* Most things should be clean enough to redefine this at will, if care
-   is taken to make libc match.  */
+/* Generic stuff below */
+#include <linux/types.h>
 
 #define _NSIG		64
-#define _NSIG_BPW	32
+#define _NSIG_BPW	__BITS_PER_LONG
 #define _NSIG_WORDS	(_NSIG / _NSIG_BPW)
 
-typedef unsigned long old_sigset_t;		/* at least 32 bits */
-
-typedef struct {
-	unsigned long sig[_NSIG_WORDS];
-} sigset_t;
-
-#else
-/* Here we must cater to libcs that poke about in kernel headers.  */
-
-#define NSIG		32
-typedef unsigned long sigset_t;
-
-#endif /* __KERNEL__ */
-
 #define SIGHUP		 1
 #define SIGINT		 2
 #define SIGQUIT		 3
@@ -68,22 +62,20 @@ typedef unsigned long sigset_t;
 
 /* These should not be considered constants from userland.  */
 #define SIGRTMIN	32
+#ifndef SIGRTMAX
 #define SIGRTMAX	_NSIG
-
-#define SIGSWI		32
+#endif
 
 /*
  * SA_FLAGS values:
  *
- * SA_NOCLDSTOP		flag to turn off SIGCHLD when children stop.
- * SA_NOCLDWAIT		flag on SIGCHLD to inhibit zombies.
- * SA_SIGINFO		deliver the signal with SIGINFO structs
- * SA_THIRTYTWO		delivers the signal in 32-bit mode, even if the task 
- *			is running in 26-bit.
- * SA_ONSTACK		allows alternate signal stacks (see sigaltstack(2)).
- * SA_RESTART		flag to get restarting signals (which were the default long ago)
- * SA_NODEFER		prevents the current signal from being masked in the handler.
- * SA_RESETHAND		clears the handler when the signal is delivered.
+ * SA_ONSTACK indicates that a registered stack_t will be used.
+ * SA_SIGINFO deliver the signal with SIGINFO structs
+ * SA_RESTART flag to get restarting signals (which were the default long ago)
+ * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
+ * SA_RESETHAND clears the handler when the signal is delivered.
+ * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
+ * SA_NODEFER prevents the current signal from being masked in the handler.
  *
  * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
  * Unix names RESETHAND and NODEFER respectively.
@@ -91,8 +83,6 @@ typedef unsigned long sigset_t;
 #define SA_NOCLDSTOP	0x00000001
 #define SA_NOCLDWAIT	0x00000002
 #define SA_SIGINFO	0x00000004
-#define SA_THIRTYTWO	0x02000000
-#define SA_RESTORER	0x04000000
 #define SA_ONSTACK	0x08000000
 #define SA_RESTART	0x10000000
 #define SA_NODEFER	0x40000000
@@ -101,8 +91,12 @@ typedef unsigned long sigset_t;
 #define SA_NOMASK	SA_NODEFER
 #define SA_ONESHOT	SA_RESETHAND
 
+/*
+ * New architectures should not define the obsolete
+ *	SA_RESTORER	0x04000000
+ */
 
-/* 
+/*
  * sigaltstack controls
  */
 #define SS_ONSTACK	1
@@ -111,20 +105,22 @@ typedef unsigned long sigset_t;
 #define MINSIGSTKSZ	2048
 #define SIGSTKSZ	8192
 
-#include <asm-generic/signal-defs.h>
+#ifndef __ASSEMBLY__
+typedef struct {
+	unsigned long sig[_NSIG_WORDS];
+} sigset_t;
 
-#ifdef __KERNEL__
-struct old_sigaction {
-	__sighandler_t sa_handler;
-	old_sigset_t sa_mask;
-	unsigned long sa_flags;
-	__sigrestore_t sa_restorer;
-};
+/* not actually used, but required for linux/syscalls.h */
+typedef unsigned long old_sigset_t;
+
+#include <asm-generic/signal-defs.h>
 
 struct sigaction {
 	__sighandler_t sa_handler;
 	unsigned long sa_flags;
+#ifdef SA_RESTORER
 	__sigrestore_t sa_restorer;
+#endif
 	sigset_t sa_mask;		/* mask last for extensibility */
 };
 
@@ -132,24 +128,6 @@ struct k_sigaction {
 	struct sigaction sa;
 };
 
-#else
-/* Here we must cater to libcs that poke about in kernel headers.  */
-
-struct sigaction {
-	union {
-	  __sighandler_t _sa_handler;
-	  void (*_sa_sigaction)(int, struct siginfo *, void *);
-	} _u;
-	sigset_t sa_mask;
-	unsigned long sa_flags;
-	void (*sa_restorer)(void);
-};
-
-#define sa_handler	_u._sa_handler
-#define sa_sigaction	_u._sa_sigaction
-
-#endif /* __KERNEL__ */
-
 typedef struct sigaltstack {
 	void __user *ss_sp;
 	int ss_flags;
@@ -157,8 +135,23 @@ typedef struct sigaltstack {
 } stack_t;
 
 #ifdef __KERNEL__
+
 #include <asm/sigcontext.h>
+#undef __HAVE_ARCH_SIG_BITOPS
+
 #define ptrace_signal_deliver(regs, cookie) do { } while (0)
-#endif
 
-#endif
+#endif /* __KERNEL__ */
+#endif /* __ASSEMBLY__ */
+
+/* End generic stuff */
+#ifdef __KERNEL__
+struct old_sigaction {
+	__sighandler_t sa_handler;
+	old_sigset_t sa_mask;
+	unsigned long sa_flags;
+	__sigrestore_t sa_restorer;
+};
+#endif /* __KERNEL__ */
+
+#endif /* _ASMARM_SIGNAL_H */
Signature · 1 line
1.7.1
#7 lore raw

PATCH 7/8 arm: generalize asm/termios.h

In reply to Arnd Bergmann

The termios header on arm differs from the asm-generic version practically only in the definition of user_termio_to_kernel_termios and user_termio_to_kernel_termios.

Using the generic definition fixes multiple problems:

- type safety of the functions
- missing check of user space pointer access
- incorrect behaviour on big-endian kernels
- missing copy of the c_line field

Moreover, once the code is identical to the generic version, we can simply use that code instead.

---
 arch/arm/include/asm/termios.h |  136 +++++++++++++++++++++++++++++-----------
 1 files changed, 99 insertions(+), 37 deletions(-)
arch/arm/include/asm/termios.h +99 -37
index 293e3f1..94ce9ec 100644
@@ -1,5 +1,12 @@
 #ifndef __ASM_ARM_TERMIOS_H
 #define __ASM_ARM_TERMIOS_H
+/*
+ * Most architectures have straight copies of the x86 code, with
+ * varying levels of bug fixes on top. Usually it's a good idea
+ * to use this generic version instead, but be careful to avoid
+ * ABI changes.
+ * New architectures should not provide their own version.
+ */
 
 #include <asm/termbits.h>
 #include <asm/ioctls.h>
@@ -21,16 +28,6 @@ struct termio {
 	unsigned char c_cc[NCC];	/* control characters */
 };
 
-#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"
-#endif
-
 /* modem lines */
 #define TIOCM_LE	0x001
 #define TIOCM_DTR	0x002
@@ -51,41 +48,106 @@ struct termio {
 
 #ifdef __KERNEL__
 
+#include <asm/uaccess.h>
+
+/*	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 SET_LOW_TERMIOS_BITS(termios, termio, x) {		\
-	unsigned short __tmp;					\
-	get_user(__tmp,&(termio)->x);				\
-	*(unsigned short *) &(termios)->x = __tmp;		\
-}
+static inline int user_termio_to_kernel_termios(struct ktermios *termios,
+						const struct termio __user *termio)
+{
+	unsigned short tmp;
+
+	if (get_user(tmp, &termio->c_iflag) < 0)
+		goto fault;
+	termios->c_iflag = (0xffff0000 & termios->c_iflag) | tmp;
 
-#define user_termio_to_kernel_termios(termios, termio) \
-({ \
-	SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \
-	SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \
-	SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \
-	SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \
-	copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
-})
+	if (get_user(tmp, &termio->c_oflag) < 0)
+		goto fault;
+	termios->c_oflag = (0xffff0000 & termios->c_oflag) | tmp;
+
+	if (get_user(tmp, &termio->c_cflag) < 0)
+		goto fault;
+	termios->c_cflag = (0xffff0000 & termios->c_cflag) | tmp;
+
+	if (get_user(tmp, &termio->c_lflag) < 0)
+		goto fault;
+	termios->c_lflag = (0xffff0000 & termios->c_lflag) | tmp;
+
+	if (get_user(termios->c_line, &termio->c_line) < 0)
+		goto fault;
+
+	if (copy_from_user(termios->c_cc, termio->c_cc, NCC) != 0)
+		goto fault;
+
+	return 0;
+
+ fault:
+	return -EFAULT;
+}
 
 /*
  * 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 termios2))
-#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios2))
-#define user_termios_to_kernel_termios_1(k, u) copy_from_user(k, u, sizeof(struct termios))
-#define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios))
+static inline int kernel_termios_to_user_termio(struct termio __user *termio,
+						struct ktermios *termios)
+{
+	if (put_user(termios->c_iflag, &termio->c_iflag) < 0 ||
+	    put_user(termios->c_oflag, &termio->c_oflag) < 0 ||
+	    put_user(termios->c_cflag, &termio->c_cflag) < 0 ||
+	    put_user(termios->c_lflag, &termio->c_lflag) < 0 ||
+	    put_user(termios->c_line,  &termio->c_line) < 0 ||
+	    copy_to_user(termio->c_cc, termios->c_cc, NCC) != 0)
+		return -EFAULT;
+
+	return 0;
+}
+
+#ifdef TCGETS2
+static inline int user_termios_to_kernel_termios(struct ktermios *k,
+						 struct termios2 __user *u)
+{
+	return copy_from_user(k, u, sizeof(struct termios2));
+}
+
+static inline int kernel_termios_to_user_termios(struct termios2 __user *u,
+						 struct ktermios *k)
+{
+	return copy_to_user(u, k, sizeof(struct termios2));
+}
+
+static inline int user_termios_to_kernel_termios_1(struct ktermios *k,
+						   struct termios __user *u)
+{
+	return copy_from_user(k, u, sizeof(struct termios));
+}
+
+static inline int kernel_termios_to_user_termios_1(struct termios __user *u,
+						   struct ktermios *k)
+{
+	return copy_to_user(u, k, sizeof(struct termios));
+}
+#else /* TCGETS2 */
+static inline int user_termios_to_kernel_termios(struct ktermios *k,
+						 struct termios __user *u)
+{
+	return copy_from_user(k, u, sizeof(struct termios));
+}
+
+static inline int kernel_termios_to_user_termios(struct termios __user *u,
+						 struct ktermios *k)
+{
+	return copy_to_user(u, k, sizeof(struct termios));
+}
+#endif /* TCGETS2 */
 
 #endif	/* __KERNEL__ */
 
Signature · 1 line
1.7.1
#8 lore raw

PATCH 8/8 arm: remove generic asm header file contents

In reply to Arnd Bergmann

Using the generic version of the header file reduces the amount of code that needs to be maintained in the ARM architecture in case of ABI changes.

These 17 header files have been previously converted to look like their generic counterparts in order to guarantee that replacing the implementation with the generic include does not have any unintended consequences.

---
 arch/arm/include/asm/ioctls.h      |   95 +-----------------
 arch/arm/include/asm/ipcbuf.h      |   35 +------
 arch/arm/include/asm/msgbuf.h      |   48 +---------
 arch/arm/include/asm/param.h       |   35 +------
 arch/arm/include/asm/parport.h     |   32 +------
 arch/arm/include/asm/posix_types.h |  163 +-----------------------------
 arch/arm/include/asm/segment.h     |   10 +--
 arch/arm/include/asm/sembuf.h      |   39 +-------
 arch/arm/include/asm/serial.h      |   27 +-----
 arch/arm/include/asm/shmbuf.h      |   60 +-----------
 arch/arm/include/asm/signal.h      |  130 +-----------------------
 arch/arm/include/asm/socket.h      |   68 +------------
 arch/arm/include/asm/sockios.h     |   14 +---
 arch/arm/include/asm/termbits.h    |  200 +-----------------------------------
 arch/arm/include/asm/termios.h     |  155 +---------------------------
 arch/arm/include/asm/timex.h       |   16 +---
 arch/arm/include/asm/types.h       |   43 +--------
 17 files changed, 17 insertions(+), 1153 deletions(-)
arch/arm/include/asm/ioctls.h +1 -94
index 0040d08..6917be1 100644
@@ -4,99 +4,6 @@
 /* ARM uses a different value from the asm-generic definition for this */
 #define FIOQSIZE	0x545E
 
-#include <linux/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 TCGETS2		_IOR('T', 0x2A, struct termios2)
-#define TCSETS2		_IOW('T', 0x2B, struct termios2)
-#define TCSETSW2	_IOW('T', 0x2C, struct termios2)
-#define TCSETSF2	_IOW('T', 0x2D, struct termios2)
-#define TIOCGRS485	0x542E
-#define TIOCSRS485	0x542F
-#define TIOCGPTN	_IOR('T', 0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
-#define TIOCSPTLCK	_IOW('T', 0x31, int)  /* Lock/unlock Pty */
-#define TCGETX		0x5432 /* SYS5 TCGETX compatibility */
-#define TCSETX		0x5433
-#define TCSETXF		0x5434
-#define TCSETXW		0x5435
-#define TIOCSIG		_IOW('T', 0x36, int)  /* pty: generate signal */
-
-#define FIONCLEX	0x5450
-#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 */
-
-/*
- * Some arches already define FIOQSIZE due to a historical
- * conflict with a Hayes modem-specific ioctl value.
- */
-#ifndef FIOQSIZE
-# define FIOQSIZE	0x5460
-#endif
-
-/* 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
arch/arm/include/asm/ipcbuf.h +1 -34
index 40e492d..84c7e51 100644
@@ -1,34 +1 @@
-#ifndef __ASMARM_IPCBUF_H
-#define __ASMARM_IPCBUF_H
-
-/*
- * The generic ipc64_perm structure:
- * Note extra padding because this structure is passed back and forth
- * between kernel and user space.
- *
- * ipc64_perm was originally meant to be architecture specific, but
- * everyone just ended up making identical copies without specific
- * optimizations, so we may just as well all use the same one.
- *
- * Pad space is left for:
- * - 32-bit mode_t on architectures that only had 16 bit
- * - 32-bit 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;
-				/* pad if mode_t is u16: */
-	unsigned char		__pad1[4 - sizeof(__kernel_mode_t)];
-	unsigned short		seq;
-	unsigned short		__pad2;
-	unsigned long		__unused1;
-	unsigned long		__unused2;
-};
-
-#endif /* __ASMARM_IPCBUF_H */
+#include <asm-generic/ipcbuf.h>
arch/arm/include/asm/msgbuf.h +1 -47

48 lines not on this page · raw message

arch/arm/include/asm/param.h +1 -34
index eaca062..965d454 100644
@@ -1,34 +1 @@
-/*
- *  arch/arm/include/asm/param.h
- *
- *  Copyright (C) 1995-1999 Russell King
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#ifndef __ASM_PARAM_H
-#define __ASM_PARAM_H
-
-
-#ifdef __KERNEL__
-# define HZ		CONFIG_HZ	/* Internal kernel timer frequency */
-# define USER_HZ	100		/* some user interfaces are */
-# define CLOCKS_PER_SEC	(USER_HZ)       /* in "ticks" like times() */
-#endif
-
-#ifndef HZ
-#define HZ 100
-#endif
-
-#ifndef EXEC_PAGESIZE
-#define EXEC_PAGESIZE	4096
-#endif
-
-#ifndef NOGROUP
-#define NOGROUP		(-1)
-#endif
-
-#define MAXHOSTNAMELEN	64	/* max length of hostname */
-
-#endif
+#include <asm-generic/param.h>
arch/arm/include/asm/parport.h +1 -31
index b4c19a8..cf252af 100644
@@ -1,31 +1 @@
-/*
- *  arch/arm/include/asm/parport.h: ARM-specific parport initialisation
- *
- *  Copyright (C) 1999, 2000  Tim Waugh <[email protected]>
- *
- * This file should only be included by drivers/parport/parport_pc.c.
- */
-
-#ifndef __ASMARM_PARPORT_H
-#define __ASMARM_PARPORT_H
-
-/*
- * An ISA bus may have i8255 parallel ports at well-known
- * locations in the I/O space, which are scanned by
- * parport_pc_find_isa_ports.
- *
- * Without ISA support, the driver will only attach
- * to devices on the PCI bus.
- */
-
-static int __devinit parport_pc_find_isa_ports(int autoirq, int autodma);
-static int __devinit parport_pc_find_nonpci_ports(int autoirq, int autodma)
-{
-#ifdef CONFIG_ISA
-	return parport_pc_find_isa_ports(autoirq, autodma);
-#else
-	return 0;
-#endif
-}
-
-#endif /* !(_ASMARM_PARPORT_H) */
+#include <asm-generic/parport.h>
arch/arm/include/asm/posix_types.h +1 -162

168 lines not on this page · raw message

arch/arm/include/asm/segment.h +1 -9
index b8b7291..f1b81e5 100644
@@ -1,9 +1 @@
-#ifndef __ASM_ARM_SEGMENT_H
-#define __ASM_ARM_SEGMENT_H
-/*
- * Only here because we have some old header files that expect it...
- *
- * New architectures probably don't want to have their own version.
- */
-
-#endif /* __ASM_ARM_SEGMENT_H */
+#include <asm-generic/segment.h>
arch/arm/include/asm/sembuf.h +1 -38
index f7131b7..7673b83 100644
@@ -1,38 +1 @@
-#ifndef _ASMARM_SEMBUF_H
-#define _ASMARM_SEMBUF_H
-
-#include <asm/bitsperlong.h>
-
-/*
- * The semid64_ds structure for x86 architecture.
- * Note extra padding because this structure is passed back and forth
- * between kernel and user space.
- *
- * semid64_ds was originally meant to be architecture specific, but
- * everyone just ended up making identical copies without specific
- * optimizations, so we may just as well all use the same one.
- *
- * 64 bit architectures typically define a 64 bit __kernel_time_t,
- * so they do not need the first two padding words.
- * On big-endian systems, the padding is in the wrong place.
- *
- * Pad space is left for:
- * - 64-bit time_t to solve y2038 problem
- * - 2 miscellaneous 32-bit values
- */
-struct semid64_ds {
-	struct ipc64_perm sem_perm;	/* permissions .. see ipc.h */
-	__kernel_time_t	sem_otime;	/* last semop time */
-#if __BITS_PER_LONG != 64
-	unsigned long	__unused1;
-#endif
-	__kernel_time_t	sem_ctime;	/* last change time */
-#if __BITS_PER_LONG != 64
-	unsigned long	__unused2;
-#endif
-	unsigned long	sem_nsems;	/* no. of semaphores in array */
-	unsigned long	__unused3;
-	unsigned long	__unused4;
-};
-
-#endif /* _ASMARM_SEMBUF_H */
+#include <asm-generic/sembuf.h>
arch/arm/include/asm/serial.h +1 -26
index 560f625..a0cb0ca 100644
@@ -1,26 +1 @@
-/*
- *  arch/arm/include/asm/serial.h
- *
- *  Copyright (C) 1996 Russell King.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- *  Changelog:
- *   15-10-1996	RMK	Created
- */
-
-#ifndef __ASM_SERIAL_H
-#define __ASM_SERIAL_H
-
-/*
- * This should not be an architecture specific #define, oh well.
- *
- * Traditionally, it just describes i8250 and related serial ports
- * that have this clock rate.
- */
-
-#define BASE_BAUD (1843200 / 16)
-
-#endif
+#include <asm-generic/serial.h>
arch/arm/include/asm/shmbuf.h +1 -59

60 lines not on this page · raw message

arch/arm/include/asm/signal.h +1 -129

137 lines not on this page · raw message

arch/arm/include/asm/socket.h +1 -67

68 lines not on this page · raw message

arch/arm/include/asm/sockios.h +1 -13
index 42b3d72..def6d47 100644
@@ -1,13 +1 @@
-#ifndef __ARCH_ARM_SOCKIOS_H
-#define __ARCH_ARM_SOCKIOS_H
-
-/* Socket-level I/O control calls. */
-#define FIOSETOWN	0x8901
-#define SIOCSPGRP	0x8902
-#define FIOGETOWN	0x8903
-#define SIOCGPGRP	0x8904
-#define SIOCATMARK	0x8905
-#define SIOCGSTAMP	0x8906		/* Get stamp (timeval) */
-#define SIOCGSTAMPNS	0x8907		/* Get stamp (timespec) */
-
-#endif
+#include <asm-generic/sockios.h>
arch/arm/include/asm/termbits.h +1 -199

200 lines not on this page · raw message

arch/arm/include/asm/termios.h +1 -154

155 lines not on this page · raw message

arch/arm/include/asm/timex.h +1 -15
index 55a01f1..a6a42d5 100644
@@ -13,20 +13,6 @@
 #define _ASMARM_TIMEX_H
 
 #include <mach/timex.h>
-
-typedef unsigned long cycles_t;
-#ifndef get_cycles
-static inline cycles_t get_cycles(void)
-{
-	return 0;
-}
-#endif
-
-/*
- * Architectures are encouraged to implement read_current_timer
- * and define this in order to avoid the expensive delay loop
- * calibration during boot.
- */
-#undef ARCH_HAS_READ_CURRENT_TIMER
+#include <asm-generic/timex.h>
 
 #endif
arch/arm/include/asm/types.h +1 -42

43 lines not on this page · raw message

Signature · 1 line
1.7.1