Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update aximemorymap Driver for Compatibility with Kernel 6.4 and Above #141

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion petalinux/aximemorymap/files/aximemorymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include <linux/of_address.h>
#include <linux/of_irq.h>
#include <linux/slab.h>
#include <linux/version.h>

/**
* MODULE_NAME - "axi_memory_map"
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions petalinux/aximemorymap/files/aximemorymap.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <linux/cdev.h>
#include <linux/types.h>
#include <linux/fs.h>
#include <linux/version.h>
#include <DmaDriver.h>

// Defines the size of the map, set to 64K.
Expand Down Expand Up @@ -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);
Expand Down