core: compile all ports before creating the modem object

Before this, we only exported the modem to DBus when all ports were organized,
in order to make sure that we select as primary port the one we really want and
not the first AT port grabbed. Given that to get all the ports organized we also
needed to wait to get all the ports grabbed, we can now also defer the creation
of the modem object until all the ports get grabbed. This allows us to create
different types of objects based on the ports available (e.g. we can now create
QMI-supported modem objects if we see a QMI port around).
This commit is contained in:
Aleksander Morgado
2012-08-06 20:06:44 +02:00
parent 4add521a98
commit 815693661c
23 changed files with 1096 additions and 868 deletions
+1 -1
View File
@@ -37,9 +37,9 @@ udevrules_DATA =
pkglib_LTLIBRARIES = \
libmm-plugin-generic.la \
libmm-plugin-nokia.la \
libmm-plugin-cinterion.la \
libmm-plugin-iridium.la \
libmm-plugin-nokia.la \
libmm-plugin-gobi.la \
libmm-plugin-motorola.la \
libmm-plugin-novatel.la \
+24 -36
View File
@@ -32,46 +32,33 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
/*****************************************************************************/
static MMBaseModem *
create_modem (MMPluginBase *plugin,
const gchar *sysfs_path,
const gchar *driver,
guint16 vendor,
guint16 product,
GList *probes,
GError **error)
{
return MM_BASE_MODEM (mm_broadband_modem_anydata_new (sysfs_path,
driver,
mm_plugin_get_name (MM_PLUGIN (plugin)),
vendor,
product));
}
static gboolean
grab_port (MMPluginBase *base,
MMBaseModem *existing,
MMBaseModem *modem,
MMPortProbe *probe,
GError **error)
{
MMBaseModem *modem = NULL;
const gchar *name, *subsys;
guint16 vendor = 0, product = 0;
subsys = mm_port_probe_get_port_subsys (probe);
name = mm_port_probe_get_port_name (probe);
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error_literal (error,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"Could not get modem product ID");
return NULL;
}
/* If this is the first port being grabbed, create a new modem object */
if (!existing)
modem = MM_BASE_MODEM (mm_broadband_modem_anydata_new (mm_port_probe_get_port_physdev (probe),
mm_port_probe_get_port_driver (probe),
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product));
if (!mm_base_modem_grab_port (existing ? existing : modem,
subsys,
name,
mm_port_probe_get_port_type (probe),
MM_AT_PORT_FLAG_NONE,
error)) {
if (modem)
g_object_unref (modem);
return NULL;
}
return existing ? existing : modem;
return mm_base_modem_grab_port (modem,
mm_port_probe_get_port_subsys (probe),
mm_port_probe_get_port_name (probe),
mm_port_probe_get_port_type (probe),
MM_AT_PORT_FLAG_NONE,
error);
}
/*****************************************************************************/
@@ -102,5 +89,6 @@ mm_plugin_anydata_class_init (MMPluginAnydataClass *klass)
{
MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass);
pb_class->create_modem = create_modem;
pb_class->grab_port = grab_port;
}
+26 -35
View File
@@ -17,7 +17,7 @@
* Boston, MA 02111-1307, USA.
*
* Copyright (C) 2011 Ammonit Measurement GmbH
* Copyright (C) 2011 Google Inc.
* Copyright (C) 2011 - 2012 Google Inc.
* Author: Aleksander Morgado <aleksander@lanedo.com>
*/
@@ -36,14 +36,27 @@ int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION;
int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
static MMBaseModem *
create_modem (MMPluginBase *plugin,
const gchar *sysfs_path,
const gchar *driver,
guint16 vendor,
guint16 product,
GList *probes,
GError **error)
{
return MM_BASE_MODEM (mm_broadband_modem_cinterion_new (sysfs_path,
driver,
mm_plugin_get_name (MM_PLUGIN (plugin)),
vendor,
product));
}
static gboolean
grab_port (MMPluginBase *base,
MMBaseModem *existing,
MMBaseModem *modem,
MMPortProbe *probe,
GError **error)
{
MMBaseModem *modem = NULL;
const gchar *name, *subsys, *driver;
guint16 vendor = 0, product = 0;
/* The Cinterion plugin cannot do anything with non-AT ports */
if (!mm_port_probe_is_at (probe)) {
@@ -51,38 +64,15 @@ grab_port (MMPluginBase *base,
MM_CORE_ERROR,
MM_CORE_ERROR_UNSUPPORTED,
"Ignoring non-AT port");
return NULL;
return FALSE;
}
subsys = mm_port_probe_get_port_subsys (probe);
name = mm_port_probe_get_port_name (probe);
driver = mm_port_probe_get_port_driver (probe);
/* Try to get Product IDs from udev. Note that it is not an error
* if we can't get them in our case, as we also support serial
* modems. */
mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product);
/* If this is the first port being grabbed, create a new modem object */
if (!existing)
modem = MM_BASE_MODEM (mm_broadband_modem_cinterion_new (mm_port_probe_get_port_physdev (probe),
driver,
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product));
if (!mm_base_modem_grab_port (existing ? existing : modem,
subsys,
name,
MM_PORT_TYPE_AT, /* we only allow AT ports here */
MM_AT_PORT_FLAG_NONE,
error)) {
if (modem)
g_object_unref (modem);
return NULL;
}
return existing ? existing : modem;
return mm_base_modem_grab_port (modem,
mm_port_probe_get_port_subsys (probe),
mm_port_probe_get_port_name (probe),
MM_PORT_TYPE_AT, /* we only allow AT ports here */
MM_AT_PORT_FLAG_NONE,
error);
}
/*****************************************************************************/
@@ -114,5 +104,6 @@ mm_plugin_cinterion_class_init (MMPluginCinterionClass *klass)
{
MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass);
pb_class->create_modem = create_modem;
pb_class->grab_port = grab_port;
}
+25 -55
View File
@@ -40,19 +40,27 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
/*****************************************************************************/
static MMBaseModem *
create_modem (MMPluginBase *plugin,
const gchar *sysfs_path,
const gchar *driver,
guint16 vendor,
guint16 product,
GList *probes,
GError **error)
{
return MM_BASE_MODEM (mm_broadband_modem_new (sysfs_path,
driver,
mm_plugin_get_name (MM_PLUGIN (plugin)),
vendor,
product));
}
static gboolean
grab_port (MMPluginBase *base,
MMBaseModem *existing,
MMBaseModem *modem,
MMPortProbe *probe,
GError **error)
{
GUdevDevice *port;
MMBaseModem *modem = NULL;
const gchar *name, *subsys, *devfile, *driver;
guint16 vendor = 0, product = 0;
subsys = mm_port_probe_get_port_subsys (probe);
name = mm_port_probe_get_port_name (probe);
/* The generic plugin cannot do anything with non-AT and non-QCDM ports */
if (!mm_port_probe_is_at (probe) &&
!mm_port_probe_is_qcdm (probe)) {
@@ -60,54 +68,15 @@ grab_port (MMPluginBase *base,
MM_CORE_ERROR,
MM_CORE_ERROR_UNSUPPORTED,
"Ignoring non-AT/non-QCDM ports");
return NULL;
return FALSE;
}
driver = mm_port_probe_get_port_driver (probe);
port = mm_port_probe_get_port (probe);
/* Check device file of the port, we expect one */
devfile = g_udev_device_get_device_file (port);
if (!devfile) {
if (!driver || !g_str_equal (driver, "bluetooth")) {
g_set_error (error,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"Could not get port's sysfs file.");
return NULL;
}
mm_warn ("%s: (%s/%s) WARNING: missing udev 'device' file",
mm_plugin_get_name (MM_PLUGIN (base)),
subsys,
name);
}
/* Vendor and Product IDs are really optional, we'll just warn if they
* cannot get loaded */
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product))
mm_warn ("Could not get modem vendor/product ID");
/* If this is the first port being grabbed, create a new modem object */
if (!existing)
modem = MM_BASE_MODEM (mm_broadband_modem_new (mm_port_probe_get_port_physdev (probe),
driver,
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product));
if (!mm_base_modem_grab_port (existing ? existing : modem,
subsys,
name,
mm_port_probe_get_port_type (probe),
MM_AT_PORT_FLAG_NONE,
error)) {
if (modem)
g_object_unref (modem);
return NULL;
}
return existing ? existing : modem;
return mm_base_modem_grab_port (modem,
mm_port_probe_get_port_subsys (probe),
mm_port_probe_get_port_name (probe),
mm_port_probe_get_port_type (probe),
MM_AT_PORT_FLAG_NONE,
error);
}
/*****************************************************************************/
@@ -136,5 +105,6 @@ mm_plugin_generic_class_init (MMPluginGenericClass *klass)
{
MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass);
pb_class->create_modem = create_modem;
pb_class->grab_port = grab_port;
}
+25 -38
View File
@@ -30,56 +30,42 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
/*****************************************************************************/
static MMBaseModem *
create_modem (MMPluginBase *plugin,
const gchar *sysfs_path,
const gchar *driver,
guint16 vendor,
guint16 product,
GList *probes,
GError **error)
{
return MM_BASE_MODEM (mm_broadband_modem_gobi_new (sysfs_path,
driver,
mm_plugin_get_name (MM_PLUGIN (plugin)),
vendor,
product));
}
static gboolean
grab_port (MMPluginBase *base,
MMBaseModem *existing,
MMBaseModem *modem,
MMPortProbe *probe,
GError **error)
{
MMBaseModem *modem = NULL;
const gchar *name, *subsys, *driver;
guint16 vendor = 0, product = 0;
/* The Gobi plugin only handles AT and QCDM ports (for now) */
if (!mm_port_probe_is_at (probe) && !mm_port_probe_is_qcdm (probe)) {
g_set_error_literal (error,
MM_CORE_ERROR,
MM_CORE_ERROR_UNSUPPORTED,
"Ignoring non-AT/non-QCDM port");
return NULL;
return FALSE;
}
subsys = mm_port_probe_get_port_subsys (probe);
name = mm_port_probe_get_port_name (probe);
driver = mm_port_probe_get_port_driver (probe);
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error_literal (error,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"Could not get modem product ID");
return NULL;
}
/* If this is the first port being grabbed, create a new modem object */
if (!existing)
modem = MM_BASE_MODEM (mm_broadband_modem_gobi_new (mm_port_probe_get_port_physdev (probe),
driver,
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product));
if (!mm_base_modem_grab_port (existing ? existing : modem,
subsys,
name,
mm_port_probe_get_port_type (probe),
MM_AT_PORT_FLAG_NONE,
error)) {
if (modem)
g_object_unref (modem);
return NULL;
}
return existing ? existing : modem;
return mm_base_modem_grab_port (modem,
mm_port_probe_get_port_subsys (probe),
mm_port_probe_get_port_name (probe),
mm_port_probe_get_port_type (probe),
MM_AT_PORT_FLAG_NONE,
error);
}
/*****************************************************************************/
@@ -110,5 +96,6 @@ mm_plugin_gobi_class_init (MMPluginGobiClass *klass)
{
MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass);
pb_class->create_modem = create_modem;
pb_class->grab_port = grab_port;
}
+25 -40
View File
@@ -16,11 +16,7 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
<<<<<<< HEAD
* Copyright (C) 2011 Ammonit Measurement GmbH
=======
* Copyright (C) 2011 - 2012 Ammonit Measurement GmbH
>>>>>>> 4ce461e... iridium: start porting the Iridium plugin to the '06-api' codebase
* Author: Aleksander Morgado <aleksander@lanedo.com>
*/
@@ -40,54 +36,42 @@ int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION;
int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
static MMBaseModem *
create_modem (MMPluginBase *plugin,
const gchar *sysfs_path,
const gchar *driver,
guint16 vendor,
guint16 product,
GList *probes,
GError **error)
{
return MM_BASE_MODEM (mm_broadband_modem_iridium_new (sysfs_path,
driver,
mm_plugin_get_name (MM_PLUGIN (plugin)),
vendor,
product));
}
static gboolean
grab_port (MMPluginBase *base,
MMBaseModem *existing,
MMBaseModem *modem,
MMPortProbe *probe,
GError **error)
{
MMBaseModem *modem = NULL;
const gchar *name, *subsys, *driver;
guint16 vendor = 0, product = 0;
/* The Iridium plugin cannot do anything with non-AT ports */
if (!mm_port_probe_is_at (probe)) {
g_set_error_literal (error,
MM_CORE_ERROR,
MM_CORE_ERROR_UNSUPPORTED,
"Ignoring non-AT port");
return NULL;
return FALSE;
}
subsys = mm_port_probe_get_port_subsys (probe);
name = mm_port_probe_get_port_name (probe);
driver = mm_port_probe_get_port_driver (probe);
/* Try to get Product IDs from udev. Note that it is not an error
* if we can't get them in our case, as we also support serial
* modems. */
mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product);
/* If this is the first port being grabbed, create a new modem object */
if (!existing)
modem = MM_BASE_MODEM (mm_broadband_modem_iridium_new (
mm_port_probe_get_port_physdev (probe),
driver,
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product));
if (!mm_base_modem_grab_port (existing ? existing : modem,
subsys,
name,
MM_PORT_TYPE_AT, /* we only allow AT ports here */
MM_AT_PORT_FLAG_NONE,
error)) {
if (modem)
g_object_unref (modem);
return NULL;
}
return existing ? existing : modem;
return mm_base_modem_grab_port (modem,
mm_port_probe_get_port_subsys (probe),
mm_port_probe_get_port_name (probe),
MM_PORT_TYPE_AT, /* we only allow AT ports here */
MM_AT_PORT_FLAG_NONE,
error);
}
/*****************************************************************************/
@@ -123,5 +107,6 @@ mm_plugin_iridium_class_init (MMPluginIridiumClass *klass)
{
MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass);
pb_class->create_modem = create_modem;
pb_class->grab_port = grab_port;
}
+27 -37
View File
@@ -30,15 +30,29 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
/*****************************************************************************/
static MMBaseModem *
create_modem (MMPluginBase *plugin,
const gchar *sysfs_path,
const gchar *driver,
guint16 vendor,
guint16 product,
GList *probes,
GError **error)
{
return MM_BASE_MODEM (mm_broadband_modem_linktop_new (sysfs_path,
driver,
mm_plugin_get_name (MM_PLUGIN (plugin)),
vendor,
product));
}
static gboolean
grab_port (MMPluginBase *base,
MMBaseModem *existing,
MMBaseModem *modem,
MMPortProbe *probe,
GError **error)
{
MMBaseModem *modem = NULL;
GUdevDevice *port;
const gchar *name, *subsys, *devfile;
guint16 vendor = 0, product = 0;
const gchar *devfile;
/* The Linktop plugin cannot do anything with non-AT ports */
if (!mm_port_probe_is_at (probe)) {
@@ -46,7 +60,7 @@ grab_port (MMPluginBase *base,
MM_CORE_ERROR,
MM_CORE_ERROR_UNSUPPORTED,
"Ignoring non-AT port");
return NULL;
return FALSE;
}
port = mm_port_probe_get_port (probe); /* transfer none */
@@ -55,40 +69,15 @@ grab_port (MMPluginBase *base,
devfile = g_udev_device_get_device_file (port);
if (!devfile) {
g_set_error (error, 0, 0, "Could not get port's sysfs file.");
return NULL;
return FALSE;
}
subsys = mm_port_probe_get_port_subsys (probe);
name = mm_port_probe_get_port_name (probe);
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error_literal (error,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"Could not get modem product ID");
return NULL;
}
/* If this is the first port being grabbed, create a new modem object */
if (!existing)
modem = MM_BASE_MODEM (mm_broadband_modem_linktop_new (mm_port_probe_get_port_physdev (probe),
mm_port_probe_get_port_driver (probe),
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product));
if (!mm_base_modem_grab_port (existing ? existing : modem,
subsys,
name,
MM_PORT_TYPE_AT, /* we only allow AT ports here */
MM_AT_PORT_FLAG_NONE,
error)) {
if (modem)
g_object_unref (modem);
return NULL;
}
return existing ? existing : modem;
return mm_base_modem_grab_port (modem,
mm_port_probe_get_port_subsys (probe),
mm_port_probe_get_port_name (probe),
MM_PORT_TYPE_AT, /* we only allow AT ports here */
MM_AT_PORT_FLAG_NONE,
error);
}
/*****************************************************************************/
@@ -118,5 +107,6 @@ mm_plugin_linktop_class_init (MMPluginLinktopClass *klass)
{
MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass);
pb_class->create_modem = create_modem;
pb_class->grab_port = grab_port;
}
+25 -38
View File
@@ -32,56 +32,42 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
/*****************************************************************************/
static MMBaseModem *
create_modem (MMPluginBase *plugin,
const gchar *sysfs_path,
const gchar *driver,
guint16 vendor,
guint16 product,
GList *probes,
GError **error)
{
return MM_BASE_MODEM (mm_broadband_modem_motorola_new (sysfs_path,
driver,
mm_plugin_get_name (MM_PLUGIN (plugin)),
vendor,
product));
}
static gboolean
grab_port (MMPluginBase *base,
MMBaseModem *existing,
MMBaseModem *modem,
MMPortProbe *probe,
GError **error)
{
MMBaseModem *modem = NULL;
const gchar *name, *subsys;
guint16 vendor = 0, product = 0;
/* The Motorola plugin cannot do anything with non-AT ports */
if (!mm_port_probe_is_at (probe)) {
g_set_error_literal (error,
MM_CORE_ERROR,
MM_CORE_ERROR_UNSUPPORTED,
"Ignoring non-AT port");
return NULL;
return FALSE;
}
subsys = mm_port_probe_get_port_subsys (probe);
name = mm_port_probe_get_port_name (probe);
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error_literal (error,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"Could not get modem product ID");
return NULL;
}
/* If this is the first port being grabbed, create a new modem object */
if (!existing)
modem = MM_BASE_MODEM (mm_broadband_modem_motorola_new (
mm_port_probe_get_port_physdev (probe),
mm_port_probe_get_port_driver (probe),
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product));
if (!mm_base_modem_grab_port (existing ? existing : modem,
subsys,
name,
MM_PORT_TYPE_AT, /* we only allow AT ports here */
MM_AT_PORT_FLAG_NONE,
error)) {
if (modem)
g_object_unref (modem);
return NULL;
}
return existing ? existing : modem;
return mm_base_modem_grab_port (modem,
mm_port_probe_get_port_subsys (probe),
mm_port_probe_get_port_name (probe),
MM_PORT_TYPE_AT, /* we only allow AT ports here */
MM_AT_PORT_FLAG_NONE,
error);
}
/*****************************************************************************/
@@ -115,5 +101,6 @@ mm_plugin_motorola_class_init (MMPluginMotorolaClass *klass)
{
MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass);
pb_class->create_modem = create_modem;
pb_class->grab_port = grab_port;
}
+31 -42
View File
@@ -12,7 +12,7 @@
*
* Copyright (C) 2008 - 2009 Novell, Inc.
* Copyright (C) 2009 - 2011 Red Hat, Inc.
* Copyright (C) 2011 Google, Inc.
* Copyright (C) 2011 - 2012 Google, Inc.
*/
#include <string.h>
@@ -42,38 +42,40 @@ static const MMPortProbeAtCommand custom_init[] = {
/*****************************************************************************/
static MMBaseModem *
create_modem (MMPluginBase *plugin,
const gchar *sysfs_path,
const gchar *driver,
guint16 vendor,
guint16 product,
GList *probes,
GError **error)
{
return MM_BASE_MODEM (mm_broadband_modem_nokia_new (sysfs_path,
driver,
mm_plugin_get_name (MM_PLUGIN (plugin)),
vendor,
product));
}
static gboolean
grab_port (MMPluginBase *base,
MMBaseModem *existing,
MMBaseModem *modem,
MMPortProbe *probe,
GError **error)
{
MMBaseModem *modem = NULL;
GUdevDevice *port;
const gchar *name, *subsys, *driver;
guint16 vendor = 0, product = 0;
MMAtPortFlag pflags = MM_AT_PORT_FLAG_NONE;
/* The Nokia plugin cannot do anything with non-AT ports */
/* The Nokia plugin cannot do anything with non-AT */
if (!mm_port_probe_is_at (probe)) {
g_set_error_literal (error,
MM_CORE_ERROR,
MM_CORE_ERROR_UNSUPPORTED,
"Ignoring non-AT port");
return NULL;
g_set_error (error,
MM_CORE_ERROR,
MM_CORE_ERROR_UNSUPPORTED,
"Ignoring non-AT port");
return FALSE;
}
port = mm_port_probe_get_port (probe); /* transfer none */
subsys = mm_port_probe_get_port_subsys (probe);
name = mm_port_probe_get_port_name (probe);
driver = mm_port_probe_get_port_driver (probe);
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error_literal (error,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"Could not get modem product ID");
return NULL;
}
/* Look for port type hints */
if (g_udev_device_get_property_as_boolean (port, "ID_MM_NOKIA_PORT_TYPE_MODEM"))
@@ -81,26 +83,12 @@ grab_port (MMPluginBase *base,
else if (g_udev_device_get_property_as_boolean (port, "ID_MM_NOKIA_PORT_TYPE_AUX"))
pflags = MM_AT_PORT_FLAG_SECONDARY;
/* If this is the first port being grabbed, create a new modem object */
if (!existing)
modem = MM_BASE_MODEM (mm_broadband_modem_nokia_new (mm_port_probe_get_port_physdev (probe),
driver,
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product));
if (!mm_base_modem_grab_port (existing ? existing : modem,
subsys,
name,
MM_PORT_TYPE_AT, /* we only allow AT ports here */
pflags,
error)) {
if (modem)
g_object_unref (modem);
return NULL;
}
return existing ? existing : modem;
return mm_base_modem_grab_port (modem,
mm_port_probe_get_port_subsys (probe),
mm_port_probe_get_port_name (probe),
mm_port_probe_get_port_type (probe),
pflags,
error);
}
/*****************************************************************************/
@@ -131,5 +119,6 @@ mm_plugin_nokia_class_init (MMPluginNokiaClass *klass)
{
MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass);
pb_class->create_modem = create_modem;
pb_class->grab_port = grab_port;
}
+25 -33
View File
@@ -34,49 +34,40 @@ int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION;
int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
static MMBaseModem *
create_modem (MMPluginBase *plugin,
const gchar *sysfs_path,
const gchar *driver,
guint16 vendor,
guint16 product,
GList *probes,
GError **error)
{
return MM_BASE_MODEM (mm_broadband_modem_novatel_new (sysfs_path,
driver,
mm_plugin_get_name (MM_PLUGIN (plugin)),
vendor,
product));
}
static gboolean
grab_port (MMPluginBase *base,
MMBaseModem *existing,
MMBaseModem *modem,
MMPortProbe *probe,
GError **error)
{
MMBaseModem *modem = NULL;
const gchar *name, *subsys, *driver;
guint16 vendor = 0, product = 0;
/* The Novatel plugin uses AT and net ports */
if (!mm_port_probe_is_at (probe) &&
!g_str_equal (mm_port_probe_get_port_subsys (probe), "net")) {
g_set_error (error, 0, 0, "Ignoring non-AT/net port");
return NULL;
return FALSE;
}
subsys = mm_port_probe_get_port_subsys (probe);
name = mm_port_probe_get_port_name (probe);
driver = mm_port_probe_get_port_driver (probe);
/* Try to get Product IDs from udev. */
mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product);
/* If this is the first port being grabbed, create a new modem object */
if (!existing)
modem = MM_BASE_MODEM (mm_broadband_modem_novatel_new (mm_port_probe_get_port_physdev (probe),
driver,
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product));
if (!mm_base_modem_grab_port (existing ? existing : modem,
subsys,
name,
mm_port_probe_get_port_type (probe),
MM_AT_PORT_FLAG_NONE,
error)) {
if (modem)
g_object_unref (modem);
return NULL;
}
return existing ? existing : modem;
return mm_base_modem_grab_port (modem,
mm_port_probe_get_port_subsys (probe),
mm_port_probe_get_port_name (probe),
mm_port_probe_get_port_type (probe),
MM_AT_PORT_FLAG_NONE,
error);
}
/*****************************************************************************/
@@ -107,5 +98,6 @@ mm_plugin_novatel_class_init (MMPluginNovatelClass *klass)
{
MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass);
pb_class->create_modem = create_modem;
pb_class->grab_port = grab_port;
}
+25 -32
View File
@@ -33,15 +33,29 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
/*****************************************************************************/
static MMBaseModem *
create_modem (MMPluginBase *plugin,
const gchar *sysfs_path,
const gchar *driver,
guint16 vendor,
guint16 product,
GList *probes,
GError **error)
{
return MM_BASE_MODEM (mm_broadband_modem_hso_new (sysfs_path,
driver,
mm_plugin_get_name (MM_PLUGIN (plugin)),
vendor,
product));
}
static gboolean
grab_port (MMPluginBase *base,
MMBaseModem *existing,
MMBaseModem *modem,
MMPortProbe *probe,
GError **error)
{
MMBaseModem *modem = NULL;
GUdevDevice *port;
const gchar *name, *subsys, *sysfs_path;
guint16 vendor = 0, product = 0;
MMAtPortFlag pflags = MM_AT_PORT_FLAG_NONE;
gchar *devfile;
MMPortType port_type;
@@ -50,14 +64,6 @@ grab_port (MMPluginBase *base,
subsys = mm_port_probe_get_port_subsys (probe);
name = mm_port_probe_get_port_name (probe);
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error_literal (error,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"Could not get modem product ID");
return NULL;
}
/* Build proper devfile path
* TODO: Why do we need to do this? If this is useful, a comment should be
* added explaining why; if it's not useful, let's get rid of it. */
@@ -79,7 +85,7 @@ grab_port (MMPluginBase *base,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"Could not get port's sysfs file.");
return NULL;
return FALSE;
}
}
g_free (devfile);
@@ -110,26 +116,12 @@ grab_port (MMPluginBase *base,
g_free (hsotype_path);
}
/* If this is the first port being grabbed, create a new modem object */
if (!existing)
modem = MM_BASE_MODEM (mm_broadband_modem_hso_new (mm_port_probe_get_port_physdev (probe),
mm_port_probe_get_port_driver (probe),
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product));
if (!mm_base_modem_grab_port (existing ? existing : modem,
subsys,
name,
port_type,
pflags,
error)) {
if (modem)
g_object_unref (modem);
return NULL;
}
return existing ? existing : modem;
return mm_base_modem_grab_port (modem,
subsys,
name,
port_type,
pflags,
error);
}
/*****************************************************************************/
@@ -160,5 +152,6 @@ mm_plugin_hso_class_init (MMPluginHsoClass *klass)
{
MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass);
pb_class->create_modem = create_modem;
pb_class->grab_port = grab_port;
}
+26 -37
View File
@@ -32,16 +32,29 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
/*****************************************************************************/
static MMBaseModem *
create_modem (MMPluginBase *plugin,
const gchar *sysfs_path,
const gchar *driver,
guint16 vendor,
guint16 product,
GList *probes,
GError **error)
{
return MM_BASE_MODEM (mm_broadband_modem_option_new (sysfs_path,
driver,
mm_plugin_get_name (MM_PLUGIN (plugin)),
vendor,
product));
}
static gboolean
grab_port (MMPluginBase *base,
MMBaseModem *existing,
MMBaseModem *modem,
MMPortProbe *probe,
GError **error)
{
MMBaseModem *modem = NULL;
GUdevDevice *port;
const gchar *name, *subsys, *driver;
guint16 vendor = 0, product = 0;
MMAtPortFlag pflags = MM_AT_PORT_FLAG_NONE;
GUdevDevice *port;
gint usbif;
/* The Option plugin cannot do anything with non-AT ports */
@@ -50,21 +63,10 @@ grab_port (MMPluginBase *base,
MM_CORE_ERROR,
MM_CORE_ERROR_UNSUPPORTED,
"Ignoring non-AT port");
return NULL;
return FALSE;
}
port = mm_port_probe_get_port (probe); /* transfer none */
subsys = mm_port_probe_get_port_subsys (probe);
name = mm_port_probe_get_port_name (probe);
driver = mm_port_probe_get_port_driver (probe);
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error_literal (error,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"Could not get modem product ID");
return NULL;
}
/* Genuine Option NV devices are always supposed to use USB interface 0 as
* the modem/data port, per mail with Option engineers. Only this port
@@ -74,26 +76,12 @@ grab_port (MMPluginBase *base,
if (usbif == 0)
pflags = MM_AT_PORT_FLAG_PRIMARY | MM_AT_PORT_FLAG_PPP;
/* If this is the first port being grabbed, create a new modem object */
if (!existing)
modem = MM_BASE_MODEM (mm_broadband_modem_option_new (mm_port_probe_get_port_physdev (probe),
driver,
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product));
if (!mm_base_modem_grab_port (existing ? existing : modem,
subsys,
name,
MM_PORT_TYPE_AT, /* we only allow AT ports here */
pflags,
error)) {
if (modem)
g_object_unref (modem);
return NULL;
}
return existing ? existing : modem;
return mm_base_modem_grab_port (modem,
mm_port_probe_get_port_subsys (probe),
mm_port_probe_get_port_name (probe),
MM_PORT_TYPE_AT, /* we only allow AT ports here */
pflags,
error);
}
/*****************************************************************************/
@@ -129,5 +117,6 @@ mm_plugin_option_class_init (MMPluginOptionClass *klass)
{
MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass);
pb_class->create_modem = create_modem;
pb_class->grab_port = grab_port;
}
+25 -36
View File
@@ -27,20 +27,32 @@ G_DEFINE_TYPE (MMPluginSimtech, mm_plugin_simtech, MM_TYPE_PLUGIN_BASE)
int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION;
int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
/*****************************************************************************/
static MMBaseModem *
create_modem (MMPluginBase *plugin,
const gchar *sysfs_path,
const gchar *driver,
guint16 vendor,
guint16 product,
GList *probes,
GError **error)
{
return MM_BASE_MODEM (mm_broadband_modem_simtech_new (sysfs_path,
driver,
mm_plugin_get_name (MM_PLUGIN (plugin)),
vendor,
product));
}
static gboolean
grab_port (MMPluginBase *base,
MMBaseModem *existing,
MMBaseModem *modem,
MMPortProbe *probe,
GError **error)
{
MMBaseModem *modem = NULL;
GUdevDevice *port;
MMPortType ptype;
const gchar *name, *subsys;
guint16 vendor = 0, product = 0;
MMAtPortFlag pflags = MM_AT_PORT_FLAG_NONE;
/* The Simtech plugin cannot do anything with non-AT non-QCDM ports */
@@ -50,20 +62,10 @@ grab_port (MMPluginBase *base,
MM_CORE_ERROR,
MM_CORE_ERROR_UNSUPPORTED,
"Ignoring non-AT non-QCDM port");
return NULL;
return FALSE;
}
port = mm_port_probe_get_port (probe); /* transfer none */
subsys = mm_port_probe_get_port_subsys (probe);
name = mm_port_probe_get_port_name (probe);
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error_literal (error,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"Could not get modem product ID");
return NULL;
}
/* Look for port type hints; just probing can't distinguish which port should
* be the data/primary port on these devices. We have to tag them based on
@@ -84,26 +86,12 @@ grab_port (MMPluginBase *base,
else
ptype = mm_port_probe_get_port_type (probe);
/* If this is the first port being grabbed, create a new modem object */
if (!existing)
modem = MM_BASE_MODEM (mm_broadband_modem_simtech_new (mm_port_probe_get_port_physdev (probe),
mm_port_probe_get_port_driver (probe),
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product));
if (!mm_base_modem_grab_port (existing ? existing : modem,
subsys,
name,
ptype,
pflags,
error)) {
if (modem)
g_object_unref (modem);
return NULL;
}
return existing ? existing : modem;
return mm_base_modem_grab_port (modem,
mm_port_probe_get_port_subsys (probe),
mm_port_probe_get_port_name (probe),
ptype,
pflags,
error);
}
/*****************************************************************************/
@@ -135,5 +123,6 @@ mm_plugin_simtech_class_init (MMPluginSimtechClass *klass)
{
MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass);
pb_class->create_modem = create_modem;
pb_class->grab_port = grab_port;
}
+25 -37
View File
@@ -38,55 +38,42 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
/*****************************************************************************/
static MMBaseModem *
create_modem (MMPluginBase *plugin,
const gchar *sysfs_path,
const gchar *driver,
guint16 vendor,
guint16 product,
GList *probes,
GError **error)
{
return MM_BASE_MODEM (mm_broadband_modem_wavecom_new (sysfs_path,
driver,
mm_plugin_get_name (MM_PLUGIN (plugin)),
vendor,
product));
}
static gboolean
grab_port (MMPluginBase *base,
MMBaseModem *existing,
MMBaseModem *modem,
MMPortProbe *probe,
GError **error)
{
MMBaseModem *modem = NULL;
const gchar *name, *subsys;
guint16 vendor = 0, product = 0;
/* The Wavecom plugin cannot do anything with non-AT ports */
if (!mm_port_probe_is_at (probe)) {
g_set_error_literal (error,
MM_CORE_ERROR,
MM_CORE_ERROR_UNSUPPORTED,
"Ignoring non-AT port");
return NULL;
return FALSE;
}
subsys = mm_port_probe_get_port_subsys (probe);
name = mm_port_probe_get_port_name (probe);
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error_literal (error,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"Could not get modem product ID");
return NULL;
}
/* If this is the first port being grabbed, create a new modem object */
if (!existing)
modem = MM_BASE_MODEM (mm_broadband_modem_wavecom_new (mm_port_probe_get_port_physdev (probe),
mm_port_probe_get_port_driver (probe),
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product));
if (!mm_base_modem_grab_port (existing ? existing : modem,
subsys,
name,
MM_PORT_TYPE_AT, /* we only allow AT ports here */
MM_AT_PORT_FLAG_NONE,
error)) {
if (modem)
g_object_unref (modem);
return NULL;
}
return existing ? existing : modem;
return mm_base_modem_grab_port (modem,
mm_port_probe_get_port_subsys (probe),
mm_port_probe_get_port_name (probe),
MM_PORT_TYPE_AT, /* we only allow AT ports here */
MM_AT_PORT_FLAG_NONE,
error);
}
/*****************************************************************************/
@@ -116,5 +103,6 @@ mm_plugin_wavecom_class_init (MMPluginWavecomClass *klass)
{
MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass);
pb_class->create_modem = create_modem;
pb_class->grab_port = grab_port;
}