Merge tag 'pm+acpi-4.2-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[linux/fpc-iii.git] / arch / s390 / include / asm / airq.h
blobbd93ff6661b809643e4dcd3e94747c4464a763a2
1 /*
2 * Copyright IBM Corp. 2002, 2007
3 * Author(s): Ingo Adlung <adlung@de.ibm.com>
4 * Cornelia Huck <cornelia.huck@de.ibm.com>
5 * Arnd Bergmann <arndb@de.ibm.com>
6 * Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
7 */
9 #ifndef _ASM_S390_AIRQ_H
10 #define _ASM_S390_AIRQ_H
12 #include <linux/bit_spinlock.h>
14 struct airq_struct {
15 struct hlist_node list; /* Handler queueing. */
16 void (*handler)(struct airq_struct *); /* Thin-interrupt handler */
17 u8 *lsi_ptr; /* Local-Summary-Indicator pointer */
18 u8 lsi_mask; /* Local-Summary-Indicator mask */
19 u8 isc; /* Interrupt-subclass */
20 u8 flags;
23 #define AIRQ_PTR_ALLOCATED 0x01
25 int register_adapter_interrupt(struct airq_struct *airq);
26 void unregister_adapter_interrupt(struct airq_struct *airq);
28 /* Adapter interrupt bit vector */
29 struct airq_iv {
30 unsigned long *vector; /* Adapter interrupt bit vector */
31 unsigned long *avail; /* Allocation bit mask for the bit vector */
32 unsigned long *bitlock; /* Lock bit mask for the bit vector */
33 unsigned long *ptr; /* Pointer associated with each bit */
34 unsigned int *data; /* 32 bit value associated with each bit */
35 unsigned long bits; /* Number of bits in the vector */
36 unsigned long end; /* Number of highest allocated bit + 1 */
37 spinlock_t lock; /* Lock to protect alloc & free */
40 #define AIRQ_IV_ALLOC 1 /* Use an allocation bit mask */
41 #define AIRQ_IV_BITLOCK 2 /* Allocate the lock bit mask */
42 #define AIRQ_IV_PTR 4 /* Allocate the ptr array */
43 #define AIRQ_IV_DATA 8 /* Allocate the data array */
45 struct airq_iv *airq_iv_create(unsigned long bits, unsigned long flags);
46 void airq_iv_release(struct airq_iv *iv);
47 unsigned long airq_iv_alloc(struct airq_iv *iv, unsigned long num);
48 void airq_iv_free(struct airq_iv *iv, unsigned long bit, unsigned long num);
49 unsigned long airq_iv_scan(struct airq_iv *iv, unsigned long start,
50 unsigned long end);
52 static inline unsigned long airq_iv_alloc_bit(struct airq_iv *iv)
54 return airq_iv_alloc(iv, 1);
57 static inline void airq_iv_free_bit(struct airq_iv *iv, unsigned long bit)
59 airq_iv_free(iv, bit, 1);
62 static inline unsigned long airq_iv_end(struct airq_iv *iv)
64 return iv->end;
67 static inline void airq_iv_lock(struct airq_iv *iv, unsigned long bit)
69 const unsigned long be_to_le = BITS_PER_LONG - 1;
70 bit_spin_lock(bit ^ be_to_le, iv->bitlock);
73 static inline void airq_iv_unlock(struct airq_iv *iv, unsigned long bit)
75 const unsigned long be_to_le = BITS_PER_LONG - 1;
76 bit_spin_unlock(bit ^ be_to_le, iv->bitlock);
79 static inline void airq_iv_set_data(struct airq_iv *iv, unsigned long bit,
80 unsigned int data)
82 iv->data[bit] = data;
85 static inline unsigned int airq_iv_get_data(struct airq_iv *iv,
86 unsigned long bit)
88 return iv->data[bit];
91 static inline void airq_iv_set_ptr(struct airq_iv *iv, unsigned long bit,
92 unsigned long ptr)
94 iv->ptr[bit] = ptr;
97 static inline unsigned long airq_iv_get_ptr(struct airq_iv *iv,
98 unsigned long bit)
100 return iv->ptr[bit];
103 #endif /* _ASM_S390_AIRQ_H */