+static int add_link(idev_element *e, idev_device *d) {
+ idev_link *l;
+
+ assert(e);
+ assert(d);
+
+ l = new0(idev_link, 1);
+ if (!l)
+ return -ENOMEM;
+
+ l->element = e;
+ l->device = d;
+ LIST_PREPEND(links_by_element, e->links, l);
+ LIST_PREPEND(links_by_device, d->links, l);
+ device_attach(d, l);
+
+ return 0;
+}
+
+static int guess_type(struct udev_device *d) {
+ const char *id_key;
+
+ id_key = udev_device_get_property_value(d, "ID_INPUT_KEY");
+ if (streq_ptr(id_key, "1"))
+ return IDEV_DEVICE_KEYBOARD;
+
+ return IDEV_DEVICE_CNT;
+}
+