bbswitch: fix build with kernel 5.6+

Closes: #23681 [via git-merge-pr]
This commit is contained in:
Matthias von Faber 2020-04-20 18:09:01 +02:00 committed by Piraty
parent 4936ca03f7
commit 564022931a
No known key found for this signature in database
GPG key ID: 82F2CC796BD07077
3 changed files with 87 additions and 7 deletions

View file

@ -0,0 +1,54 @@
# upstream: yes
From b0fdcfd847ecf5cbe6754b50f0db78600380b9f0 Mon Sep 17 00:00:00 2001
From: Mateusz Mandera <mateusz.mandera@protonmail.com>
Date: Tue, 31 Mar 2020 15:11:30 +0200
Subject: [PATCH 1/2] Use proc_ops structure for kernel version >= 5.6.0
Since 5.6.0, proc_create requires a `struct proc_ops *` argument instead
of `struct file_operations *`.
Commit with the migration in the kernel source can be found at
https://github.com/torvalds/linux/commit/d56c0d45f0e27f814e87a1676b6bdccccbc252e9
---
bbswitch.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git bbswitch.c bbswitch.c
index 228d722..4ce9aae 100644
--- bbswitch.c
+++ bbswitch.c
@@ -35,6 +35,7 @@
#include <linux/suspend.h>
#include <linux/seq_file.h>
#include <linux/pm_runtime.h>
+#include <linux/version.h>
#define BBSWITCH_VERSION "0.8"
@@ -375,6 +376,15 @@ static int bbswitch_pm_handler(struct notifier_block *nbp,
return 0;
}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
+static struct proc_ops bbswitch_fops = {
+ .proc_open = bbswitch_proc_open,
+ .proc_read = seq_read,
+ .proc_write = bbswitch_proc_write,
+ .proc_lseek = seq_lseek,
+ .proc_release= single_release
+};
+#else
static struct file_operations bbswitch_fops = {
.open = bbswitch_proc_open,
.read = seq_read,
@@ -382,6 +392,7 @@ static struct file_operations bbswitch_fops = {
.llseek = seq_lseek,
.release= single_release
};
+#endif
static struct notifier_block nb = {
.notifier_call = &bbswitch_pm_handler
--
2.28.0

View file

@ -0,0 +1,28 @@
# upstream: yes
From ddbd243638c7bc2baecf43a78aff46cdc12e9b2e Mon Sep 17 00:00:00 2001
From: Peter Wu <peter@lekensteyn.nl>
Date: Tue, 26 May 2020 21:43:35 +0200
Subject: [PATCH 2/2] Add missing proc_fs.h header
Required for 'struct proc_ops' since v5.7-rc1 with commit df23e2be3d24
("acpi: Remove header dependency").
---
bbswitch.c | 1 +
1 file changed, 1 insertion(+)
diff --git bbswitch.c bbswitch.c
index 4ce9aae..c0c6713 100644
--- bbswitch.c
+++ bbswitch.c
@@ -35,6 +35,7 @@
#include <linux/suspend.h>
#include <linux/seq_file.h>
#include <linux/pm_runtime.h>
+#include <linux/proc_fs.h>
#include <linux/version.h>
#define BBSWITCH_VERSION "0.8"
--
2.28.0

View file

@ -1,18 +1,16 @@
# Template file for 'bbswitch' # Template file for 'bbswitch'
pkgname=bbswitch pkgname=bbswitch
version=0.8 version=0.8
revision=2 revision=3
hostmakedepends="git" archs=noarch
makedepends="dkms"
depends="dkms" depends="dkms"
dkms_modules="${pkgname} ${version}" short_desc="Kernel module for disabling the nVidia GPU on Optimus laptops"
short_desc="kernel module allowing to switch dedicated graphics card on Optimus laptops"
maintainer="Orphaned <orphan@voidlinux.org>" maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-2" license="GPL-2.0-or-later"
homepage="http://github.com/Bumblebee-Project/bbswitch" homepage="http://github.com/Bumblebee-Project/bbswitch"
archs="i686 x86_64"
distfiles="https://github.com/Bumblebee-Project/bbswitch/archive/v$version.tar.gz" distfiles="https://github.com/Bumblebee-Project/bbswitch/archive/v$version.tar.gz"
checksum=76cabd3f734fb4fe6ebfe3ec9814138d0d6f47d47238521ecbd6a986b60d1477 checksum=76cabd3f734fb4fe6ebfe3ec9814138d0d6f47d47238521ecbd6a986b60d1477
dkms_modules="${pkgname} ${version}"
do_install() { do_install() {
vinstall Makefile 644 usr/src/${pkgname}-${version} vinstall Makefile 644 usr/src/${pkgname}-${version}