aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2018-07-27 11:43:48 +0200
committerDan Williams <dcbw@redhat.com>2018-08-10 04:19:13 +0000
commit548b7f88473827954a389d96dac298fa6b6453a6 (patch)
treee0958961a754c27c72db8294addf502d7ab8b560
parentaff633b1b002ecfecc51d589d580e963c931cb6d (diff)
base-modem: load AT port type hints when adding port
We keep the pflags input in mm_base_modem_grab_port() so that plugins can use other methods to gather port type hints (e.g. querying with AT commands as in Huawei/Telit or looking at sysfs properties as in HSO). For standard udev tag port type hints, it will be the base modem looking them up. Note that there is no longer any need to ignore non-flagged ports for those modems that require primary/secondary flags. They will be implicitly ignored when mm_base_modem_organize_ports() decides which ports to use, as the flagged ones are preferred over the non-flagged ones.
-rw-r--r--plugins/haier/mm-plugin-haier.c27
-rw-r--r--plugins/huawei/mm-plugin-huawei.c18
-rw-r--r--plugins/longcheer/mm-plugin-longcheer.c43
-rw-r--r--plugins/mtk/mm-plugin-mtk.c35
-rw-r--r--plugins/nokia/mm-plugin-nokia-icera.c34
-rw-r--r--plugins/simtech/mm-plugin-simtech.c47
-rw-r--r--plugins/telit/mm-common-telit.c37
-rw-r--r--plugins/x22x/mm-plugin-x22x.c45
-rw-r--r--plugins/zte/mm-plugin-zte.c18
-rw-r--r--src/mm-base-modem.c14
10 files changed, 20 insertions, 298 deletions
diff --git a/plugins/haier/mm-plugin-haier.c b/plugins/haier/mm-plugin-haier.c
index ce97401d..86f17300 100644
--- a/plugins/haier/mm-plugin-haier.c
+++ b/plugins/haier/mm-plugin-haier.c
@@ -46,32 +46,6 @@ create_modem (MMPlugin *self,
product));
}
-static gboolean
-grab_port (MMPlugin *self,
- MMBaseModem *modem,
- MMPortProbe *probe,
- GError **error)
-{
- MMKernelDevice *port;
- MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
-
- port = mm_port_probe_peek_port (probe);
-
- /* Look for port type hints */
- if (mm_port_probe_is_at (probe) && mm_kernel_device_get_property_as_boolean (port, "ID_MM_PORT_TYPE_AT_PRIMARY")) {
- mm_dbg ("HAIER: AT port '%s/%s' flagged as primary",
- mm_port_probe_get_port_subsys (probe),
- mm_port_probe_get_port_name (probe));
- pflags = (MM_PORT_SERIAL_AT_FLAG_PRIMARY | MM_PORT_SERIAL_AT_FLAG_PPP);
- }
-
- return mm_base_modem_grab_port (modem,
- port,
- mm_port_probe_get_port_type (probe),
- pflags,
- error);
-}
-
/*****************************************************************************/
G_MODULE_EXPORT MMPlugin *
@@ -99,5 +73,4 @@ mm_plugin_haier_class_init (MMPluginHaierClass *klass)
MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass);
plugin_class->create_modem = create_modem;
- plugin_class->grab_port = grab_port;
}
diff --git a/plugins/huawei/mm-plugin-huawei.c b/plugins/huawei/mm-plugin-huawei.c
index f3bfd865..fda22794 100644
--- a/plugins/huawei/mm-plugin-huawei.c
+++ b/plugins/huawei/mm-plugin-huawei.c
@@ -525,29 +525,19 @@ grab_port (MMPlugin *self,
MMPortProbe *probe,
GError **error)
{
- MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
+ MMPortSerialAtFlag pflags;
MMKernelDevice *port;
MMPortType port_type;
port_type = mm_port_probe_get_port_type (probe);
port = mm_port_probe_peek_port (probe);
- if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_PORT_TYPE_AT_PRIMARY")) {
- mm_dbg ("(%s/%s)' Port flagged as primary",
- mm_port_probe_get_port_subsys (probe),
- mm_port_probe_get_port_name (probe));
- pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
- } else if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_PORT_TYPE_AT_PPP")) {
- mm_dbg ("(%s/%s) Port flagged as PPP",
- mm_port_probe_get_port_subsys (probe),
- mm_port_probe_get_port_name (probe));
- pflags = MM_PORT_SERIAL_AT_FLAG_PPP;
- } else {
+ pflags = (MMPortSerialAtFlag) GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (probe), TAG_AT_PORT_FLAGS));
+ if (pflags != MM_PORT_SERIAL_AT_FLAG_NONE) {
gchar *str;
- pflags = (MMPortSerialAtFlag) GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (probe), TAG_AT_PORT_FLAGS));
str = mm_port_serial_at_flag_build_string_from_mask (pflags);
- mm_dbg ("(%s/%s) Port will have AT flags '%s'",
+ mm_dbg ("(%s/%s) huawei port will have AT flags '%s'",
mm_port_probe_get_port_subsys (probe),
mm_port_probe_get_port_name (probe),
str);
diff --git a/plugins/longcheer/mm-plugin-longcheer.c b/plugins/longcheer/mm-plugin-longcheer.c
index a83a688e..59b84575 100644
--- a/plugins/longcheer/mm-plugin-longcheer.c
+++ b/plugins/longcheer/mm-plugin-longcheer.c
@@ -196,48 +196,6 @@ create_modem (MMPlugin *self,
product));
}
-static gboolean
-grab_port (MMPlugin *self,
- MMBaseModem *modem,
- MMPortProbe *probe,
- GError **error)
-{
- MMKernelDevice *port;
- MMPortType ptype;
- MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
-
- port = mm_port_probe_peek_port (probe);
- ptype = mm_port_probe_get_port_type (probe);
-
- /* 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
- * what the Windows .INF files say the port layout should be.
- */
- if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_PORT_TYPE_AT_PRIMARY")) {
- mm_dbg ("longcheer: AT port '%s/%s' flagged as primary",
- mm_port_probe_get_port_subsys (probe),
- mm_port_probe_get_port_name (probe));
- pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
- } else if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_PORT_TYPE_AT_SECONDARY")) {
- mm_dbg ("longcheer: AT port '%s/%s' flagged as secondary",
- mm_port_probe_get_port_subsys (probe),
- mm_port_probe_get_port_name (probe));
- pflags = MM_PORT_SERIAL_AT_FLAG_SECONDARY;
- } else {
- /* If the port was tagged by the udev rules but isn't a primary or secondary,
- * then ignore it to guard against race conditions if a device just happens
- * to show up with more than two AT-capable ports.
- */
- ptype = MM_PORT_TYPE_IGNORED;
- }
-
- return mm_base_modem_grab_port (modem,
- port,
- ptype,
- pflags,
- error);
-}
-
/*****************************************************************************/
G_MODULE_EXPORT MMPlugin *
@@ -280,5 +238,4 @@ mm_plugin_longcheer_class_init (MMPluginLongcheerClass *klass)
MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass);
plugin_class->create_modem = create_modem;
- plugin_class->grab_port = grab_port;
}
diff --git a/plugins/mtk/mm-plugin-mtk.c b/plugins/mtk/mm-plugin-mtk.c
index a3ed236e..3f6745ae 100644
--- a/plugins/mtk/mm-plugin-mtk.c
+++ b/plugins/mtk/mm-plugin-mtk.c
@@ -49,40 +49,6 @@ create_modem (MMPlugin *self,
product));
}
-/* MTK done */
-static gboolean
-grab_port (MMPlugin *self,
- MMBaseModem *modem,
- MMPortProbe *probe,
- GError **error)
-{
- MMKernelDevice *port;
- MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
-
- port = mm_port_probe_peek_port (probe);
-
- if (mm_port_probe_is_at (probe)) {
- /* Get port type from udev */
- if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_PORT_TYPE_AT_SECONDARY")) {
- mm_dbg ("MTK: AT port '%s/%s' flagged as secondary",
- mm_port_probe_get_port_subsys (probe),
- mm_port_probe_get_port_name (probe));
- pflags = MM_PORT_SERIAL_AT_FLAG_SECONDARY;
- } else if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_PORT_TYPE_AT_PRIMARY")) {
- mm_dbg ("MTK: Modem port '%s/%s' flagged as primary",
- mm_port_probe_get_port_subsys (probe),
- mm_port_probe_get_port_name (probe));
- pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
- }
- }
-
- return mm_base_modem_grab_port (modem,
- port,
- mm_port_probe_get_port_type (probe),
- pflags,
- error);
-}
-
/*****************************************************************************/
G_MODULE_EXPORT MMPlugin *
@@ -113,5 +79,4 @@ mm_plugin_mtk_class_init (MMPluginMtkClass *klass)
MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass);
plugin_class->create_modem = create_modem;
- plugin_class->grab_port = grab_port;
}
diff --git a/plugins/nokia/mm-plugin-nokia-icera.c b/plugins/nokia/mm-plugin-nokia-icera.c
index c55eac72..e2d587a4 100644
--- a/plugins/nokia/mm-plugin-nokia-icera.c
+++ b/plugins/nokia/mm-plugin-nokia-icera.c
@@ -57,39 +57,6 @@ create_modem (MMPlugin *self,
product));
}
-static gboolean
-grab_port (MMPlugin *self,
- MMBaseModem *modem,
- MMPortProbe *probe,
- GError **error)
-{
- MMKernelDevice *port;
- MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
-
- port = mm_port_probe_peek_port (probe);
-
- /* Look for port type hints */
- if (mm_port_probe_is_at (probe)) {
- if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_PORT_TYPE_AT_PRIMARY")) {
- mm_dbg ("Nokia: AT port '%s/%s' flagged as primary",
- mm_port_probe_get_port_subsys (probe),
- mm_port_probe_get_port_name (probe));
- pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
- } else if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_PORT_TYPE_AT_SECONDARY")) {
- mm_dbg ("Nokia: AT port '%s/%s' flagged as secondary",
- mm_port_probe_get_port_subsys (probe),
- mm_port_probe_get_port_name (probe));
- pflags = MM_PORT_SERIAL_AT_FLAG_SECONDARY;
- }
- }
-
- return mm_base_modem_grab_port (modem,
- port,
- mm_port_probe_get_port_type (probe),
- pflags,
- error);
-}
-
/*****************************************************************************/
G_MODULE_EXPORT MMPlugin *
@@ -120,5 +87,4 @@ mm_plugin_nokia_icera_class_init (MMPluginNokiaIceraClass *klass)
MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass);
plugin_class->create_modem = create_modem;
- plugin_class->grab_port = grab_port;
}
diff --git a/plugins/simtech/mm-plugin-simtech.c b/plugins/simtech/mm-plugin-simtech.c
index eef2f633..fb3a7950 100644
--- a/plugins/simtech/mm-plugin-simtech.c
+++ b/plugins/simtech/mm-plugin-simtech.c
@@ -63,52 +63,6 @@ create_modem (MMPlugin *self,
product));
}
-static gboolean
-grab_port (MMPlugin *self,
- MMBaseModem *modem,
- MMPortProbe *probe,
- GError **error)
-{
- MMKernelDevice *port;
- MMPortType ptype;
- MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
-
- port = mm_port_probe_peek_port (probe);
- ptype = mm_port_probe_get_port_type (probe);
-
- if (mm_port_probe_is_at (probe)) {
- /* 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
- * what the Windows .INF files say the port layout should be.
- */
- if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_PORT_TYPE_AT_PRIMARY")) {
- mm_dbg ("Simtech: AT port '%s/%s' flagged as primary",
- mm_port_probe_get_port_subsys (probe),
- mm_port_probe_get_port_name (probe));
- pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
- } else if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_PORT_TYPE_AT_SECONDARY")) {
- mm_dbg ("Simtech: AT port '%s/%s' flagged as secondary",
- mm_port_probe_get_port_subsys (probe),
- mm_port_probe_get_port_name (probe));
- pflags = MM_PORT_SERIAL_AT_FLAG_SECONDARY;
- }
-
- /* If the port was tagged by the udev rules but isn't a primary or secondary,
- * then ignore it to guard against race conditions if a device just happens
- * to show up with more than two AT-capable ports.
- */
- if (pflags == MM_PORT_SERIAL_AT_FLAG_NONE &&
- mm_kernel_device_get_global_property_as_boolean (port, "ID_MM_SIMTECH_TAGGED"))
- ptype = MM_PORT_TYPE_IGNORED;
- }
-
- return mm_base_modem_grab_port (modem,
- port,
- ptype,
- pflags,
- error);
-}
-
/*****************************************************************************/
G_MODULE_EXPORT MMPlugin *
@@ -140,5 +94,4 @@ mm_plugin_simtech_class_init (MMPluginSimtechClass *klass)
MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass);
plugin_class->create_modem = create_modem;
- plugin_class->grab_port = grab_port;
}
diff --git a/plugins/telit/mm-common-telit.c b/plugins/telit/mm-common-telit.c
index 41b5e3a1..71f11e3e 100644
--- a/plugins/telit/mm-common-telit.c
+++ b/plugins/telit/mm-common-telit.c
@@ -49,24 +49,8 @@ telit_grab_port (MMPlugin *self,
if (!g_str_equal (subsys, "tty"))
goto out;
- /* 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
- * what the Windows .INF files say the port layout should be.
- *
- * If no udev rules are found, AT#PORTCFG (if supported) can be used for
- * identifying the port layout
- */
- if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_PORT_TYPE_AT_PRIMARY")) {
- mm_dbg ("telit: AT port '%s/%s' flagged as primary",
- mm_port_probe_get_port_subsys (probe),
- mm_port_probe_get_port_name (probe));
- pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
- } else if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_PORT_TYPE_AT_SECONDARY")) {
- mm_dbg ("telit: AT port '%s/%s' flagged as secondary",
- mm_port_probe_get_port_subsys (probe),
- mm_port_probe_get_port_name (probe));
- pflags = MM_PORT_SERIAL_AT_FLAG_SECONDARY;
- } else if (g_object_get_data (G_OBJECT (device), TAG_GETPORTCFG_SUPPORTED) != NULL) {
+ /* AT#PORTCFG (if supported) can be used for identifying the port layout */
+ if (g_object_get_data (G_OBJECT (device), TAG_GETPORTCFG_SUPPORTED) != NULL) {
if (g_strcmp0 (mm_kernel_device_get_property (port, "ID_USB_INTERFACE_NUM"), g_object_get_data (G_OBJECT (device), TAG_TELIT_MODEM_PORT)) == 0) {
mm_dbg ("telit: AT port '%s/%s' flagged as primary",
mm_port_probe_get_port_subsys (probe),
@@ -84,23 +68,6 @@ telit_grab_port (MMPlugin *self,
ptype = MM_PORT_TYPE_GPS;
} else
ptype = MM_PORT_TYPE_IGNORED;
- } else {
- /* If the port isn't explicitly tagged as primary, secondary, or gps
- * port, we will fallback to flagging it as secondary, but only if it
- * probed AT successfully.
- *
- * This is so that we support the case where a single TTY is exposed
- * by the modem and no explicit port type hint is specified.
- *
- * From the modem point of view, only the AT_FLAG_PRIMARY would be
- * important, as that is the port that would end up getting used for PPP
- * in this case, so having multiple secondary ports, if that ever
- * happened, wouldn't be an issue.
- */
- if (mm_port_probe_is_at (probe))
- pflags = MM_PORT_SERIAL_AT_FLAG_SECONDARY;
- else
- ptype = MM_PORT_TYPE_IGNORED;
}
out:
diff --git a/plugins/x22x/mm-plugin-x22x.c b/plugins/x22x/mm-plugin-x22x.c
index 8e38abb6..795d30a7 100644
--- a/plugins/x22x/mm-plugin-x22x.c
+++ b/plugins/x22x/mm-plugin-x22x.c
@@ -206,50 +206,6 @@ create_modem (MMPlugin *self,
product));
}
-static gboolean
-grab_port (MMPlugin *self,
- MMBaseModem *modem,
- MMPortProbe *probe,
- GError **error)
-{
- MMKernelDevice *port;
- MMPortType ptype;
- MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
-
- port = mm_port_probe_peek_port (probe);
- ptype = mm_port_probe_get_port_type (probe);
-
- if (ptype == MM_PORT_TYPE_AT) {
- /* 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
- * what the Windows .INF files say the port layout should be.
- */
- if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_PORT_TYPE_AT_PRIMARY")) {
- mm_dbg ("x22x: AT port '%s/%s' flagged as primary",
- mm_port_probe_get_port_subsys (probe),
- mm_port_probe_get_port_name (probe));
- pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
- } else if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_PORT_TYPE_AT_SECONDARY")) {
- mm_dbg ("x22x: AT port '%s/%s' flagged as secondary",
- mm_port_probe_get_port_subsys (probe),
- mm_port_probe_get_port_name (probe));
- pflags = MM_PORT_SERIAL_AT_FLAG_SECONDARY;
- } else {
- /* If the port was tagged by the udev rules but isn't a primary or secondary,
- * then ignore it to guard against race conditions if a device just happens
- * to show up with more than two AT-capable ports.
- */
- ptype = MM_PORT_TYPE_IGNORED;
- }
- }
-
- return mm_base_modem_grab_port (modem,
- port,
- ptype,
- pflags,
- error);
-}
-
/*****************************************************************************/
G_MODULE_EXPORT MMPlugin *
@@ -291,5 +247,4 @@ mm_plugin_x22x_class_init (MMPluginX22xClass *klass)
MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass);
plugin_class->create_modem = create_modem;
- plugin_class->grab_port = grab_port;
}
diff --git a/plugins/zte/mm-plugin-zte.c b/plugins/zte/mm-plugin-zte.c
index 010fdceb..7b0849f1 100644
--- a/plugins/zte/mm-plugin-zte.c
+++ b/plugins/zte/mm-plugin-zte.c
@@ -111,7 +111,6 @@ grab_port (MMPlugin *self,
GError **error)
{
MMKernelDevice *port;
- MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
MMPortType ptype;
port = mm_port_probe_peek_port (probe);
@@ -126,21 +125,6 @@ grab_port (MMPlugin *self,
return FALSE;
}
- if (mm_port_probe_is_at (probe)) {
- /* Look for port type hints */
- if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_PORT_TYPE_AT_PRIMARY")) {
- mm_dbg ("ZTE: AT port '%s/%s' flagged as primary",
- mm_port_probe_get_port_subsys (probe),
- mm_port_probe_get_port_name (probe));
- pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
- } else if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_PORT_TYPE_AT_SECONDARY")) {
- mm_dbg ("ZTE: AT port '%s/%s' flagged as secondary",
- mm_port_probe_get_port_subsys (probe),
- mm_port_probe_get_port_name (probe));
- pflags = MM_PORT_SERIAL_AT_FLAG_SECONDARY;
- }
- }
-
if (mm_kernel_device_get_global_property_as_boolean (port, "ID_MM_ZTE_ICERA_DHCP")) {
mm_dbg ("ZTE: Icera-based modem will use DHCP");
g_object_set (modem,
@@ -151,7 +135,7 @@ grab_port (MMPlugin *self,
return mm_base_modem_grab_port (modem,
port,
ptype,
- pflags,
+ MM_PORT_SERIAL_AT_FLAG_NONE,
error);
}
diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c
index bf49c37b..2fa39b32 100644
--- a/src/mm-base-modem.c
+++ b/src/mm-base-modem.c
@@ -211,7 +211,19 @@ mm_base_modem_grab_port (MMBaseModem *self,
mm_serial_parser_v1_parse,
mm_serial_parser_v1_new (),
mm_serial_parser_v1_destroy);
- /* Store flags already */
+ /* Prefer plugin-provided flags to the generic ones */
+ if (at_pflags == MM_PORT_SERIAL_AT_FLAG_NONE) {
+ if (mm_kernel_device_get_property_as_boolean (kernel_device, "ID_MM_PORT_TYPE_AT_PRIMARY")) {
+ mm_dbg ("AT port '%s/%s' flagged as primary", subsys, name);
+ at_pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
+ } else if (mm_kernel_device_get_property_as_boolean (kernel_device, "ID_MM_PORT_TYPE_AT_SECONDARY")) {
+ mm_dbg ("AT port '%s/%s' flagged as secondary", subsys, name);
+ at_pflags = MM_PORT_SERIAL_AT_FLAG_SECONDARY;
+ } else if (mm_kernel_device_get_property_as_boolean (kernel_device, "ID_MM_PORT_TYPE_AT_PPP")) {
+ mm_dbg ("AT port '%s/%s' flagged as PPP", subsys, name);
+ at_pflags = MM_PORT_SERIAL_AT_FLAG_PPP;
+ }
+ }
mm_port_serial_at_set_flags (MM_PORT_SERIAL_AT (port), at_pflags);
} else if (ptype == MM_PORT_TYPE_GPS) {
/* Raw GPS port */