core: no need to check Capabilities during port probing

Capabilities checking is done during the Modem interface initialization.
This commit is contained in:
Aleksander Morgado
2011-11-23 11:08:33 +01:00
parent 6552393c8e
commit fa01e7a6d3
6 changed files with 4 additions and 212 deletions

View File

@@ -60,7 +60,6 @@ typedef struct {
gboolean sort_last;
/* Plugin-specific setups */
guint32 capabilities;
const gchar **subsystems;
const gchar **drivers;
const guint16 *vendor_ids;
@@ -76,7 +75,6 @@ typedef struct {
enum {
PROP_0,
PROP_NAME,
PROP_ALLOWED_CAPABILITIES,
PROP_ALLOWED_SUBSYSTEMS,
PROP_ALLOWED_DRIVERS,
PROP_ALLOWED_VENDOR_IDS,
@@ -408,12 +406,6 @@ apply_post_probing_filters (MMPluginBase *self,
MMPluginBasePrivate *priv = MM_PLUGIN_BASE_GET_PRIVATE (self);
guint i;
/* The plugin may specify that only some capabilities are supported. If that
* is the case, filter by capabilities */
if (priv->capabilities &&
!(priv->capabilities & mm_port_probe_get_capabilities (probe)))
return TRUE;
/* The plugin may specify that only some vendor strings are supported. If
* that is the case, filter by vendor string. */
if (priv->vendor_strings) {
@@ -643,8 +635,6 @@ supports_port (MMPlugin *plugin,
/* Build flags depending on what probing needed */
probe_run_flags = 0;
if (priv->capabilities)
probe_run_flags |= MM_PORT_PROBE_AT_CAPABILITIES;
if (need_vendor_probing)
probe_run_flags |= MM_PORT_PROBE_AT_VENDOR;
if (need_product_probing)
@@ -770,10 +760,6 @@ set_property (GObject *object, guint prop_id,
/* Construct only */
priv->name = g_value_dup_string (value);
break;
case PROP_ALLOWED_CAPABILITIES:
/* Construct only */
priv->capabilities = (guint32)g_value_get_uint (value);
break;
case PROP_ALLOWED_SUBSYSTEMS:
/* Construct only */
priv->subsystems = (const gchar **)g_value_get_pointer (value);
@@ -834,9 +820,6 @@ get_property (GObject *object, guint prop_id,
case PROP_NAME:
g_value_set_string (value, priv->name);
break;
case PROP_ALLOWED_CAPABILITIES:
g_value_set_uint (value, (guint)priv->capabilities);
break;
case PROP_ALLOWED_SUBSYSTEMS:
g_value_set_pointer (value, (gpointer)priv->subsystems);
break;
@@ -910,14 +893,6 @@ mm_plugin_base_class_init (MMPluginBaseClass *klass)
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property
(object_class, PROP_ALLOWED_CAPABILITIES,
g_param_spec_uint (MM_PLUGIN_BASE_ALLOWED_CAPABILITIES,
"Allowed capabilities",
"Mask of capabilities this plugin can support",
0, G_MAXUINT, 0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property
(object_class, PROP_ALLOWED_SUBSYSTEMS,
g_param_spec_pointer (MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS,

View File

@@ -35,7 +35,6 @@
#define MM_PLUGIN_BASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_BASE, MMPluginBaseClass))
#define MM_PLUGIN_BASE_NAME "name"
#define MM_PLUGIN_BASE_ALLOWED_CAPABILITIES "allowed-capabilities"
#define MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS "allowed-subsystems"
#define MM_PLUGIN_BASE_ALLOWED_DRIVERS "allowed-drivers"
#define MM_PLUGIN_BASE_ALLOWED_VENDOR_IDS "allowed-vendor-ids"

View File

@@ -73,123 +73,6 @@ mm_port_probe_at_command_get_probing (void)
return at_probing;
}
/* ---- CAPABILITIES probing ---- */
struct modem_caps {
gchar *name;
guint32 bits;
};
static const struct modem_caps modem_caps[] = {
{ "+CGSM", MM_PORT_PROBE_CAPABILITY_GSM },
{ "+CIS707-A", MM_PORT_PROBE_CAPABILITY_IS707_A },
{ "+CIS707A", MM_PORT_PROBE_CAPABILITY_IS707_A }, /* Cmotech */
{ "+CIS707", MM_PORT_PROBE_CAPABILITY_IS707_A },
{ "CIS707", MM_PORT_PROBE_CAPABILITY_IS707_A }, /* Qualcomm Gobi */
{ "+CIS707P", MM_PORT_PROBE_CAPABILITY_IS707_P },
{ "CIS-856", MM_PORT_PROBE_CAPABILITY_IS856 },
{ "+IS-856", MM_PORT_PROBE_CAPABILITY_IS856 }, /* Cmotech */
{ "CIS-856-A", MM_PORT_PROBE_CAPABILITY_IS856_A },
{ "CIS-856A", MM_PORT_PROBE_CAPABILITY_IS856_A }, /* Kyocera KPC680 */
{ "+DS", MM_PORT_PROBE_CAPABILITY_DS },
{ "+ES", MM_PORT_PROBE_CAPABILITY_ES },
{ "+MS", MM_PORT_PROBE_CAPABILITY_MS },
{ "+FCLASS", MM_PORT_PROBE_CAPABILITY_FCLASS },
{ NULL }
};
static gboolean
parse_caps_gcap (const gchar *response,
const GError *error,
GValue *result,
GError **result_error)
{
const struct modem_caps *cap = modem_caps;
guint32 ret = 0;
/* Some modems (Huawei E160g) won't respond to +GCAP with no SIM, but
* will respond to ATI. Ignore the error and continue.
*/
if (response && strstr (response, "+CME ERROR:"))
return FALSE;
while (cap->name) {
if (strstr (response, cap->name))
ret |= cap->bits;
cap++;
}
/* No result built? */
if (ret == 0)
return FALSE;
g_value_init (result, G_TYPE_UINT);
g_value_set_uint (result, (guint)ret);
return TRUE;
}
static gboolean
parse_caps_cpin (const gchar *response,
const GError *error,
GValue *result,
GError **result_error)
{
if (strcasestr (response, "SIM PIN") ||
strcasestr (response, "SIM PUK") ||
strcasestr (response, "PH-SIM PIN") ||
strcasestr (response, "PH-FSIM PIN") ||
strcasestr (response, "PH-FSIM PUK") ||
strcasestr (response, "SIM PIN2") ||
strcasestr (response, "SIM PUK2") ||
strcasestr (response, "PH-NET PIN") ||
strcasestr (response, "PH-NET PUK") ||
strcasestr (response, "PH-NETSUB PIN") ||
strcasestr (response, "PH-NETSUB PUK") ||
strcasestr (response, "PH-SP PIN") ||
strcasestr (response, "PH-SP PUK") ||
strcasestr (response, "PH-CORP PIN") ||
strcasestr (response, "PH-CORP PUK") ||
strcasestr (response, "READY")) {
/* At least, it's a GSM modem */
g_value_init (result, G_TYPE_UINT);
g_value_set_uint (result, MM_PORT_PROBE_CAPABILITY_GSM);
return TRUE;
}
return FALSE;
}
static gboolean
parse_caps_cgmm (const gchar *response,
const GError *error,
GValue *result,
GError **result_error)
{
if (strstr (response, "GSM900") ||
strstr (response, "GSM1800") ||
strstr (response, "GSM1900") ||
strstr (response, "GSM850")) {
/* At least, it's a GSM modem */
g_value_init (result, G_TYPE_UINT);
g_value_set_uint (result, MM_PORT_PROBE_CAPABILITY_GSM);
return TRUE;
}
return FALSE;
}
static const MMPortProbeAtCommand capabilities_probing[] = {
{ "+GCAP", parse_caps_gcap },
{ "I", parse_caps_gcap },
{ "+CPIN?", parse_caps_cpin },
{ "+CGMM", parse_caps_cgmm },
{ NULL }
};
const MMPortProbeAtCommand *
mm_port_probe_at_command_get_capabilities_probing (void)
{
return capabilities_probing;
}
/* ---- VENDOR probing ---- */
static gboolean

View File

@@ -26,7 +26,6 @@ typedef struct {
/* The response processor. The expected result depends on the
* probing type:
* - AT --> G_TYPE_BOOLEAN
* - Capabilities --> G_TYPE_UINT
* - Vendor --> G_TYPE_STRING
* - Product --> G_TYPE_STRING
* When a result is given, TRUE is returned.
@@ -52,7 +51,6 @@ typedef struct {
/* Default commands used during probing */
const MMPortProbeAtCommand *mm_port_probe_at_command_get_probing (void);
const MMPortProbeAtCommand *mm_port_probe_at_command_get_capabilities_probing (void);
const MMPortProbeAtCommand *mm_port_probe_at_command_get_vendor_probing (void);
const MMPortProbeAtCommand *mm_port_probe_at_command_get_product_probing (void);

View File

@@ -40,7 +40,6 @@
* ----> AT Serial Open
* |----> Custom Init
* |----> AT?
* |----> Capabilities
* |----> Vendor
* |----> Product
* ----> QCDM Serial Open
@@ -83,7 +82,6 @@ struct _MMPortProbePrivate {
guint32 flags;
gboolean is_at;
gboolean is_qcdm;
guint32 capabilities;
gchar *vendor;
gchar *product;
@@ -337,25 +335,6 @@ serial_probe_at_vendor_result_processor (MMPortProbe *self,
self->priv->flags |= MM_PORT_PROBE_AT_VENDOR;
}
static void
serial_probe_at_capabilities_result_processor (MMPortProbe *self,
GValue *result)
{
if (result) {
/* If any result given, it must be a uint */
g_assert (G_VALUE_HOLDS_UINT (result));
mm_dbg ("(%s) capabilities probing finished", self->priv->name);
self->priv->capabilities = (guint32) g_value_get_uint (result);
self->priv->flags |= MM_PORT_PROBE_AT_CAPABILITIES;
return;
}
mm_dbg ("(%s) no result in capabilities probing", self->priv->name);
self->priv->capabilities = 0;
self->priv->flags |= MM_PORT_PROBE_AT_CAPABILITIES;
}
static void
serial_probe_at_result_processor (MMPortProbe *self,
GValue *result)
@@ -379,7 +358,6 @@ serial_probe_at_result_processor (MMPortProbe *self,
mm_dbg ("(%s) port is not AT-capable", self->priv->name);
self->priv->is_at = FALSE;
self->priv->flags |= (MM_PORT_PROBE_AT |
MM_PORT_PROBE_AT_CAPABILITIES |
MM_PORT_PROBE_AT_VENDOR |
MM_PORT_PROBE_AT_PRODUCT);
}
@@ -506,13 +484,6 @@ serial_probe_schedule (MMPortProbe *self)
task->at_result_processor = serial_probe_at_result_processor;
task->at_commands = mm_port_probe_at_command_get_probing ();
}
/* Capabilities requested and not already probed? */
else if ((task->flags & MM_PORT_PROBE_AT_CAPABILITIES) &&
!(self->priv->flags & MM_PORT_PROBE_AT_CAPABILITIES)) {
/* Prepare AT capabilities probing */
task->at_result_processor = serial_probe_at_capabilities_result_processor;
task->at_commands = mm_port_probe_at_command_get_capabilities_probing ();
}
/* Vendor requested and not already probed? */
else if ((task->flags & MM_PORT_PROBE_AT_VENDOR) &&
!(self->priv->flags & MM_PORT_PROBE_AT_VENDOR)) {
@@ -793,8 +764,7 @@ mm_port_probe_run (MMPortProbe *self,
self->priv->task = task;
/* If any AT-specific probing requested, require generic AT check before */
if (task->flags & (MM_PORT_PROBE_AT_CAPABILITIES |
MM_PORT_PROBE_AT_VENDOR |
if (task->flags & (MM_PORT_PROBE_AT_VENDOR |
MM_PORT_PROBE_AT_PRODUCT)) {
task->flags |= MM_PORT_PROBE_AT;
}
@@ -833,15 +803,6 @@ mm_port_probe_is_qcdm (MMPortProbe *self)
return self->priv->is_qcdm;
}
guint32
mm_port_probe_get_capabilities (MMPortProbe *self)
{
g_return_val_if_fail (MM_IS_PORT_PROBE (self), 0);
g_return_val_if_fail (self->priv->flags & MM_PORT_PROBE_AT_CAPABILITIES, 0);
return self->priv->capabilities;
}
GUdevDevice *
mm_port_probe_get_port (MMPortProbe *self)
{

View File

@@ -34,32 +34,9 @@
/* Flags to request port probing */
#define MM_PORT_PROBE_AT 0x0001
#define MM_PORT_PROBE_AT_CAPABILITIES 0x0002
#define MM_PORT_PROBE_AT_VENDOR 0x0004
#define MM_PORT_PROBE_AT_PRODUCT 0x0008
#define MM_PORT_PROBE_QCDM 0x0010
/* Flags to report probed capabilities */
#define MM_PORT_PROBE_CAPABILITY_GSM 0x0001 /* GSM */
#define MM_PORT_PROBE_CAPABILITY_IS707_A 0x0002 /* CDMA Circuit Switched Data */
#define MM_PORT_PROBE_CAPABILITY_IS707_P 0x0004 /* CDMA Packet Switched Data */
#define MM_PORT_PROBE_CAPABILITY_DS 0x0008 /* Data compression selection (v.42bis) */
#define MM_PORT_PROBE_CAPABILITY_ES 0x0010 /* Error control selection (v.42) */
#define MM_PORT_PROBE_CAPABILITY_FCLASS 0x0020 /* Group III Fax */
#define MM_PORT_PROBE_CAPABILITY_MS 0x0040 /* Modulation selection */
#define MM_PORT_PROBE_CAPABILITY_W 0x0080 /* Wireless commands */
#define MM_PORT_PROBE_CAPABILITY_IS856 0x0100 /* CDMA 3G EVDO rev 0 */
#define MM_PORT_PROBE_CAPABILITY_IS856_A 0x0200 /* CDMA 3G EVDO rev A */
#define MM_PORT_PROBE_CAPABILITY_CDMA \
(MM_PORT_PROBE_CAPABILITY_IS707_A | \
MM_PORT_PROBE_CAPABILITY_IS707_P | \
MM_PORT_PROBE_CAPABILITY_IS856 | \
MM_PORT_PROBE_CAPABILITY_IS856_A)
#define MM_PORT_PROBE_CAPABILITY_GSM_OR_CDMA \
(MM_PORT_PROBE_CAPABILITY_CDMA | \
MM_PORT_PROBE_CAPABILITY_GSM)
#define MM_PORT_PROBE_AT_VENDOR 0x0002
#define MM_PORT_PROBE_AT_PRODUCT 0x0004
#define MM_PORT_PROBE_QCDM 0x0008
typedef struct _MMPortProbe MMPortProbe;
typedef struct _MMPortProbeClass MMPortProbeClass;
@@ -101,7 +78,6 @@ gboolean mm_port_probe_run_cancel (MMPortProbe *self);
/* Probing result getters */
gboolean mm_port_probe_is_at (MMPortProbe *self);
gboolean mm_port_probe_is_qcdm (MMPortProbe *self);
guint32 mm_port_probe_get_capabilities (MMPortProbe *self);
const gchar *mm_port_probe_get_vendor (MMPortProbe *self);
const gchar *mm_port_probe_get_product (MMPortProbe *self);