diff options
author | Johannes Berg <johannes.berg@intel.com> | 2017-02-07 14:13:14 +0100 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2017-02-07 15:07:22 +0100 |
commit | f75286f723c2e04f72b99da93f22df6d48bc8002 (patch) | |
tree | 5ccf28de74700d2a2ebe92287322732d6b5858d3 /backport | |
parent | 5318b2e6923dd8957bcc9b9474e979b1cb483897 (diff) |
backports: add sg_nents()
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'backport')
-rw-r--r-- | backport/backport-include/linux/scatterlist.h | 4 | ||||
-rw-r--r-- | backport/compat/compat-3.7.c | 10 |
2 files changed, 14 insertions, 0 deletions
diff --git a/backport/backport-include/linux/scatterlist.h b/backport/backport-include/linux/scatterlist.h index 62d7078c..6a264ed4 100644 --- a/backport/backport-include/linux/scatterlist.h +++ b/backport/backport-include/linux/scatterlist.h @@ -2,6 +2,10 @@ #define __BACKPORT_SCATTERLIST_H #include_next <linux/scatterlist.h> +#if LINUX_VERSION_IS_LESS(3,7,0) +int sg_nents(struct scatterlist *sg); +#endif + #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0) /* diff --git a/backport/compat/compat-3.7.c b/backport/compat/compat-3.7.c index f7e7848b..e3721676 100644 --- a/backport/compat/compat-3.7.c +++ b/backport/compat/compat-3.7.c @@ -13,6 +13,7 @@ #include <linux/pci.h> #include <linux/pci_regs.h> #include <linux/of.h> +#include <linux/scatterlist.h> bool mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay) @@ -278,3 +279,12 @@ struct device_node *of_get_child_by_name(const struct device_node *node, EXPORT_SYMBOL_GPL(of_get_child_by_name); #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) */ #endif /* CONFIG_OF */ + +int sg_nents(struct scatterlist *sg) +{ + int nents; + for (nents = 0; sg; sg = sg_next(sg)) + nents++; + return nents; +} +EXPORT_SYMBOL_GPL(sg_nents); |