Open Source Telephony
 help / color / mirror / Atom feed
From: Florian Steinel <Florian.Steinel@gmail.com>
To: ofono@ofono.org
Subject: [PATCH 1/1] Huawei E176: Mark primary and secondary device at ofono.rules TODO: Fix sim_add detection, add E1552 idProduct to ofono.rules
Date: Sun, 30 May 2010 15:47:21 +0200	[thread overview]
Message-ID: <20100530134721.GA14827@h02.hostsharing.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 4402 bytes --]

---
 plugins/ofono.rules |   15 +++++++++++
 plugins/udev.c      |   70 ++++++++++++++++++++++-----------------------------
 2 files changed, 45 insertions(+), 40 deletions(-)

diff --git a/plugins/ofono.rules b/plugins/ofono.rules
index 0575362..abae06a 100644
--- a/plugins/ofono.rules
+++ b/plugins/ofono.rules
@@ -1,11 +1,26 @@
 # do not edit this file, it will be overwritten on update
 
 ACTION!="add|change", GOTO="ofono_end"
+
+SUBSYSTEM!="tty", GOTO="ofono_typ_end"
+KERNEL!="ttyUSB[0-9]*", GOTO="ofono_typ_end"
+
+# HUAWEI E176
+ENV{ID_VENDOR_ID}=="12d1", ENV{ID_MODEL_ID}=="1003", ENV{ID_IFACE}=="00", ENV{OFONO_TYP}="PRIMARY"
+ENV{ID_VENDOR_ID}=="12d1", ENV{ID_MODEL_ID}=="1003", ENV{ID_IFACE}=="01", ENV{OFONO_TYP}="SECONDARY"
+# HUAWEI E1552
+# TODO: Add ID_MODEL_ID aka idProduct for E1552
+#ENV{ID_VENDOR_ID}=="12d1", ENV{ID_MODEL_ID}=="1003", ENV{ID_IFACE}=="00", ENV{OFONO_TYP}="PRIMARY"
+#ENV{ID_VENDOR_ID}=="12d1", ENV{ID_MODEL_ID}=="1003", ENV{ID_IFACE}=="02", ENV{OFONO_TYP}="SECONDARY"
+
+LABEL="ofono_typ_end"
+
 SUBSYSTEM!="usb", GOTO="ofono_end"
 ENV{DEVTYPE}!="usb_device", GOTO="ofono_end"
 
 # HUAWEI Technology
 ATTRS{idVendor}=="12d1", ENV{OFONO_DRIVER}="huawei"
+# HUAWEI EM770
 ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1404", ENV{OFONO_DRIVER}="em770"
 
 # Novatel Wireless
diff --git a/plugins/udev.c b/plugins/udev.c
index bdac4fd..d52a758 100644
--- a/plugins/udev.c
+++ b/plugins/udev.c
@@ -89,24 +89,6 @@ static const char *get_serial(struct udev_device *udev_device)
 	return serial;
 }
 
-static const char *get_usb_num(struct udev_device *udev_device)
-{
-	struct udev_list_entry *entry;
-	const char *num = NULL;
-
-	entry = udev_device_get_properties_list_entry(udev_device);
-	while (entry) {
-		const char *name = udev_list_entry_get_name(entry);
-
-		if (g_strcmp0(name, "ID_USB_INTERFACE_NUM") == 0)
-			num = udev_list_entry_get_value(entry);
-
-		entry = udev_list_entry_get_next(entry);
-	}
-
-	return num;
-}
-
 #define MODEM_DEVICE		"ModemDevice"
 #define DATA_DEVICE		"DataDevice"
 #define GPS_DEVICE		"GPSDevice"
@@ -219,7 +201,8 @@ static void add_hso(struct ofono_modem *modem,
 static void add_huawei(struct ofono_modem *modem,
 					struct udev_device *udev_device)
 {
-	const char *devnode, *num;
+	struct udev_list_entry *entry;
+	const char *devnode, *serial_typ = NULL;
 	int primary, secondary;
 
 	primary = ofono_modem_get_integer(modem, "PrimaryRegistered");
@@ -228,32 +211,39 @@ static void add_huawei(struct ofono_modem *modem,
 	if (primary && secondary)
 		return;
 
-	num = get_usb_num(udev_device);
+	entry = udev_device_get_properties_list_entry(udev_device);
+	while (entry) {
+		const char *name = udev_list_entry_get_name(entry);
 
-	/*
-	 * Here is is assumed that that usb port number 0 is the control
-	 * port and port 2 is the event port. This assumption will surely
-	 * be false with some devices and better heuristics is needed.
-	 */
-	if (g_strcmp0(num, "00") == 0) {
-		if (primary != 0)
-			return;
+		if (g_strcmp0(name, "OFONO_TYP") == 0) {
+			serial_typ = udev_list_entry_get_value(entry);
 
-		devnode = udev_device_get_devnode(udev_device);
-		ofono_modem_set_string(modem, "Device", devnode);
+			if (g_strcmp0(serial_typ, "PRIMARY") == 0) {
+				if (primary != 0)
+					return;
 
-		primary = 1;
-		ofono_modem_set_integer(modem, "PrimaryRegistered", primary);
-	} else if (g_strcmp0(num, "02") == 0) {
-		if (secondary != 0)
-			return;
+				devnode = udev_device_get_devnode(udev_device);
+				ofono_modem_set_string(modem, "Device", devnode);
 
-		devnode = udev_device_get_devnode(udev_device);
-		ofono_modem_set_string(modem, "SecondaryDevice", devnode);
+				primary = 1;
+				ofono_modem_set_integer(modem, "PrimaryRegistered", primary);
+			}
+
+			if (g_strcmp0(serial_typ, "SECONDARY") == 0) {
+				if (secondary != 0)
+					return;
+
+				devnode = udev_device_get_devnode(udev_device);
+				ofono_modem_set_string(modem, "SecondaryDevice", devnode);
+
+				secondary = 1;
+				ofono_modem_set_integer(modem, "SecondaryRegistered",
+							secondary);
+			}
 
-		secondary = 1;
-		ofono_modem_set_integer(modem, "SecondaryRegistered",
-					secondary);
+		}
+
+		entry = udev_list_entry_get_next(entry);
 	}
 
 	if (primary && secondary)
-- 
1.6.4.4


             reply	other threads:[~2010-05-30 13:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-30 13:47 Florian Steinel [this message]
2010-05-31 12:29 ` [PATCH 1/1] Huawei E176: Mark primary and secondary device at ofono.rules TODO: Fix sim_add detection, add E1552 idProduct to ofono.rules Kalle Valo
2010-05-31 15:52   ` Marcel Holtmann
2010-05-31 16:52     ` Kalle Valo
2010-05-31 17:00       ` Daniel Oliveira Nascimento
2010-06-01 19:09       ` Denis Kenzior
2010-05-31 17:57   ` Florian Steinel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100530134721.GA14827@h02.hostsharing.net \
    --to=florian.steinel@gmail.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox