From 724e0aff6da862de2bf6981cc4f215f6199bd6ea Mon Sep 17 00:00:00 2001 From: Larry Ruckman Date: Sun, 2 Jun 2024 20:59:53 -0700 Subject: [PATCH 1/2] Updated compatibility for Linux kernel version 6.4.0 and above --- diff_output.txt | 60 +++++++++++++++++++++ petalinux/aximemorymap/files/aximemorymap.c | 9 +++- petalinux/aximemorymap/files/aximemorymap.h | 5 ++ 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 diff_output.txt diff --git a/diff_output.txt b/diff_output.txt new file mode 100644 index 0000000..c6d0b52 --- /dev/null +++ b/diff_output.txt @@ -0,0 +1,60 @@ +diff --git a/petalinux/aximemorymap/files/aximemorymap.c b/petalinux/aximemorymap/files/aximemorymap.c +index 68e20f5..ab76304 100644 +--- a/petalinux/aximemorymap/files/aximemorymap.c ++++ b/petalinux/aximemorymap/files/aximemorymap.c +@@ -34,7 +34,6 @@ + #include + #include + #include +-#include + + /** + * MODULE_NAME - "axi_memory_map" +@@ -112,7 +111,11 @@ struct file_operations MapFunctions = { + * Note: The permissions set by this callback can be overridden by udev rules on + * systems where udev is responsible for device node creation and management. + */ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0) + char *Map_DevNode(struct device *dev, umode_t *mode) { ++#else ++char *Map_DevNode(const struct device *dev, umode_t *mode) { ++#endif + if (mode != NULL) *mode = 0666; // Set default permissions to read and write for user, group, and others + return NULL; // Return NULL as no specific device node name alteration is required + } +@@ -157,7 +160,11 @@ int Map_Init(void) { + + // Step 4: Create a device class + pr_info("%s: Init: Creating device class\n", MOD_NAME); ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0) + gCl = class_create(THIS_MODULE, dev.devName); ++#else ++ gCl = class_create(dev.devName); ++#endif + if (IS_ERR(gCl)) { + pr_err("%s: Init: Failed to create device class\n", MOD_NAME); + unregister_chrdev_region(dev.devNum, 1); // Clean up allocated resources +diff --git a/petalinux/aximemorymap/files/aximemorymap.h b/petalinux/aximemorymap/files/aximemorymap.h +index 96d502b..73490d2 100755 +--- a/petalinux/aximemorymap/files/aximemorymap.h ++++ b/petalinux/aximemorymap/files/aximemorymap.h +@@ -30,6 +30,7 @@ + #include + #include + #include ++#include + #include + + // Defines the size of the map, set to 64K. +@@ -71,7 +72,11 @@ struct MapDevice { + }; + + // Function prototypes for device operations. ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0) + char *Map_DevNode(struct device *dev, umode_t *mode); ++#else ++char *Map_DevNode(const struct device *dev, umode_t *mode); ++#endif + int Map_Init(void); + void Map_Exit(void); + int Map_Open(struct inode *inode, struct file *filp); diff --git a/petalinux/aximemorymap/files/aximemorymap.c b/petalinux/aximemorymap/files/aximemorymap.c index 68e20f5..ab76304 100644 --- a/petalinux/aximemorymap/files/aximemorymap.c +++ b/petalinux/aximemorymap/files/aximemorymap.c @@ -34,7 +34,6 @@ #include #include #include -#include /** * MODULE_NAME - "axi_memory_map" @@ -112,7 +111,11 @@ struct file_operations MapFunctions = { * Note: The permissions set by this callback can be overridden by udev rules on * systems where udev is responsible for device node creation and management. */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0) char *Map_DevNode(struct device *dev, umode_t *mode) { +#else +char *Map_DevNode(const struct device *dev, umode_t *mode) { +#endif if (mode != NULL) *mode = 0666; // Set default permissions to read and write for user, group, and others return NULL; // Return NULL as no specific device node name alteration is required } @@ -157,7 +160,11 @@ int Map_Init(void) { // Step 4: Create a device class pr_info("%s: Init: Creating device class\n", MOD_NAME); +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0) gCl = class_create(THIS_MODULE, dev.devName); +#else + gCl = class_create(dev.devName); +#endif if (IS_ERR(gCl)) { pr_err("%s: Init: Failed to create device class\n", MOD_NAME); unregister_chrdev_region(dev.devNum, 1); // Clean up allocated resources diff --git a/petalinux/aximemorymap/files/aximemorymap.h b/petalinux/aximemorymap/files/aximemorymap.h index 96d502b..73490d2 100755 --- a/petalinux/aximemorymap/files/aximemorymap.h +++ b/petalinux/aximemorymap/files/aximemorymap.h @@ -30,6 +30,7 @@ #include #include #include +#include #include // Defines the size of the map, set to 64K. @@ -71,7 +72,11 @@ struct MapDevice { }; // Function prototypes for device operations. +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0) char *Map_DevNode(struct device *dev, umode_t *mode); +#else +char *Map_DevNode(const struct device *dev, umode_t *mode); +#endif int Map_Init(void); void Map_Exit(void); int Map_Open(struct inode *inode, struct file *filp); From 89be14364b7c5e6ac2c8640914048bce7cf514de Mon Sep 17 00:00:00 2001 From: Larry Ruckman Date: Sun, 2 Jun 2024 21:02:48 -0700 Subject: [PATCH 2/2] remove file --- diff_output.txt | 60 ------------------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 diff_output.txt diff --git a/diff_output.txt b/diff_output.txt deleted file mode 100644 index c6d0b52..0000000 --- a/diff_output.txt +++ /dev/null @@ -1,60 +0,0 @@ -diff --git a/petalinux/aximemorymap/files/aximemorymap.c b/petalinux/aximemorymap/files/aximemorymap.c -index 68e20f5..ab76304 100644 ---- a/petalinux/aximemorymap/files/aximemorymap.c -+++ b/petalinux/aximemorymap/files/aximemorymap.c -@@ -34,7 +34,6 @@ - #include - #include - #include --#include - - /** - * MODULE_NAME - "axi_memory_map" -@@ -112,7 +111,11 @@ struct file_operations MapFunctions = { - * Note: The permissions set by this callback can be overridden by udev rules on - * systems where udev is responsible for device node creation and management. - */ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0) - char *Map_DevNode(struct device *dev, umode_t *mode) { -+#else -+char *Map_DevNode(const struct device *dev, umode_t *mode) { -+#endif - if (mode != NULL) *mode = 0666; // Set default permissions to read and write for user, group, and others - return NULL; // Return NULL as no specific device node name alteration is required - } -@@ -157,7 +160,11 @@ int Map_Init(void) { - - // Step 4: Create a device class - pr_info("%s: Init: Creating device class\n", MOD_NAME); -+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0) - gCl = class_create(THIS_MODULE, dev.devName); -+#else -+ gCl = class_create(dev.devName); -+#endif - if (IS_ERR(gCl)) { - pr_err("%s: Init: Failed to create device class\n", MOD_NAME); - unregister_chrdev_region(dev.devNum, 1); // Clean up allocated resources -diff --git a/petalinux/aximemorymap/files/aximemorymap.h b/petalinux/aximemorymap/files/aximemorymap.h -index 96d502b..73490d2 100755 ---- a/petalinux/aximemorymap/files/aximemorymap.h -+++ b/petalinux/aximemorymap/files/aximemorymap.h -@@ -30,6 +30,7 @@ - #include - #include - #include -+#include - #include - - // Defines the size of the map, set to 64K. -@@ -71,7 +72,11 @@ struct MapDevice { - }; - - // Function prototypes for device operations. -+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0) - char *Map_DevNode(struct device *dev, umode_t *mode); -+#else -+char *Map_DevNode(const struct device *dev, umode_t *mode); -+#endif - int Map_Init(void); - void Map_Exit(void); - int Map_Open(struct inode *inode, struct file *filp);