aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2020-11-06 12:27:40 +0100
committerAleksander Morgado <aleksander@aleksander.es>2020-11-13 08:57:06 +0000
commit950abbf8ee8624827d63a0d0186beac81232e8f6 (patch)
tree675ff1b0231b196af7530041d167cca7eb4d17fa
parent519df2544b04ccbc9cf87fbfbdbbaf44edeef75b (diff)
core: stop monitoring the 'usb' subsystem
Back in Linux < 3.6 days, the cdc-wdm ports exposed by the QMI driver were flagged as owned by the 'usb' subsystem. That changed in 3.6 when the subsystem was renamed to 'usbmisc': https://mail.gnome.org/archives/networkmanager-list/2012-June/msg00125.html This patch removes all monitoring of the 'usb' subsystem completely, which is anyway a valid subsystem but for which we shouldn't need any special handling. Right now, with newer kernels, we were using that monitoring exclusively to get notified of full USB device remove events, which is really not required as we already process the port removals one by one. We simplify the logic everywhere that attempted to match either the 'usb' or 'usbmisc' subsystems, and we no longer require the explicit checks for the port name being named 'cdc-wdm[0-9]*' in the code, as that is already taken care of by the ID_MM_CANDIDATE udev tag rule.
-rw-r--r--plugins/anydata/mm-plugin-anydata.c2
-rw-r--r--plugins/broadmobi/mm-plugin-broadmobi.c2
-rw-r--r--plugins/cinterion/mm-plugin-cinterion.c2
-rw-r--r--plugins/dell/mm-plugin-dell.c2
-rw-r--r--plugins/dlink/mm-plugin-dlink.c2
-rw-r--r--plugins/fibocom/mm-plugin-fibocom.c2
-rw-r--r--plugins/foxconn/mm-plugin-foxconn.c2
-rw-r--r--plugins/generic/mm-plugin-generic.c2
-rw-r--r--plugins/gosuncn/mm-plugin-gosuncn.c2
-rw-r--r--plugins/huawei/mm-plugin-huawei.c5
-rw-r--r--plugins/mbm/mm-plugin-mbm.c2
-rw-r--r--plugins/novatel/mm-plugin-novatel.c2
-rw-r--r--plugins/pantech/mm-plugin-pantech.c2
-rw-r--r--plugins/quectel/mm-plugin-quectel.c2
-rw-r--r--plugins/sierra/mm-plugin-sierra.c2
-rw-r--r--plugins/simtech/mm-plugin-simtech.c2
-rw-r--r--plugins/telit/mm-plugin-telit.c2
-rw-r--r--plugins/tplink/mm-plugin-tplink.c2
-rw-r--r--plugins/x22x/mm-plugin-x22x.c2
-rw-r--r--plugins/zte/mm-plugin-zte.c2
-rw-r--r--src/80-mm-candidate.rules3
-rw-r--r--src/mm-base-manager.c142
-rw-r--r--src/mm-base-modem.c2
-rw-r--r--src/mm-filter.c2
-rw-r--r--src/mm-plugin.c4
-rw-r--r--src/mm-port-probe.c2
26 files changed, 55 insertions, 143 deletions
diff --git a/plugins/anydata/mm-plugin-anydata.c b/plugins/anydata/mm-plugin-anydata.c
index cc118963..f8c0c30e 100644
--- a/plugins/anydata/mm-plugin-anydata.c
+++ b/plugins/anydata/mm-plugin-anydata.c
@@ -68,7 +68,7 @@ create_modem (MMPlugin *self,
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
- static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
+ static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
static const guint16 vendor_ids[] = { 0x16d5, 0 };
return MM_PLUGIN (
diff --git a/plugins/broadmobi/mm-plugin-broadmobi.c b/plugins/broadmobi/mm-plugin-broadmobi.c
index c6a5782c..6df926d6 100644
--- a/plugins/broadmobi/mm-plugin-broadmobi.c
+++ b/plugins/broadmobi/mm-plugin-broadmobi.c
@@ -67,7 +67,7 @@ create_modem (MMPlugin *self,
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
- static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
+ static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
static const guint16 vendor_ids[] = { 0x2020, 0 };
return MM_PLUGIN (
diff --git a/plugins/cinterion/mm-plugin-cinterion.c b/plugins/cinterion/mm-plugin-cinterion.c
index f2eb5d73..1a58008f 100644
--- a/plugins/cinterion/mm-plugin-cinterion.c
+++ b/plugins/cinterion/mm-plugin-cinterion.c
@@ -181,7 +181,7 @@ grab_port (MMPlugin *self,
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
- static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
+ static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
static const gchar *vendor_strings[] = { "cinterion", "siemens", NULL };
static const guint16 vendor_ids[] = { 0x1e2d, 0x0681, 0 };
static const MMAsyncMethod custom_init = {
diff --git a/plugins/dell/mm-plugin-dell.c b/plugins/dell/mm-plugin-dell.c
index cc0d803b..36c21cf9 100644
--- a/plugins/dell/mm-plugin-dell.c
+++ b/plugins/dell/mm-plugin-dell.c
@@ -491,7 +491,7 @@ grab_port (MMPlugin *self,
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
- static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
+ static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
static const guint16 vendors[] = { 0x413c, 0 };
static const MMAsyncMethod custom_init = {
.async = G_CALLBACK (dell_custom_init),
diff --git a/plugins/dlink/mm-plugin-dlink.c b/plugins/dlink/mm-plugin-dlink.c
index 46c96088..7fb0e962 100644
--- a/plugins/dlink/mm-plugin-dlink.c
+++ b/plugins/dlink/mm-plugin-dlink.c
@@ -67,7 +67,7 @@ create_modem (MMPlugin *self,
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
- static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
+ static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
static const guint16 vendor_ids[] = { 0x2001, 0 };
return MM_PLUGIN (
diff --git a/plugins/fibocom/mm-plugin-fibocom.c b/plugins/fibocom/mm-plugin-fibocom.c
index e2188561..f2189840 100644
--- a/plugins/fibocom/mm-plugin-fibocom.c
+++ b/plugins/fibocom/mm-plugin-fibocom.c
@@ -101,7 +101,7 @@ create_modem (MMPlugin *self,
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
- static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
+ static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
static const guint16 vendor_ids[] = { 0x2cb7, 0 };
static const gchar *drivers[] = { "cdc_mbim", "qmi_wwan", NULL };
diff --git a/plugins/foxconn/mm-plugin-foxconn.c b/plugins/foxconn/mm-plugin-foxconn.c
index 1ad0681b..19071c0b 100644
--- a/plugins/foxconn/mm-plugin-foxconn.c
+++ b/plugins/foxconn/mm-plugin-foxconn.c
@@ -98,7 +98,7 @@ create_modem (MMPlugin *self,
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
- static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
+ static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
static const guint16 vendors[] = { 0x0489, 0 };
return MM_PLUGIN (
diff --git a/plugins/generic/mm-plugin-generic.c b/plugins/generic/mm-plugin-generic.c
index c2e3a07e..f4c73421 100644
--- a/plugins/generic/mm-plugin-generic.c
+++ b/plugins/generic/mm-plugin-generic.c
@@ -91,7 +91,7 @@ create_modem (MMPlugin *self,
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
- static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
+ static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
return MM_PLUGIN (
g_object_new (MM_TYPE_PLUGIN_GENERIC,
diff --git a/plugins/gosuncn/mm-plugin-gosuncn.c b/plugins/gosuncn/mm-plugin-gosuncn.c
index 653ba307..7ac517fa 100644
--- a/plugins/gosuncn/mm-plugin-gosuncn.c
+++ b/plugins/gosuncn/mm-plugin-gosuncn.c
@@ -82,7 +82,7 @@ create_modem (MMPlugin *self,
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
- static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
+ static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
static const guint16 vendor_ids[] = { 0x305a, 0 };
static const gchar *drivers[] = { "qmi_wwan", "cdc_mbim", NULL };
diff --git a/plugins/huawei/mm-plugin-huawei.c b/plugins/huawei/mm-plugin-huawei.c
index cf1ed6f8..4c5c39ed 100644
--- a/plugins/huawei/mm-plugin-huawei.c
+++ b/plugins/huawei/mm-plugin-huawei.c
@@ -556,8 +556,7 @@ fallback_primary_cdcwdm (MMPlugin *self,
if (!mm_port_probe_is_at (probe))
continue;
- if (g_str_has_prefix (mm_port_probe_get_port_subsys (probe), "usb") &&
- g_str_has_prefix (mm_port_probe_get_port_name (probe), "cdc-wdm")) {
+ if (g_str_equal (mm_port_probe_get_port_subsys (probe), "usbmisc")) {
mm_obj_dbg (self, "fallback port type hint applied to first cdc-wmd port found");
g_object_set_data (G_OBJECT (probe), TAG_AT_PORT_FLAGS, GUINT_TO_POINTER (MM_PORT_SERIAL_AT_FLAG_PRIMARY));
return 1;
@@ -700,7 +699,7 @@ grab_port (MMPlugin *self,
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
- static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
+ static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
static const guint16 vendor_ids[] = { 0x12d1, 0 };
static const MMAsyncMethod custom_init = {
.async = G_CALLBACK (huawei_custom_init),
diff --git a/plugins/mbm/mm-plugin-mbm.c b/plugins/mbm/mm-plugin-mbm.c
index cae41d85..ffd633e3 100644
--- a/plugins/mbm/mm-plugin-mbm.c
+++ b/plugins/mbm/mm-plugin-mbm.c
@@ -70,7 +70,7 @@ create_modem (MMPlugin *self,
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
- static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
+ static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
static const gchar *udev_tags[] = {
"ID_MM_ERICSSON_MBM",
NULL
diff --git a/plugins/novatel/mm-plugin-novatel.c b/plugins/novatel/mm-plugin-novatel.c
index f90a8788..b26dcf9a 100644
--- a/plugins/novatel/mm-plugin-novatel.c
+++ b/plugins/novatel/mm-plugin-novatel.c
@@ -76,7 +76,7 @@ create_modem (MMPlugin *self,
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
- static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
+ static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
static const guint16 vendors[] = { 0x1410, 0 };
static const mm_uint16_pair forbidden_products[] = { { 0x1410, 0x9010 }, /* Novatel E362 */
{ 0, 0 } };
diff --git a/plugins/pantech/mm-plugin-pantech.c b/plugins/pantech/mm-plugin-pantech.c
index 5301ea94..6820e383 100644
--- a/plugins/pantech/mm-plugin-pantech.c
+++ b/plugins/pantech/mm-plugin-pantech.c
@@ -130,7 +130,7 @@ grab_port (MMPlugin *self,
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
- static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
+ static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
static const guint16 vendor_ids[] = { 0x106c, 0 };
return MM_PLUGIN (
diff --git a/plugins/quectel/mm-plugin-quectel.c b/plugins/quectel/mm-plugin-quectel.c
index 7d0988b2..d07ee945 100644
--- a/plugins/quectel/mm-plugin-quectel.c
+++ b/plugins/quectel/mm-plugin-quectel.c
@@ -81,7 +81,7 @@ create_modem (MMPlugin *self,
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
- static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
+ static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
static const gchar *vendor_strings[] = { "quectel", NULL };
static const guint16 vendor_ids[] = { 0x2c7c, 0 };
diff --git a/plugins/sierra/mm-plugin-sierra.c b/plugins/sierra/mm-plugin-sierra.c
index 75fdc90d..2ce00f56 100644
--- a/plugins/sierra/mm-plugin-sierra.c
+++ b/plugins/sierra/mm-plugin-sierra.c
@@ -104,7 +104,7 @@ create_modem (MMPlugin *self,
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
- static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
+ static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
static const guint16 vendor_ids[] = { 0x1199, 0 };
static const gchar *drivers[] = { "qmi_wwan", "cdc_mbim", NULL };
diff --git a/plugins/simtech/mm-plugin-simtech.c b/plugins/simtech/mm-plugin-simtech.c
index 48daa842..99c7697d 100644
--- a/plugins/simtech/mm-plugin-simtech.c
+++ b/plugins/simtech/mm-plugin-simtech.c
@@ -68,7 +68,7 @@ create_modem (MMPlugin *self,
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
- static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
+ static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
static const guint16 vendor_ids[] = { 0x1e0e, /* A-Link (for now) */
0 };
diff --git a/plugins/telit/mm-plugin-telit.c b/plugins/telit/mm-plugin-telit.c
index aa6f52ab..3532d2fd 100644
--- a/plugins/telit/mm-plugin-telit.c
+++ b/plugins/telit/mm-plugin-telit.c
@@ -87,7 +87,7 @@ create_modem (MMPlugin *self,
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
- static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
+ static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
/* Vendors: Telit */
static const guint16 vendor_ids[] = { 0x1bc7, 0 };
static const gchar *vendor_strings[] = { "telit", NULL };
diff --git a/plugins/tplink/mm-plugin-tplink.c b/plugins/tplink/mm-plugin-tplink.c
index da70d0f9..4698ba16 100644
--- a/plugins/tplink/mm-plugin-tplink.c
+++ b/plugins/tplink/mm-plugin-tplink.c
@@ -67,7 +67,7 @@ create_modem (MMPlugin *self,
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
- static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
+ static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
static const guint16 vendor_ids[] = { 0x2357, 0 };
return MM_PLUGIN (
diff --git a/plugins/x22x/mm-plugin-x22x.c b/plugins/x22x/mm-plugin-x22x.c
index 248d5fd9..9bfc62d2 100644
--- a/plugins/x22x/mm-plugin-x22x.c
+++ b/plugins/x22x/mm-plugin-x22x.c
@@ -215,7 +215,7 @@ create_modem (MMPlugin *self,
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
- static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
+ static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
/* Vendors: TAMobile and Olivetti */
static const guint16 vendor_ids[] = { 0x1bbb, 0x0b3c, 0 };
/* Only handle X22X tagged devices here. */
diff --git a/plugins/zte/mm-plugin-zte.c b/plugins/zte/mm-plugin-zte.c
index 195ff56f..27dcb4fa 100644
--- a/plugins/zte/mm-plugin-zte.c
+++ b/plugins/zte/mm-plugin-zte.c
@@ -144,7 +144,7 @@ grab_port (MMPlugin *self,
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
- static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
+ static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
static const guint16 vendor_ids[] = { 0x19d2, 0 };
return MM_PLUGIN (
diff --git a/src/80-mm-candidate.rules b/src/80-mm-candidate.rules
index 3d9cd6e7..7e7988e5 100644
--- a/src/80-mm-candidate.rules
+++ b/src/80-mm-candidate.rules
@@ -15,7 +15,6 @@ KERNEL=="rfcomm*", DEVPATH=="*/virtual/*", GOTO="mm_candidate_end"
SUBSYSTEM=="tty", ENV{ID_MM_CANDIDATE}="1"
SUBSYSTEM=="net", ENV{ID_MM_CANDIDATE}="1"
-KERNEL=="cdc-wdm*", SUBSYSTEM=="usb", ENV{ID_MM_CANDIDATE}="1"
-KERNEL=="cdc-wdm*", SUBSYSTEM=="usbmisc", ENV{ID_MM_CANDIDATE}="1"
+KERNEL=="cdc-wdm[0-9]*", SUBSYSTEM=="usbmisc", ENV{ID_MM_CANDIDATE}="1"
LABEL="mm_candidate_end"
diff --git a/src/mm-base-manager.c b/src/mm-base-manager.c
index b8adcdbc..87eddc34 100644
--- a/src/mm-base-manager.c
+++ b/src/mm-base-manager.c
@@ -143,13 +143,6 @@ find_device_by_physdev_uid (MMBaseManager *self,
return g_hash_table_lookup (self->priv->devices, physdev_uid);
}
-static MMDevice *
-find_device_by_kernel_device (MMBaseManager *manager,
- MMKernelDevice *kernel_device)
-{
- return find_device_by_physdev_uid (manager, mm_kernel_device_get_physdev_uid (kernel_device));
-}
-
/*****************************************************************************/
typedef struct {
@@ -221,46 +214,13 @@ static void
device_removed (MMBaseManager *self,
MMKernelDevice *kernel_device)
{
- MMDevice *device;
- const gchar *subsys;
- const gchar *name;
+ g_autoptr(MMDevice) device = NULL;
+ const gchar *name;
g_return_if_fail (kernel_device != NULL);
- subsys = mm_kernel_device_get_subsystem (kernel_device);
- name = mm_kernel_device_get_name (kernel_device);
-
- if (!g_str_has_prefix (subsys, "usb") ||
- (name && g_str_has_prefix (name, "cdc-wdm"))) {
- /* Handle tty/net/wdm port removal */
- device = find_device_by_port (self, kernel_device);
- if (device) {
- /* The callbacks triggered when the port is released or device support is
- * cancelled may end up unreffing the device or removing it from the HT, and
- * so in order to make sure the reference is still valid when we call
- * support_check_cancel() and g_hash_table_remove(), we hold a full reference
- * ourselves. */
- g_object_ref (device);
- {
- mm_obj_info (self, "port %s released by device '%s'", name, mm_device_get_uid (device));
- mm_device_release_port (device, kernel_device);
-
- /* If port probe list gets empty, remove the device object iself */
- if (!mm_device_peek_port_probe_list (device)) {
- mm_obj_dbg (self, "removing empty device '%s'", mm_device_get_uid (device));
- if (mm_plugin_manager_device_support_check_cancel (self->priv->plugin_manager, device))
- mm_obj_dbg (self, "device support check has been cancelled");
-
- /* The device may have already been removed from the tracking HT, we
- * just try to remove it and if it fails, we ignore it */
- mm_device_remove_modem (device);
- g_hash_table_remove (self->priv->devices, mm_device_get_uid (device));
- }
- }
- g_object_unref (device);
- return;
- }
-
+ device = find_device_by_port (self, kernel_device);
+ if (!device) {
/* If the device was inhibited and the port is gone, untrack it.
* This is only needed for ports that were tracked out of device objects.
* In this case we don't rely on the physdev uid, as API-reported
@@ -269,33 +229,27 @@ device_removed (MMBaseManager *self,
return;
}
-#if defined WITH_UDEV
- /* When a USB modem is switching its USB configuration, udev may deliver
- * the remove events of USB interfaces associated with the old USB
- * configuration and the add events of USB interfaces associated with the
- * new USB configuration in an interleaved fashion. As we don't want a
- * remove event of an USB interface trigger the removal of a MMDevice for
- * the special case being handled here, we ignore any remove event with
- * DEVTYPE != usb_device.
- */
- if (g_strcmp0 (mm_kernel_device_get_property (kernel_device, "DEVTYPE"), "usb_device") != 0)
- return;
-#endif
+ /* The callbacks triggered when the port is released or device support is
+ * cancelled may end up unreffing the device or removing it from the HT, and
+ * so in order to make sure the reference is still valid when we call
+ * support_check_cancel() and g_hash_table_remove(), we hold a full reference
+ * ourselves. */
+ g_object_ref (device);
- /* This case is designed to handle the case where, at least with kernel 2.6.31, unplugging
- * an in-use ttyACMx device results in udev generating remove events for the usb, but the
- * ttyACMx device (subsystem tty) is not removed, since it was in-use. So if we have not
- * found a modem for the port (above), we're going to look here to see if we have a modem
- * associated with the newly removed device. If so, we'll remove the modem, since the
- * device has been removed. That way, if the device is reinserted later, we'll go through
- * the process of exporting it.
- */
- device = find_device_by_kernel_device (self, kernel_device);
- if (device) {
- mm_obj_dbg (self, "removing device '%s'", mm_device_get_uid (device));
+ name = mm_kernel_device_get_name (kernel_device);
+ mm_obj_info (self, "port %s released by device '%s'", name, mm_device_get_uid (device));
+ mm_device_release_port (device, kernel_device);
+
+ /* If port probe list gets empty, remove the device object iself */
+ if (!mm_device_peek_port_probe_list (device)) {
+ mm_obj_dbg (self, "removing empty device '%s'", mm_device_get_uid (device));
+ if (mm_plugin_manager_device_support_check_cancel (self->priv->plugin_manager, device))
+ mm_obj_dbg (self, "device support check has been cancelled");
+
+ /* The device may have already been removed from the tracking HT, we
+ * just try to remove it and if it fails, we ignore it */
mm_device_remove_modem (device);
g_hash_table_remove (self->priv->devices, mm_device_get_uid (device));
- return;
}
}
@@ -451,37 +405,17 @@ handle_kernel_event (MMBaseManager *self,
#if defined WITH_UDEV
static void
-handle_uevent (GUdevClient *client,
- const gchar *action,
- GUdevDevice *device,
- gpointer user_data)
+handle_uevent (MMBaseManager *self,
+ const gchar *action,
+ GUdevDevice *device)
{
- MMBaseManager *self;
- const gchar *subsys;
- const gchar *name;
- MMKernelDevice *kernel_device;
-
- self = MM_BASE_MANAGER (user_data);
- g_return_if_fail (action != NULL);
-
- /* A bit paranoid */
- subsys = g_udev_device_get_subsystem (device);
- g_return_if_fail (subsys != NULL);
- g_return_if_fail (g_str_equal (subsys, "tty") || g_str_equal (subsys, "net") || g_str_has_prefix (subsys, "usb"));
+ g_autoptr(MMKernelDevice) kernel_device = NULL;
kernel_device = mm_kernel_device_udev_new (device);
-
- /* We only care about tty/net and usb/cdc-wdm devices when adding modem ports,
- * but for remove, also handle usb parent device remove events
- */
- name = mm_kernel_device_get_name (kernel_device);
- if ( (g_str_equal (action, "add") || g_str_equal (action, "move") || g_str_equal (action, "change"))
- && (!g_str_has_prefix (subsys, "usb") || (name && g_str_has_prefix (name, "cdc-wdm"))))
+ if (g_str_equal (action, "add") || g_str_equal (action, "move") || g_str_equal (action, "change"))
device_added (self, kernel_device, TRUE, FALSE);
else if (g_str_equal (action, "remove"))
device_removed (self, kernel_device);
-
- g_object_unref (kernel_device);
}
typedef struct {
@@ -539,25 +473,9 @@ process_scan (MMBaseManager *self,
}
g_list_free (devices);
- devices = g_udev_client_query_by_subsystem (self->priv->udev, "usb");
- for (iter = devices; iter; iter = g_list_next (iter)) {
- const gchar *name;
-
- name = g_udev_device_get_name (G_UDEV_DEVICE (iter->data));
- if (name && g_str_has_prefix (name, "cdc-wdm"))
- start_device_added (self, G_UDEV_DEVICE (iter->data), manual_scan);
- g_object_unref (G_OBJECT (iter->data));
- }
- g_list_free (devices);
-
- /* Newer kernels report 'usbmisc' subsystem */
devices = g_udev_client_query_by_subsystem (self->priv->udev, "usbmisc");
for (iter = devices; iter; iter = g_list_next (iter)) {
- const gchar *name;
-
- name = g_udev_device_get_name (G_UDEV_DEVICE (iter->data));
- if (name && g_str_has_prefix (name, "cdc-wdm"))
- start_device_added (self, G_UDEV_DEVICE (iter->data), manual_scan);
+ start_device_added (self, G_UDEV_DEVICE (iter->data), manual_scan);
g_object_unref (G_OBJECT (iter->data));
}
g_list_free (devices);
@@ -1449,7 +1367,7 @@ mm_base_manager_init (MMBaseManager *self)
#if defined WITH_UDEV
{
- const gchar *subsys[5] = { "tty", "net", "usb", "usbmisc", NULL };
+ const gchar *subsys[5] = { "tty", "net", "usbmisc", NULL };
/* Setup UDev client */
self->priv->udev = g_udev_client_new (subsys);
@@ -1484,7 +1402,7 @@ initable_init (GInitable *initable,
#if defined WITH_UDEV
/* If autoscan enabled, list for udev events */
if (self->priv->auto_scan)
- g_signal_connect (self->priv->udev, "uevent", G_CALLBACK (handle_uevent), initable);
+ g_signal_connect_swapped (self->priv->udev, "uevent", G_CALLBACK (handle_uevent), initable);
#endif
/* Create filter */
diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c
index a21d7838..09227da5 100644
--- a/src/mm-base-modem.c
+++ b/src/mm-base-modem.c
@@ -276,7 +276,7 @@ mm_base_modem_grab_port (MMBaseModem *self,
port = base_modem_create_net_port (self, name);
else if (g_str_equal (subsys, "tty"))
port = base_modem_create_tty_port (self, name, kernel_device, ptype);
- else if (g_str_has_prefix (subsys, "usb") && g_str_has_prefix (name, "cdc-wdm"))
+ else if (g_str_equal (subsys, "usbmisc"))
port = base_modem_create_usbmisc_port (self, name, ptype);
else if (g_str_equal (subsys, "virtual"))
port = base_modem_create_virtual_port (self, name);
diff --git a/src/mm-filter.c b/src/mm-filter.c
index e91fa398..c5a15312 100644
--- a/src/mm-filter.c
+++ b/src/mm-filter.c
@@ -194,7 +194,7 @@ mm_filter_port (MMFilter *self,
/* If this is a cdc-wdm device, we always allow it */
if ((self->priv->enabled_rules & MM_FILTER_RULE_USBMISC) &&
- (g_strcmp0 (subsystem, "usb") == 0 || g_strcmp0 (subsystem, "usbmisc") == 0)) {
+ (g_strcmp0 (subsystem, "usbmisc") == 0)) {
mm_obj_dbg (self, "(%s/%s) port allowed: usbmisc device", subsystem, name);
return TRUE;
}
diff --git a/src/mm-plugin.c b/src/mm-plugin.c
index dc1171d4..a713ddf1 100644
--- a/src/mm-plugin.c
+++ b/src/mm-plugin.c
@@ -217,10 +217,6 @@ apply_subsystem_filter (MMPlugin *self,
for (i = 0; self->priv->subsystems[i]; i++) {
if (g_str_equal (subsys, self->priv->subsystems[i]))
break;
- /* New kernels may report as 'usbmisc' the subsystem */
- else if (g_str_equal (self->priv->subsystems[i], "usb") &&
- g_str_equal (subsys, "usbmisc"))
- break;
}
/* If we didn't match any subsystem: unsupported */
diff --git a/src/mm-port-probe.c b/src/mm-port-probe.c
index 7f8f9157..c6b535b5 100644
--- a/src/mm-port-probe.c
+++ b/src/mm-port-probe.c
@@ -1271,7 +1271,7 @@ serial_open_at (MMPortProbe *self)
gpointer parser;
MMPortSubsys subsys = MM_PORT_SUBSYS_TTY;
- if (g_str_has_prefix (mm_kernel_device_get_subsystem (self->priv->port), "usb"))
+ if (g_str_equal (mm_kernel_device_get_subsystem (self->priv->port), "usbmisc"))
subsys = MM_PORT_SUBSYS_USBMISC;
ctx->serial = MM_PORT_SERIAL (mm_port_serial_at_new (mm_kernel_device_get_name (self->priv->port), subsys));