rascol / Raspberry-Pi-PPS-Client

Microsecond PPS time synchronization client for Raspberry Pi.
GNU General Public License v2.0
32 stars 6 forks source link

Kernel module not loading with kernel 4.14 #2

Closed scrupeus closed 6 years ago

scrupeus commented 6 years ago

"vfs_read undefined" warning when building the kernel module for kernel 4.14

Apparently vfs_read was deprecated in favour of kernel_read in kernel 4.14. vfs_read still exists but it's not exported. kernel_read wraps vfs_read and the associated code. See fs/read_write.c in the kernel source.

The module can be fixed by changing your file_read function in driver/gps-pps-io.c to the following: (the same solution has been used by various projects)

int file_read(struct file* file, unsigned long long offset, unsigned char* data, unsigned int size) {
    int ret;

#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)
    mm_segment_t oldfs;

    oldfs = get_fs();
    set_fs(get_ds());

    ret = vfs_read(file, data, size, &offset);

    set_fs(oldfs);
#else
    ret = kernel_read(file, data, size, &offset);
#endif
    return ret;
}

The above also requires #include <linux/version.h>

Apologies for not providing a pull request but you may prefer a different solution to #ifdef. Unfortunately, kernel_read has only had its current parameters since September 2017.

Thanks for your code and the impressive docs.

rascol commented 6 years ago

Thanks. I'll look into this. Offhand, it looks like a good solution. Get back to you in a few days.