Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use apt-cache show in CI #18

Merged
merged 3 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/arm-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 24 additions & 0 deletions cr14.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include <linux/i2c.h>
#include <linux/circ_buf.h>

#include <linux/version.h>

// ========================================================================== //
// PROTOCOL
// ========================================================================== //
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down
Loading