Linux Users

Reply
This is an open group. Sign in and click the "Join Group" button to become a group member and start posting.
Highlighted

Fix for NI-VISA for kernel >=4.10

Hi,

 

I hacked a quick fix together for everyone using kernel 4.10 or newer:

 

I made a quick git repo and a diff:

diff --git a/nikal.c b/nikal.c
index e63534c..258813a 100644
--- a/nikal.c
+++ b/nikal.c
@@ -2038,14 +2038,6 @@ nNIKAL100_tBoolean nNIKAL200_isAddressableMemOver4G()
 
 #define NLNIKAL_CMD_SEND     1
 
-static struct genl_family nikal_netlink_family =
-{
-   .id = GENL_ID_GENERATE,
-   .name = "nlnikal",
-   .version = 1,
-   .maxattr = 1
-};
-
 static int nlnikal_msg(struct sk_buff *skb, struct genl_info *info) { return 0; }
 
 static struct genl_ops nikal_netlink_ops[] =
@@ -2056,6 +2048,20 @@ static struct genl_ops nikal_netlink_ops[] =
    },
 };
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0))
+#define GENL_ID_GENERATE 0
+#endif /* Linux 4.10.0 */
+
+static struct genl_family nikal_netlink_family =
+{
+   .id = GENL_ID_GENERATE,
+   .name = "nlnikal",
+   .version = 1,
+   .maxattr = 1,
+   #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0))
+   .ops        =   nikal_netlink_ops,
+   #endif /* Linux 4.10.0 */
+};
 
 static int __init nNIKAL100_initDriver(void)
 {
@@ -2077,11 +2083,15 @@ static int __init nNIKAL100_initDriver(void)
    kref_init(&(nNIKAL200_sPALPseudoDevice.kref));
    kref_init(&(nNIKAL200_sPALPseudoDeviceInterface.kref));
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0))
+    return genl_register_family(&nikal_netlink_family);
+#else
 #ifdef nNIKAL1400_kHasFamilyGenlOpsGroups
    if ((status = genl_register_family_with_ops(&nikal_netlink_family, nikal_netlink_ops))) return status;
 #else
    if ((status = genl_register_family_with_ops(&nikal_netlink_family, nikal_netlink_ops, 1))) return status;
 #endif
+#endif
 
 
    nNIKAL200_sProcRootDir = proc_mkdir("driver/ni", NULL);

 

Have fun!

Message 1 of 1
(758 Views)
Reply
This is an open group. Sign in and click the "Join Group" button to become a group member and start posting.