[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH 1/5] node_device: refactor udevProcessCCW



From: Boris Fiuczynski <fiuczy linux ibm com>

Refactor out CCW address parsing for later reuse.

Reviewed-by: Bjoern Walk <bwalk linux ibm com>
Signed-off-by: Boris Fiuczynski <fiuczy linux ibm com>
---
 src/node_device/node_device_udev.c | 31 ++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index ff558efb..d478a673 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1058,27 +1058,38 @@ udevProcessMediatedDevice(struct udev_device *dev,
 
 
 static int
-udevProcessCCW(struct udev_device *device,
-               virNodeDeviceDefPtr def)
+udevGetCCWAddress(const char *sysfs_path,
+                  virNodeDevCapDataPtr data)
 {
-    int online;
     char *p;
-    virNodeDevCapDataPtr data = &def->caps->data;
-
-    /* process only online devices to keep the list sane */
-    if (udevGetIntSysfsAttr(device, "online", &online, 0) < 0 || online != 1)
-        return -1;
 
-    if ((p = strrchr(def->sysfs_path, '/')) == NULL ||
+    if ((p = strrchr(sysfs_path, '/')) == NULL ||
         virStrToLong_ui(p + 1, &p, 16, &data->ccw_dev.cssid) < 0 || p == NULL ||
         virStrToLong_ui(p + 1, &p, 16, &data->ccw_dev.ssid) < 0 || p == NULL ||
         virStrToLong_ui(p + 1, &p, 16, &data->ccw_dev.devno) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("failed to parse the CCW address from sysfs path: '%s'"),
-                       def->sysfs_path);
+                       sysfs_path);
         return -1;
     }
 
+    return 0;
+}
+
+
+static int
+udevProcessCCW(struct udev_device *device,
+               virNodeDeviceDefPtr def)
+{
+    int online;
+
+    /* process only online devices to keep the list sane */
+    if (udevGetIntSysfsAttr(device, "online", &online, 0) < 0 || online != 1)
+        return -1;
+
+    if (udevGetCCWAddress(def->sysfs_path, &def->caps->data) < 0)
+        return -1;
+
     if (udevGenerateDeviceName(device, def, NULL) != 0)
         return -1;
 
-- 
2.24.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]