From: Hirokazu Takata <takata@linux-m32r.org>

This patch is for upgrading m32r's code to the 2.6.9-rc1-mm5 source as well as
the other architectures.

* arch/m32r/Makefile: Replace assigment to CHECK with assignment to CHECKFLAGS

* arch/m32r/kernel/vmlinux.lds.S:
	- out-of-line locks / m32r; Include LOCK_TEXT to .text section.
	- Move param section out of init area, for export of built-in
	  module params

* arch/m32r/mm/ioremap.c (__ioremap):
	Add __iomem modifier to the return value type of __ioremap()
	for much stricter type-checking.

* include/asm-m32r/resource.h:
	- rlimit-based mlocks for unprivileged users
	- Increase per-user mlock limit default to 32k	

* include/asm-m32r/socket.h:
	- [NET]: Move SOCK_foo types into linux/net.h

* include/asm-m32r/unistd.h:
  Add system calls; taken from asm-i386/unistd.h.
    - [PATCH][2/6] perfctr-2.7.3 for 2.6.7-rc1-mm1: i386  (05/31/2004)
    - [PATCH] Make key management use syscalls not prctls (09/06/2004)

Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/m32r/Makefile             |    2 +-
 25-akpm/arch/m32r/kernel/vmlinux.lds.S |    4 +---
 25-akpm/arch/m32r/mm/ioremap.c         |   10 +++++-----
 25-akpm/include/asm-m32r/resource.h    |    2 +-
 25-akpm/include/asm-m32r/socket.h      |   20 --------------------
 25-akpm/include/asm-m32r/unistd.h      |   20 ++++++++++++++++----
 6 files changed, 24 insertions(+), 34 deletions(-)

diff -puN arch/m32r/kernel/vmlinux.lds.S~m32r-upgrade-for-mm5-changes arch/m32r/kernel/vmlinux.lds.S
--- 25/arch/m32r/kernel/vmlinux.lds.S~m32r-upgrade-for-mm5-changes	2004-09-23 23:20:41.535791624 -0700
+++ 25-akpm/arch/m32r/kernel/vmlinux.lds.S	2004-09-23 23:20:41.545790104 -0700
@@ -27,6 +27,7 @@ SECTIONS
   .text : {
 	*(.text)
 	SCHED_TEXT
+	LOCK_TEXT
 	*(.fixup)
 	*(.gnu.warning)
 	} = 0x9090
@@ -81,9 +82,6 @@ SECTIONS
   __setup_start = .;
   .init.setup : { *(.init.setup) }
   __setup_end = .;
