Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d32311fe authored by Herbert Xu's avatar Herbert Xu
Browse files

[PATCH] Introduce sg_set_buf



sg_init_one is a nice tool for the block layer.  However, users
of struct scatterlist in other subsystems don't usually need the
DMA attributes.  For them it's a waste of time and space to
initialise the whole struct scatterlist structure.

Therefore this patch adds a new function sg_set_buf to initialise
a scatterlist without zeroing the DMA attributes.

Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent be15cd72
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
#ifndef _LINUX_SCATTERLIST_H
#define _LINUX_SCATTERLIST_H

static inline void sg_init_one(struct scatterlist *sg,
			       u8 *buf, unsigned int buflen)
{
	memset(sg, 0, sizeof(*sg));
#include <asm/scatterlist.h>
#include <linux/mm.h>
#include <linux/string.h>

static inline void sg_set_buf(struct scatterlist *sg, void *buf,
			      unsigned int buflen)
{
	sg->page = virt_to_page(buf);
	sg->offset = offset_in_page(buf);
	sg->length = buflen;
}

static inline void sg_init_one(struct scatterlist *sg, void *buf,
			       unsigned int buflen)
{
	memset(sg, 0, sizeof(*sg));
	sg_set_buf(sg, buf, buflen);
}

#endif /* _LINUX_SCATTERLIST_H */