Lines Matching refs:sg
15 #define sg_is_chain(sg) ((sg)->page_link & 0x01) argument
16 #define sg_is_last(sg) ((sg)->page_link & 0x02) argument
17 #define sg_chain_ptr(sg) \ argument
18 ((struct scatterlist *) ((sg)->page_link & ~0x03))
30 static inline void sg_assign_page(struct scatterlist *sg, struct page *page) in sg_assign_page() argument
32 unsigned long page_link = sg->page_link & 0x3; in sg_assign_page()
40 BUG_ON(sg_is_chain(sg)); in sg_assign_page()
42 sg->page_link = page_link | (unsigned long) page; in sg_assign_page()
59 static inline void sg_set_page(struct scatterlist *sg, struct page *page, in sg_set_page() argument
62 sg_assign_page(sg, page); in sg_set_page()
63 sg->offset = offset; in sg_set_page()
64 sg->length = len; in sg_set_page()
67 static inline struct page *sg_page(struct scatterlist *sg) in sg_page() argument
70 BUG_ON(sg_is_chain(sg)); in sg_page()
72 return (struct page *)((sg)->page_link & ~0x3); in sg_page()
78 #define for_each_sg(sglist, sg, nr, __i) \ argument
79 for (__i = 0, sg = (sglist); __i < (nr); __i++, sg = sg_next(sg))
116 static inline void sg_mark_end(struct scatterlist *sg) in sg_mark_end() argument
121 sg->page_link |= 0x02; in sg_mark_end()
122 sg->page_link &= ~0x01; in sg_mark_end()
133 static inline void sg_unmark_end(struct scatterlist *sg) in sg_unmark_end() argument
135 sg->page_link &= ~0x02; in sg_unmark_end()
138 static inline struct scatterlist *sg_next(struct scatterlist *sg) in sg_next() argument
140 if (sg_is_last(sg)) in sg_next()
143 sg++; in sg_next()
144 if (unlikely(sg_is_chain(sg))) in sg_next()
145 sg = sg_chain_ptr(sg); in sg_next()
147 return sg; in sg_next()
156 static inline dma_addr_t sg_phys(struct scatterlist *sg) in sg_phys() argument
158 return page_to_phys(sg_page(sg)) + sg->offset; in sg_phys()
161 static inline void sg_set_buf(struct scatterlist *sg, const void *buf, in sg_set_buf() argument
164 sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf)); in sg_set_buf()
167 static inline void sg_init_one(struct scatterlist *sg, in sg_init_one() argument
170 sg_init_table(sg, 1); in sg_init_one()
171 sg_set_buf(sg, buf, buflen); in sg_init_one()