blob: fc71d8a6709b53f34306fc6a286ad7d69770b372 [file] [log] [blame]
Peter Oberparleiterf86635f2007-04-27 16:01:26 +02001/*
2 * drivers/s390/cio/chpid.h
3 *
4 * Copyright IBM Corp. 2007
5 * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
6 */
7
Peter Oberparleitere5854a52007-04-27 16:01:31 +02008#ifndef _ASM_S390_CHPID_H
9#define _ASM_S390_CHPID_H _ASM_S390_CHPID_H
Peter Oberparleiterf86635f2007-04-27 16:01:26 +020010
11#include <linux/string.h>
Heiko Carstens0680ba02009-01-09 12:14:52 +010012#include <linux/types.h>
Peter Oberparleitere5854a52007-04-27 16:01:31 +020013
14#define __MAX_CHPID 255
Peter Oberparleiterf86635f2007-04-27 16:01:26 +020015
16struct chp_id {
17 u8 reserved1;
18 u8 cssid;
19 u8 reserved2;
20 u8 id;
21} __attribute__((packed));
22
Adrian Bunk626f3112008-07-17 17:16:42 +020023#ifdef __KERNEL__
24#include <asm/cio.h>
25
Peter Oberparleiterf86635f2007-04-27 16:01:26 +020026static inline void chp_id_init(struct chp_id *chpid)
27{
28 memset(chpid, 0, sizeof(struct chp_id));
29}
30
31static inline int chp_id_is_equal(struct chp_id *a, struct chp_id *b)
32{
33 return (a->id == b->id) && (a->cssid == b->cssid);
34}
35
36static inline void chp_id_next(struct chp_id *chpid)
37{
38 if (chpid->id < __MAX_CHPID)
39 chpid->id++;
40 else {
41 chpid->id = 0;
42 chpid->cssid++;
43 }
44}
45
46static inline int chp_id_is_valid(struct chp_id *chpid)
47{
48 return (chpid->cssid <= __MAX_CSSID);
49}
50
51
52#define chp_id_for_each(c) \
53 for (chp_id_init(c); chp_id_is_valid(c); chp_id_next(c))
Cornelia Huck9d92a7e2008-07-14 09:59:05 +020054#endif /* __KERNEL */
Peter Oberparleiterf86635f2007-04-27 16:01:26 +020055
Peter Oberparleitere5854a52007-04-27 16:01:31 +020056#endif /* _ASM_S390_CHPID_H */