blob: e5bde9f9291f9a57b7bd6cfce430f7a9c7e37160 [file] [log] [blame]
Peter Oberparleiterf86635f2007-04-27 16:01:26 +02001/*
Peter Oberparleiterf86635f2007-04-27 16:01:26 +02002 * Copyright IBM Corp. 2007
3 * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
4 */
5
Peter Oberparleitere5854a52007-04-27 16:01:31 +02006#ifndef _ASM_S390_CHPID_H
David Howells87d2f5e2011-12-13 09:26:45 +00007#define _ASM_S390_CHPID_H
Peter Oberparleiterf86635f2007-04-27 16:01:26 +02008
9#include <linux/string.h>
Heiko Carstens0680ba02009-01-09 12:14:52 +010010#include <linux/types.h>
Peter Oberparleitere5854a52007-04-27 16:01:31 +020011
12#define __MAX_CHPID 255
Peter Oberparleiterf86635f2007-04-27 16:01:26 +020013
14struct chp_id {
15 u8 reserved1;
16 u8 cssid;
17 u8 reserved2;
18 u8 id;
19} __attribute__((packed));
20
Adrian Bunk626f3112008-07-17 17:16:42 +020021#ifdef __KERNEL__
22#include <asm/cio.h>
23
Peter Oberparleiterf86635f2007-04-27 16:01:26 +020024static inline void chp_id_init(struct chp_id *chpid)
25{
26 memset(chpid, 0, sizeof(struct chp_id));
27}
28
29static 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
34static 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
44static 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))
Cornelia Huck9d92a7e2008-07-14 09:59:05 +020052#endif /* __KERNEL */
Peter Oberparleiterf86635f2007-04-27 16:01:26 +020053
Peter Oberparleitere5854a52007-04-27 16:01:31 +020054#endif /* _ASM_S390_CHPID_H */