]> xenbits.xensource.com Git - libvirt.git/commitdiff
nodedev: Introduce udevHandleOneDevice
authorErik Skultety <eskultet@redhat.com>
Tue, 25 Jul 2017 15:41:31 +0000 (17:41 +0200)
committerErik Skultety <eskultet@redhat.com>
Thu, 17 Aug 2017 14:50:47 +0000 (16:50 +0200)
Let this new method handle the device object we obtained from the
monitor in order to enhance readability.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
src/node_device/node_device_udev.c

index a0e425d515cd8b3adc9f38e69b11ab544e737bb6..f4177455c109806a2d53bee04a0849e93b5ed5fd 100644 (file)
@@ -1598,6 +1598,23 @@ nodeStateCleanup(void)
 }
 
 
+static int
+udevHandleOneDevice(struct udev_device *device)
+{
+    const char *action = udev_device_get_action(device);
+
+    VIR_DEBUG("udev action: '%s'", action);
+
+    if (STREQ(action, "add") || STREQ(action, "change"))
+        return udevAddOneDevice(device);
+
+    if (STREQ(action, "remove"))
+        return udevRemoveOneDevice(device);
+
+    return 0;
+}
+
+
 static void
 udevEventHandleCallback(int watch ATTRIBUTE_UNUSED,
                         int fd,
@@ -1606,7 +1623,6 @@ udevEventHandleCallback(int watch ATTRIBUTE_UNUSED,
 {
     struct udev_device *device = NULL;
     struct udev_monitor *udev_monitor = DRV_STATE_UDEV_MONITOR(driver);
-    const char *action = NULL;
     int udev_fd = -1;
 
     udev_fd = udev_monitor_get_fd(udev_monitor);
@@ -1635,18 +1651,7 @@ udevEventHandleCallback(int watch ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    action = udev_device_get_action(device);
-    VIR_DEBUG("udev action: '%s'", action);
-
-    if (STREQ(action, "add") || STREQ(action, "change")) {
-        udevAddOneDevice(device);
-        goto cleanup;
-    }
-
-    if (STREQ(action, "remove")) {
-        udevRemoveOneDevice(device);
-        goto cleanup;
-    }
+    udevHandleOneDevice(device);
 
  cleanup:
     udev_device_unref(device);