Lines Matching refs:miter
674 void sg_miter_start(struct sg_mapping_iter *miter, struct scatterlist *sgl, in sg_miter_start() argument
677 memset(miter, 0, sizeof(struct sg_mapping_iter)); in sg_miter_start()
679 __sg_page_iter_start(&miter->piter, sgl, nents, 0); in sg_miter_start()
681 miter->__flags = flags; in sg_miter_start()
685 static bool sg_miter_get_next_page(struct sg_mapping_iter *miter) in sg_miter_get_next_page() argument
687 if (!miter->__remaining) { in sg_miter_get_next_page()
690 if (!__sg_page_iter_next(&miter->piter)) in sg_miter_get_next_page()
693 sg = miter->piter.sg; in sg_miter_get_next_page()
695 miter->__offset = miter->piter.sg_pgoffset ? 0 : sg->offset; in sg_miter_get_next_page()
696 miter->piter.sg_pgoffset += miter->__offset >> PAGE_SHIFT; in sg_miter_get_next_page()
697 miter->__offset &= PAGE_SIZE - 1; in sg_miter_get_next_page()
698 miter->__remaining = sg->offset + sg->length - in sg_miter_get_next_page()
699 (miter->piter.sg_pgoffset << PAGE_SHIFT) - in sg_miter_get_next_page()
700 miter->__offset; in sg_miter_get_next_page()
701 miter->__remaining = min_t(unsigned long, miter->__remaining, in sg_miter_get_next_page()
702 PAGE_SIZE - miter->__offset); in sg_miter_get_next_page()
726 bool sg_miter_skip(struct sg_mapping_iter *miter, off_t offset) in sg_miter_skip() argument
728 sg_miter_stop(miter); in sg_miter_skip()
733 if (!sg_miter_get_next_page(miter)) in sg_miter_skip()
736 consumed = min_t(off_t, offset, miter->__remaining); in sg_miter_skip()
737 miter->__offset += consumed; in sg_miter_skip()
738 miter->__remaining -= consumed; in sg_miter_skip()
763 bool sg_miter_next(struct sg_mapping_iter *miter) in sg_miter_next() argument
765 sg_miter_stop(miter); in sg_miter_next()
771 if (!sg_miter_get_next_page(miter)) in sg_miter_next()
774 miter->page = sg_page_iter_page(&miter->piter); in sg_miter_next()
775 miter->consumed = miter->length = miter->__remaining; in sg_miter_next()
777 if (miter->__flags & SG_MITER_ATOMIC) in sg_miter_next()
778 miter->addr = kmap_atomic(miter->page) + miter->__offset; in sg_miter_next()
780 miter->addr = kmap(miter->page) + miter->__offset; in sg_miter_next()
800 void sg_miter_stop(struct sg_mapping_iter *miter) in sg_miter_stop() argument
802 WARN_ON(miter->consumed > miter->length); in sg_miter_stop()
805 if (miter->addr) { in sg_miter_stop()
806 miter->__offset += miter->consumed; in sg_miter_stop()
807 miter->__remaining -= miter->consumed; in sg_miter_stop()
809 if ((miter->__flags & SG_MITER_TO_SG) && in sg_miter_stop()
810 !PageSlab(miter->page)) in sg_miter_stop()
811 flush_kernel_dcache_page(miter->page); in sg_miter_stop()
813 if (miter->__flags & SG_MITER_ATOMIC) { in sg_miter_stop()
815 kunmap_atomic(miter->addr); in sg_miter_stop()
817 kunmap(miter->page); in sg_miter_stop()
819 miter->page = NULL; in sg_miter_stop()
820 miter->addr = NULL; in sg_miter_stop()
821 miter->length = 0; in sg_miter_stop()
822 miter->consumed = 0; in sg_miter_stop()
844 struct sg_mapping_iter miter; in sg_copy_buffer() local
852 sg_miter_start(&miter, sgl, nents, sg_flags); in sg_copy_buffer()
854 if (!sg_miter_skip(&miter, skip)) in sg_copy_buffer()
857 while ((offset < buflen) && sg_miter_next(&miter)) { in sg_copy_buffer()
860 len = min(miter.length, buflen - offset); in sg_copy_buffer()
863 memcpy(buf + offset, miter.addr, len); in sg_copy_buffer()
865 memcpy(miter.addr, buf + offset, len); in sg_copy_buffer()
870 sg_miter_stop(&miter); in sg_copy_buffer()
959 struct sg_mapping_iter miter; in sg_zero_buffer() local
962 sg_miter_start(&miter, sgl, nents, sg_flags); in sg_zero_buffer()
964 if (!sg_miter_skip(&miter, skip)) in sg_zero_buffer()
967 while (offset < buflen && sg_miter_next(&miter)) { in sg_zero_buffer()
970 len = min(miter.length, buflen - offset); in sg_zero_buffer()
971 memset(miter.addr, 0, len); in sg_zero_buffer()
976 sg_miter_stop(&miter); in sg_zero_buffer()