diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2013-04-02 19:27:23 +0200 |
---|---|---|
committer | Johannes Berg <johannes@sipsolutions.net> | 2013-04-02 19:27:23 +0200 |
commit | 3ec07b8dc2ef11b1bfbdec3b6ed335b013be779b (patch) | |
tree | 42eaf82491e75302af703f7b8f5f048c76862da8 /backport/compat/compat-3.9.c | |
parent | 3cefcdd73225e5404b077640ece987efff04216f (diff) |
rename compat dir to backport
Then we can also move all the plumbing/ stuff into it.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Diffstat (limited to 'backport/compat/compat-3.9.c')
-rw-r--r-- | backport/compat/compat-3.9.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/backport/compat/compat-3.9.c b/backport/compat/compat-3.9.c new file mode 100644 index 00000000..1f248421 --- /dev/null +++ b/backport/compat/compat-3.9.c @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2013 Luis R. Rodriguez <mcgrof@do-not-panic.com> + * + * Compatibility file for Linux wireless for kernels 3.9. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include <linux/module.h> +#include <linux/scatterlist.h> + +#ifdef __sg_page_iter_next + +void __sg_page_iter_start(struct sg_page_iter *piter, + struct scatterlist *sglist, unsigned int nents, + unsigned long pgoffset) +{ + piter->__pg_advance = 0; + piter->__nents = nents; + + piter->page = NULL; + piter->sg = sglist; + piter->sg_pgoffset = pgoffset; +} +EXPORT_SYMBOL_GPL(__sg_page_iter_start); + +static int sg_page_count(struct scatterlist *sg) +{ + return PAGE_ALIGN(sg->offset + sg->length) >> PAGE_SHIFT; +} + +bool __sg_page_iter_next(struct sg_page_iter *piter) +{ + if (!piter->__nents || !piter->sg) + return false; + + piter->sg_pgoffset += piter->__pg_advance; + piter->__pg_advance = 1; + + while (piter->sg_pgoffset >= sg_page_count(piter->sg)) { + piter->sg_pgoffset -= sg_page_count(piter->sg); + piter->sg = sg_next(piter->sg); + if (!--piter->__nents || !piter->sg) + return false; + } + piter->page = nth_page(sg_page(piter->sg), piter->sg_pgoffset); + + return true; +} +EXPORT_SYMBOL_GPL(__sg_page_iter_next); + +#endif /* __sg_page_iter_next */ |