diff --git a/android/hidhost.c b/android/hidhost.c
index fdbe885..0c0d69d 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
hid_device_free(dev);
}
+static struct hid_device *hid_device_new(const bdaddr_t *addr)
+{
+ struct hid_device *dev;
+
+ dev = g_new0(struct hid_device, 1);
+ bacpy(&dev->dst, addr);
+ dev->state = HAL_HIDHOST_STATE_DISCONNECTED;
+ devices = g_slist_append(devices, dev);
+
+ return dev;
+}
+
static bool hex2buf(const uint8_t *hex, uint8_t *buf, int buf_size)
{
int i, j;
}
if (!dev) {
- dev = g_new0(struct hid_device, 1);
- bacpy(&dev->dst, addr);
- devices = g_slist_append(devices, dev);
+ dev = hid_device_new(addr);
bt_hid_notify_state(dev, HAL_HIDHOST_STATE_CONNECTING);
}
goto failed;
}
- dev = g_new0(struct hid_device, 1);
- bacpy(&dev->dst, &dst);
- dev->state = HAL_HIDHOST_STATE_DISCONNECTED;
+ dev = hid_device_new(&dst);
ba2str(&dev->dst, addr);
DBG("connecting to %s", addr);
- devices = g_slist_append(devices, dev);
-
if (bt_is_device_le(&dst)) {
if (!hog_connect(dev)) {
status = HAL_STATUS_FAILED;
if (l)
return;
- dev = g_new0(struct hid_device, 1);
- bacpy(&dev->dst, &dst);
+ dev = hid_device_new(&dst);
dev->ctrl_io = g_io_channel_ref(chan);
sdp_uuid16_create(&uuid, PNP_INFO_SVCLASS_ID);
return;
}
- devices = g_slist_append(devices, dev);
-
dev->ctrl_watch = g_io_add_watch(dev->ctrl_io,
G_IO_HUP | G_IO_ERR | G_IO_NVAL,
ctrl_watch_cb, dev);