diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2006-06-19 08:41:30 +1000 |
---|---|---|
committer | Nathan Scott <nathans@sgi.com> | 2006-06-19 08:41:30 +1000 |
commit | 0d8fee3270f8a5e4bf95fbed3e81e21b57f8a5a0 (patch) | |
tree | e965874962259a2f16980f19a4e5c03ef635a86f /fs/xfs/linux-2.6 | |
parent | a805bad5daae8d4f92ce46f467484d4867e996d4 (diff) | |
download | linux-0d8fee3270f8a5e4bf95fbed3e81e21b57f8a5a0.tar.bz2 |
[XFS] Kill direct access to ->count in valusema(); all we ever use it for
is check if semaphore is actually locked, which can be trivially done in
portable way. Code gets more reabable, while we are at it...
SGI-PV: 953915
SGI-Modid: xfs-linux-melb:xfs-kern:26274a
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Nathan Scott <nathans@sgi.com>
Diffstat (limited to 'fs/xfs/linux-2.6')
-rw-r--r-- | fs/xfs/linux-2.6/sema.h | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/fs/xfs/linux-2.6/sema.h b/fs/xfs/linux-2.6/sema.h index 194a84490bd1..b25090094cca 100644 --- a/fs/xfs/linux-2.6/sema.h +++ b/fs/xfs/linux-2.6/sema.h @@ -34,20 +34,21 @@ typedef struct semaphore sema_t; #define initnsema(sp, val, name) sema_init(sp, val) #define psema(sp, b) down(sp) #define vsema(sp) up(sp) -#define valusema(sp) (atomic_read(&(sp)->count)) -#define freesema(sema) +#define freesema(sema) do { } while (0) + +static inline int issemalocked(sema_t *sp) +{ + return down_trylock(sp) || (up(sp), 0); +} /* * Map cpsema (try to get the sema) to down_trylock. We need to switch * the return values since cpsema returns 1 (acquired) 0 (failed) and * down_trylock returns the reverse 0 (acquired) 1 (failed). */ - -#define cpsema(sp) (down_trylock(sp) ? 0 : 1) - -/* - * Didn't do cvsema(sp). Not sure how to map this to up/down/... - * It does a vsema if the values is < 0 other wise nothing. - */ +static inline int cpsema(sema_t *sp) +{ + return down_trylock(sp) ? 0 : 1; +} #endif /* __XFS_SUPPORT_SEMA_H__ */ |