core: don't automatically probe ports of USB<->serial adapters

We should not automatically probe ports marked as coming from USB to serial
adapters, as we're not sure that a modem is behind the adapter. Still, let the
user request a manual scan and have these devices probed in that case.

https://bugzilla.gnome.org/show_bug.cgi?id=647556
https://bugzilla.gnome.org/show_bug.cgi?id=691076
This commit is contained in:
Aleksander Morgado
2013-03-02 14:13:32 +01:00
parent 3678ae5378
commit 8450b7b2a3
6 changed files with 50 additions and 20 deletions

View File

@@ -62,12 +62,6 @@ ATTRS{idVendor}=="0592", ATTRS{idProduct}=="0002", ENV{ID_MM_DEVICE_IGNORE}="1"
# that isn't blacklisted. # that isn't blacklisted.
ATTRS{idVendor}=="0830", ATTRS{idProduct}=="0061", ENV{ID_MM_DEVICE_IGNORE}="1" ATTRS{idVendor}=="0830", ATTRS{idProduct}=="0061", ENV{ID_MM_DEVICE_IGNORE}="1"
# Belkin F5U183 Serial Adapter (unlikely to have a modem behind it)
ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0103", ENV{ID_MM_DEVICE_IGNORE}="1"
# ATEN Intl UC-232A (Prolific)
ATTRS{idVendor}=="0557", ATTRS{idProduct}=="2008", ENV{ID_MM_DEVICE_IGNORE}="1"
# GlobalScaleTechnologies SheevaPlug # GlobalScaleTechnologies SheevaPlug
ATTRS{idVendor}=="9e88", ATTRS{idProduct}=="9e8f", ENV{ID_MM_DEVICE_IGNORE}="1" ATTRS{idVendor}=="9e88", ATTRS{idProduct}=="9e8f", ENV{ID_MM_DEVICE_IGNORE}="1"

View File

@@ -0,0 +1,22 @@
# do not edit this file, it will be overwritten on update
ACTION!="add|change", GOTO="mm_usb_serial_adapters_greylist_end"
SUBSYSTEM!="usb", GOTO="mm_usb_serial_adapters_greylist_end"
ENV{DEVTYPE}!="usb_device", GOTO="mm_usb_serial_adapters_greylist_end"
# Belkin F5U183 Serial Adapter
ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0103", ENV{ID_MM_DEVICE_MANUAL_SCAN_ONLY}="1"
# FTDI-based serial adapters
# FTDI does USB to serial converter ICs; and it's very likely that they'll
# never do modems themselves, so it should be safe to add a rule only based
# on the vendor Id.
ATTRS{idVendor}=="0403", ENV{ID_MM_DEVICE_MANUAL_SCAN_ONLY}="1"
# ATEN Intl UC-232A (Prolific)
ATTRS{idVendor}=="0557", ATTRS{idProduct}=="2008", ENV{ID_MM_DEVICE_MANUAL_SCAN_ONLY}="1"
# Prolific USB to Serial adapter
ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", ENV{ID_MM_DEVICE_MANUAL_SCAN_ONLY}="1"
LABEL="mm_usb_serial_adapters_greylist_end"

View File

@@ -5,6 +5,7 @@ udevrules_DATA = \
77-mm-usb-device-blacklist.rules \ 77-mm-usb-device-blacklist.rules \
77-mm-pcmcia-device-blacklist.rules \ 77-mm-pcmcia-device-blacklist.rules \
77-mm-platform-serial-whitelist.rules \ 77-mm-platform-serial-whitelist.rules \
77-mm-usb-serial-adapters-greylist.rules \
80-mm-candidate.rules 80-mm-candidate.rules
noinst_LTLIBRARIES = libmodem-helpers.la libserial.la noinst_LTLIBRARIES = libmodem-helpers.la libserial.la

View File

