chpid.h 1022 字节
Newer Older
1 2 3 4 5 6 7
/*
 *  drivers/s390/cio/chpid.h
 *
 *    Copyright IBM Corp. 2007
 *    Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
 */

8
#ifndef _ASM_S390_CHPID_H
9
#define _ASM_S390_CHPID_H
10 11

#include <linux/string.h>
12
#include <linux/types.h>
13 14

#define __MAX_CHPID 255
15 16 17 18 19 20 21 22

struct chp_id {
	u8 reserved1;
	u8 cssid;
	u8 reserved2;
	u8 id;
} __attribute__((packed));

23 24 25
#ifdef __KERNEL__
#include <asm/cio.h>

26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
static inline void chp_id_init(struct chp_id *chpid)
{
	memset(chpid, 0, sizeof(struct chp_id));
}

static inline int chp_id_is_equal(struct chp_id *a, struct chp_id *b)
{
	return (a->id == b->id) && (a->cssid == b->cssid);
}

static inline void chp_id_next(struct chp_id *chpid)
{
	if (chpid->id < __MAX_CHPID)
		chpid->id++;
	else {
		chpid->id = 0;
		chpid->cssid++;
	}
}

static inline int chp_id_is_valid(struct chp_id *chpid)
{
	return (chpid->cssid <= __MAX_CSSID);
}


#define chp_id_for_each(c) \
	for (chp_id_init(c); chp_id_is_valid(c); chp_id_next(c))
54
#endif /* __KERNEL */
55

56
#endif /* _ASM_S390_CHPID_H */