device: Cancel pending SNEP message when removing a device
authorSamuel Ortiz <sameo@linux.intel.com>
Fri, 28 Jun 2013 15:09:32 +0000 (17:09 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 28 Jun 2013 15:10:42 +0000 (17:10 +0200)
src/device.c

index 4f4306b..18b6d1f 100644 (file)
@@ -91,21 +91,6 @@ struct near_device *near_device_get_device(uint32_t adapter_idx,
        return device;
 }
 
-void __near_device_remove(struct near_device *device)
-{
-       char *path = device->path;
-
-       DBG("path %s", device->path);
-
-       if (g_hash_table_lookup(device_hash, device->path) == NULL)
-               return;
-
-       g_dbus_unregister_interface(connection, device->path,
-                                               NFC_DEVICE_INTERFACE);
-
-       g_hash_table_remove(device_hash, path);
-}
-
 const char *__near_device_get_path(struct near_device *device)
 {
        return device->path;
@@ -308,6 +293,24 @@ static const GDBusSignalTable device_signals[] = {
        { }
 };
 
+void __near_device_remove(struct near_device *device)
+{
+       char *path = device->path;
+
+       DBG("path %s", device->path);
+
+       if (g_hash_table_lookup(device_hash, device->path) == NULL)
+               return;
+
+       if (device->push_msg != NULL)
+               push_cb(device->adapter_idx, device->target_idx, EIO);
+
+       g_dbus_unregister_interface(connection, device->path,
+                                               NFC_DEVICE_INTERFACE);
+
+       g_hash_table_remove(device_hash, path);
+}
+
 int near_device_add_data(uint32_t adapter_idx, uint32_t target_idx,
                        uint8_t *data, size_t data_length)
 {