diff options
author | Julian Stecklina <julian.stecklina@cyberus-technology.de> | 2023-01-25 16:44:29 +0100 |
---|---|---|
committer | Julian Stecklina <js@alien8.de> | 2023-01-25 21:22:55 +0100 |
commit | 7e9f022808a42552871b3d3f0ed6726fe2ddf95f (patch) | |
tree | 049e7fe318f55561195bef0e72443e44e64ed9a5 /pkgs/os-specific/linux/ax99100 | |
parent | 1b1f50645af2a70dc93eae18bfd88d330bfbcf7f (diff) | |
download | nixpkgs-7e9f022808a42552871b3d3f0ed6726fe2ddf95f.tar nixpkgs-7e9f022808a42552871b3d3f0ed6726fe2ddf95f.tar.gz nixpkgs-7e9f022808a42552871b3d3f0ed6726fe2ddf95f.tar.bz2 nixpkgs-7e9f022808a42552871b3d3f0ed6726fe2ddf95f.tar.lz nixpkgs-7e9f022808a42552871b3d3f0ed6726fe2ddf95f.tar.xz nixpkgs-7e9f022808a42552871b3d3f0ed6726fe2ddf95f.tar.zst nixpkgs-7e9f022808a42552871b3d3f0ed6726fe2ddf95f.zip |
linuxPackages.ax99100: fix build on newer kernels
Diffstat (limited to 'pkgs/os-specific/linux/ax99100')
3 files changed, 58 insertions, 5 deletions
diff --git a/pkgs/os-specific/linux/ax99100/default.nix b/pkgs/os-specific/linux/ax99100/default.nix index 9167b4e5f89..600e02de707 100644 --- a/pkgs/os-specific/linux/ax99100/default.nix +++ b/pkgs/os-specific/linux/ax99100/default.nix @@ -1,15 +1,35 @@ -{ kernel, stdenv, kmod, lib, fetchzip }: +{ kernel, stdenv, kmod, lib, fetchzip, fetchpatch, dos2unix }: stdenv.mkDerivation { pname = "ax99100"; version = "1.8.0"; - nativeBuildInputs = [ kmod ] ++ kernel.moduleBuildDependencies; + + nativeBuildInputs = [ dos2unix kmod ] ++ kernel.moduleBuildDependencies; + src = fetchzip { url = "https://www.asix.com.tw/en/support/download/file/1229"; sha256 = "1rbp1m01qr6b3nbr72vpbw89pjh8mddc60im78z2yjd951xkbcjh"; 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 + ]; + + patchFlags = [ "-p0" ]; + makeFlags = [ "KDIR='${kernel.dev}/lib/modules/${kernel.modDirVersion}/build'" ]; installPhase = '' @@ -18,12 +38,13 @@ stdenv.mkDerivation ''; meta = { - description = "ASIX AX99100 Serial and Parralel Port driver"; + description = "ASIX AX99100 Serial and Parallel Port driver"; homepage = "https://www.asix.com.tw/en/product/Interface/PCIe_Bridge/AX99100"; # According to the source code in the tarball, the license is gpl2. license = lib.licenses.gpl2; platforms = lib.platforms.linux; - # currently, the build fails with kernels newer than 5.17 - broken = lib.versionAtLeast kernel.version "5.18.0"; + + # Older Linux versions need more patches to work. + broken = lib.versionOlder kernel.version "5.4.0"; }; } 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 new file mode 100644 index 00000000000..05ec0cfad22 --- /dev/null +++ b/pkgs/os-specific/linux/ax99100/kernel-5.18-pci_free_consistent-pci_alloc_consistent.patch @@ -0,0 +1,14 @@ +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 new file mode 100644 index 00000000000..8d75ad454cf --- /dev/null +++ b/pkgs/os-specific/linux/ax99100/kernel-6.1-set_termios-const-ktermios.patch @@ -0,0 +1,18 @@ +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 + { |