Lines Matching refs:iv

130 	struct airq_iv *iv;
133 iv = kzalloc(sizeof(*iv), GFP_KERNEL);
134 if (!iv)
136 iv->bits = bits;
137 iv->flags = flags;
145 iv->vector = dma_pool_zalloc(airq_iv_cache, GFP_KERNEL,
146 &iv->vector_dma);
147 if (!iv->vector)
150 iv->vector = cio_dma_zalloc(size);
151 if (!iv->vector)
155 iv->avail = kmalloc(size, GFP_KERNEL);
156 if (!iv->avail)
158 memset(iv->avail, 0xff, size);
159 iv->end = 0;
161 iv->end = bits;
163 iv->bitlock = kzalloc(size, GFP_KERNEL);
164 if (!iv->bitlock)
169 iv->ptr = kzalloc(size, GFP_KERNEL);
170 if (!iv->ptr)
175 iv->data = kzalloc(size, GFP_KERNEL);
176 if (!iv->data)
179 spin_lock_init(&iv->lock);
180 return iv;
183 kfree(iv->ptr);
184 kfree(iv->bitlock);
185 kfree(iv->avail);
186 if (iv->flags & AIRQ_IV_CACHELINE && iv->vector)
187 dma_pool_free(airq_iv_cache, iv->vector, iv->vector_dma);
189 cio_dma_free(iv->vector, size);
190 kfree(iv);
198 * @iv: pointer to interrupt vector structure
200 void airq_iv_release(struct airq_iv *iv)
202 kfree(iv->data);
203 kfree(iv->ptr);
204 kfree(iv->bitlock);
205 if (iv->flags & AIRQ_IV_CACHELINE)
206 dma_pool_free(airq_iv_cache, iv->vector, iv->vector_dma);
208 cio_dma_free(iv->vector, iv_size(iv->bits));
209 kfree(iv->avail);
210 kfree(iv);
216 * @iv: pointer to an interrupt vector structure
223 unsigned long airq_iv_alloc(struct airq_iv *iv, unsigned long num)
227 if (!iv->avail || num == 0)
229 spin_lock_irqsave(&iv->lock, flags);
230 bit = find_first_bit_inv(iv->avail, iv->bits);
231 while (bit + num <= iv->bits) {
233 if (!test_bit_inv(bit + i, iv->avail))
238 clear_bit_inv(bit + i, iv->avail);
239 if (bit + num >= iv->end)
240 iv->end = bit + num + 1;
243 bit = find_next_bit_inv(iv->avail, iv->bits, bit + i + 1);
245 if (bit + num > iv->bits)
247 spin_unlock_irqrestore(&iv->lock, flags);
254 * @iv: pointer to interrupt vector structure
258 void airq_iv_free(struct airq_iv *iv, unsigned long bit, unsigned long num)
262 if (!iv->avail || num == 0)
264 spin_lock_irqsave(&iv->lock, flags);
267 clear_bit_inv(bit + i, iv->vector);
269 set_bit_inv(bit + i, iv->avail);
271 if (bit + num >= iv->end) {
273 while (iv->end > 0 && !test_bit_inv(iv->end - 1, iv->avail))
274 iv->end--;
276 spin_unlock_irqrestore(&iv->lock, flags);
282 * @iv: pointer to interrupt vector structure
289 unsigned long airq_iv_scan(struct airq_iv *iv, unsigned long start,
295 bit = find_next_bit_inv(iv->vector, end, start);
298 clear_bit_inv(bit, iv->vector);