chpid.h 812 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright IBM Corp. 2007, 2012
  3. * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
  4. */
  5. #ifndef _ASM_S390_CHPID_H
  6. #define _ASM_S390_CHPID_H
  7. #include <uapi/asm/chpid.h>
  8. #include <asm/cio.h>
  9. static inline void chp_id_init(struct chp_id *chpid)
  10. {
  11. memset(chpid, 0, sizeof(struct chp_id));
  12. }
  13. static inline int chp_id_is_equal(struct chp_id *a, struct chp_id *b)
  14. {
  15. return (a->id == b->id) && (a->cssid == b->cssid);
  16. }
  17. static inline void chp_id_next(struct chp_id *chpid)
  18. {
  19. if (chpid->id < __MAX_CHPID)
  20. chpid->id++;
  21. else {
  22. chpid->id = 0;
  23. chpid->cssid++;
  24. }
  25. }
  26. static inline int chp_id_is_valid(struct chp_id *chpid)
  27. {
  28. return (chpid->cssid <= __MAX_CSSID);
  29. }
  30. #define chp_id_for_each(c) \
  31. for (chp_id_init(c); chp_id_is_valid(c); chp_id_next(c))
  32. #endif /* _ASM_S390_CHPID_H */