diff options
author | Johannes Berg <johannes.berg@intel.com> | 2013-04-11 20:48:09 +0200 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2013-04-15 11:32:45 +0200 |
commit | 33b2d02fb520d39a9a96ffc5e63de06df8a75c75 (patch) | |
tree | 4550318c41f21502fc94952b7bdf877cbedfb831 /backport/backport-include/linux/scatterlist.h | |
parent | 5dcba8d70aa49ddb6072550398b658b8bd68cd42 (diff) |
backports: dissolve compat-3.9.h
Move everything into the appropriate header files.
Also include uidgid.h into the new fs.h since kernels
that had uidgid.h include it already, so it doesn't
change anything there, but those that don't have it
obviously can't have included it and people rely on
it behing included there.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'backport/backport-include/linux/scatterlist.h')
-rw-r--r-- | backport/backport-include/linux/scatterlist.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/backport/backport-include/linux/scatterlist.h b/backport/backport-include/linux/scatterlist.h new file mode 100644 index 00000000..aaa73719 --- /dev/null +++ b/backport/backport-include/linux/scatterlist.h @@ -0,0 +1,51 @@ +#ifndef __BACKPORT_SCATTERLIST_H +#define __BACKPORT_SCATTERLIST_H +#include_next <linux/scatterlist.h> +#include <linux/version.h> + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0) + +/* Lets expect distributions might backport this */ +#ifndef for_each_sg_page +/* + * sg page iterator + * + * Iterates over sg entries page-by-page. On each successful iteration, + * @piter->page points to the current page, @piter->sg to the sg holding this + * page and @piter->sg_pgoffset to the page's page offset within the sg. The + * iteration will stop either when a maximum number of sg entries was reached + * or a terminating sg (sg_last(sg) == true) was reached. + */ +struct sg_page_iter { + struct page *page; /* current page */ + struct scatterlist *sg; /* sg holding the page */ + unsigned int sg_pgoffset; /* page offset within the sg */ + + /* these are internal states, keep away */ + unsigned int __nents; /* remaining sg entries */ + int __pg_advance; /* nr pages to advance at the + * next step */ +}; + +#define __sg_page_iter_next LINUX_BACKPORT(__sg_page_iter_next) +bool __sg_page_iter_next(struct sg_page_iter *piter); +#define __sg_page_iter_start LINUX_BACKPORT(__sg_page_iter_start) +void __sg_page_iter_start(struct sg_page_iter *piter, + struct scatterlist *sglist, unsigned int nents, + unsigned long pgoffset); + +/** + * for_each_sg_page - iterate over the pages of the given sg list + * @sglist: sglist to iterate over + * @piter: page iterator to hold current page, sg, sg_pgoffset + * @nents: maximum number of sg entries to iterate over + * @pgoffset: starting page offset + */ +#define for_each_sg_page(sglist, piter, nents, pgoffset) \ + for (__sg_page_iter_start((piter), (sglist), (nents), (pgoffset)); \ + __sg_page_iter_next(piter);) + +#endif /* for_each_sg_page assumption */ +#endif /* version < 3.9 */ + +#endif /* __BACKPORT_SCATTERLIST_H */ |