plugin: avoid unneeded vendor/product AT probing if already passed USB ID filter
Don't require vendor/product string probing if the plugin already had vendor/product ID filters and we actually passed those.
This commit is contained in:
@@ -326,16 +326,27 @@ apply_pre_probing_filters (MMPlugin *self,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we need to filter by vendor/product strings, need to probe for both.
|
/* Check if we need vendor/product string probing
|
||||||
* This covers the case where a RS232 modem is connected via a USB<->RS232
|
* Only require these probings if the corresponding filters are given, and:
|
||||||
* adaptor, and we get in udev the vendor ID of the adaptor */
|
* 1) if there was no vendor/product ID probing
|
||||||
|
* 2) if there was vendor/product ID probing but we got filtered
|
||||||
if (self->priv->product_strings ||
|
*
|
||||||
self->priv->forbidden_product_strings) {
|
* In other words, don't require vendor/product string probing if the plugin
|
||||||
*need_vendor_probing = TRUE;
|
* already had vendor/product ID filters and we actually passed those. */
|
||||||
*need_product_probing = TRUE;
|
if ((!self->priv->vendor_ids && !self->priv->product_ids) ||
|
||||||
} else if (self->priv->vendor_strings)
|
vendor_filtered ||
|
||||||
*need_vendor_probing = TRUE;
|
product_filtered) {
|
||||||
|
/* If product strings related filters around, we need to probe for both
|
||||||
|
* vendor and product strings */
|
||||||
|
if (self->priv->product_strings ||
|
||||||
|
self->priv->forbidden_product_strings) {
|
||||||
|
*need_vendor_probing = TRUE;
|
||||||
|
*need_product_probing = TRUE;
|
||||||
|
}
|
||||||
|
/* If only vendor string filter is needed, only probe for vendor string */
|
||||||
|
else if (self->priv->vendor_strings)
|
||||||
|
*need_vendor_probing = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* The plugin may specify that only ports with some given udev tags are
|
/* The plugin may specify that only ports with some given udev tags are
|
||||||
* supported. If that is the case, filter by udev tag */
|
* supported. If that is the case, filter by udev tag */
|
||||||
@@ -362,6 +373,7 @@ apply_pre_probing_filters (MMPlugin *self,
|
|||||||
/* Returns TRUE if the support check request was filtered out */
|
/* Returns TRUE if the support check request was filtered out */
|
||||||
static gboolean
|
static gboolean
|
||||||
apply_post_probing_filters (MMPlugin *self,
|
apply_post_probing_filters (MMPlugin *self,
|
||||||
|
MMPortProbeFlag flags,
|
||||||
MMPortProbe *probe)
|
MMPortProbe *probe)
|
||||||
{
|
{
|
||||||
gboolean vendor_filtered = FALSE;
|
gboolean vendor_filtered = FALSE;
|
||||||
@@ -369,7 +381,8 @@ apply_post_probing_filters (MMPlugin *self,
|
|||||||
|
|
||||||
/* The plugin may specify that only some vendor strings are supported. If
|
/* The plugin may specify that only some vendor strings are supported. If
|
||||||
* that is the case, filter by vendor string. */
|
* that is the case, filter by vendor string. */
|
||||||
if (self->priv->vendor_strings) {
|
if ((flags & MM_PORT_PROBE_AT_VENDOR) &&
|
||||||
|
self->priv->vendor_strings) {
|
||||||
const gchar *vendor;
|
const gchar *vendor;
|
||||||
|
|
||||||
vendor = mm_port_probe_get_vendor (probe);
|
vendor = mm_port_probe_get_vendor (probe);
|
||||||
@@ -409,8 +422,9 @@ apply_post_probing_filters (MMPlugin *self,
|
|||||||
/* The plugin may specify that only some vendor+product string pairs are
|
/* The plugin may specify that only some vendor+product string pairs are
|
||||||
* supported or unsupported. If that is the case, filter by product
|
* supported or unsupported. If that is the case, filter by product
|
||||||
* string */
|
* string */
|
||||||
if (self->priv->product_strings ||
|
if ((flags & MM_PORT_PROBE_AT_PRODUCT) &&
|
||||||
self->priv->forbidden_product_strings) {
|
(self->priv->product_strings ||
|
||||||
|
self->priv->forbidden_product_strings)) {
|
||||||
const gchar *vendor;
|
const gchar *vendor;
|
||||||
const gchar *product;
|
const gchar *product;
|
||||||
|
|
||||||
@@ -545,7 +559,7 @@ port_probe_run_ready (MMPortProbe *probe,
|
|||||||
/* Probing succeeded */
|
/* Probing succeeded */
|
||||||
MMPluginSupportsResult supports_result;
|
MMPluginSupportsResult supports_result;
|
||||||
|
|
||||||
if (!apply_post_probing_filters (ctx->self, probe)) {
|
if (!apply_post_probing_filters (ctx->self, ctx->flags, probe)) {
|
||||||
/* Port is supported! */
|
/* Port is supported! */
|
||||||
supports_result = MM_PLUGIN_SUPPORTS_PORT_SUPPORTED;
|
supports_result = MM_PLUGIN_SUPPORTS_PORT_SUPPORTED;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user