From ccaf37e00a53047762b16a6fa8929fae9d741145 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 23 Nov 2016 14:59:17 +0100 Subject: [PATCH] accel: Use udev tags to know which driver to use This means that the buffer driver can now handle more than the bog-standard HID sensor hub, and that the polling driver can handle any IIO polling device. Closes: #39 --- src/drv-iio-buffer-accel.c | 7 ++----- src/drv-iio-poll-accel.c | 8 ++------ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/drv-iio-buffer-accel.c b/src/drv-iio-buffer-accel.c index 2691204..3ed58b1 100644 --- a/src/drv-iio-buffer-accel.c +++ b/src/drv-iio-buffer-accel.c @@ -156,13 +156,10 @@ read_orientation (gpointer user_data) static gboolean iio_buffer_accel_discover (GUdevDevice *device) { - if (g_strcmp0 (g_udev_device_get_subsystem (device), "iio") != 0) + if (g_strcmp0 (g_udev_device_get_property (device, "IIO_SENSOR_PROXY_TYPE"), "iio-buffer-accel") != 0) return FALSE; - if (g_strcmp0 ("accel_3d", g_udev_device_get_sysfs_attr (device, "name")) != 0) - return FALSE; - - g_debug ("Found accel_3d at %s", g_udev_device_get_sysfs_path (device)); + g_debug ("Found IIO buffer accelerometer at %s", g_udev_device_get_sysfs_path (device)); return TRUE; } diff --git a/src/drv-iio-poll-accel.c b/src/drv-iio-poll-accel.c index 7173b5d..1571904 100644 --- a/src/drv-iio-poll-accel.c +++ b/src/drv-iio-poll-accel.c @@ -88,14 +88,10 @@ poll_orientation (gpointer user_data) static gboolean iio_poll_accel_discover (GUdevDevice *device) { - if (g_strcmp0 (g_udev_device_get_subsystem (device), "iio") != 0) + if (g_strcmp0 (g_udev_device_get_property (device, "IIO_SENSOR_PROXY_TYPE"), "iio-poll-accel") != 0) return FALSE; - if (g_strcmp0 ("i2c-SMO8500:00", g_udev_device_get_sysfs_attr (device, "name")) != 0 && - g_strcmp0 ("i2c-KIOX000A:00", g_udev_device_get_sysfs_attr (device, "name")) != 0) - return FALSE; - - g_debug ("Found polling accelerometer at %s", g_udev_device_get_sysfs_path (device)); + g_debug ("Found IIO poll accelerometer at %s", g_udev_device_get_sysfs_path (device)); return TRUE; }