Search Linux Wireless

Re: Compilation error in rtl8821ce driver and possible fix

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/1/19 7:02 PM, Francesco Napoleoni wrote:
Hi

A few days ago I downloaded rtl8821ce wireless network driver from endlessm/
linux repository (master branch), and I managed to build module for kernel
4.19.16 on my Linux laptop, a HP 15-DB0035NL with an AMD Ryzen 5 2500U CPU.

When upgrading to kernel 4.20.5 I could not build the module anymore, the
compilation stopped with an error about the use of get_monotonic_boottime()
function, which apparently was deprecated and has been removed.

I’m no expert in kernel development, however I discovered that such function
has been superseded by ktime_get_boottime_ts64(), and so I tried to use it in
place of get_monotonic_boottime(). The resulting code compiled correctly, and
the module seems to load and work without problem.

The code I changed is in the rtl8821ce/os_dep/linux/ioctl_cfg80211.c (lines
338-339), you can find a patchfile attached here.

Sorry for any mistake I may have done in this report, this is the first time I
do such a thing.

When you use an out-of-kernel driver, then you are responsible for making the changes that result from kernel API changes. For the in-kernel drivers, the person changing the API is responsible for all the fixes. For that reason, I'm not sure that the linux-wireless mailing list was appropriate for your "fix", but I am replying to it just in case someone else needs to fix one of Realtek's drivers.

By the way, your fix will break the driver for anyone trying to go back to kernel 4.19, or for anyone running a 32-bit system. My fix for this problem with Realtek drivers is to make rtw_get_systime_us() to look like this:

static u64 rtw_get_systime_us(void)
{
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0))
        u64 ts;
        ts = ktime_get_boottime();
        return do_div(ts, 1000);
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
        struct timespec ts;
        get_monotonic_boottime(&ts);
        return ((u64)ts.tv_sec * 1000000) + ts.tv_nsec / 1000;
#else
        struct timeval tv;
        do_gettimeofday(&tv);
        return ((u64)tv.tv_sec * 1000000) + tv.tv_usec;
#endif
}

The above version will build on all kernel versions. The use of do_div() is to prevent a missing divide routine in 32-bit systems.

Larry






[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux