Skip to contentSkip to conversation

PATCH: Enable udev-based autodetection of calypso modem on Freerunner

PATCH Neil Jerram 3 participants 13 messages Dec 15, 2010 – Dec 23, 2010

lore
Share & tools
lore
#0 lore raw

Hi all,

With the patch below, ofono-0.36 (the current Debian unstable version) detects the calypso modem on my freerunner. (Whereas without it, it doesn't.)

I don't feel confident that the ofono.rules change is in its nicest possible form, and (IIUC) it's dependent on these earlier rules in /lib/udev/rules.d/55-openmoko-gta01-gta02.rules on my phone:

# Samsung UARTS
KERNEL=="s3c2410_serial[0-9]", NAME="ttySAC%n"
KERNEL=="ttySAC[0-9]", NAME="ttySAC%n"

Given that the actual udev DB entry, under 2.6.34, is:

P: /devices/platform/s3c2440-uart.0/tty/ttySAC0
N: ttySAC0
S: char/204:64
E: UDEV_LOG=3
E: DEVPATH=/devices/platform/s3c2440-uart.0/tty/ttySAC0
E: MAJOR=204
E: MINOR=64
E: DEVNAME=/dev/ttySAC0
E: SUBSYSTEM=tty
E: DEVLINKS=/dev/char/204:64

what's the neatest way of writing a udev rule for that?

Regards,
Neil

Quoted 1 line

From 79cc63c30dded269cdb8e8dbba78036847f6357e Mon Sep 17 00:00:00 2001

From: Neil Jerram <[email protected]>
Date: Wed, 15 Dec 2010 21:56:50 +0000
Subject: [PATCH] Enable udev-based autodetection of calypso modem on Freerunner

As https://ofono.org/wiki/ofono-supported-modems says for calypso: "It works with modem.conf. However it may need udev rule now." This patch addresses that.

* plugins/udev.c (add_calypso): New function. (add_modem): Call add_calypso for "calypso" driver.

* plugins/ofono.rules: Add udev rules for Freerunner calypso under 2.6.29 and 2.6.34 kernels.

---
 plugins/ofono.rules |    7 +++++++
 plugins/udev.c      |   16 ++++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)
plugins/ofono.rules +7 -0
index da8a8ef..a0fdc96 100644
@@ -2,6 +2,13 @@
 
 ACTION!="add|change", GOTO="ofono_end"
 
+SUBSYSTEM!="tty", GOTO="ofono_calypso_end"
+NAME!="ttySAC0*", GOTO="ofono_calypso_end"
+
+ENV{OFONO_DRIVER}="calypso"
+
+LABEL="ofono_calypso_end"
+
 SUBSYSTEM!="tty", GOTO="ofono_tty_end"
 KERNEL!="ttyUSB[0-9]*", GOTO="ofono_tty_end"
 
plugins/udev.c +16 -0
index 255755e..837ee9c 100644
@@ -449,6 +449,20 @@ static void add_isi(struct ofono_modem *modem,
 	ofono_modem_register(modem);
 }
 
+static void add_calypso(struct ofono_modem *modem,
+					struct udev_device *udev_device)
+{
+	struct udev_list_entry *entry;
+	const char *devnode;
+
+	DBG("modem %p", modem);
+
+	devnode = udev_device_get_devnode(udev_device);
+	ofono_modem_set_string(modem, "Device", devnode);
+
+	ofono_modem_register(modem);
+}
+
 static void add_modem(struct udev_device *udev_device)
 {
 	struct ofono_modem *modem;
@@ -533,6 +547,8 @@ done:
 		add_isi(modem, udev_device);
 	else if (g_strcmp0(driver, "n900") == 0)
 		add_isi(modem, udev_device);
+	else if (g_strcmp0(driver, "calypso") == 0)
+		add_calypso(modem, udev_device);
 }
 
 static gboolean devpath_remove(gpointer key, gpointer value, gpointer user_data)
Signature · 1 line
1.7.1
#1 lore raw

Hi Neil,

Quoted 5 lines · Neil Jerram

Hi all,

