[PATCH 10/10] huawei: no need to explicitly udev query, as we already have a MMKernelDevice

Aleksander Morgado aleksander at aleksander.es
Sat Aug 6 13:03:38 UTC 2016


This makes the huawei logic work also when udev support isn't built, as we can
rely on the MMKernelDevice, regardless of how it was built.
---
 plugins/huawei/mm-broadband-modem-huawei.c | 48 ++++++++----------------------
 1 file changed, 13 insertions(+), 35 deletions(-)

diff --git a/plugins/huawei/mm-broadband-modem-huawei.c b/plugins/huawei/mm-broadband-modem-huawei.c
index eab747a..1a2f9e5 100644
--- a/plugins/huawei/mm-broadband-modem-huawei.c
+++ b/plugins/huawei/mm-broadband-modem-huawei.c
@@ -27,10 +27,6 @@
 #include <ctype.h>
 #include <time.h>
 
-#if WITH_UDEV
-# include <gudev/gudev.h>
-#endif
-
 #include <ModemManager.h>
 #define _LIBMM_INSIDE_MM
 #include <libmm-glib.h>
@@ -2211,38 +2207,20 @@ ensure_ndisdup_support_checked (MMBroadbandModemHuawei *self,
     if (self->priv->ndisdup_support != FEATURE_SUPPORT_UNKNOWN)
         return;
 
-#if WITH_UDEV
-    {
-        GUdevClient *client;
-        GUdevDevice *data_device;
-
-        /* First, check for devices which support NDISDUP on any AT port. These
-         * devices are tagged by udev */
-        client = g_udev_client_new (NULL);
-        data_device = (g_udev_client_query_by_subsystem_and_name (
-                       client,
-                       "net",
-                       mm_port_get_device (port)));
-        if (data_device && g_udev_device_get_property_as_boolean (data_device, "ID_MM_HUAWEI_NDISDUP_SUPPORTED")) {
-            mm_dbg ("This device (%s) can support ndisdup feature", mm_port_get_device (port));
-            self->priv->ndisdup_support = FEATURE_SUPPORTED;
-        }
-        /* Then, look for devices which have both a net port and a cdc-wdm
-         * AT-capable port. We assume that these devices allow NDISDUP only
-         * when issued in the cdc-wdm port. */
-        else if (peek_port_at_for_data (self, port)) {
-            mm_dbg ("This device (%s) can support ndisdup feature on non-serial AT port",
-                    mm_port_get_device (port));
-            self->priv->ndisdup_support = FEATURE_SUPPORTED;
-        }
-
-        if (data_device)
-            g_object_unref (data_device);
-        g_object_unref (client);
+    /* First, check for devices which support NDISDUP on any AT port. These
+     * devices are tagged by udev */
+    if (mm_kernel_device_get_property_as_boolean (mm_port_peek_kernel_device (port), "ID_MM_HUAWEI_NDISDUP_SUPPORTED")) {
+        mm_dbg ("This device (%s) can support ndisdup feature", mm_port_get_device (port));
+        self->priv->ndisdup_support = FEATURE_SUPPORTED;
+    }
+    /* Then, look for devices which have both a net port and a cdc-wdm
+     * AT-capable port. We assume that these devices allow NDISDUP only
+     * when issued in the cdc-wdm port. */
+    else if (peek_port_at_for_data (self, port)) {
+        mm_dbg ("This device (%s) can support ndisdup feature on non-serial AT port",
+                mm_port_get_device (port));
+        self->priv->ndisdup_support = FEATURE_SUPPORTED;
     }
-#else
-    mm_warn ("NDISDUP support check not implemented");
-#endif
 
     if (self->priv->ndisdup_support != FEATURE_SUPPORT_UNKNOWN)
         return;
-- 
2.9.0



More information about the ModemManager-devel mailing list