ddcci-dkms: update to 0.4.3.

This commit is contained in:
Đoàn Trần Công Danh 2023-07-10 10:59:49 +07:00
parent 7d061de6ef
commit 65342ff66e
5 changed files with 133 additions and 33 deletions

View file

@ -1,30 +0,0 @@
diff --git a/ddcci/ddcci.c b/ddcci/ddcci.c
index 586b6e29b48439e4b6132295c14891e938fe3dbb..ea76352904bb1920a9a816691d30d51591c803fa 100644
--- a/ddcci/ddcci.c
+++ b/ddcci/ddcci.c
@@ -1785,6 +1785,13 @@ static int ddcci_remove(struct i2c_client *client)
return 0;
}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
+static void ddcci_remove_void(struct i2c_client *client)
+{
+ ddcci_remove(client);
+}
+#endif
+
/*
* I2C driver device identification table.
*/
@@ -1806,7 +1813,11 @@ static struct i2c_driver ddcci_driver = {
.id_table = ddcci_idtable,
.probe = ddcci_probe,
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
+ .remove = ddcci_remove_void,
+ #else
.remove = ddcci_remove,
+ #endif
.class = I2C_CLASS_DDC,
.detect = ddcci_detect,
.address_list = I2C_ADDRS(

View file

@ -0,0 +1,99 @@
--- a/ddcci/ddcci.c
+++ b/ddcci/ddcci.c
@@ -35,6 +35,7 @@
static unsigned int delay = 60;
static unsigned short autoprobe_addrs[127] = {0xF0, 0xF2, 0xF4, 0xF6, 0xF8};
static int autoprobe_addr_count = 5;
+static bool is_registered;
static dev_t ddcci_cdev_first;
static dev_t ddcci_cdev_next;
@@ -930,8 +931,7 @@ static struct attribute *ddcci_char_devi
ATTRIBUTE_GROUPS(ddcci_char_device);
/* DDC/CI bus */
-
-static int ddcci_device_uevent(struct device *dev, struct kobj_uevent_env *env)
+static int ddcci_device_uevent(CSTRUCT device *dev, struct kobj_uevent_env *env)
{
struct ddcci_device *device = to_ddcci_device(dev);
char model[ARRAY_SIZE(device->model)];
@@ -1011,7 +1011,7 @@ static void ddcci_device_release(struct
kfree(device);
}
-static char *ddcci_devnode(struct device *dev,
+static char *ddcci_devnode(CSTRUCT device *dev,
umode_t *mode, kuid_t *uid, kgid_t *gid)
{
struct ddcci_device *device;
@@ -1021,7 +1021,7 @@ static char *ddcci_devnode(struct device
device->i2c_client->adapter->nr);
}
-static char *ddcci_dependent_devnode(struct device *dev,
+static char *ddcci_dependent_devnode(CSTRUCT device *dev,
umode_t *mode, kuid_t *uid, kgid_t *gid)
{
struct ddcci_device *device;
@@ -1065,7 +1065,7 @@ static struct device_type ddcci_dependen
* ddcci_verify_device - return parameter as ddcci_device, or NULL
* @dev: device, probably from some driver model iterator
*/
-struct ddcci_device *ddcci_verify_device(struct device *dev)
+struct ddcci_device *ddcci_verify_device(CSTRUCT device *dev)
{
if (unlikely(!dev))
return NULL;
@@ -1100,7 +1100,7 @@ int ddcci_register_driver(struct module
int ret;
/* Can't register until after driver model init */
- if (unlikely(WARN_ON(!ddcci_bus_type.p)))
+ if (unlikely(WARN_ON(!is_registered)))
return -EAGAIN;
pr_debug("registering driver [%s]\n", driver->driver.name);
@@ -1857,6 +1857,7 @@ static int __init ddcci_module_init(void
goto err_drvreg;
}
+ is_registered = true;
pr_debug("ddcci driver initialized\n");
return 0;
@@ -1886,6 +1887,7 @@ static void __exit ddcci_module_exit(voi
i2c_del_driver(&ddcci_driver);
bus_unregister(&ddcci_bus_type);
+ is_registered = false;
unregister_chrdev_region(ddcci_cdev_first, 128);
}
--- a/include/linux/ddcci.h
+++ b/include/linux/ddcci.h
@@ -17,9 +17,14 @@
#include <linux/mod_devicetable.h>
#include <linux/device.h>
#include <linux/cdev.h>
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 2, 0)
+#define CSTRUCT const struct
+#else
+#define CSTRUCT struct
+#endif
#define DDCCI_MODULE_PREFIX "ddcci:"
-
/* Special addresses */
/* default device address (even) */
@@ -132,7 +137,7 @@ int ddcci_register_driver(struct module
ddcci_register_driver(THIS_MODULE, driver)
void ddcci_del_driver(struct ddcci_driver *driver);
-struct ddcci_device *ddcci_verify_device(struct device *dev);
+struct ddcci_device *ddcci_verify_device(CSTRUCT device *dev);
#define module_ddcci_driver(__ddcci_driver) \
module_driver(__ddcci_driver, ddcci_add_driver, \

View file

@ -0,0 +1,17 @@
--- a/ddcci/ddcci.c
+++ b/ddcci/ddcci.c
@@ -1672,8 +1672,14 @@ static int ddcci_detect(struct i2c_clien
}
/* I2C probe function */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
+static int ddcci_probe(struct i2c_client *client)
+{
+ const struct i2c_device_id *id = i2c_client_get_device_id(client);
+#else
static int ddcci_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
+#endif
int i, ret = -ENODEV, tmp;
unsigned char main_addr, addr;
struct ddcci_bus_drv_data *drv_data;

View file

@ -0,0 +1,14 @@
--- a/ddcci/ddcci.c
+++ b/ddcci/ddcci.c
@@ -40,7 +40,11 @@ static bool is_registered;
static dev_t ddcci_cdev_first;
static dev_t ddcci_cdev_next;
static dev_t ddcci_cdev_end;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
+static DEFINE_SEMAPHORE(core_lock, 1);
+#else
static DEFINE_SEMAPHORE(core_lock);
+#endif
struct bus_type ddcci_bus_type;
EXPORT_SYMBOL_GPL(ddcci_bus_type);

View file

@ -1,14 +1,14 @@
# Template file for 'ddcci-dkms'
pkgname=ddcci-dkms
version=0.4.2
revision=2
version=0.4.3
revision=1
depends="dkms"
short_desc="Pair of Linux kernel drivers for DDC/CI monitors (DKMS)"
maintainer="Subhaditya Nath <sn03.general@gmail.com>"
license="GPL-2.0-or-later"
homepage="https://gitlab.com/ddcci-driver-linux/ddcci-driver-linux/"
distfiles="https://gitlab.com/ddcci-driver-linux/ddcci-driver-linux/-/archive/v${version}/ddcci-driver-linux-v${version}.tar.gz"
checksum=ae70c6049c9020ce0557f3ccf3a3982be760c007410eb0441c668f30116edabd
checksum=2c13fb0a66fea3fcd0070c7cce07ec3943550dee667f066562f810b8c2f01656
dkms_modules="ddcci ${version}"
do_install() {