Skip to contentSkip to conversation

Update to fix compile errors

PATCH In review Hirokazu Takata 3 participants 9 messages Sep 11, 2004

lore
Share & tools
lore
#0 lore raw

cover Update to fix compile errors

Hello,

I made patches to fix compile errors for m32r architecture port. These patches are against 2.6.9-rc1-mm4.
Please apply them.

---

[PATCH 2.6.9-rc1-mm4 1/6] [m32r] Update for profiling
This patch is for profiling support. profile_tick() is used instead of m32r_do_profile().

 arch/m32r/kernel/smp.c    |   10 ++++------
 arch/m32r/kernel/time.c   |    5 ++---
 include/asm-m32r/hw_irq.h |   33 +--------------------------------
 include/asm-m32r/ptrace.h |   14 ++++++++------
 4 files changed, 15 insertions(+), 47 deletions(-)

--
[PATCH 2.6.9-rc1-mm4 2/6] [m32r] Update zone_sizes_init()
This patch upgrades zone_sizes_init() function.
This patch is required because free_area_init_node()'s interface has been changed.

 arch/m32r/mm/discontig.c |    2 +-
 arch/m32r/mm/init.c      |    3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

--
[PATCH 2.6.9-rc1-mm4 3/6] [m32r] Update to fix compile errors
This patch updates code to fix compile errors, and so on.

 arch/m32r/kernel/Makefile  |    2 -
 arch/m32r/kernel/process.c |    5 +--
 arch/m32r/kernel/signal.c  |   68 +++++++++++++++++++++++++--------------------
 include/asm-m32r/hardirq.h |   18 -----------
 include/asm-m32r/page.h    |    4 +-
 5 files changed, 43 insertions(+), 54 deletions(-)

--
[PATCH 2.6.9-rc1-mm4 4/6] [m32r] Update uaccess.h
This patch updates asm-m32r/uaccess.h.

 include/asm-m32r/uaccess.h |  349 +++++++++++++++++++++++++++++++++++++--------
 1 files changed, 290 insertions(+), 59 deletions(-)

--
[PATCH 2.6.9-rc1-mm4 5/6] [m32r] Update checksum functions
This patch update checksum routines.
And EXPORT_SYMBOL() is moved from m32r_ksyms.c to csum_partial_copy.c.

 arch/m32r/kernel/m32r_ksyms.c     |    2 
 arch/m32r/lib/csum_partial_copy.c |   39 ++--------
 include/asm-m32r/checksum.h       |  136 +++++++++++---------------------------
 3 files changed, 52 insertions(+), 125 deletions(-)

--
[PATCH 2.6.9-rc1-mm4 6/6] [m32r] Update CF/PCMCIA drivers
This patch updates m32r-specific CF/PCMCIA drivers and fixes compile errors.

 arch/m32r/drivers/m32r_cfc.c |   14 +++++++-------
 arch/m32r/drivers/m32r_pcc.c |   25 ++++++++++++++-----------
 2 files changed, 21 insertions(+), 18 deletions(-)

-----

Thank you.
--
Hirokazu Takata <[email protected]>
Linux/M32R Project: http://www.linux-m32r.org/

#1 lore raw

PATCH 1/6 Update for profiling

[PATCH 2.6.9-rc1-mm4 1/6] [m32r] Update for profiling
This patch is for profiling support. profile_tick() is used instead of m32r_do_profile().

* arch/m32r/kernel/smp.c
(smp_local_timer_interrupt): Change profile API, use profile_tick() instead of m32r_do_profile().

* arch/m32r/kernel/time.c: ditto.

* include/asm-m32r/hw_irq.h (m32r_do_profile): Removed.

* include/asm-m32r/ptrace.h (profile_pc): Add profile_pc() macro.

---

 arch/m32r/kernel/smp.c    |   10 ++++------
 arch/m32r/kernel/time.c   |    5 ++---
 include/asm-m32r/hw_irq.h |   33 +--------------------------------
 include/asm-m32r/ptrace.h |   14 ++++++++------
 4 files changed, 15 insertions(+), 47 deletions(-)
arch/m32r/kernel/smp.c +4 -6
diff -ruNp linux-2.6.9-rc1-mm4.orig/arch/m32r/kernel/smp.c linux-2.6.9-rc1-mm4/arch/m32r/kernel/smp.c
@@ -1,8 +1,7 @@
 /*
  *  linux/arch/m32r/kernel/smp.c
- *    orig : i386 2.4.10
  *
- *  MITSUBISHI M32R SMP support routines.
+ *  M32R SMP support routines.
  *
  *  Copyright (c) 2001, 2002  Hitoshi Yamamoto
  *
@@ -14,8 +13,6 @@
  *  later.
  */
 
-/* $Id$ */
-
 #undef DEBUG_SMP
 
 #include <linux/irq.h>
@@ -23,6 +20,7 @@
 #include <linux/spinlock.h>
 #include <linux/mm.h>
 #include <linux/smp.h>
+#include <linux/profile.h>
 
 #include <asm/cacheflush.h>
 #include <asm/pgalloc.h>