-  __start___param = .;
-  __param : { *(__param) }
-  __stop___param = .;
   __initcall_start = .;
   .initcall.init : {
 	*(.initcall1.init)
diff -puN arch/m32r/Makefile~m32r-upgrade-for-mm5-changes arch/m32r/Makefile
--- 25/arch/m32r/Makefile~m32r-upgrade-for-mm5-changes	2004-09-23 23:20:41.536791472 -0700
+++ 25-akpm/arch/m32r/Makefile	2004-09-23 23:20:41.545790104 -0700
@@ -25,7 +25,7 @@ aflags-$(CONFIG_ISA_M32R)	+= -DNO_FPU -W
 CFLAGS += $(cflags-y)
 AFLAGS += $(aflags-y)
 
-CHECK	:= $(CHECK) -D__m32r__=1
+CHECKFLAGS	:= $(CHECK) -D__m32r__=1
 
 head-y	:= arch/m32r/kernel/head.o arch/m32r/kernel/init_task.o
 
diff -puN arch/m32r/mm/ioremap.c~m32r-upgrade-for-mm5-changes arch/m32r/mm/ioremap.c
--- 25/arch/m32r/mm/ioremap.c~m32r-upgrade-for-mm5-changes	2004-09-23 23:20:41.537791320 -0700
+++ 25-akpm/arch/m32r/mm/ioremap.c	2004-09-23 23:20:41.545790104 -0700
@@ -122,9 +122,9 @@ static int remap_area_pages(unsigned lon
 
 #define IS_LOW512(addr) (!((unsigned long)(addr) & ~0x1fffffffUL))
 
-void * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags)
+void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags)
 {
-	void * addr;
+	void __iomem * addr;
 	struct vm_struct * area;
 	unsigned long offset, last_addr;
 
@@ -169,13 +169,13 @@ void * __ioremap(unsigned long phys_addr
 	if (!area)
 		return NULL;
 	area->phys_addr = phys_addr;
-	addr = area->addr;
+	addr = (void __iomem *) area->addr;
 	if (remap_area_pages((unsigned long)addr, phys_addr, size, flags)) {
-		vunmap(addr);
+		vunmap((void __force *) addr);
 		return NULL;
 	}
 
-	return (void *) (offset + (char *)addr);
+	return (void __iomem *) (offset + (char __iomem *)addr);
 }
 
 #define IS_KSEG1(addr) (((unsigned long)(addr) & ~0x1fffffffUL) == KSEG1)
diff -puN include/asm-m32r/resource.h~m32r-upgrade-for-mm5-changes include/asm-m32r/resource.h
--- 25/include/asm-m32r/resource.h~m32r-upgrade-for-mm5-changes	2004-09-23 23:20:41.539791016 -0700
+++ 25-akpm/include/asm-m32r/resource.h	2004-09-23 23:20:41.546789952 -0700
@@ -43,7 +43,7 @@
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
 	{             0,             0 },		\
 	{      INR_OPEN,     INR_OPEN  },		\
-	{ RLIM_INFINITY, RLIM_INFINITY },		\
+	{ MLOCK_LIMIT,   MLOCK_LIMIT   },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
 	{ MAX_SIGPENDING, MAX_SIGPENDING },		\
diff -puN include/asm-m32r/socket.h~m32r-upgrade-for-mm5-changes include/asm-m32r/socket.h
--- 25/include/asm-m32r/socket.h~m32r-upgrade-for-mm5-changes	2004-09-23 23:20:41.540790864 -0700
+++ 25-akpm/include/asm-m32r/socket.h	2004-09-23 23:20:41.546789952 -0700
@@ -1,10 +1,6 @@
 #ifndef _ASM_M32R_SOCKET_H
 #define _ASM_M32R_SOCKET_H
 
-/* $Id$ */
-
-/* orig : i386 2.4.18 */
-
 #include <asm/sockios.h>
 
 /* For setsockoptions(2) */
@@ -51,20 +47,4 @@
 
 #define SO_PEERSEC		31
 
-/* Nasty libc5 fixup - bletch */
-#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
-/* Socket types. */
-#define SOCK_STREAM	1		/* stream (connection) socket	*/
-#define SOCK_DGRAM	2		/* datagram (conn.less) socket	*/
-#define SOCK_RAW	3		/* raw socket			*/
-#define SOCK_RDM	4		/* reliably-delivered message	*/
-#define SOCK_SEQPACKET	5		/* sequential packet socket	*/
-#define SOCK_PACKET	10		/* linux specific way of	*/
-					/* getting packets at the dev	*/
-					/* level.  For writing rarp and	*/
-					/* other similar things on the	*/
-					/* user level.			*/
-#define	SOCK_MAX	(SOCK_PACKET+1)
-#endif
-
 #endif /* _ASM_M32R_SOCKET_H */
diff -puN include/asm-m32r/unistd.h~m32r-upgrade-for-mm5-changes include/asm-m32r/unistd.h
--- 25/include/asm-m32r/unistd.h~m32r-upgrade-for-mm5-changes	2004-09-23 23:20:41.542790560 -0700
+++ 25-akpm/include/asm-m32r/unistd.h	2004-09-23 23:20:41.547789800 -0700
@@ -292,15 +292,27 @@
 #define __NR_mq_timedreceive    (__NR_mq_open+3)
 #define __NR_mq_notify          (__NR_mq_open+4)
 #define __NR_mq_getsetattr      (__NR_mq_open+5)
-#define __NR_kexec_load		283
+#define __NR_sys_kexec_load    283
+#define __NR_waitid            284
+#define __NR_perfctr_info      285
+#define __NR_vperfctr_open     (__NR_perfctr_info+1)
+#define __NR_vperfctr_control  (__NR_perfctr_info+2)
+#define __NR_vperfctr_unlink   (__NR_perfctr_info+3)
+#define __NR_vperfctr_iresume  (__NR_perfctr_info+4)
+#define __NR_vperfctr_read     (__NR_perfctr_info+5)
+#define __NR_add_key           291
+#define __NR_request_key       292
+#define __NR_keyctl            293
 
-#define NR_syscalls     284
+#define NR_syscalls 294
 
-/* user-visible error numbers are in the range -1 - -124: see <asm-m32r/errno.h> */
+/* user-visible error numbers are in the range -1 - -128: see
+ * <asm-m32r/errno.h>
+ */
 
 #define __syscall_return(type, res) \
 do { \
-	if ((unsigned long)(res) >= (unsigned long)(-125)) { \
+	if ((unsigned long)(res) >= (unsigned long)(-(128 + 1))) { \
 	/* Avoid using "res" which is declared to be in register r0; \
 	   errno might expand to a function call and clobber it.  */ \
 		int __err = -(res); \
_