Commit | Line | Data |
---|---|---|
f86635fa | 1 | /* |
f86635fa PO |
2 | * Copyright IBM Corp. 2007 |
3 | * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com> | |
4 | */ | |
5 | ||
e5854a58 | 6 | #ifndef _ASM_S390_CHPID_H |
87d2f5e3 | 7 | #define _ASM_S390_CHPID_H |
f86635fa PO |
8 | |
9 | #include <linux/string.h> | |
0680ba01 | 10 | #include <linux/types.h> |
e5854a58 PO |
11 | |
12 | #define __MAX_CHPID 255 | |
f86635fa PO |
13 | |
14 | struct chp_id { | |
15 | u8 reserved1; | |
16 | u8 cssid; | |
17 | u8 reserved2; | |
18 | u8 id; | |
19 | } __attribute__((packed)); | |
20 | ||
626f3117 AB |
21 | #ifdef __KERNEL__ |
22 | #include <asm/cio.h> | |
23 | ||
f86635fa PO |
24 | static inline void chp_id_init(struct chp_id *chpid) |
25 | { | |
26 | memset(chpid, 0, sizeof(struct chp_id)); | |
27 | } | |
28 | ||
29 | static inline int chp_id_is_equal(struct chp_id *a, struct chp_id *b) | |
30 | { | |
31 | return (a->id == b->id) && (a->cssid == b->cssid); | |
32 | } | |
33 | ||
34 | static inline void chp_id_next(struct chp_id *chpid) | |
35 | { | |
36 | if (chpid->id < __MAX_CHPID) | |
37 | chpid->id++; | |
38 | else { | |
39 | chpid->id = 0; | |
40 | chpid->cssid++; | |
41 | } | |
42 | } | |
43 | ||
44 | static inline int chp_id_is_valid(struct chp_id *chpid) | |
45 | { | |
46 | return (chpid->cssid <= __MAX_CSSID); | |
47 | } | |
48 | ||
49 | ||
50 | #define chp_id_for_each(c) \ | |
51 | for (chp_id_init(c); chp_id_is_valid(c); chp_id_next(c)) | |
9d92a7e1 | 52 | #endif /* __KERNEL */ |
f86635fa | 53 | |
e5854a58 | 54 | #endif /* _ASM_S390_CHPID_H */ |