@@ -109,7 +107,7 @@ static void send_IPI_mask(cpumask_t, int
 unsigned long send_IPI_mask_phys(cpumask_t, int, int);
 
 /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
-/* Rescheduling request Routins                                              */
+/* Rescheduling request Routines                                             */
 /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
 
 /*==========================================================================*
@@ -762,7 +760,7 @@ void smp_local_timer_interrupt(struct pt
 	 * useful with a profiling multiplier != 1
 	 */
 
-	m32r_do_profile(regs);
+	profile_tick(CPU_PROFILING, regs);
 
 	if (--per_cpu(prof_counter, cpu_id) <= 0) {
 		/*
arch/m32r/kernel/time.c +2 -3
diff -ruNp linux-2.6.9-rc1-mm4.orig/arch/m32r/kernel/time.c linux-2.6.9-rc1-mm4/arch/m32r/kernel/time.c
@@ -15,8 +15,6 @@
  *    Copyright (C) 2000  Philipp Rumpf <[email protected]>
  */
 
-/* $Id$ */
-
 #undef  DEBUG_TIMER
 
 #include <linux/config.h>
@@ -29,6 +27,7 @@
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/interrupt.h>
+#include <linux/profile.h>
 
 #include <asm/io.h>
 #include <asm/m32r.h>
@@ -243,7 +242,7 @@ irqreturn_t timer_interrupt(int irq, voi
 	write_sequnlock(&xtime_lock);
 
 #ifndef CONFIG_SMP
-	m32r_do_profile(regs);
+	profile_tick(CPU_PROFILING, regs);
 #endif
 
 	return IRQ_HANDLED;
include/asm-m32r/hw_irq.h +1 -32
diff -ruNp linux-2.6.9-rc1-mm4.orig/include/asm-m32r/hw_irq.h linux-2.6.9-rc1-mm4/include/asm-m32r/hw_irq.h
@@ -1,40 +1,9 @@
 #ifndef _ASM_M32R_HW_IRQ_H
 #define _ASM_M32R_HW_IRQ_H
 
-/* $Id$ */
-
-#include <linux/profile.h>
-#include <linux/sched.h>
-#include <asm/sections.h>
-
-static __inline__ void hw_resend_irq(struct hw_interrupt_type *h,
-				     unsigned int i)
+static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i)
 {
 	/* Nothing to do */
 }
 
-static __inline__ void m32r_do_profile (struct pt_regs *regs)
-{
-        unsigned long pc = regs->bpc;
-
-        profile_hook(regs);
-
-        if (user_mode(regs))
-                return;
-
-        if (!prof_buffer)
-                return;
-
-        pc -= (unsigned long) &_stext;
-        pc >>= prof_shift;
-        /*
-         * Don't ignore out-of-bounds PC values silently,
-         * put them into the last histogram slot, so if
-         * present, they will show up as a sharp peak.
-         */
-        if (pc > prof_len - 1)
-                pc = prof_len - 1;
-        atomic_inc((atomic_t *)&prof_buffer[pc]);
-}
-
 #endif /* _ASM_M32R_HW_IRQ_H */
include/asm-m32r/ptrace.h +8 -6
diff -ruNp linux-2.6.9-rc1-mm4.orig/include/asm-m32r/ptrace.h linux-2.6.9-rc1-mm4/include/asm-m32r/ptrace.h
@@ -1,14 +1,15 @@
-#ifndef _M32R_PTRACE_H
-#define _M32R_PTRACE_H
-
-/* $Id$ */
+#ifndef _ASM_M32R_PTRACE_H
+#define _ASM_M32R_PTRACE_H
 
 /*
+ * linux/include/asm-m32r/ptrace.h
+ *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 2001, 2002, 2004  Hirokazu Takata
+ * M32R version:
+ *   Copyright (C) 2001-2002, 2004  Hirokazu Takata <takata at linux-m32r.org>
  */
 
 #include <linux/config.h>
@@ -153,6 +154,7 @@ struct pt_regs {
 #endif
 
 #define instruction_pointer(regs) ((regs)->bpc)
+#define profile_pc(regs) instruction_pointer(regs)
 
 extern void show_regs(struct pt_regs *);
 
@@ -160,4 +162,4 @@ extern void withdraw_debug_trap(struct p
 
 #endif /* __KERNEL */
 
-#endif /* _M32R_PTRACE_H */
+#endif /* _ASM_M32R_PTRACE_H */

--
Hirokazu Takata <[email protected]>
Linux/M32R Project: http://www.linux-m32r.org/

#2 lore raw

PATCH 2/6 Update zone_sizes_init()

In reply to Hirokazu Takata

[PATCH 2.6.9-rc1-mm4 2/6] [m32r] Update zone_sizes_init()
This patch upgrades zone_sizes_init() function.
This patch is required because free_area_init_node()'s interface has been changed.

* arch/m32r/mm/discontig.c (zone_sizes_init):
Change free_area_init_node() interface.

* arch/m32r/mm/init.c: ditto.

---

 arch/m32r/mm/discontig.c |    2 +-
 arch/m32r/mm/init.c      |    3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)
arch/m32r/mm/discontig.c +1 -1
diff -ruNp linux-2.6.9-rc1-mm4.orig/arch/m32r/mm/discontig.c linux-2.6.9-rc1-mm4/arch/m32r/mm/discontig.c
@@ -152,7 +152,7 @@ unsigned long __init zone_sizes_init(voi
 		zholes_size[ZONE_DMA] = mp->holes;
 		holes += zholes_size[ZONE_DMA];
 
-		free_area_init_node(nid, NODE_DATA(nid), NULL, zones_size,
+		free_area_init_node(nid, NODE_DATA(nid), zones_size,
 			start_pfn, zholes_size);
 	}
 
arch/m32r/mm/init.c +1 -2
diff -ruNp linux-2.6.9-rc1-mm4.orig/arch/m32r/mm/init.c linux-2.6.9-rc1-mm4/arch/m32r/mm/init.c
@@ -120,8 +120,7 @@ unsigned long __init zone_sizes_init(voi
 	start_pfn = __MEMORY_START >> PAGE_SHIFT;
 #endif /* CONFIG_MMU */
 
-	free_area_init_node(0, NODE_DATA(0), 0, zones_size,
-		start_pfn, 0);
+	free_area_init_node(0, NODE_DATA(0), zones_size, start_pfn, 0);
 
 	mem_map = contig_page_data.node_mem_map;
 

--
Hirokazu Takata <[email protected]>
Linux/M32R Project: http://www.linux-m32r.org/

#3 lore raw

PATCH 3/6 Update to fix compile errors

In reply to Hirokazu Takata

[PATCH 2.6.9-rc1-mm4 3/6] [m32r] Update to fix compile errors
This patch updates code to fix compile errors, and so on.

* arch/m32r/kernel/Makefile:
Change linker script's name from vmlinux.lds.s to vmlinux.lds.

* arch/m32r/kernel/process.c (sys_clone):
Fix the first parameter of do_fork() call.

* arch/m32r/kernel/signal.c:
(handle_signal): Add a new second argument, struct k_sigaction *ka. (do_signal): Change get_signal_to_deliver() interface.

* include/asm-m32r/hardirq.h:
Some declarations are moved to linux/hardirq.h.

* include/asm-m32r/page.h:
Add devmem_is_allowed() macro.

---

 arch/m32r/kernel/Makefile  |    2 -
 arch/m32r/kernel/process.c |    5 +--
 arch/m32r/kernel/signal.c  |   68 +++++++++++++++++++++++++--------------------
 include/asm-m32r/hardirq.h |   18 -----------
 include/asm-m32r/page.h    |    4 +-
 5 files changed, 43 insertions(+), 54 deletions(-)
arch/m32r/kernel/Makefile +1 -1
diff -ruNp linux-2.6.9-rc1-mm4.orig/arch/m32r/kernel/Makefile linux-2.6.9-rc1-mm4/arch/m32r/kernel/Makefile
@@ -2,7 +2,7 @@
 # Makefile for the Linux/M32R kernel.
 #
 
-extra-y	:= head.o init_task.o vmlinux.lds.s
+extra-y	:= head.o init_task.o vmlinux.lds
 
 obj-y	:= process.o entry.o traps.o align.o irq.o setup.o time.o \
 	m32r_ksyms.o sys_m32r.o semaphore.o signal.o ptrace.o
arch/m32r/kernel/process.c +2 -3
diff -ruNp linux-2.6.9-rc1-mm4.orig/arch/m32r/kernel/process.c linux-2.6.9-rc1-mm4/arch/m32r/kernel/process.c
@@ -27,8 +27,8 @@
 #include <linux/ptrace.h>
 #include <linux/unistd.h>
 #include <linux/slab.h>
+#include <linux/hardirq.h>
 
-#include <asm/hardirq.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/mmu_context.h>
@@ -298,8 +298,7 @@ asmlinkage int sys_clone(unsigned long c
 	if (!newsp)
 		newsp = regs.spu;
 
-	return do_fork(clone_flags & ~CLONE_IDLETASK, newsp, &regs, 0, NULL,
-			NULL);
+	return do_fork(clone_flags, newsp, &regs, 0, NULL, NULL);
 }
 
 /*
arch/m32r/kernel/signal.c +38 -30

164 lines not on this page · raw message

include/asm-m32r/hardirq.h +0 -18
diff -ruNp linux-2.6.9-rc1-mm4.orig/include/asm-m32r/hardirq.h linux-2.6.9-rc1-mm4/include/asm-m32r/hardirq.h
@@ -1,10 +1,6 @@
 #ifndef __ASM_HARDIRQ_H
 #define __ASM_HARDIRQ_H
 
-/* $Id$ */
-
-/* orig : i386 2.5.67 */
-
 #include <linux/config.h>
 #include <linux/threads.h>
 #include <linux/irq.h>
@@ -40,20 +36,6 @@ typedef struct {
 #define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
 #define HARDIRQ_SHIFT	(SOFTIRQ_SHIFT + SOFTIRQ_BITS)
 
-#define __MASK(x)	((1UL << (x))-1)
-
-#define PREEMPT_MASK	(__MASK(PREEMPT_BITS) << PREEMPT_SHIFT)
-#define HARDIRQ_MASK	(__MASK(HARDIRQ_BITS) << HARDIRQ_SHIFT)
-#define SOFTIRQ_MASK	(__MASK(SOFTIRQ_BITS) << SOFTIRQ_SHIFT)
-
-#define hardirq_count()	(preempt_count() & HARDIRQ_MASK)
-#define softirq_count()	(preempt_count() & SOFTIRQ_MASK)
-#define irq_count()	(preempt_count() & (HARDIRQ_MASK | SOFTIRQ_MASK))
-
-#define PREEMPT_OFFSET	(1UL << PREEMPT_SHIFT)
-#define SOFTIRQ_OFFSET	(1UL << SOFTIRQ_SHIFT)
-#define HARDIRQ_OFFSET	(1UL << HARDIRQ_SHIFT)
-
 /*
  * The hardirq mask has to be large enough to have
  * space for potentially all IRQ sources in the system
include/asm-m32r/page.h +2 -2
diff -ruNp linux-2.6.9-rc1-mm4.orig/include/asm-m32r/page.h linux-2.6.9-rc1-mm4/include/asm-m32r/page.h
@@ -1,8 +1,6 @@
 #ifndef _ASM_M32R_PAGE_H
 #define _ASM_M32R_PAGE_H
 
-/* $Id$ */
-
 #include <linux/config.h>
 
 /* PAGE_SHIFT determines the page size */
@@ -106,6 +104,8 @@ static __inline__ int get_order(unsigned
 #define VM_DATA_DEFAULT_FLAGS	(VM_READ | VM_WRITE | VM_EXEC | \
 				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC )
 
+#define devmem_is_allowed(x) 1
+
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_M32R_PAGE_H */

--
Hirokazu Takata <[email protected]>
Linux/M32R Project: http://www.linux-m32r.org/

#4 lore raw

PATCH 4/6 Update uaccess.h

In reply to Hirokazu Takata

[PATCH 2.6.9-rc1-mm4 4/6] [m32r] Update uaccess.h
This patch updates asm-m32r/uaccess.h.

	* include/asm-m32r/uaccess.h:
	(__copy_to_user_inatomic): Added.
	(__copy_from_user_inatomic): Added.
	Update comments.

---

 include/asm-m32r/uaccess.h |  349 +++++++++++++++++++++++++++++++++++++--------
 1 files changed, 290 insertions(+), 59 deletions(-)
include/asm-m32r/uaccess.h +290 -59
diff -ruNp linux-2.6.9-rc1-mm4.orig/include/asm-m32r/uaccess.h linux-2.6.9-rc1-mm4/include/asm-m32r/uaccess.h
@@ -1,7 +1,12 @@
 #ifndef _ASM_M32R_UACCESS_H
 #define _ASM_M32R_UACCESS_H
 
-/* $Id$ */
+/*
+ *  linux/include/asm-m32r/uaccess.h
+ *
+ *  M32R version.
+ *    Copyright (C) 2004  Hirokazu Takata <takata at linux-m32r.org>
+ */
 
 #undef UACCESS_DEBUG
 
@@ -61,7 +66,13 @@ static inline void set_fs(mm_segment_t s
 	((unsigned long)(addr) < (current_thread_info()->addr_limit.seg))
 
 /*
- * Uhhuh, this needs 33-bit arithmetic. We have a carry..
+ * Test whether a block of memory is a valid user space address.
+ * Returns 0 if the range is valid, nonzero otherwise.
+ *
+ * This is equivalent to the following test:
+ * (u33)addr + (u33)size >= (u33)current->addr_limit.seg
+ *
+ * This needs 33-bit arithmetic. We have a carry...
  */
 #define __range_ok(addr,size) ({					\
 	unsigned long flag, sum; 					\
@@ -78,8 +89,27 @@ static inline void set_fs(mm_segment_t s
 		: "cbit" );						\
 	flag; })
 
+/**
+ * access_ok: - Checks if a user space pointer is valid
+ * @type: Type of access: %VERIFY_READ or %VERIFY_WRITE.  Note that
+ *        %VERIFY_WRITE is a superset of %VERIFY_READ - if it is safe
+ *        to write to a block, it is always safe to read from it.
+ * @addr: User space pointer to start of block to check
+ * @size: Size of block to check
+ *
+ * Context: User context only.  This function may sleep.
+ *
+ * Checks if a pointer to a block of memory in user space is valid.
+ *
+ * Returns true (nonzero) if the memory block may be valid, false (zero)
+ * if it is definitely invalid.
+ *
+ * Note that, depending on architecture, this function probably just
+ * checks that the pointer is in the user space range - after calling
+ * this function, memory access functions may still return -EFAULT.
+ */
 #ifdef CONFIG_MMU
-#define access_ok(type,addr,size) (__range_ok(addr,size) == 0)
+#define access_ok(type,addr,size) (likely(__range_ok(addr,size) == 0))
 #else
 static inline int access_ok(int type, const void *addr, unsigned long size)
 {
@@ -90,8 +120,25 @@ static inline int access_ok(int type, co
 }
 #endif /* CONFIG_MMU */
 
-static __inline__ int verify_area(int type, const void __user *addr,
-	unsigned long size)
+/**
+ * verify_area: - Obsolete, use access_ok()
+ * @type: Type of access: %VERIFY_READ or %VERIFY_WRITE
+ * @addr: User space pointer to start of block to check
+ * @size: Size of block to check
+ *
+ * Context: User context only.  This function may sleep.
+ *
+ * This function has been replaced by access_ok().
+ *
+ * Checks if a pointer to a block of memory in user space is valid.
+ *
+ * Returns zero if the memory block may be valid, -EFAULT
+ * if it is definitely invalid.
+ *
+ * See access_ok() for more details.
+ */
+static inline int verify_area(int type, const void __user *addr,
+			      unsigned long size)
 {
 	return access_ok(type, addr, size) ? 0 : -EFAULT;
 }
@@ -167,6 +214,23 @@ extern void __get_user_4(void);
 
 /* Careful: we have to cast the result to the type of the pointer for sign
    reasons */
+/**
+ * get_user: - Get a simple variable from user space.
+ * @x:   Variable to store result.
+ * @ptr: Source address, in user space.
+ *
+ * Context: User context only.  This function may sleep.
+ *
+ * This macro copies a single simple variable from user space to kernel
+ * space.  It supports simple types like char and int, but not larger
+ * data types like structures or arrays.
+ *
+ * @ptr must have pointer-to-simple-variable type, and the result of
+ * dereferencing @ptr must be assignable to @x without a cast.
+ *
+ * Returns zero on success, or -EFAULT on error.
+ * On error, the variable @x is set to zero.
+ */
 #define get_user(x,ptr)							\
 ({	int __ret_gu,__val_gu;						\
 	__chk_user_ptr(ptr);						\
@@ -182,11 +246,69 @@ extern void __get_user_4(void);
 
 extern void __put_user_bad(void);
 
+/**
+ * put_user: - Write a simple value into user space.
+ * @x:   Value to copy to user space.
+ * @ptr: Destination address, in user space.
+ *
+ * Context: User context only.  This function may sleep.
+ *
+ * This macro copies a single simple value from kernel space to user
+ * space.  It supports simple types like char and int, but not larger
+ * data types like structures or arrays.
+ *
+ * @ptr must have pointer-to-simple-variable type, and @x must be assignable
+ * to the result of dereferencing @ptr.
+ *
+ * Returns zero on success, or -EFAULT on error.
+ */
 #define put_user(x,ptr)							\
   __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
 
+
+/**
+ * __get_user: - Get a simple variable from user space, with less checking.
+ * @x:   Variable to store result.
+ * @ptr: Source address, in user space.
+ *
+ * Context: User context only.  This function may sleep.
+ *
+ * This macro copies a single simple variable from user space to kernel
+ * space.  It supports simple types like char and int, but not larger
+ * data types like structures or arrays.
+ *
+ * @ptr must have pointer-to-simple-variable type, and the result of
+ * dereferencing @ptr must be assignable to @x without a cast.
+ *
+ * Caller must check the pointer with access_ok() before calling this
+ * function.
+ *
+ * Returns zero on success, or -EFAULT on error.
+ * On error, the variable @x is set to zero.
+ */
 #define __get_user(x,ptr) \
   __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
+
+
+/**
+ * __put_user: - Write a simple value into user space, with less checking.
+ * @x:   Value to copy to user space.
+ * @ptr: Destination address, in user space.
+ *
+ * Context: User context only.  This function may sleep.
+ *
+ * This macro copies a single simple value from kernel space to user
+ * space.  It supports simple types like char and int, but not larger
+ * data types like structures or arrays.
+ *
+ * @ptr must have pointer-to-simple-variable type, and @x must be assignable
+ * to the result of dereferencing @ptr.
+ *
+ * Caller must check the pointer with access_ok() before calling this
+ * function.
+ *
+ * Returns zero on success, or -EFAULT on error.
+ */
 #define __put_user(x,ptr) \
   __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
 
@@ -208,48 +330,6 @@ extern void __put_user_bad(void);
 	__pu_err;							\
 })
 
-#define __put_user_size(x,ptr,size,retval)				\
-do {									\
-	retval = 0;							\
-	__chk_user_ptr(ptr);						\
-	switch (size) {							\
-	  case 1: __put_user_asm(x,ptr,retval,"b"); break;		\
-	  case 2: __put_user_asm(x,ptr,retval,"h"); break;		\
-	  case 4: __put_user_asm(x,ptr,retval,""); break;		\
-	  case 8: __put_user_u64((__typeof__(*ptr))(x),ptr,retval); break;\
-	  default: __put_user_bad();					\
-	}								\
-} while (0)
-
-struct __large_struct { unsigned long buf[100]; };
-#define __m(x) (*(struct __large_struct *)(x))
-
-/*
- * Tell gcc we read from memory instead of writing: this is because
- * we do not write to any memory gcc knows about, so there are no
- * aliasing issues.
- */
-#define __put_user_asm(x, addr, err, itype)				\
-	__asm__ __volatile__(						\
-		"	.fillinsn\n"					\
-		"1:	st"itype" %1,@%2\n"				\
-		"	.fillinsn\n"					\
-		"2:\n"							\
-		".section .fixup,\"ax\"\n"				\
-		"	.balign 4\n"					\
-		"3:	ldi %0,%3\n"					\
-		"	seth r14,#high(2b)\n"				\
-		"	or3 r14,r14,#low(2b)\n"				\
-		"	jmp r14\n"					\
-		".previous\n"						\
-		".section __ex_table,\"a\"\n"				\
-		"	.balign 4\n"					\
-		"	.long 1b,3b\n"					\
-		".previous"						\
-		: "=r"(err)						\
-		: "r"(x), "r"(addr), "i"(-EFAULT), "0"(err)		\
-		: "r14", "memory")
-
 #if defined(__LITTLE_ENDIAN__)
 #define __put_user_u64(x, addr, err)                                    \
         __asm__ __volatile__(                                           \
@@ -303,6 +383,48 @@ struct __large_struct { unsigned long bu
 #error no endian defined
 #endif
 
+#define __put_user_size(x,ptr,size,retval)				\
+do {									\
+	retval = 0;							\
+	__chk_user_ptr(ptr);						\
+	switch (size) {							\
+	  case 1: __put_user_asm(x,ptr,retval,"b"); break;		\
+	  case 2: __put_user_asm(x,ptr,retval,"h"); break;		\
+	  case 4: __put_user_asm(x,ptr,retval,""); break;		\
+	  case 8: __put_user_u64((__typeof__(*ptr))(x),ptr,retval); break;\
+	  default: __put_user_bad();					\
+	}								\
+} while (0)
+
+struct __large_struct { unsigned long buf[100]; };
+#define __m(x) (*(struct __large_struct *)(x))
+
+/*
+ * Tell gcc we read from memory instead of writing: this is because
+ * we do not write to any memory gcc knows about, so there are no
+ * aliasing issues.
+ */
+#define __put_user_asm(x, addr, err, itype)				\
+	__asm__ __volatile__(						\
+		"	.fillinsn\n"					\
+		"1:	st"itype" %1,@%2\n"				\
+		"	.fillinsn\n"					\
+		"2:\n"							\
+		".section .fixup,\"ax\"\n"				\
+		"	.balign 4\n"					\
+		"3:	ldi %0,%3\n"					\
+		"	seth r14,#high(2b)\n"				\
+		"	or3 r14,r14,#low(2b)\n"				\
+		"	jmp r14\n"					\
+		".previous\n"						\
+		".section __ex_table,\"a\"\n"				\
+		"	.balign 4\n"					\
+		"	.long 1b,3b\n"					\
+		".previous"						\
+		: "=r"(err)						\
+		: "r"(x), "r"(addr), "i"(-EFAULT), "0"(err)		\
+		: "r14", "memory")
+
 #define __get_user_nocheck(x,ptr,size)					\
 ({									\
 	long __gu_err, __gu_val;					\
@@ -346,6 +468,13 @@ do {									\
 		: "r"(addr), "i"(-EFAULT), "0"(err)			\
 		: "r14", "memory")
 
+/*
+ * Here we special-case 1, 2 and 4-byte copy_*_user invocations.  On a fault
+ * we return the initial request size (1, 2 or 4), as copy_*_user should do.
+ * If a store crosses a page boundary and gets a fault, the m32r will not write
+ * anything, so this is accurate.
+ */
+
 
 /*
  * Copy To/From Userspace
@@ -475,14 +604,14 @@ do {									\
 /* We let the __ versions of copy_from/to_user inline, because they're often
  * used in fast paths and have only a small space overhead.
  */
-static __inline__ unsigned long __generic_copy_from_user_nocheck(void *to,
+static inline unsigned long __generic_copy_from_user_nocheck(void *to,
 	const void __user *from, unsigned long n)
 {
 	__copy_user_zeroing(to,from,n);
 	return n;
 }
 
-static __inline__ unsigned long __generic_copy_to_user_nocheck(void __user *to,
+static inline unsigned long __generic_copy_to_user_nocheck(void __user *to,
 	const void *from, unsigned long n)
 {
 	__copy_user(to,from,n);
@@ -492,30 +621,132 @@ static __inline__ unsigned long __generi
 unsigned long __generic_copy_to_user(void *, const void *, unsigned long);
 unsigned long __generic_copy_from_user(void *, const void *, unsigned long);
 
+/**
+ * __copy_to_user: - Copy a block of data into user space, with less checking.
+ * @to:   Destination address, in user space.
+ * @from: Source address, in kernel space.
+ * @n:    Number of bytes to copy.
+ *
+ * Context: User context only.  This function may sleep.
+ *
+ * Copy data from kernel space to user space.  Caller must check
+ * the specified block with access_ok() before calling this function.
+ *
+ * Returns number of bytes that could not be copied.
+ * On success, this will be zero.
+ */
+#define __copy_to_user(to,from,n)			\
+	__generic_copy_to_user_nocheck((to),(from),(n))
+
+#define __copy_to_user_inatomic __copy_to_user
+#define __copy_from_user_inatomic __copy_from_user
+
+/**
+ * copy_to_user: - Copy a block of data into user space.
+ * @to:   Destination address, in user space.
+ * @from: Source address, in kernel space.
+ * @n:    Number of bytes to copy.
+ *
+ * Context: User context only.  This function may sleep.
+ *
+ * Copy data from kernel space to user space.
+ *
+ * Returns number of bytes that could not be copied.
+ * On success, this will be zero.
+ */
 #define copy_to_user(to,from,n)				\
 ({							\
 	might_sleep();					\
 	__generic_copy_to_user((to),(from),(n));	\
 })
 
+/**
+ * __copy_from_user: - Copy a block of data from user space, with less checking. * @to:   Destination address, in kernel space.
+ * @from: Source address, in user space.
+ * @n:    Number of bytes to copy.
+ *
+ * Context: User context only.  This function may sleep.
+ *
+ * Copy data from user space to kernel space.  Caller must check
+ * the specified block with access_ok() before calling this function.
+ *
+ * Returns number of bytes that could not be copied.
+ * On success, this will be zero.
+ *
+ * If some data could not be copied, this function will pad the copied
+ * data to the requested size using zero bytes.
+ */
+#define __copy_from_user(to,from,n)			\
+	__generic_copy_from_user_nocheck((to),(from),(n))
+
+/**
+ * copy_from_user: - Copy a block of data from user space.
+ * @to:   Destination address, in kernel space.
+ * @from: Source address, in user space.
+ * @n:    Number of bytes to copy.
+ *
+ * Context: User context only.  This function may sleep.
+ *
+ * Copy data from user space to kernel space.
+ *
+ * Returns number of bytes that could not be copied.
+ * On success, this will be zero.
+ *
+ * If some data could not be copied, this function will pad the copied
+ * data to the requested size using zero bytes.
+ */
 #define copy_from_user(to,from,n)			\
 ({							\
 	might_sleep();					\
-	__generic_copy_from_user((to),(from),(n));	\
+__generic_copy_from_user((to),(from),(n));	\
 })
 
-#define __copy_to_user(to,from,n)			\
-	__generic_copy_to_user_nocheck((to),(from),(n))
+long __must_check strncpy_from_user(char *dst, const char __user *src, 
+				long count);
+long __must_check __strncpy_from_user(char *dst, 
+				const char __user *src, long count);
+
+/**
+ * __clear_user: - Zero a block of memory in user space, with less checking.
+ * @to:   Destination address, in user space.
+ * @n:    Number of bytes to zero.
+ *
+ * Zero a block of memory in user space.  Caller must check
+ * the specified block with access_ok() before calling this function.
+ *
+ * Returns number of bytes that could not be cleared.
+ * On success, this will be zero.
+ */
+unsigned long __clear_user(void __user *mem, unsigned long len);
 
-#define __copy_from_user(to,from,n)			\
-	__generic_copy_from_user_nocheck((to),(from),(n))
+/**
+ * clear_user: - Zero a block of memory in user space.
+ * @to:   Destination address, in user space.
+ * @n:    Number of bytes to zero.
+ *
+ * Zero a block of memory in user space.  Caller must check
+ * the specified block with access_ok() before calling this function.
+ *
+ * Returns number of bytes that could not be cleared.
+ * On success, this will be zero.
+ */
+unsigned long clear_user(void __user *mem, unsigned long len);
 
-long strncpy_from_user(char *dst, const char __user *src, long count);
-long __strncpy_from_user(char *dst, const char __user *src, long count);
+/**
+ * strlen_user: - Get the size of a string in user space.
+ * @str: The string to measure.
+ *
+ * Context: User context only.  This function may sleep.
+ *
+ * Get the size of a NUL-terminated string in user space.
+ *
+ * Returns the size of the string INCLUDING the terminating NUL.
+ * On exception, returns 0.
+ *
+ * If there is a limit on the length of a valid string, you may wish to
+ * consider using strnlen_user() instead.
+ */
 #define strlen_user(str) strnlen_user(str, ~0UL >> 1)
 long strnlen_user(const char __user *str, long n);
-unsigned long clear_user(void __user *mem, unsigned long len);
-unsigned long __clear_user(void __user *mem, unsigned long len);
 
 #endif /* _ASM_M32R_UACCESS_H */
-

--
Hirokazu Takata <[email protected]>
Linux/M32R Project: http://www.linux-m32r.org/

#5 lore raw

PATCH 5/6 Update checksum functions

In reply to Hirokazu Takata

[PATCH 2.6.9-rc1-mm4 5/6] [m32r] Update checksum functions
This patch update checksum routines.
And EXPORT_SYMBOL() is moved from m32r_ksyms.c to csum_partial_copy.c.

---

 arch/m32r/kernel/m32r_ksyms.c     |    2 
 arch/m32r/lib/csum_partial_copy.c |   39 ++--------
 include/asm-m32r/checksum.h       |  136 +++++++++++---------------------------
 3 files changed, 52 insertions(+), 125 deletions(-)
arch/m32r/kernel/m32r_ksyms.c +0 -2
diff -ruNp linux-2.6.9-rc1-mm4.orig/arch/m32r/kernel/m32r_ksyms.c linux-2.6.9-rc1-mm4/arch/m32r/kernel/m32r_ksyms.c
@@ -14,7 +14,6 @@
 #include <asm/uaccess.h>
 #include <asm/checksum.h>
 #include <asm/io.h>
-#include <asm/hardirq.h>
 #include <asm/delay.h>
 #include <asm/irq.h>
 #include <asm/tlbflush.h>
@@ -42,7 +41,6 @@ EXPORT_SYMBOL(__up);
 EXPORT_SYMBOL(__down_trylock);
 
 /* Networking helper routines. */
-EXPORT_SYMBOL(csum_partial_copy);
 /* Delay loops */
 EXPORT_SYMBOL(__udelay);
 EXPORT_SYMBOL(__delay);
arch/m32r/lib/csum_partial_copy.c +10 -29
diff -ruNp linux-2.6.9-rc1-mm4.orig/arch/m32r/lib/csum_partial_copy.c linux-2.6.9-rc1-mm4/arch/m32r/lib/csum_partial_copy.c
@@ -14,38 +14,34 @@
  *		as published by the Free Software Foundation; either version
  *		2 of the License, or (at your option) any later version.
  *
- * $Id$
  */
-#include <net/checksum.h>
+
+#include <linux/module.h>
 #include <linux/types.h>
+
+#include <net/checksum.h>
 #include <asm/byteorder.h>
 #include <asm/string.h>
 #include <asm/uaccess.h>
 
 /*
- * copy while checksumming, otherwise like csum_partial
+ * Copy while checksumming, otherwise like csum_partial
  */
-unsigned int csum_partial_copy(const char *src, char *dst,
-                               int len, int sum)
+unsigned int csum_partial_copy_nocheck (const char *src, char *dst,
+                                        int len, unsigned int sum)
 {
-	/*
-	 * It's 2:30 am and I don't feel like doing it real ...
-	 * This is lots slower than the real thing (tm)
-	 */
 	sum = csum_partial(src, len, sum);
 	memcpy(dst, src, len);
 
 	return sum;
 }
+EXPORT_SYMBOL(csum_partial_copy_nocheck);
 
 /*
  * Copy from userspace and compute checksum.  If we catch an exception
  * then zero the rest of the buffer.
-unsigned int csum_partial_copy_from_user (const char *src, char *dst,
-                                          int len, unsigned int sum,
-                                          int *err_ptr)
  */
-unsigned int csum_partial_copy_generic_from (const char *src, char *dst,
+unsigned int csum_partial_copy_from_user (const char __user *src, char *dst,
                                           int len, unsigned int sum,
                                           int *err_ptr)
 {
@@ -59,19 +55,4 @@ unsigned int csum_partial_copy_generic_f
 
 	return csum_partial(dst, len-missing, sum);
 }
-unsigned int csum_partial_copy_generic_to (const char *src, char *dst,
-                                          int len, unsigned int sum,
-                                          int *err_ptr)
-{
-	int missing;
-
-	missing = copy_to_user(dst, src, len);
-	if (missing) {
-/*
-		memset(dst + len - missing, 0, missing);
-*/
-		*err_ptr = -EFAULT;
-	}
-
-	return csum_partial(src, len-missing, sum);
-}
+EXPORT_SYMBOL(csum_partial_copy_from_user);
include/asm-m32r/checksum.h +42 -94

207 lines not on this page · raw message

--
Hirokazu Takata <[email protected]>
Linux/M32R Project: http://www.linux-m32r.org/

#6 lore raw

PATCH 6/6 Update CF/PCMCIA drivers

In reply to Hirokazu Takata

[PATCH 2.6.9-rc1-mm4 6/6] [m32r] Update CF/PCMCIA drivers
This patch updates m32r-specific CF/PCMCIA drivers and fixes compile errors.

---

 arch/m32r/drivers/m32r_cfc.c |   14 +++++++-------
 arch/m32r/drivers/m32r_pcc.c |   25 ++++++++++++++-----------
 2 files changed, 21 insertions(+), 18 deletions(-)
arch/m32r/drivers/m32r_cfc.c +7 -7
diff -ruNp linux-2.6.9-rc1-mm4.orig/arch/m32r/drivers/m32r_cfc.c linux-2.6.9-rc1-mm4/arch/m32r/drivers/m32r_cfc.c
@@ -4,7 +4,7 @@
  *  Device driver for the CFC functionality of M32R.
  *
  *  Copyright (c) 2001, 2002, 2003, 2004
- *   Hiroyuki Kondo, Sugai Naotom, Hayato Fujiwara
+ *    Hiroyuki Kondo, Naoto Sugai, Hayato Fujiwara
  */
 
 #include <linux/module.h>
@@ -592,15 +592,15 @@ static int _pcc_set_mem_map(u_short sock
 	u_long addr;
 	pcc_socket_t *t = &socket[sock];
 
-	DEBUG(3, "m32r_cfc: SetMemMap(%d, %d, %#2.2x, %d ns, %#5.5lx-%#5.5"
-		  "lx, %#5.5x)\n", sock, map, mem->flags, mem->speed,
-		  mem->sys_start, mem->sys_stop, mem->card_start);
+	DEBUG(3, "m32r_cfc: SetMemMap(%d, %d, %#2.2x, %d ns, "
+		 "%#5.5lx-%#5.5lx, %#5.5x)\n", sock, map, mem->flags,
+		 mem->speed, mem->res->start, mem->res->end, mem->card_start);
 
 	/*
 	 * sanity check
 	 */
 	if ((map > MAX_WIN) || (mem->card_start > 0x3ffffff) ||
-		(mem->sys_start > mem->sys_stop)) {
+		(mem->res->start > mem->res->end)) {
 		return -EINVAL;
 	}
 
@@ -635,8 +635,8 @@ static int _pcc_set_mem_map(u_short sock
 	addr = t->mapaddr + (mem->card_start & M32R_PCC_MAPMASK);
 //	pcc_set(sock, PCADR, addr);
 
-	mem->sys_start = addr + mem->card_start;
-	mem->sys_stop = mem->sys_start + (M32R_PCC_MAPSIZE - 1);
+	mem->res->start = addr + mem->card_start;
+	mem->res->end = mem->res->start + (M32R_PCC_MAPSIZE - 1);
 
 	/*
 	 * Set timing
arch/m32r/drivers/m32r_pcc.c +14 -11
diff -ruNp linux-2.6.9-rc1-mm4.orig/arch/m32r/drivers/m32r_pcc.c linux-2.6.9-rc1-mm4/arch/m32r/drivers/m32r_pcc.c
@@ -1,8 +1,11 @@
-/*======================================================================
-
-	Device driver for the PCMCIA functionality of M32R.
-
-======================================================================*/
+/*
+ *  linux/arch/m32r/drivers/m32r_pcc.c
+ *
+ *  Device driver for the PCMCIA functionality of M32R.
+ *
+ *  Copyright (c) 2001, 2002, 2003, 2004
+ *    Hiroyuki Kondo, Naoto Sugai, Hayato Fujiwara
+ */
 
 #include <linux/module.h>
 #include <linux/moduleparam.h>
@@ -524,15 +527,15 @@ static int _pcc_set_mem_map(u_short sock
 #endif
 #endif
 
-	DEBUG(3, "m32r-pcc: SetMemMap(%d, %d, %#2.2x, %d ns, %#5.5lx-%#5.5"
-		  "lx, %#5.5x)\n", sock, map, mem->flags, mem->speed,
-		  mem->sys_start, mem->sys_stop, mem->card_start);
+	DEBUG(3, "m32r-pcc: SetMemMap(%d, %d, %#2.2x, %d ns, "
+		 "%#5.5lx-%#5.5lx, %#5.5x)\n", sock, map, mem->flags,
+		 mem->speed, mem->res->start,  mem->res->end, mem->card_start);
 
 	/*
 	 * sanity check
 	 */
 	if ((map > MAX_WIN) || (mem->card_start > 0x3ffffff) ||
-		(mem->sys_start > mem->sys_stop)) {
+		(mem->res->start > mem->res->end)) {
 		return -EINVAL;
 	}
 
@@ -567,8 +570,8 @@ static int _pcc_set_mem_map(u_short sock
 	addr = t->mapaddr + (mem->card_start & M32R_PCC_MAPMASK);
 	pcc_set(sock, PCADR, addr);
 
-	mem->sys_start = addr + mem->card_start;
-	mem->sys_stop = mem->sys_start + (M32R_PCC_MAPSIZE - 1);
+	mem->res->start = addr + mem->card_start;
+	mem->res->end = mem->res->start + (M32R_PCC_MAPSIZE - 1);
 
 	/*
 	 * Enable again

--
Hirokazu Takata <[email protected]>
Linux/M32R Project: http://www.linux-m32r.org/

#7 lore raw

Re: [PATCH 2.6.9-rc1-mm4 6/6] [m32r] Update CF/PCMCIA drivers

Quoted 3 lines · Hirokazu Takata

[PATCH 2.6.9-rc1-mm4 6/6] [m32r] Update CF/PCMCIA drivers
This patch updates m32r-specific CF/PCMCIA drivers and fixes compile errors.

Note that these really should be in drivers/pcmcia/

Please also send them to [email protected] for review.

#8 lore raw

Re: [PATCH 2.6.9-rc1-mm4 6/6] [m32r] Update CF/PCMCIA drivers

In reply to Hirokazu Takata
Quoted 3 lines · Hirokazu Takata

[PATCH 2.6.9-rc1-mm4 6/6] [m32r] Update CF/PCMCIA drivers
This patch updates m32r-specific CF/PCMCIA drivers and fixes compile errors.

why are these still in arch/m32r/drivers ??
please move them to drivers/pcmcia