Lines Matching refs:iter
435 static struct msc_block_desc *msc_iter_bdesc(struct msc_iter *iter) in msc_iter_bdesc() argument
437 return sg_virt(iter->block); in msc_iter_bdesc()
442 struct msc_iter *iter; in msc_iter_install() local
444 iter = kzalloc(sizeof(*iter), GFP_KERNEL); in msc_iter_install()
445 if (!iter) in msc_iter_install()
457 kfree(iter); in msc_iter_install()
458 iter = ERR_PTR(-EBUSY); in msc_iter_install()
462 iter->msc = msc; in msc_iter_install()
464 list_add_tail(&iter->entry, &msc->iter_list); in msc_iter_install()
468 return iter; in msc_iter_install()
471 static void msc_iter_remove(struct msc_iter *iter, struct msc *msc) in msc_iter_remove() argument
474 list_del(&iter->entry); in msc_iter_remove()
477 kfree(iter); in msc_iter_remove()
480 static void msc_iter_block_start(struct msc_iter *iter) in msc_iter_block_start() argument
482 if (iter->start_block) in msc_iter_block_start()
485 iter->start_block = msc_win_oldest_sg(iter->win); in msc_iter_block_start()
486 iter->block = iter->start_block; in msc_iter_block_start()
487 iter->wrap_count = 0; in msc_iter_block_start()
493 if (msc_block_wrapped(msc_iter_bdesc(iter))) in msc_iter_block_start()
494 iter->wrap_count = 2; in msc_iter_block_start()
498 static int msc_iter_win_start(struct msc_iter *iter, struct msc *msc) in msc_iter_win_start() argument
501 if (iter->start_win) in msc_iter_win_start()
504 iter->start_win = msc_oldest_window(msc); in msc_iter_win_start()
505 if (!iter->start_win) in msc_iter_win_start()
508 iter->win = iter->start_win; in msc_iter_win_start()
509 iter->start_block = NULL; in msc_iter_win_start()
511 msc_iter_block_start(iter); in msc_iter_win_start()
516 static int msc_iter_win_advance(struct msc_iter *iter) in msc_iter_win_advance() argument
518 iter->win = msc_next_window(iter->win); in msc_iter_win_advance()
519 iter->start_block = NULL; in msc_iter_win_advance()
521 if (iter->win == iter->start_win) { in msc_iter_win_advance()
522 iter->eof++; in msc_iter_win_advance()
526 msc_iter_block_start(iter); in msc_iter_win_advance()
531 static int msc_iter_block_advance(struct msc_iter *iter) in msc_iter_block_advance() argument
533 iter->block_off = 0; in msc_iter_block_advance()
536 if (iter->wrap_count && iter->block == iter->start_block) { in msc_iter_block_advance()
537 iter->wrap_count--; in msc_iter_block_advance()
538 if (!iter->wrap_count) in msc_iter_block_advance()
540 return msc_iter_win_advance(iter); in msc_iter_block_advance()
544 if (!iter->wrap_count && msc_block_last_written(msc_iter_bdesc(iter))) in msc_iter_block_advance()
546 return msc_iter_win_advance(iter); in msc_iter_block_advance()
549 if (sg_is_last(iter->block)) in msc_iter_block_advance()
550 iter->block = msc_win_base_sg(iter->win); in msc_iter_block_advance()
552 iter->block = sg_next(iter->block); in msc_iter_block_advance()
555 if (!iter->wrap_count && iter->block == iter->start_block) in msc_iter_block_advance()
556 return msc_iter_win_advance(iter); in msc_iter_block_advance()
578 msc_buffer_iterate(struct msc_iter *iter, size_t size, void *data, in msc_buffer_iterate() argument
581 struct msc *msc = iter->msc; in msc_buffer_iterate()
585 if (iter->eof) in msc_buffer_iterate()
589 if (msc_iter_win_start(iter, msc)) in msc_buffer_iterate()
593 unsigned long data_bytes = msc_data_sz(msc_iter_bdesc(iter)); in msc_buffer_iterate()
594 void *src = (void *)msc_iter_bdesc(iter) + MSC_BDESC; in msc_buffer_iterate()
612 if (iter->block == iter->start_block && iter->wrap_count == 2) { in msc_buffer_iterate()
620 tocopy -= iter->block_off; in msc_buffer_iterate()
621 src += iter->block_off; in msc_buffer_iterate()
635 iter->block_off += copied; in msc_buffer_iterate()
636 iter->offset += copied; in msc_buffer_iterate()
642 if (msc_iter_block_advance(iter)) in msc_buffer_iterate()
1248 struct msc_window *win, *iter; in msc_buffer_multi_free() local
1250 list_for_each_entry_safe(win, iter, &msc->win_list, entry) in msc_buffer_multi_free()
1462 struct msc_iter *iter; in intel_th_msc_open() local
1467 iter = msc_iter_install(msc); in intel_th_msc_open()
1468 if (IS_ERR(iter)) in intel_th_msc_open()
1469 return PTR_ERR(iter); in intel_th_msc_open()
1471 file->private_data = iter; in intel_th_msc_open()
1478 struct msc_iter *iter = file->private_data; in intel_th_msc_release() local
1479 struct msc *msc = iter->msc; in intel_th_msc_release()
1481 msc_iter_remove(iter, msc); in intel_th_msc_release()
1525 struct msc_iter *iter = file->private_data; in intel_th_msc_read() local
1526 struct msc *msc = iter->msc; in intel_th_msc_read()
1558 ret = msc_buffer_iterate(iter, len, &u, msc_win_to_user); in intel_th_msc_read()
1560 *ppos = iter->offset; in intel_th_msc_read()
1577 struct msc_iter *iter = vma->vm_file->private_data; in msc_mmap_open() local
1578 struct msc *msc = iter->msc; in msc_mmap_open()
1585 struct msc_iter *iter = vma->vm_file->private_data; in msc_mmap_close() local
1586 struct msc *msc = iter->msc; in msc_mmap_close()
1610 struct msc_iter *iter = vmf->vma->vm_file->private_data; in msc_mmap_fault() local
1611 struct msc *msc = iter->msc; in msc_mmap_fault()
1633 struct msc_iter *iter = vma->vm_file->private_data; in intel_th_msc_mmap() local
1634 struct msc *msc = iter->msc; in intel_th_msc_mmap()