With the patch below, ofono-0.36 (the current Debian unstable version) detects the calypso modem on my freerunner. (Whereas without it, it doesn't.)

We prefer if you use git send-email to format the patch for submission.
For now I applied your patch without the ofono.rules changes.

Quoted 11 lines

I don't feel confident that the ofono.rules change is in its nicest possible form, and (IIUC) it's dependent on these earlier rules in /lib/udev/rules.d/55-openmoko-gta01-gta02.rules on my phone:

# Samsung UARTS
KERNEL=="s3c2410_serial[0-9]", NAME="ttySAC%n"
KERNEL=="ttySAC[0-9]", NAME="ttySAC%n"

Given that the actual udev DB entry, under 2.6.34, is:

Quoted 11 lines

P: /devices/platform/s3c2440-uart.0/tty/ttySAC0
N: ttySAC0
S: char/204:64
E: UDEV_LOG=3
E: DEVPATH=/devices/platform/s3c2440-uart.0/tty/ttySAC0
E: MAJOR=204
E: MINOR=64
E: DEVNAME=/dev/ttySAC0
E: SUBSYSTEM=tty
E: DEVLINKS=/dev/char/204:64

I think the better way would be to drop a udev rule directly into /etc/udev.d or similar. The rule should be as simple as:
KERNEL=="ttySAC0", ENV{OFONO_DRIVER}="calypso"

Let me know if this works for you and I can add a comment in the calypso plugin.

Reg

#2 lore raw
Quoted 2 lines · Denis Kenzior

We prefer if you use git send-email to format the patch for submission.

Sure, I will do that in future. Thanks for looking at the patch anyway.

Quoted 3 lines

I think the better way would be to drop a udev rule directly into /etc/udev.d or similar. The rule should be as simple as:
KERNEL=="ttySAC0", ENV{OFONO_DRIVER}="calypso"

Do you mean in another file than 97-ofono.rules?

Quoted 2 lines

Let me know if this works for you and I can add a comment in the calypso plugin.

Will do. Thanks again,

Neil

#3 lore raw

Hi Neil,

Quoted 5 lines
Quoted 3 lines

I think the better way would be to drop a udev rule directly into /etc/udev.d or similar. The rule should be as simple as:
KERNEL=="ttySAC0", ENV{OFONO_DRIVER}="calypso"

Do you mean in another file than 97-ofono.rules?

Yep.

Regards,
-Denis

#4 lore raw

Hi Denis,

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

I think the better way would be to drop a udev rule directly into /etc/udev.d or similar. The rule should be as simple as:
KERNEL=="ttySAC0", ENV{OFONO_DRIVER}="calypso"

Do you mean in another file than 97-ofono.rules?

Yep.

I prefer not to have this inside ofono.git at all. We also leave the IFX specific ones out. It is really up to the package maintainers to get this sorted.

We could document this as Freerunner specific notes to point people into the right direction. And we should maybe to the same for IFX since that is currently only documented in the GIT commit logs.

Regards

Marcel

#5 lore raw

Hi Marcel,

Quoted 6 lines · Marcel Holtmann

Hi Denis,

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

I think the better way would be to drop a udev rule directly into /etc/udev.d or similar. The rule should be as simple as:
KERNEL=="ttySAC0", ENV{OFONO_DRIVER}="calypso"

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Do you mean in another file than 97-ofono.rules?

Yep.

I prefer not to have this inside ofono.git at all. We also leave the IFX specific ones out. It is really up to the package maintainers to get this sorted.

That is actually what I had in mind. Maybe I didn't communicate this properly.

Quoted 3 lines

We could document this as Freerunner specific notes to point people into the right direction. And we should maybe to the same for IFX since that is currently only documented in the GIT commit logs.

Documentation inside the individual modem driver is the way to go. And IFX isn't even documented in git commit logs. I looked ;)

Regards,
-Denis

#6 lore raw

Hi Denis,

Quoted 6 lines
Quoted 3 lines

We could document this as Freerunner specific notes to point people into the right direction. And we should maybe to the same for IFX since that is currently only documented in the GIT commit logs.

Documentation inside the individual modem driver is the way to go. And IFX isn't even documented in git commit logs. I looked ;)

commit 3443a7a177fbaca24c84658968aff0a55db8a51d

Author: Marcel Holtmann <[email protected]>
Date:   Sat Sep 18 22:08:41 2010 +0900

udev: Add support for IFX device detection

The IFX device detection is pretty static, but instead of using a static configuration file it is important to know when the device node is actually present. For this udev is perfect. Adding a simple udev rule is all that it takes:

KERNEL=="ttyIFX[0-9]*", ENV{OFONO_DRIVER}="ifx"

With this rule for every TTY with the kernel name like ttyIFX0, a new modem will be added and the IFX modem plugin driver requested for it.

this is not enough?

Regards

Marcel

#7 lore raw

Hi Marcel,

Quoted 20 lines · Marcel Holtmann

Hi Denis,

Quoted 6 lines
Quoted 3 lines

We could document this as Freerunner specific notes to point people into the right direction. And we should maybe to the same for IFX since that is currently only documented in the GIT commit logs.

Documentation inside the individual modem driver is the way to go. And IFX isn't even documented in git commit logs. I looked ;)

commit 3443a7a177fbaca24c84658968aff0a55db8a51d

Author: Marcel Holtmann <[email protected]>
Date:   Sat Sep 18 22:08:41 2010 +0900

udev: Add support for IFX device detection

The IFX device detection is pretty static, but instead of using a static configuration file it is important to know when the device node is actually present. For this udev is perfect. Adding a simple udev rule is all that it takes:

Quoted 6 lines

KERNEL=="ttyIFX[0-9]*", ENV{OFONO_DRIVER}="ifx"

With this rule for every TTY with the kernel name like ttyIFX0, a new modem will be added and the IFX modem plugin driver requested for it.

this is not enough?

Then I didn't look far back enough (or I'm simply blind). But I still prefer this to be inside the driver or HACKING.calypso for easier access.

