diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-02-13 22:19:28 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-15 14:15:05 +0100 |
commit | 8b7b614105c784b391f818a2eb6462accd844a4e (patch) | |
tree | 7d517f9a322d7f9306a26dd7689f2734e208af3d /src/mm-manager.c | |
parent | 0b39bf91ecde4d19d231e495bc9573a67869c3f2 (diff) |
core: rework port grabbing and organization
Make port roles more flexible. We have modems that do PPP
on interfaces other than the primary interface, and that
wasn't possible with the old code. So clean up all that
logic and move the port organization code into the core
so we can reduce code in the plugins.
In the new world order, the plugins say whether the port
is a QCDM port, an AT port, or ignored. If it's an AT
port the plugins get to tag it as primary, secondary, or
PPP, or any combination of the 3. This allows for modems
where PPP should really be done on the secondary port
(Huawei E220, Sierra devices) so that the primary port
stays open for command and status.
After all ports are grabbed by the generic classes, they get
"organized", which assigns various ports to the roles of
PRIMARY, SECONDARY, DATA, and QCDM based on specific rules
and hints that the plugin provided (which are expressed as
MMAtPortFlags).
The plugin code is responsible for determining the port
hints (ie MMAtPortFlags) at probe time, instead of having
a combination of the plugin and the modem class do the
job. This simplifies things greatly for the plugins at
the expense of more complicated logic in the core.
This is the port of commit 96505d42ed62327101dcee7c2bf31177b0bb1c9f
to the 06-api branch.
Diffstat (limited to 'src/mm-manager.c')
-rw-r--r-- | src/mm-manager.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/mm-manager.c b/src/mm-manager.c index e3a793b6..6b8ceba9 100644 --- a/src/mm-manager.c +++ b/src/mm-manager.c @@ -115,6 +115,8 @@ remove_modem (MMManager *manager, mm_dbg ("Unexported modem '%s' from path '%s'", device, path); g_free (path); + } else { + mm_dbg ("Removing modem '%s', which wasn't exported yet", device); } /* Run dispose before unref-ing, in order to cleanup the SIM object, @@ -161,6 +163,7 @@ static void check_export_modem (MMManager *self, MMBaseModem *modem) { + GError *error = NULL; static guint32 id = 0; const gchar *modem_physdev; const gchar *name; @@ -194,12 +197,22 @@ check_export_modem (MMManager *self, return; } - /* If modem not yet valid, don't export it */ - if (!mm_base_modem_get_valid (modem)) { - mm_dbg ("Not exporting invalid modem '%s'", modem_physdev); + /* Plugin manager is not trying to find more ports supported by this device, + * so we can organize the ports now (if not done already). */ + if (!mm_base_modem_organize_ports (modem, &error)) { + /* If the ports were not properly organized, the modem will be marked as + * invalid and therefore removed */ + mm_err ("Failed to organize modem ports: '%s'", + error->message); + g_error_free (error); + remove_modem (self, modem); return; } + /* If modem not yet valid (not fully initialized), don't export it */ + if (!mm_base_modem_get_valid (modem)) + return; + /* Don't export already exported modems */ g_object_get (modem, "g-object-path", &path, |