Skip to content

Commit

Permalink
Support kernels 6.2+
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Guyot <[email protected]>
  • Loading branch information
pguyot committed May 6, 2024
1 parent bea885e commit 8cb0921
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cr14.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,16 @@ 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);
static void cr14_i2c_remove(struct i2c_client *client);
#endif

// ========================================================================== //
Expand Down Expand Up @@ -1124,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 @@ -1168,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

0 comments on commit 8cb0921

Please sign in to comment.