summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-05-02 07:59:59 +0200
committerThomas Haller <thaller@redhat.com>2015-06-05 16:52:50 +0200
commit77a3767d1e7f99a4f59d292eeab9363687697606 (patch)
treebb1e9463afbeec083bf72005234725f97b2179f5
parentce700d94f54eae64d0f3aac0c6ef50a051dd9a2b (diff)
downloadNetworkManager-77a3767d1e7f99a4f59d292eeab9363687697606.tar.gz
platform: move code udev_get_driver() to nmp_utils_udev_get_driver()
-rw-r--r--src/platform/nm-linux-platform.c44
-rw-r--r--src/platform/nm-platform-utils.c41
-rw-r--r--src/platform/nm-platform-utils.h5
3 files changed, 48 insertions, 42 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index e55670c61e..373c59125d 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -58,6 +58,7 @@
#include "nm-core-internal.h"
#include "NetworkManagerUtils.h"
#include "nm-linux-platform.h"
+#include "nm-platform-utils.h"
#include "NetworkManagerUtils.h"
#include "nm-utils.h"
#include "nm-logging.h"
@@ -480,47 +481,6 @@ ethtool_get_permanent_address (const char *ifname,
}
/******************************************************************
- * udev
- ******************************************************************/
-
-static const char *
-udev_get_driver (GUdevDevice *device, int ifindex)
-{
- GUdevDevice *parent = NULL, *grandparent = NULL;
- const char *driver, *subsys;
-
- driver = g_udev_device_get_driver (device);
- if (driver)
- goto out;
-
- /* Try the parent */
- parent = g_udev_device_get_parent (device);
- if (parent) {
- driver = g_udev_device_get_driver (parent);
- if (!driver) {
- /* Try the grandparent if it's an ibmebus device or if the
- * subsys is NULL which usually indicates some sort of
- * platform device like a 'gadget' net interface.
- */
- subsys = g_udev_device_get_subsystem (parent);
- if ( (g_strcmp0 (subsys, "ibmebus") == 0)
- || (subsys == NULL)) {
- grandparent = g_udev_device_get_parent (parent);
- if (grandparent)
- driver = g_udev_device_get_driver (grandparent);
- }
- }
- }
- g_clear_object (&parent);
- g_clear_object (&grandparent);
-
-out:
- /* Intern the string so we don't have to worry about memory
- * management in NMPlatformLink. */
- return g_intern_string (driver);
-}
-
-/******************************************************************
* NMPlatform types and functions
******************************************************************/
@@ -1102,7 +1062,7 @@ init_link (NMPlatform *platform, NMPlatformLink *info, struct rtnl_link *rtnllin
udev_device = g_hash_table_lookup (priv->udev_devices, GINT_TO_POINTER (info->ifindex));
if (udev_device) {
- info->driver = udev_get_driver (udev_device, info->ifindex);
+ info->driver = nmp_utils_udev_get_driver (udev_device);
info->udi = g_udev_device_get_sysfs_path (udev_device);
info->initialized = TRUE;
}
diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c
index 34d4b0a69a..62127142cb 100644
--- a/src/platform/nm-platform-utils.c
+++ b/src/platform/nm-platform-utils.c
@@ -20,4 +20,45 @@
#include "nm-platform-utils.h"
+/******************************************************************
+ * udev
+ ******************************************************************/
+
+const char *
+nmp_utils_udev_get_driver (GUdevDevice *device)
+{
+ GUdevDevice *parent = NULL, *grandparent = NULL;
+ const char *driver, *subsys;
+
+ driver = g_udev_device_get_driver (device);
+ if (driver)
+ goto out;
+
+ /* Try the parent */
+ parent = g_udev_device_get_parent (device);
+ if (parent) {
+ driver = g_udev_device_get_driver (parent);
+ if (!driver) {
+ /* Try the grandparent if it's an ibmebus device or if the
+ * subsys is NULL which usually indicates some sort of
+ * platform device like a 'gadget' net interface.
+ */
+ subsys = g_udev_device_get_subsystem (parent);
+ if ( (g_strcmp0 (subsys, "ibmebus") == 0)
+ || (subsys == NULL)) {
+ grandparent = g_udev_device_get_parent (parent);
+ if (grandparent)
+ driver = g_udev_device_get_driver (grandparent);
+ }
+ }
+ }
+ g_clear_object (&parent);
+ g_clear_object (&grandparent);
+
+out:
+ /* Intern the string so we don't have to worry about memory
+ * management in NMPlatformLink. */
+ return g_intern_string (driver);
+}
+
diff --git a/src/platform/nm-platform-utils.h b/src/platform/nm-platform-utils.h
index a6da1a8934..76f285d7d0 100644
--- a/src/platform/nm-platform-utils.h
+++ b/src/platform/nm-platform-utils.h
@@ -23,7 +23,12 @@
#include "config.h"
+#include <gudev/gudev.h>
+
#include "nm-platform.h"
+const char *nmp_utils_udev_get_driver (GUdevDevice *device);
+
+
#endif /* __NM_PLATFORM_UTILS_H__ */