From 3c4ae7bde99db0d585e40bd8942ae67d4edc3d25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=A7=E7=80=AC=E7=B4=85=E8=8E=89=E6=A0=96?= Date: Mon, 6 Mar 2023 15:59:20 +0800 Subject: [PATCH 1/2] maintainers: add MakiseKurisu --- maintainers/maintainer-list.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 3db5bdef519f..a10ab9e5ff5c 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -9156,6 +9156,11 @@ githubId = 115218; name = "Felix Richter"; }; + MakiseKurisu = { + github = "MakiseKurisu"; + githubId = 2321672; + name = "Makise Kurisu"; + }; malbarbo = { email = "malbarbo@gmail.com"; github = "malbarbo"; From 924887fec4b1eb69d3c8c166d4730caa51444454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=A7=E7=80=AC=E7=B4=85=E8=8E=89=E6=A0=96?= Date: Mon, 6 Mar 2023 15:59:57 +0800 Subject: [PATCH 2/2] ch9344: init at 1.9 --- pkgs/os-specific/linux/ch9344/default.nix | 48 +++++++++++++++++++ .../fix-incompatible-pointer-types.patch | 22 +++++++++ pkgs/top-level/linux-kernels.nix | 2 + 3 files changed, 72 insertions(+) create mode 100644 pkgs/os-specific/linux/ch9344/default.nix create mode 100644 pkgs/os-specific/linux/ch9344/fix-incompatible-pointer-types.patch diff --git a/pkgs/os-specific/linux/ch9344/default.nix b/pkgs/os-specific/linux/ch9344/default.nix new file mode 100644 index 000000000000..25d7ecf02552 --- /dev/null +++ b/pkgs/os-specific/linux/ch9344/default.nix @@ -0,0 +1,48 @@ +{ stdenv, lib, fetchzip, kernel }: + +stdenv.mkDerivation rec { + pname = "ch9344"; + version = "1.9"; + + src = fetchzip { + name = "CH9344SER_LINUX.zip"; + url = "https://www.wch.cn/downloads/file/386.html#CH9344SER_LINUX.zip"; + hash = "sha256-g55ftAfjKKlUFzGhI1a/O7Eqbz6rkGf1vWuEJjBZxBE="; + }; + + patches = lib.optionals (lib.versionAtLeast kernel.modDirVersion "6.1") [ + # https://github.com/torvalds/linux/commit/a8c11c1520347be74b02312d10ef686b01b525f1 + ./fix-incompatible-pointer-types.patch + ]; + + sourceRoot = "${src.name}/driver"; + hardeningDisable = [ "pic" ]; + nativeBuildInputs = kernel.moduleBuildDependencies; + + preBuild = '' + substituteInPlace Makefile --replace "KERNELDIR :=" "KERNELDIR ?=" + ''; + + makeFlags = [ + "KERNELDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" + ]; + + installPhase = '' + runHook preInstall + install -D ch9344.ko $out/lib/modules/${kernel.modDirVersion}/usb/serial/ch9344.ko + runHook postInstall + ''; + + meta = with lib; { + homepage = "http://www.wch-ic.com/"; + downloadPage = "https://www.wch.cn/downloads/CH9344SER_LINUX_ZIP.html"; + description = "WCH CH9344/CH348 UART driver"; + longDescription = '' + A kernel module for WinChipHead CH9344/CH348 USB To Multi Serial Ports controller. + ''; + # Archive contains no license. + license = licenses.unfree; + platforms = platforms.linux; + maintainers = with maintainers; [ MakiseKurisu ]; + }; +} diff --git a/pkgs/os-specific/linux/ch9344/fix-incompatible-pointer-types.patch b/pkgs/os-specific/linux/ch9344/fix-incompatible-pointer-types.patch new file mode 100644 index 000000000000..31088538733e --- /dev/null +++ b/pkgs/os-specific/linux/ch9344/fix-incompatible-pointer-types.patch @@ -0,0 +1,22 @@ +diff --git a/ch9344.c b/ch9344.c +index 1e37293..a16af82 100644 +--- a/ch9344.c ++++ b/ch9344.c +@@ -79,7 +79,7 @@ static DEFINE_IDR(ch9344_minors); + static DEFINE_MUTEX(ch9344_minors_lock); + + static void ch9344_tty_set_termios(struct tty_struct *tty, +- struct ktermios *termios_old); ++ const struct ktermios *termios_old); + + static int ch9344_get_portnum(int index); + +@@ -1597,7 +1597,7 @@ u8 cal_recv_tmt(__le32 bd) + } + + static void ch9344_tty_set_termios(struct tty_struct *tty, +- struct ktermios *termios_old) ++ const struct ktermios *termios_old) + { + struct ch9344 *ch9344 = tty->driver_data; + struct ktermios *termios = &tty->termios; diff --git a/pkgs/top-level/linux-kernels.nix b/pkgs/top-level/linux-kernels.nix index 14767d88c1f3..a0b0f2d00ad0 100644 --- a/pkgs/top-level/linux-kernels.nix +++ b/pkgs/top-level/linux-kernels.nix @@ -308,6 +308,8 @@ in { bbswitch = callPackage ../os-specific/linux/bbswitch {}; + ch9344 = callPackage ../os-specific/linux/ch9344 { }; + chipsec = callPackage ../tools/security/chipsec { inherit kernel; withDriver = true;