diff mbox

[dpdk-dev,v4,3/4] kni: replace strict_strtoul with kstrtoul

Message ID 1418209443-1744-4-git-send-email-jmiao@redhat.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Jincheng Miao Dec. 10, 2014, 11:04 a.m. UTC
Add kni/compat.h for be compatible with older kernel.

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
---
 lib/librte_eal/linuxapp/kni/compat.h    | 16 ++++++++++++++++
 lib/librte_eal/linuxapp/kni/kni_vhost.c |  3 ++-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 lib/librte_eal/linuxapp/kni/compat.h
diff mbox

Patch

diff --git a/lib/librte_eal/linuxapp/kni/compat.h b/lib/librte_eal/linuxapp/kni/compat.h
new file mode 100644
index 0000000..39e07ef
--- /dev/null
+++ b/lib/librte_eal/linuxapp/kni/compat.h
@@ -0,0 +1,16 @@ 
+/*
+ * Minimal wrappers to allow compiling kni on older kernels.
+ */
+
+#ifndef RHEL_RELEASE_VERSION
+#define RHEL_RELEASE_VERSION(a, b) (((a) << 8) + (b))
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) && \
+	(!(defined(RHEL_RELEASE_CODE) && \
+	 RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 4)))
+
+#define kstrtoul strict_strtoul
+
+#endif /* < 2.6.39 */
+
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index 7bcc985..35263f2 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -35,6 +35,7 @@ 
 
 #include "kni_dev.h"
 #include "kni_fifo.h"
+#include "compat.h"
 
 #define RX_BURST_SZ 4
 
@@ -740,7 +741,7 @@  set_sock_en(struct device *dev, struct device_attribute *attr,
 	unsigned long en;
 	int err = 0;
 
-	if (0 != strict_strtoul(buf, 0, &en))
+	if (0 != kstrtoul(buf, 0, &en))
 		return -EINVAL;
 
 	if (en)