Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750750AbWIVG34 (ORCPT ); Fri, 22 Sep 2006 02:29:56 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750775AbWIVG34 (ORCPT ); Fri, 22 Sep 2006 02:29:56 -0400 Received: from hcc3d73d5a1.bai.ne.jp ([61.115.213.161]:23213 "HELO linux-m32r.org") by vger.kernel.org with SMTP id S1750750AbWIVG34 (ORCPT ); Fri, 22 Sep 2006 02:29:56 -0400 Date: Fri, 22 Sep 2006 15:29:53 +0900 Message-ID: From: Hirokazu Takata To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Matthew Wilcox , takata@linux-m32r.org Subject: [PATCH] m32r: Revise __raw_read_trylock() User-Agent: Wanderlust/2.14.0 (Africa) Emacs/21.4 Mule/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1275 Lines: 43 Hi, Matthew Wilcox pointed out that generic__raw_read_trylock() is unfit for use. Here is a patch to fix __raw_read_trylock() for m32r. It is taken from the i386 implementation. Signed-off-by: Hirokazu Takata Cc: Matthew Wilcox --- include/asm-m32r/spinlock.h | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/include/asm-m32r/spinlock.h b/include/asm-m32r/spinlock.h index f94c1a6..78205f0 100644 --- a/include/asm-m32r/spinlock.h +++ b/include/asm-m32r/spinlock.h @@ -298,7 +298,15 @@ #endif /* CONFIG_CHIP_M32700_TS1 */ ); } -#define __raw_read_trylock(lock) generic__raw_read_trylock(lock) +static inline int __raw_read_trylock(raw_rwlock_t *lock) +{ + atomic_t *count = (atomic_t*)lock; + atomic_dec(count); + if (atomic_read(count) >= 0) + return 1; + atomic_inc(count); + return 0; +} static inline int __raw_write_trylock(raw_rwlock_t *lock) { -- Hirokazu Takata Linux/M32R Project: http://www.linux-m32r.org/ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/