[PATCH] identify mbm modems by GUID
- From: Jonas Sjöquist <jonas sjoquist ericsson com>
- To: <networkmanager-list gnome org>
- Subject: [PATCH] identify mbm modems by GUID
- Date: Fri, 11 Jun 2010 17:13:19 +0200
Hi,
This patch identifies mbm modems by the GUID in the USB MDLM descriptor. With this solution
there is no need to add vid/pid to an udev rule for every new CDC Ethernet based mbm device.
All mbm devices currently handled the mbm plugin as well as future devices should be identified
by the GUID.
In this patch the GUID is read from the descriptors binary sysfs attribute, it does not use
libudev for this as libudev only seems to handle string attributes.
I would appreciate if someone could try this patch with SE MD300 or SE MD400 device as I
don't have neither of them.
Regards,
Jonas Sjöquist
---
diff --git a/plugins/77-mm-ericsson-mbm.rules b/plugins/77-mm-ericsson-mbm.rules
deleted file mode 100644
index 8804036..0000000
--- a/plugins/77-mm-ericsson-mbm.rules
+++ /dev/null
@@ -1,51 +0,0 @@
-# do not edit this file, it will be overwritten on update
-
-ACTION!="add|change", GOTO="mm_mbm_end"
-SUBSYSTEM!="usb", GOTO="mm_mbm_end"
-ENV{DEVTYPE}!="usb_device", GOTO="mm_mbm_end"
-
-# Ericsson F3507g
-ATTRS{idVendor}=="0bdb", ATTRS{idProduct}=="1900", ENV{ID_MM_ERICSSON_MBM}="1"
-ATTRS{idVendor}=="0bdb", ATTRS{idProduct}=="1902", ENV{ID_MM_ERICSSON_MBM}="1"
-
-# Ericsson F3607gw
-ATTRS{idVendor}=="0bdb", ATTRS{idProduct}=="1904", ENV{ID_MM_ERICSSON_MBM}="1"
-ATTRS{idVendor}=="0bdb", ATTRS{idProduct}=="1905", ENV{ID_MM_ERICSSON_MBM}="1"
-ATTRS{idVendor}=="0bdb", ATTRS{idProduct}=="1906", ENV{ID_MM_ERICSSON_MBM}="1"
-
-# Ericsson F3307
-ATTRS{idVendor}=="0bdb", ATTRS{idProduct}=="190a", ENV{ID_MM_ERICSSON_MBM}="1"
-ATTRS{idVendor}=="0bdb", ATTRS{idProduct}=="1909", ENV{ID_MM_ERICSSON_MBM}="1"
-
-# Ericsson C3607w
-ATTRS{idVendor}=="0bdb", ATTRS{idProduct}=="1049", ENV{ID_MM_ERICSSON_MBM}="1"
-
-# Ericsson C3607w v2
-ATTRS{idVendor}=="0bdb", ATTRS{idProduct}=="190b", ENV{ID_MM_ERICSSON_MBM}="1"
-
-# Sony-Ericsson MD300
-ATTRS{idVendor}=="0fce", ATTRS{idProduct}=="d0cf", ENV{ID_MM_ERICSSON_MBM}="1"
-
-# Sony-Ericsson MD400
-ATTRS{idVendor}=="0fce", ATTRS{idProduct}=="d0e1", ENV{ID_MM_ERICSSON_MBM}="1"
-
-# Dell 5530 HSDPA
-ATTRS{idVendor}=="413c", ATTRS{idProduct}=="8147", ENV{ID_MM_ERICSSON_MBM}="1"
-
-# Dell F3607gw
-ATTRS{idVendor}=="413c", ATTRS{idProduct}=="8183", ENV{ID_MM_ERICSSON_MBM}="1"
-ATTRS{idVendor}=="413c", ATTRS{idProduct}=="8184", ENV{ID_MM_ERICSSON_MBM}="1"
-
-# Dell F3307
-ATTRS{idVendor}=="413c", ATTRS{idProduct}=="818b", ENV{ID_MM_ERICSSON_MBM}="1"
-ATTRS{idVendor}=="413c", ATTRS{idProduct}=="818c", ENV{ID_MM_ERICSSON_MBM}="1"
-
-# Toshiba
-ATTRS{idVendor}=="0930", ATTRS{idProduct}=="130b", ENV{ID_MM_ERICSSON_MBM}="1"
-
-# Toshiba F3607gw
-ATTRS{idVendor}=="0930", ATTRS{idProduct}=="130c", ENV{ID_MM_ERICSSON_MBM}="1"
-ATTRS{idVendor}=="0930", ATTRS{idProduct}=="1311", ENV{ID_MM_ERICSSON_MBM}="1"
-
-LABEL="mm_mbm_end"
-
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 8192653..e302965 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -277,7 +277,6 @@ libmm_plugin_simtech_la_LDFLAGS = \
udevrulesdir = $(UDEV_BASE_DIR)/rules.d
udevrules_DATA = \
- 77-mm-ericsson-mbm.rules \
77-mm-zte-port-types.rules \
77-mm-longcheer-port-types.rules \
77-mm-simtech-port-types.rules
diff --git a/plugins/mm-plugin-mbm.c b/plugins/mm-plugin-mbm.c
index 5554d84..486af40 100644
--- a/plugins/mm-plugin-mbm.c
+++ b/plugins/mm-plugin-mbm.c
@@ -25,6 +25,9 @@
#include "mm-plugin-mbm.h"
#include "mm-modem-mbm.h"
+#include <fcntl.h>
+#include <unistd.h>
+
G_DEFINE_TYPE (MMPluginMbm, mm_plugin_mbm, MM_TYPE_PLUGIN_BASE)
int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION;
@@ -57,6 +60,8 @@ probe_result (MMPluginBase *base,
mm_plugin_base_supports_task_complete (task, get_level_for_capabilities (capabilities));
}
+#define GUID_OFFSET 0xDF
+
static MMPluginSupportsResult
supports_port (MMPluginBase *base,
MMModem *existing,
@@ -67,7 +72,15 @@ supports_port (MMPluginBase *base,
GUdevDevice *port, *physdev;
guint32 cached = 0, level;
const char *driver, *subsys, *physdev_path;
- gboolean is_mbm;
+ char *desc_path;
+ char desc[4096];
+ int fd;
+ ssize_t size;
+
+ const gchar mbm_guid[16] = {
+ 0xa3, 0x17, 0xa8, 0x8b, 0x04, 0x5e, 0x4f, 0x01,
+ 0xa6, 0x07, 0xc0, 0xff, 0xcb, 0x7e, 0x39, 0x2a,
+ };
/* Can't do anything with non-serial ports */
port = mm_plugin_base_supports_task_get_port (task);
@@ -90,17 +103,30 @@ supports_port (MMPluginBase *base,
/* Look up the port's physical device and see if this port is really an
* 'mbm' modem, since we have no other way of telling.
+ * The 'mbm' modem is identified by the GUID in the MDLM descriptor.
*/
physdev_path = mm_plugin_base_supports_task_get_physdev_path (task);
physdev = g_udev_client_query_by_sysfs_path (client, physdev_path);
g_assert (physdev);
- is_mbm = g_udev_device_get_property_as_boolean (physdev, "ID_MM_ERICSSON_MBM");
g_object_unref (client);
- if (!is_mbm)
+ desc_path = g_strconcat(physdev_path,"/descriptors",NULL);
+
+ fd = open(desc_path, O_RDONLY|O_CLOEXEC);
+ if (fd < 0)
+ return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
+
+ size = read(fd, desc, sizeof(desc));
+ if (size < 0)
+ return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
+
+ if (memcmp(&desc[GUID_OFFSET], mbm_guid, sizeof(mbm_guid)))
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
+ close(fd);
+ g_free(desc_path);
+
if (!strcmp (subsys, "net")) {
mm_plugin_base_supports_task_complete (task, 10);
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]