diff --git a/profiles/input/hog_device.c b/profiles/input/hog_device.c
index c7b5bcb..ffd7139 100644
--- a/profiles/input/hog_device.c
+++ b/profiles/input/hog_device.c
static void attio_disconnected_cb(gpointer user_data)
{
struct hog_device *hogdev = user_data;
- struct uhid_event ev;
-
- memset(&ev, 0, sizeof(ev));
- ev.type = UHID_DESTROY;
- if (write(hogdev->uhid_fd, &ev, sizeof(ev)) < 0)
- error("Failed to destroy uHID device: %s", strerror(errno));
g_attrib_unregister(hogdev->attrib, hogdev->report_cb_id);
hogdev->report_cb_id = 0;
int hog_device_unregister(const char *path)
{
struct hog_device *hogdev;
+ struct uhid_event ev;
hogdev = find_device_by_path(devices, path);
if (hogdev == NULL)
hogdev->uhid_watch_id = 0;
}
+ memset(&ev, 0, sizeof(ev));
+ ev.type = UHID_DESTROY;
+ if (write(hogdev->uhid_fd, &ev, sizeof(ev)) < 0)
+ error("Failed to destroy uHID device: %s", strerror(errno));
+
close(hogdev->uhid_fd);
hogdev->uhid_fd = -1;