2 * JFFS2 -- Journalling Flash File System, Version 2.
4 * Copyright (C) 2001, 2002 Red Hat, Inc.
6 * Created by David Woodhouse <dwmw2@infradead.org>
8 * For licensing information, see the file 'LICENCE' in this directory.
10 * $Id: pushpull.h,v 1.10 2004/11/16 20:36:11 dwmw2 Exp $
14 #ifndef __PUSHPULL_H__
15 #define __PUSHPULL_H__
17 #include <linux/errno.h>
27 static inline void init_pushpull(struct pushpull
*pp
, char *buf
, unsigned buflen
, unsigned ofs
, unsigned reserve
)
32 pp
->reserve
= reserve
;
35 static inline int pushbit(struct pushpull
*pp
, int bit
, int use_reserved
)
37 if (pp
->ofs
>= pp
->buflen
- (use_reserved
?0:pp
->reserve
)) {
42 pp
->buf
[pp
->ofs
>> 3] |= (1<<(7-(pp
->ofs
&7)));
45 pp
->buf
[pp
->ofs
>> 3] &= ~(1<<(7-(pp
->ofs
&7)));
52 static inline int pushedbits(struct pushpull
*pp
)
57 static inline int pullbit(struct pushpull
*pp
)
61 bit
= (pp
->buf
[pp
->ofs
>> 3] >> (7-(pp
->ofs
& 7))) & 1;
67 static inline int pulledbits(struct pushpull
*pp
)
72 #endif /* __PUSHPULL_H__ */