From f188d5894b5f5f0922fd4b20a14d892f267a8f7c Mon Sep 17 00:00:00 2001 From: Paul Guyot Date: Mon, 6 May 2024 08:23:15 +0200 Subject: [PATCH] Use apt-cache show in CI (#18) * Use apt-cache show in CI * Support kernel 6.1. (#17) * Support kernels 6.2+ Signed-off-by: Paul Guyot Co-authored-by: Fabrice Laurens <33164641+f-laurens@users.noreply.github.com> --- .github/workflows/arm-runner.yml | 8 ++++---- Makefile | 8 ++++++++ cr14.c | 24 ++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/.github/workflows/arm-runner.yml b/.github/workflows/arm-runner.yml index c6bc956..fd469d5 100644 --- a/.github/workflows/arm-runner.yml +++ b/.github/workflows/arm-runner.yml @@ -52,10 +52,10 @@ jobs: cpu: ${{ matrix.cpu }} cpu_info: ${{ matrix.cpu_info }} commands: | - kernel_version=`apt list --installed | grep raspberrypi-kernel | awk 'NR == 1 { print $2 }' | sed -e 's|1:||g'` - arch=`apt list --installed | grep raspberrypi-kernel | awk 'NR == 1 { print $3 }'` - wget -q http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/raspberrypi-kernel-headers_${kernel_version}_${arch}.deb - dpkg --install raspberrypi-kernel-headers_${kernel_version}_${arch}.deb + apt-get update -y --allow-releaseinfo-change + kernel_headers_pkg=`apt-cache show raspberrypi-kernel-headers | sed -n -e 's|Filename: .*/||p'` + wget -q http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/${kernel_headers_pkg} + dpkg --install ${kernel_headers_pkg} apt-get update -y --allow-releaseinfo-change apt-get install --no-install-recommends -y libasound2-dev make gcc libc6-dev for builddir in /lib/modules/*/build ; do diff --git a/Makefile b/Makefile index f913bd3..d1dec54 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,14 @@ endif all: make -C /lib/modules/$(KERNELRELEASE)/build M=$(PWD) modules +# dtbo rule is no longer available +ifeq ($(firstword $(subst ., ,$(KERNELRELEASE))),6) +all: cr14.dtbo + +cr14.dtbo: cr14-overlay.dts + dtc -I dts -O dtb -o $@ $< +endif + clean: make -C /lib/modules/$(KERNELRELEASE)/build M=$(PWD) clean diff --git a/cr14.c b/cr14.c index 3648737..9d9e184 100644 --- a/cr14.c +++ b/cr14.c @@ -21,6 +21,8 @@ #include #include +#include + // ========================================================================== // // PROTOCOL // ========================================================================== // @@ -230,9 +232,17 @@ static ssize_t cr14_write(struct file *file, const char __user *buffer, size_t len, loff_t *ppos); static unsigned int cr14_poll(struct file *file, poll_table *wait); +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0) static int cr14_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id); +#else +static int cr14_i2c_probe(struct i2c_client *i2c); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0) static int cr14_i2c_remove(struct i2c_client *client); +#else +static void cr14_i2c_remove(struct i2c_client *client); +#endif // ========================================================================== // // Polling code @@ -1118,8 +1128,12 @@ static struct file_operations cr14_fops = { // Probing, initialization and cleanup // ========================================================================== // +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0) static int cr14_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) +#else +static int cr14_i2c_probe(struct i2c_client *i2c) +#endif { struct cr14_i2c_data *priv; struct device *dev = &i2c->dev; @@ -1162,7 +1176,11 @@ static int cr14_i2c_probe(struct i2c_client *i2c, } // Create device class +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0) priv->cr14_class = class_create(THIS_MODULE, DEVICE_NAME); +#else + priv->cr14_class = class_create(DEVICE_NAME); +#endif if (IS_ERR(priv->cr14_class)) { err = PTR_ERR(priv->cr14_class); dev_err(dev, "class_create failed: %d", err); @@ -1199,7 +1217,11 @@ static int cr14_i2c_probe(struct i2c_client *i2c, return 0; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0) static int cr14_i2c_remove(struct i2c_client *client) +#else +static void cr14_i2c_remove(struct i2c_client *client) +#endif { struct cr14_i2c_data *priv; priv = i2c_get_clientdata(client); @@ -1220,7 +1242,9 @@ static int cr14_i2c_remove(struct i2c_client *client) del_timer_sync(&priv->polling_timer); cancel_work_sync(&priv->polling_work); +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0) return 0; +#endif } #ifdef CONFIG_OF