@@ -78,9 +78,9 @@ name_acquired_cb (GDBusConnection *connection,
{ {
mm_dbg ("Service name '%s' was acquired", name); mm_dbg ("Service name '%s' was acquired", name);
/* Launch scan for devices */ /* Launch automatic scan for devices */
g_assert (manager); g_assert (manager);
mm_manager_start (manager); mm_manager_start (manager, FALSE);
} }
static void static void

View File

@@ -217,7 +217,8 @@ find_physical_device (GUdevDevice *child)
static void static void
device_added (MMManager *manager, device_added (MMManager *manager,
GUdevDevice *port, GUdevDevice *port,
gboolean hotplugged) gboolean hotplugged,
gboolean manual_scan)
{ {
MMDevice *device; MMDevice *device;
const char *subsys, *name, *physdev_path, *physdev_subsys; const char *subsys, *name, *physdev_path, *physdev_subsys;
@@ -272,6 +273,13 @@ device_added (MMManager *manager,
goto out; goto out;
} }
/* Is the device in the manual-only greylist? If so, return if this is an
* automatic scan. */
if (!manual_scan && g_udev_device_get_property_as_boolean (physdev, "ID_MM_DEVICE_MANUAL_SCAN_ONLY")) {
mm_dbg ("(%s/%s): port probed only in manual scan", subsys, name);
goto out;
}
/* If the physdev is a 'platform' device that's not whitelisted, ignore it */ /* If the physdev is a 'platform' device that's not whitelisted, ignore it */
physdev_subsys = g_udev_device_get_subsystem (physdev); physdev_subsys = g_udev_device_get_subsystem (physdev);
if ( physdev_subsys if ( physdev_subsys
@@ -395,7 +403,7 @@ handle_uevent (GUdevClient *client,
name = g_udev_device_get_name (device); name = g_udev_device_get_name (device);
if ( (g_str_equal (action, "add") || g_str_equal (action, "move") || g_str_equal (action, "change")) 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")))) && (!g_str_has_prefix (subsys, "usb") || (name && g_str_has_prefix (name, "cdc-wdm"))))
device_added (self, device, TRUE); device_added (self, device, TRUE, FALSE);
else if (g_str_equal (action, "remove")) else if (g_str_equal (action, "remove"))
device_removed (self, device); device_removed (self, device);
} }
@@ -403,12 +411,13 @@ handle_uevent (GUdevClient *client,
typedef struct { typedef struct {
MMManager *self; MMManager *self;
GUdevDevice *device; GUdevDevice *device;
gboolean manual_scan;
} StartDeviceAdded; } StartDeviceAdded;
static gboolean static gboolean
start_device_added_idle (StartDeviceAdded *ctx) start_device_added_idle (StartDeviceAdded *ctx)
{ {
device_added (ctx->self, ctx->device, FALSE); device_added (ctx->self, ctx->device, FALSE, ctx->manual_scan);
g_object_unref (ctx->self); g_object_unref (ctx->self);
g_object_unref (ctx->device); g_object_unref (ctx->device);
g_slice_free (StartDeviceAdded, ctx); g_slice_free (StartDeviceAdded, ctx);
@@ -417,36 +426,39 @@ start_device_added_idle (StartDeviceAdded *ctx)
static void static void
start_device_added (MMManager *self, start_device_added (MMManager *self,
GUdevDevice *device) GUdevDevice *device,
gboolean manual_scan)
{ {
StartDeviceAdded *ctx; StartDeviceAdded *ctx;
ctx = g_slice_new (StartDeviceAdded); ctx = g_slice_new (StartDeviceAdded);
ctx->self = g_object_ref (self); ctx->self = g_object_ref (self);
ctx->device = g_object_ref (device); ctx->device = g_object_ref (device);
ctx->manual_scan = manual_scan;
g_idle_add ((GSourceFunc)start_device_added_idle, ctx); g_idle_add ((GSourceFunc)start_device_added_idle, ctx);
} }
void void
mm_manager_start (MMManager *manager) mm_manager_start (MMManager *manager,
gboolean manual_scan)
{ {
GList *devices, *iter; GList *devices, *iter;
g_return_if_fail (manager != NULL); g_return_if_fail (manager != NULL);
g_return_if_fail (MM_IS_MANAGER (manager)); g_return_if_fail (MM_IS_MANAGER (manager));
mm_dbg ("Starting device scan..."); mm_dbg ("Starting %s device scan...", manual_scan ? "manual" : "automatic");
devices = g_udev_client_query_by_subsystem (manager->priv->udev, "tty"); devices = g_udev_client_query_by_subsystem (manager->priv->udev, "tty");
for (iter = devices; iter; iter = g_list_next (iter)) { for (iter = devices; iter; iter = g_list_next (iter)) {
start_device_added (manager, G_UDEV_DEVICE (iter->data)); start_device_added (manager, G_UDEV_DEVICE (iter->data), manual_scan);
g_object_unref (G_OBJECT (iter->data)); g_object_unref (G_OBJECT (iter->data));
} }
g_list_free (devices); g_list_free (devices);
devices = g_udev_client_query_by_subsystem (manager->priv->udev, "net"); devices = g_udev_client_query_by_subsystem (manager->priv->udev, "net");
for (iter = devices; iter; iter = g_list_next (iter)) { for (iter = devices; iter; iter = g_list_next (iter)) {
start_device_added (manager, G_UDEV_DEVICE (iter->data)); start_device_added (manager, G_UDEV_DEVICE (iter->data), manual_scan);
g_object_unref (G_OBJECT (iter->data)); g_object_unref (G_OBJECT (iter->data));
} }
g_list_free (devices); g_list_free (devices);
@@ -457,7 +469,7 @@ mm_manager_start (MMManager *manager)
name = g_udev_device_get_name (G_UDEV_DEVICE (iter->data)); name = g_udev_device_get_name (G_UDEV_DEVICE (iter->data));
if (name && g_str_has_prefix (name, "cdc-wdm")) if (name && g_str_has_prefix (name, "cdc-wdm"))
start_device_added (manager, G_UDEV_DEVICE (iter->data)); start_device_added (manager, G_UDEV_DEVICE (iter->data), manual_scan);
g_object_unref (G_OBJECT (iter->data)); g_object_unref (G_OBJECT (iter->data));
} }
g_list_free (devices); g_list_free (devices);
@@ -469,7 +481,7 @@ mm_manager_start (MMManager *manager)
name = g_udev_device_get_name (G_UDEV_DEVICE (iter->data)); name = g_udev_device_get_name (G_UDEV_DEVICE (iter->data));
if (name && g_str_has_prefix (name, "cdc-wdm")) if (name && g_str_has_prefix (name, "cdc-wdm"))
start_device_added (manager, G_UDEV_DEVICE (iter->data)); start_device_added (manager, G_UDEV_DEVICE (iter->data), manual_scan);
g_object_unref (G_OBJECT (iter->data)); g_object_unref (G_OBJECT (iter->data));
} }
g_list_free (devices); g_list_free (devices);
@@ -629,7 +641,7 @@ scan_devices_auth_ready (MMAuthProvider *authp,
g_dbus_method_invocation_take_error (ctx->invocation, error); g_dbus_method_invocation_take_error (ctx->invocation, error);
else { else {
/* Otherwise relaunch device scan */ /* Otherwise relaunch device scan */
mm_manager_start (MM_MANAGER (ctx->self)); mm_manager_start (MM_MANAGER (ctx->self), TRUE);
mm_gdbus_org_freedesktop_modem_manager1_complete_scan_devices ( mm_gdbus_org_freedesktop_modem_manager1_complete_scan_devices (
MM_GDBUS_ORG_FREEDESKTOP_MODEM_MANAGER1 (ctx->self), MM_GDBUS_ORG_FREEDESKTOP_MODEM_MANAGER1 (ctx->self),
ctx->invocation); ctx->invocation);

View File

@@ -48,7 +48,8 @@ GType mm_manager_get_type (void);
MMManager *mm_manager_new (GDBusConnection *bus, MMManager *mm_manager_new (GDBusConnection *bus,
GError **error); GError **error);
void mm_manager_start (MMManager *manager); void mm_manager_start (MMManager *manager,
gboolean manual_scan);
void mm_manager_shutdown (MMManager *manager); void mm_manager_shutdown (MMManager *manager);