diff --git a/src/driver-test.c b/src/driver-test.c index cb10ad83..5a42932e 100644 --- a/src/driver-test.c +++ b/src/driver-test.c @@ -23,6 +23,8 @@ #include "config.h" +#include + #include "libratbag-private.h" #include "libratbag-test.h" @@ -81,12 +83,15 @@ test_write_profile(struct ratbag_profile *profile) } static int -test_probe(struct ratbag_device *device) +test_fake_probe(struct ratbag_device *device) { - struct ratbag_test_device *test_device; + return -ENODEV; +} - /* FIXME: after the move to hwdb the test_device is no - * longer passed in. */ +static int +test_probe(struct ratbag_device *device, void *data) +{ + struct ratbag_test_device *test_device = data; ratbag_set_drv_data(device, test_device); ratbag_device_init_profiles(device, @@ -109,7 +114,9 @@ test_remove(struct ratbag_device *device) struct ratbag_driver test_driver = { .name = "Test driver", - .probe = test_probe, + .id = "test_driver", + .probe = test_fake_probe, + .__test_probe = test_probe, .remove = test_remove, .read_profile = test_read_profile, .write_profile = test_write_profile, diff --git a/src/libratbag-private.h b/src/libratbag-private.h index 0a97e929..d5dfd878 100644 --- a/src/libratbag-private.h +++ b/src/libratbag-private.h @@ -181,6 +181,8 @@ struct ratbag_driver { int dpi_x, int dpi_y); /* private */ + int (*__test_probe)(struct ratbag_device *device, void *data); + struct list link; }; diff --git a/src/libratbag.c b/src/libratbag.c index 3da09fc0..063cd544 100644 --- a/src/libratbag.c +++ b/src/libratbag.c @@ -294,9 +294,13 @@ ratbag_find_driver(struct ratbag_device *device, int rc; const char *driver_name; - driver_name = udev_prop_value(device->udev_device, "RATBAG_DRIVER"); - if (!driver_name) - return NULL; + if (!test_device) { + driver_name = udev_prop_value(device->udev_device, "RATBAG_DRIVER"); + if (!driver_name) + return NULL; + } else { + driver_name = "test_driver"; + } list_for_each(driver, &ratbag->drivers, link) { if (!streq(driver->id, driver_name)) @@ -304,7 +308,10 @@ ratbag_find_driver(struct ratbag_device *device, device->driver = driver; - rc = driver->probe(device); + if (test_device) + rc = driver->__test_probe(device, test_device); + else + rc = driver->probe(device); if (rc == 0) { if (!ratbag_sanity_check_device(device)) { return NULL;