2005-04-16 16:20:36 -06:00
|
|
|
#ifndef _LINUX_SCATTERLIST_H
|
|
|
|
#define _LINUX_SCATTERLIST_H
|
|
|
|
|
2005-09-16 22:41:40 -06:00
|
|
|
#include <asm/scatterlist.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/string.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2006-08-14 07:11:53 -06:00
|
|
|
static inline void sg_set_buf(struct scatterlist *sg, const void *buf,
|
2005-09-16 22:41:40 -06:00
|
|
|
unsigned int buflen)
|
|
|
|
{
|
2005-04-16 16:20:36 -06:00
|
|
|
sg->page = virt_to_page(buf);
|
|
|
|
sg->offset = offset_in_page(buf);
|
|
|
|
sg->length = buflen;
|
|
|
|
}
|
|
|
|
|
2006-08-14 07:11:53 -06:00
|
|
|
static inline void sg_init_one(struct scatterlist *sg, const void *buf,
|
2005-09-16 22:41:40 -06:00
|
|
|
unsigned int buflen)
|
|
|
|
{
|
|
|
|
memset(sg, 0, sizeof(*sg));
|
|
|
|
sg_set_buf(sg, buf, buflen);
|
|
|
|
}
|
|
|
|
|
2007-05-09 01:02:57 -06:00
|
|
|
#define sg_next(sg) ((sg) + 1)
|
|
|
|
#define sg_last(sg, nents) (&(sg[(nents) - 1]))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Loop over each sg element, following the pointer to a new list if necessary
|
|
|
|
*/
|
|
|
|
#define for_each_sg(sglist, sg, nr, __i) \
|
|
|
|
for (__i = 0, sg = (sglist); __i < (nr); __i++, sg = sg_next(sg))
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
#endif /* _LINUX_SCATTERLIST_H */
|