---
 plugins/ofono.rules | 24 ++++++++++++++++++++++++
 plugins/udevng.c    | 28 ++++++++++++++--------------
 2 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/plugins/ofono.rules b/plugins/ofono.rules
index fe673cd..4d70735 100644
--- a/plugins/ofono.rules
+++ b/plugins/ofono.rules
@@ -36,4 +36,28 @@ DRIVER=="cdc_phonet",ENV{OFONO_DRIVER}="isiusb"
 ENV{OFONO_DRIVER}=="isiusb",ATTR{type}=="820",ENV{OFONO_LABEL}="modem"
 ENV{OFONO_LABEL}=="modem",ENV{INTERFACE}=="2/254/0",ENV{OFONO_LABEL}="modem16"
 
+# If OFONO_DRIVER is set now, we are done.  If not, we make an additional
+# effort to find an appropriate driver and labelling.
+ENV{OFONO_DRIVER}="?*",GOTO="ofono_end"
+
+# If no product rule matched the interface then we still have an option:
+# the kernel also has device tables that it uses to attach drivers to
+# devices.  If the interface has an attached driver, then we can use
+# this information to attempt to label it.
+
+DRIVER=="qmi_wwan",ENV{OFONO_DRIVER}="gobi",ENV{OFONO_LABEL}="qmi"
+
+# Product rules are preferred for everything except "qmi" interfaces
+# in order to keep the below rules as minimal as possible.  The below
+# should be considered only as a fallback.
+
+DRIVER=="qcserial",ENV{OFONO_DRIVER}="gobi"
+ENV{OFONO_DRIVER}!="gobi",GOTO="gobi_end"
+ENV{INTERFACE}!="255/255/255",GOTO="gobi_end"
+ATTR{bInterfaceNumber}=="00",ENV{OFONO_LABEL}="net"
+ATTR{bInterfaceNumber}=="01",ENV{OFONO_LABEL}="diag"
+ATTR{bInterfaceNumber}=="02",ENV{OFONO_LABEL}="modem"
+ATTR{bInterfaceNumber}=="03",ENV{OFONO_LABEL}="gps"
+LABEL="gobi_end"
+
 LABEL="ofono_end"
diff --git a/plugins/udevng.c b/plugins/udevng.c
index 508db04..c19dc1c 100644
--- a/plugins/udevng.c
+++ b/plugins/udevng.c
@@ -204,18 +204,19 @@ static gboolean setup_gobi(struct modem_info *modem)
                DBG("%s %s %s %s", info->devnode, info->interface,
                                                info->number, info->label);
 
-               if (g_strcmp0(info->interface, "255/255/255") == 0) {
-                       if (info->number == NULL)
-                               qmi = info->devnode;
-                       else if (g_strcmp0(info->number, "00") == 0)
-                               net = info->devnode;
-                       else if (g_strcmp0(info->number, "01") == 0)
-                               diag = info->devnode;
-                       else if (g_strcmp0(info->number, "02") == 0)
-                               mdm = info->devnode;
-                       else if (g_strcmp0(info->number, "03") == 0)
-                               gps = info->devnode;
-               }
+               if (g_strcmp0(info->label, "qmi") == 0)
+                       /* FIXME: subsystem detection to separate 'qmi' and
+                        * 'net' atoms???
+                        */
+                       qmi = info->devnode;
+               else if (g_strcmp0(info->label, "net") == 0)
+                       net = info->devnode;
+               else if (g_strcmp0(info->label, "modem") == 0)
+                       mdm = info->devnode;
+               else if (g_strcmp0(info->label, "diag") == 0)
+                       diag = info->devnode;
+               else if (g_strcmp0(info->label, "gps") == 0)
+                       gps = info->devnode;
        }
 
        if (qmi == NULL || mdm == NULL || net == NULL)
@@ -223,6 +224,7 @@ static gboolean setup_gobi(struct modem_info *modem)
 
        DBG("qmi=%s net=%s mdm=%s gps=%s diag=%s", qmi, net, mdm, gps, diag);
 
+       /* FIXME: gps node not used... */
        ofono_modem_set_string(modem->modem, "Device", qmi);
        ofono_modem_set_string(modem->modem, "Modem", mdm);
        ofono_modem_set_string(modem->modem, "Diag", diag);
@@ -1337,8 +1339,6 @@ static struct {
        { "mbm",        "cdc_acm",      "0930"          },
        { "mbm",        "cdc_ether",    "0930"          },
        { "mbm",        "cdc_ncm",      "0930"          },
-       { "gobi",       "qmi_wwan"                      },
-       { "gobi",       "qcserial"                      },
        { "sierra",     "qmi_wwan",     "1199"          },
        { "sierra",     "qcserial",     "1199"          },
        { "sierra",     "sierra"                        },
-- 
2.9.3

_______________________________________________
ofono mailing list
[email protected]
https://lists.ofono.org/mailman/listinfo/ofono

Reply via email to