100 lines
3.0 KiB
Diff
100 lines
3.0 KiB
Diff
--- 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, \
|