All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] Huawei E176: Mark primary and secondary device at ofono.rules TODO: Fix sim_add detection, add E1552 idProduct to ofono.rules
@ 2010-05-30 13:47 Florian Steinel
  2010-05-31 12:29 ` Kalle Valo
  0 siblings, 1 reply; 7+ messages in thread
From: Florian Steinel @ 2010-05-30 13:47 UTC (permalink / raw)
  To: ofono

[-- 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-06-01 19:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-30 13:47 [PATCH 1/1] Huawei E176: Mark primary and secondary device at ofono.rules TODO: Fix sim_add detection, add E1552 idProduct to ofono.rules Florian Steinel
2010-05-31 12:29 ` 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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.