Regards,
-Denis

#8 lore raw

Hi Denis,

Quoted 20 lines
Quoted 20 lines
Quoted 6 lines
Quoted 3 lines

We could document this as Freerunner specific notes to point people into the right direction. And we should maybe to the same for IFX since that is currently only documented in the GIT commit logs.

Documentation inside the individual modem driver is the way to go. And IFX isn't even documented in git commit logs. I looked ;)

commit 3443a7a177fbaca24c84658968aff0a55db8a51d

Author: Marcel Holtmann <[email protected]>
Date:   Sat Sep 18 22:08:41 2010 +0900

udev: Add support for IFX device detection

The IFX device detection is pretty static, but instead of using a static configuration file it is important to know when the device node is actually present. For this udev is perfect. Adding a simple udev rule is all that it takes:

KERNEL=="ttyIFX[0-9]*", ENV{OFONO_DRIVER}="ifx"

Quoted 7 lines
Quoted 4 lines

With this rule for every TTY with the kernel name like ttyIFX0, a new modem will be added and the IFX modem plugin driver requested for it.

this is not enough?

Then I didn't look far back enough (or I'm simply blind). But I still prefer this to be inside the driver or HACKING.calypso for easier access.

I am with you that this needs to be documented better than GIT commit logs.

However I do prefer doc/calypso-modem.txt and doc/ifx-modem.txt though since I don't wanna clutter the root directory.

Regards

Marcel

#9 lore raw

Hi Marcel,

Quoted 9 lines
Quoted 2 lines

Then I didn't look far back enough (or I'm simply blind). But I still prefer this to be inside the driver or HACKING.calypso for easier access.

I am with you that this needs to be documented better than GIT commit logs.

However I do prefer doc/calypso-modem.txt and doc/ifx-modem.txt though since I don't wanna clutter the root directory.

Sounds good to me.

Regards,
-Denis

#10 lore raw
Quoted 5 lines · Denis Kenzior

Hi Marcel,

Quoted 3 lines
Quoted 2 lines

Then I didn't look far back enough (or I'm simply blind). But I still prefer this to be inside the driver or HACKING.calypso for easier access.

Quoted 8 lines
Quoted 6 lines

I am with you that this needs to be documented better than GIT commit logs.

However I do prefer doc/calypso-modem.txt and doc/ifx-modem.txt though since I don't wanna clutter the root directory.

Sounds good to me.

Cool. Once I've worked out the simplest udev rule for calypso, I'll submit a patch to create doc/calypso-modem.txt to document that.

(I don't yet understand why it makes sense for calypso to be handled differently from other cases in plugins/ofono.rules, but I'm happy to trust that there is a good reason for this.)

Regards,
Neil

#11 lore raw

Hi Neil,

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 2 lines

Then I didn't look far back enough (or I'm simply blind). But I still prefer this to be inside the driver or HACKING.calypso for easier access.

I am with you that this needs to be documented better than GIT commit logs.

However I do prefer doc/calypso-modem.txt and doc/ifx-modem.txt though since I don't wanna clutter the root directory.

Quoted 8 lines
Quoted 1 line

Sounds good to me.

Cool. Once I've worked out the simplest udev rule for calypso, I'll submit a patch to create doc/calypso-modem.txt to document that.

(I don't yet understand why it makes sense for calypso to be handled differently from other cases in plugins/ofono.rules, but I'm happy to trust that there is a good reason for this.)

the other cases come from an unique vendor and product ID. The Calypso and also IFX modems are based on device nodes. These are not unique. They are platform specific. Not all platform will have a Calypso modem behind /dev/ttySAC0 for example.

Regards

Marcel

#12 lore raw
Quoted 10 lines · Marcel Holtmann

Hi Neil,

Quoted 3 lines

(I don't yet understand why it makes sense for calypso to be handled differently from other cases in plugins/ofono.rules, but I'm happy to trust that there is a good reason for this.)

the other cases come from an unique vendor and product ID. The Calypso and also IFX modems are based on device nodes. These are not unique. They are platform specific. Not all platform will have a Calypso modem behind /dev/ttySAC0 for example.

Ah yes, that makes sense. Thanks for explaining.

Neil