From 2c79712b36331f566500148c8e22ee01f03dcada Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Fri, 7 Nov 2025 11:06:01 -0500 Subject: [PATCH] ax99100: 1.8.0 -> 2.3.0 --- pkgs/os-specific/linux/ax99100/default.nix | 37 +++++-------------- ...free_consistent-pci_alloc_consistent.patch | 14 ------- ...ernel-6.1-set_termios-const-ktermios.patch | 18 --------- .../ax99100/kernel-6.2-fix-pointer-type.patch | 11 ------ .../kernel-6.4-fix-define-semaphore.patch | 14 ------- 5 files changed, 9 insertions(+), 85 deletions(-) delete mode 100644 pkgs/os-specific/linux/ax99100/kernel-5.18-pci_free_consistent-pci_alloc_consistent.patch delete mode 100644 pkgs/os-specific/linux/ax99100/kernel-6.1-set_termios-const-ktermios.patch delete mode 100644 pkgs/os-specific/linux/ax99100/kernel-6.2-fix-pointer-type.patch delete mode 100644 pkgs/os-specific/linux/ax99100/kernel-6.4-fix-define-semaphore.patch diff --git a/pkgs/os-specific/linux/ax99100/default.nix b/pkgs/os-specific/linux/ax99100/default.nix index e4f9a2accc50..83de9068f755 100644 --- a/pkgs/os-specific/linux/ax99100/default.nix +++ b/pkgs/os-specific/linux/ax99100/default.nix @@ -1,5 +1,6 @@ { kernel, + kernelModuleMakeFlags, stdenv, kmod, lib, @@ -9,7 +10,7 @@ stdenv.mkDerivation { pname = "ax99100"; - version = "1.8.0"; + version = "2.3.0"; nativeBuildInputs = [ dos2unix @@ -18,38 +19,16 @@ stdenv.mkDerivation { ++ kernel.moduleBuildDependencies; src = fetchzip { - url = "https://www.asix.com.tw/en/support/download/file/1229"; - sha256 = "1rbp1m01qr6b3nbr72vpbw89pjh8mddc60im78z2yjd951xkbcjh"; + url = "https://www.asix.com.tw/en/support/download/file/1956"; + sha256 = "sha256-acvKb+ohOFrfytgHp9KUVivqDRvgsFgK8bxxHkIh8PU="; extension = "tar.bz2"; }; - prePatch = '' - # The sources come with Windows file endings and that makes - # applying patches hard without first fixing the line endings. - dos2unix *.c *.h - ''; - - # The patches are adapted from: https://aur.archlinux.org/packages/asix-ax99100 - # - # We included them here instead of fetching them, because of line - # ending issues that are easier to fix manually. Also the - # set_termios patch needs to be applied for 6.1 not for 6.0. - patches = [ - ./kernel-5.18-pci_free_consistent-pci_alloc_consistent.patch - ./kernel-6.1-set_termios-const-ktermios.patch - ] - ++ lib.optionals (lib.versionAtLeast kernel.version "6.2") [ - ./kernel-6.2-fix-pointer-type.patch - ./kernel-6.4-fix-define-semaphore.patch - ]; - - patchFlags = [ "-p0" ]; - - makeFlags = [ "KDIR='${kernel.dev}/lib/modules/${kernel.modDirVersion}/build'" ]; + makeFlags = kernelModuleMakeFlags ++ [ "KDIR='${kernel.dev}/lib/modules/${kernel.modDirVersion}'" ]; installPhase = '' mkdir -p $out/lib/modules/${kernel.modDirVersion}/kernel/drivers/tty/serial - cp ax99100.ko $out/lib/modules/${kernel.modDirVersion}/kernel/drivers/tty/serial + cp ax99100x.ko $out/lib/modules/${kernel.modDirVersion}/kernel/drivers/tty/serial ''; meta = { @@ -60,6 +39,8 @@ stdenv.mkDerivation { platforms = lib.platforms.linux; # Older Linux versions need more patches to work. - broken = lib.versionOlder kernel.version "5.4.0"; + # Newer Linux versions switched from a ring buffer to fifo for serial, + # which would require a lot of patching: see Linux commit https://github.com/torvalds/linux/commit/1788cf6a91d9fa9aa61fc2917afe192c23d67f6a. + broken = (kernel.kernelOlder "5.4.0") || (kernel.kernelAtLeast "6.10"); }; } diff --git a/pkgs/os-specific/linux/ax99100/kernel-5.18-pci_free_consistent-pci_alloc_consistent.patch b/pkgs/os-specific/linux/ax99100/kernel-5.18-pci_free_consistent-pci_alloc_consistent.patch deleted file mode 100644 index 05ec0cfad222..000000000000 --- a/pkgs/os-specific/linux/ax99100/kernel-5.18-pci_free_consistent-pci_alloc_consistent.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff -pNaru5 a/ax99100_sp.h b/ax99100_sp.h ---- ax99100_sp.h 2022-06-07 16:55:26.621034945 -0400 -+++ ax99100_sp.h 2022-06-07 16:58:32.488989767 -0400 -@@ -255,5 +255,10 @@ struct custom_eeprom { - #define _INLINE_ - #endif - - #define DEFAULT99100_BAUD 115200 - #endif -+ -+/* #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,18,0) */ -+#define pci_alloc_consistent(hwdev,size,dma_handle) dma_alloc_coherent(&hwdev->dev, size, dma_handle, GFP_ATOMIC) -+#define pci_free_consistent(hwdev,size,vaddr,dma_handle) dma_free_coherent(&hwdev->dev, size, vaddr, dma_handle) -+/* #endif */ diff --git a/pkgs/os-specific/linux/ax99100/kernel-6.1-set_termios-const-ktermios.patch b/pkgs/os-specific/linux/ax99100/kernel-6.1-set_termios-const-ktermios.patch deleted file mode 100644 index 8d75ad454cfe..000000000000 --- a/pkgs/os-specific/linux/ax99100/kernel-6.1-set_termios-const-ktermios.patch +++ /dev/null @@ -1,18 +0,0 @@ -diff -pNaru5 a/ax99100_sp.c b/ax99100_sp.c ---- ax99100_sp.c 2023-01-02 23:44:46.707423858 -0500 -+++ ax99100_sp.c 2023-01-02 23:44:27.171293092 -0500 -@@ -1915,11 +1915,13 @@ static unsigned int serial99100_get_divi - DEBUG("In %s quot=%u----baud=%u-----------------------------END\n",__FUNCTION__,quot,baud); - return quot; - } - - //This is a port ops function to set the terminal settings. --#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,0) -+static void serial99100_set_termios(struct uart_port *port, struct ktermios *termios, const struct ktermios *old) -+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) - static void serial99100_set_termios(struct uart_port *port, struct ktermios *termios, struct ktermios *old) - #else - static void serial99100_set_termios(struct uart_port *port, struct termios *termios, struct termios *old) - #endif - { diff --git a/pkgs/os-specific/linux/ax99100/kernel-6.2-fix-pointer-type.patch b/pkgs/os-specific/linux/ax99100/kernel-6.2-fix-pointer-type.patch deleted file mode 100644 index 39071f2f4798..000000000000 --- a/pkgs/os-specific/linux/ax99100/kernel-6.2-fix-pointer-type.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- ax99100_spi.c -+++ ax99100_spi.c -@@ -76,7 +76,7 @@ int spi_suspend_count; - static unsigned int spi_major = 241; - static unsigned int spi_min_count = 0; - /* device Class */ --static char *ax_devnode(struct device *dev, umode_t *mode) -+static char *ax_devnode(const struct device *dev, umode_t *mode) - { - return kasprintf(GFP_KERNEL, "%s", dev_name(dev)); - } diff --git a/pkgs/os-specific/linux/ax99100/kernel-6.4-fix-define-semaphore.patch b/pkgs/os-specific/linux/ax99100/kernel-6.4-fix-define-semaphore.patch deleted file mode 100644 index 434bb559e177..000000000000 --- a/pkgs/os-specific/linux/ax99100/kernel-6.4-fix-define-semaphore.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- ax99100_sp.c -+++ ax99100_sp.c -@@ -2670,8 +2670,10 @@ static void serial99100_dma_tx_tasklet (unsigned long param) - - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37) - static DECLARE_MUTEX(serial99100_sem); --#else -+#elif LINUX_VERSION_CODE < KERNEL_VERSION(6,4,0) - static DEFINE_SEMAPHORE(serial99100_sem); -+#else -+static DEFINE_SEMAPHORE(serial99100_sem, 1); - #endif - - static struct uart_driver starex_serial_driver = {