summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backport/backport-include/linux/scatterlist.h4
-rw-r--r--backport/compat/compat-3.7.c10
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);