Skip to contentSkip to conversation

Huawei GPRS support

PATCH Superseded Kalle Valo 3 participants 12 messages May 19, 2010 – Aug 11, 2010

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Kalle Valo

author
#0 lore raw

v3 cover Huawei GPRS support

Here's v3 of my Huawei GPRS patches. I followed Marcel's advice and implemented all Huawei quirks in the huawei plugin. Now the patches are a lot smaller.

Please comment.

---

Kalle Valo (2):
huawei: add gprs context
huawei: detect SecondaryDevice which is used for events

 drivers/atmodem/network-registration.c |    4 +
 plugins/huawei.c                       |  112 +++++++++++++++++++++++++++++++-
 plugins/udev.c                         |   61 +++++++++++++++--
 3 files changed, 167 insertions(+), 10 deletions(-)
author
#1 lore raw

PATCH v3 1/2 huawei: detect SecondaryDevice which is used for events

---

 plugins/huawei.c |   39 ++++++++++++++++++++++++++++++++++-
 plugins/udev.c   |   61 +++++++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 91 insertions(+), 9 deletions(-)
plugins/huawei.c +38 -1
index df4d177..83a46e3 100644
@@ -45,7 +45,7 @@
 #include <drivers/atmodem/vendor.h>
 
 struct huawei_data {
-	GAtChat *chat;
+	GAtChat *chat, *event;
 };
 
 static int huawei_probe(struct ofono_modem *modem)
@@ -72,6 +72,7 @@ static void huawei_remove(struct ofono_modem *modem)
 	ofono_modem_set_data(modem, NULL);
 
 	g_at_chat_unref(data->chat);
+	g_at_chat_unref(data->event);
 	g_free(data);
 }
 
@@ -80,6 +81,11 @@ static void huawei_debug(const char *str, void *user_data)
 	ofono_info("%s", str);
 }
 
+static void huawei_event_debug(const char *str, void *user_data)
+{
+	ofono_info("* %s", str);
+}
+
 static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct ofono_modem *modem = user_data;
@@ -120,6 +126,29 @@ static int huawei_enable(struct ofono_modem *modem)
 	if (getenv("OFONO_AT_DEBUG"))
 		g_at_chat_set_debug(data->chat, huawei_debug, NULL);
 
+	device = ofono_modem_get_string(modem, "SecondaryDevice");
+	if (!device)
+		return -EINVAL;
+
+	channel = g_at_tty_open(device, NULL);
+	if (!channel)
+		return -EIO;
+
+	syntax = g_at_syntax_new_gsm_permissive();
+	data->event = g_at_chat_new(channel, syntax);
+	g_at_syntax_unref(syntax);
+	g_io_channel_unref(channel);
+
+	if (!data->event)
+		return -EIO;
+
+	g_at_chat_add_terminator(data->event, "COMMAND NOT SUPPORT", -1,
+				 FALSE);
+
+	if (getenv("OFONO_AT_DEBUG"))
+		g_at_chat_set_debug(data->event, huawei_event_debug, NULL);
+
+
 	g_at_chat_send(data->chat, "ATE0", NULL, NULL, NULL, NULL);
 
 	g_at_chat_send(data->chat, "AT+CFUN=1", NULL,
@@ -138,6 +167,9 @@ static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
 	g_at_chat_unref(data->chat);
 	data->chat = NULL;
 
+	g_at_chat_unref(data->event);
+	data->event = NULL;
+
 	if (ok)
 		ofono_modem_set_powered(modem, FALSE);
 }
@@ -148,6 +180,11 @@ static int huawei_disable(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
+	if (data->event) {
+		g_at_chat_cancel_all(data->event);
+		g_at_chat_unregister_all(data->event);
+	}
+
 	if (!data->chat)
 		return 0;
 
plugins/udev.c +53 -8

77 lines not on this page · raw message

#2 lore raw

Re: [PATCH v3 1/2] huawei: detect SecondaryDevice which is used for events

Hi Kalle,

Please keep the commit header to less than 50 lines.

plugins/huawei.c static int huawei_enable(struct ofono_modem *modem) · line 131

Quoted 3 lines
plugins/huawei.c +3 -0
+	device = ofono_modem_get_string(modem, "SecondaryDevice");
+	if (!device)
+		return -EINVAL;

Two tabs is enough here.

Quoted 5 lines
plugins/huawei.c +5 -0
+
+	channel = g_at_tty_open(device, NULL);
+	if (!channel)
+		return -EIO;
+

plugins/huawei.c static int huawei_enable(struct ofono_modem *modem) · line 146

Quoted 10 lines
plugins/huawei.c +10 -0
+	syntax = g_at_syntax_new_gsm_permissive();
+	data->event = g_at_chat_new(channel, syntax);
+	g_at_syntax_unref(syntax);
+	g_io_channel_unref(channel);
+
+	if (!data->event)
+		return -EIO;
+
+	g_at_chat_add_terminator(data->event, "COMMAND NOT SUPPORT", -1,
+				 FALSE);

Don't mix spaces and tabs for indentation

plugins/huawei.c static int huawei_enable(struct ofono_modem *modem) · line 151

Quoted 5 lines
plugins/huawei.c +5 -0
+
+	if (getenv("OFONO_AT_DEBUG"))
+		g_at_chat_set_debug(data->event, huawei_event_debug, NULL);
+
+

Why the extra space?

Also, this entire sequence leaks the data->chat in case the 2nd port could not be opened. See plugins/mbm.c for an example on how to do this better.

Regards,
-Denis

author
#3 lore raw

Re: [PATCH v3 1/2] huawei: detect SecondaryDevice which is used for events

Quoted 1 line · Denis Kenzior

Hi Kalle,

Hi Denis,

Quoted 1 line

Please keep the commit header to less than 50 lines.

Fixed.

Quoted 5 lines

plugins/huawei.c static int huawei_enable(struct ofono_modem *modem) · line 131

Quoted 3 lines
plugins/huawei.c +3 -0
+	device = ofono_modem_get_string(modem, "SecondaryDevice");
+	if (!device)
+		return -EINVAL;

Two tabs is enough here.

Sorry, but I see only two tabs here. What am I missing? Ah, now I understand. I think you are commenting the line earlier in huawei_enable() which is indented wrong. I'll fix that.

Quoted 8 lines
Quoted 8 lines
plugins/huawei.c +8 -0
+	channel = g_at_tty_open(device, NULL);
+	if (!channel)
+		return -EIO;
+
+	syntax = g_at_syntax_new_gsm_permissive();
+	data->event = g_at_chat_new(channel, syntax);
+	g_at_syntax_unref(syntax);
+	g_io_channel_unref(channel);
Quoted 8 lines

plugins/huawei.c static int huawei_enable(struct ofono_modem *modem) · line 146

Quoted 6 lines
plugins/huawei.c +6 -0
+
+	if (!data->event)
+		return -EIO;
+
+	g_at_chat_add_terminator(data->event, "COMMAND NOT SUPPORT", -1,
+				 FALSE);

Don't mix spaces and tabs for indentation

Fixed.

Quoted 7 lines

plugins/huawei.c static int huawei_enable(struct ofono_modem *modem) · line 151

Quoted 5 lines
plugins/huawei.c +5 -0
+
+	if (getenv("OFONO_AT_DEBUG"))
+		g_at_chat_set_debug(data->event, huawei_event_debug, NULL);
+
+

Why the extra space?

You mean the newline, right? That's by accident, I removed it now.

Quoted 3 lines

Also, this entire sequence leaks the data->chat in case the 2nd port could not be opened. See plugins/mbm.c for an example on how to do this better.

Damn, so it does. I changed it now to follow the style from mbm.c.

Thanks a lot for the comments.

Signature · 1 line
Kalle Valo
author
#4 lore raw

PATCH v3 2/2 huawei: add gprs context

In reply to Kalle Valo

Tested with Huawei E1552 HSDPA USB stick using a finnish Saunalahti prepaid SIM.
---

 drivers/atmodem/network-registration.c |    4 ++
 plugins/huawei.c                       |   73 ++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+), 1 deletions(-)
drivers/atmodem/network-registration.c +4 -0
index f7aafbe..f528339 100644
@@ -916,6 +916,10 @@ static void at_creg_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
 				cind_support_cb, netreg, NULL);
 
 		break;
+	case OFONO_VENDOR_HUAWEI:
+		/* huawei doesn't support CIND */
+		ofono_netreg_register(netreg);
+		break;
 	default:
 		g_at_chat_send(nd->chat, "AT+CIND=?", cind_prefix,
 				cind_support_cb, netreg, NULL);
plugins/huawei.c +72 -1

93 lines not on this page · raw message

#5 lore raw

Re: [PATCH v3 2/2] huawei: add gprs context

Hi Kalle,

plugins/huawei.c static void huawei_pre_sim(struct ofono_modem *modem) · line 227

Quoted 3 lines
plugins/huawei.c +3 -0
+	ret = at_util_parse_reg_unsolicited(result, "+CGREG:", &status,
+					    NULL, NULL, NULL,
+					    OFONO_VENDOR_HUAWEI);

No mixing of tabs & spaces for indentation

plugins/huawei.c static void huawei_pre_sim(struct ofono_modem *modem) · line 236

Quoted 9 lines
plugins/huawei.c +9 -0
+
+	if (ret == FALSE)
+		return;
+
+	ofono_gprs_status_notify(gprs, status);
+}
+
+static inline void report_signal_strength(struct ofono_netreg *netreg,
+					  int strength)

And here

plugins/huawei.c static void huawei_pre_sim(struct ofono_modem *modem) · line 246

Quoted 10 lines
plugins/huawei.c +10 -0
+{
+	DBG("%d", strength);
+
+	if (strength == 99)
+		strength = -1;
+	else
+		strength = (strength * 100) / 31;
+
+	ofono_netreg_strength_notify(netreg, strength);
+}

You might really want to make this into an atutil function instead of copy- pasting it around.

Quoted 20 lines
plugins/huawei.c +18 -0
+
+static void huawei_rssi_notify(GAtResult *result, gpointer user_data)
+{
+	struct ofono_netreg *netreg = user_data;
+	GAtResultIter iter;
+	int strength;
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "^RSSI:"))
+		return;
+
+	if (!g_at_result_iter_next_number(&iter, &strength))
+		return;
+
+	report_signal_strength(netreg, strength);
+}
+
 static void huawei_post_sim(struct ofono_modem *modem)
 {

plugins/huawei.c static void huawei_pre_sim(struct ofono_modem *modem) · line 275

Quoted 10 lines
plugins/huawei.c +5 -1
 	struct huawei_data *data = ofono_modem_get_data(modem);
+	struct ofono_gprs_context *gc;
+	struct ofono_netreg *netreg;
+	struct ofono_gprs *gprs;
 
 	DBG("%p", modem);
 
-	ofono_netreg_create(modem, OFONO_VENDOR_HUAWEI, "atmodem", data->chat);
+	netreg = ofono_netreg_create(modem, OFONO_VENDOR_HUAWEI, "atmodem",
+				     data->chat);

Again with mixed indentation

plugins/huawei.c static void huawei_pre_sim(struct ofono_modem *modem) · line 279

Quoted 4 lines
plugins/huawei.c +2 -0
 	ofono_sms_create(modem, OFONO_VENDOR_QUALCOMM_MSM, "atmodem",
 data->chat); +
+	gprs = ofono_gprs_create(modem, OFONO_VENDOR_HUAWEI, "atmodem",
+				 data->chat);

And here

plugins/huawei.c static void huawei_pre_sim(struct ofono_modem *modem) · line 287

Quoted 8 lines
plugins/huawei.c +8 -0
+	gc = ofono_gprs_context_create(modem, 0, "atmodem", data->chat);
+
+	if (gprs && gc) {
+		ofono_gprs_add_context(gprs, gc);
+
+		/* huawei has a separate channel for CGREG notifications */
+		g_at_chat_register(data->event, "+CGREG:",
+				   huawei_cgreg_notify, FALSE, gprs, NULL);

And here

plugins/huawei.c static void huawei_pre_sim(struct ofono_modem *modem) · line 291

Quoted 4 lines
plugins/huawei.c +4 -0
+
+		/* huawei uses non-standard "^RSSI:18" strings */
+		g_at_chat_register(data->event, "^RSSI:",
+				   huawei_rssi_notify, FALSE, netreg, NULL);

And here

plugins/huawei.c static void huawei_pre_sim(struct ofono_modem *modem) · line 295

Quoted 4 lines
plugins/huawei.c +1 -0
+	}
 }
 
 static struct ofono_modem_driver huawei_driver = {

Regards,
-Denis

author
#6 lore raw

Re: [PATCH v3 2/2] huawei: add gprs context

Quoted 1 line · Denis Kenzior

Hi Kalle,

Hi again Denis,

Quoted 5 lines

plugins/huawei.c static void huawei_pre_sim(struct ofono_modem *modem) · line 227

Quoted 3 lines
plugins/huawei.c +3 -0
+	ret = at_util_parse_reg_unsolicited(result, "+CGREG:", &status,
+					    NULL, NULL, NULL,
+					    OFONO_VENDOR_HUAWEI);

No mixing of tabs & spaces for indentation

Fixed.

Oh man, I have to fix my emacs settings :/

Quoted 11 lines

plugins/huawei.c static void huawei_pre_sim(struct ofono_modem *modem) · line 236

Quoted 9 lines
plugins/huawei.c +9 -0
+
+	if (ret == FALSE)
+		return;
+
+	ofono_gprs_status_notify(gprs, status);
+}
+
+static inline void report_signal_strength(struct ofono_netreg *netreg,
+					  int strength)

And here

This function is gone now.

Quoted 4 lines
Quoted 4 lines
plugins/huawei.c +4 -0
+	DBG("%d", strength);
+
+	if (strength == 99)
+		strength = -1;
Quoted 8 lines

plugins/huawei.c static void huawei_pre_sim(struct ofono_modem *modem) · line 246

Quoted 5 lines
plugins/huawei.c +5 -0
+	else
+		strength = (strength * 100) / 31;
+
+	ofono_netreg_strength_notify(netreg, strength);
+}

You might really want to make this into an atutil function instead of copy- pasting it around.

I created this:

static inline int at_util_convert_signal_strength(int strength)

{
	int result;

	if (strength == 99)
		result = -1;
	else
		result = (strength * 100) / 31;

	return result;
}
Quoted 5 lines

plugins/huawei.c static void huawei_pre_sim(struct ofono_modem *modem) · line 275

Quoted 3 lines
plugins/huawei.c +2 -1
-	ofono_netreg_create(modem, OFONO_VENDOR_HUAWEI, "atmodem", data->chat);
+	netreg = ofono_netreg_create(modem, OFONO_VENDOR_HUAWEI, "atmodem",
+				     data->chat);

Again with mixed indentation

Fixed.

Quoted 6 lines

plugins/huawei.c static void huawei_pre_sim(struct ofono_modem *modem) · line 279

Quoted 4 lines
plugins/huawei.c +2 -0
 	ofono_sms_create(modem, OFONO_VENDOR_QUALCOMM_MSM, "atmodem",
 data->chat); +
+	gprs = ofono_gprs_create(modem, OFONO_VENDOR_HUAWEI, "atmodem",
+				 data->chat);

And here

Fixed.

Quoted 10 lines

plugins/huawei.c static void huawei_pre_sim(struct ofono_modem *modem) · line 287

Quoted 8 lines
plugins/huawei.c +8 -0
+	gc = ofono_gprs_context_create(modem, 0, "atmodem", data->chat);
+
+	if (gprs && gc) {
+		ofono_gprs_add_context(gprs, gc);
+
+		/* huawei has a separate channel for CGREG notifications */
+		g_at_chat_register(data->event, "+CGREG:",
+				   huawei_cgreg_notify, FALSE, gprs, NULL);

And here

Fixed.

Quoted 6 lines

plugins/huawei.c static void huawei_pre_sim(struct ofono_modem *modem) · line 291

Quoted 4 lines
plugins/huawei.c +4 -0
+
+		/* huawei uses non-standard "^RSSI:18" strings */
+		g_at_chat_register(data->event, "^RSSI:",
+				   huawei_rssi_notify, FALSE, netreg, NULL);

And here

Fixed.

Thank you for the comments. I'll run some tests first and send v4 soon.

Signature · 1 line
Kalle Valo
#7 lore raw

Re: [PATCH v3 2/2] huawei: add gprs context

Hi Kale

Quoted 12 lines · Kalle Valo
Quoted 1 line · Denis Kenzior

Hi Kalle,

Hi again Denis,

Quoted 5 lines

plugins/huawei.c static void huawei_pre_sim(struct ofono_modem *modem) · line 227

Quoted 3 lines
plugins/huawei.c +3 -0
+	ret = at_util_parse_reg_unsolicited(result, "+CGREG:", &status,
+					    NULL, NULL, NULL,
+					    OFONO_VENDOR_HUAWEI);

No mixing of tabs & spaces for indentation

Quoted 3 lines

Fixed.

Oh man, I have to fix my emacs settings :/

Did you find a set of emacs offset settings to get to oFono's liking? I've been fiddling with it for a while, but keep alking in circles around it. It's been too long since I've done emacs config :(

thanks!

author
#8 lore raw

Re: [PATCH v3 2/2] huawei: add gprs context

Quoted 1 line · Inaky Perez-Gonzalez

Hi Kale

Hi Inaky,

Quoted 5 lines · Kalle Valo
Quoted 4 lines
Quoted 1 line · Denis Kenzior

No mixing of tabs & spaces for indentation

Quoted 7 lines
Quoted 3 lines

Fixed.

Oh man, I have to fix my emacs settings :/

Did you find a set of emacs offset settings to get to oFono's liking? I've been fiddling with it for a while, but keep alking in circles around it. It's been too long since I've done emacs config :(

This is my setup:

; from linux/Documentation/CodingStyle
(defun c-lineup-arglist-tabs-only (ignored)
"Line up argument lists by tabs, not spaces" (let* ((anchor (c-langelem-pos c-syntactic-element))

	 (column (c-langelem-2nd-pos c-syntactic-element))
	 (offset (- (1+ column) anchor))
	 (steps (floor offset c-basic-offset)))
    (* (max steps 1)
       c-basic-offset)))

(add-hook 'c-mode-common-hook

          (lambda ()
            ;; Add kernel style
            (c-add-style
             "linux-tabs-only"
             '("linux" (c-offsets-alist
                        (arglist-cont-nonempty
                         c-lineup-gcc-asm-reg
                         c-lineup-arglist-tabs-only))))))

And whenever I start editing ofono or connman, I run command "C-c . linux-tabs-only" choose the style. But it's not perfect yet, for example I need to manually add tabs when having multi-line function calls.

Signature · 1 line
Kalle Valo
#9 lore raw

Re: [PATCH v3 2/2] huawei: add gprs context

Hi Kale

Quoted 13 lines · Kalle Valo

....

Quoted 5 lines
Quoted 1 line

Oh man, I have to fix my emacs settings :/

Did you find a set of emacs offset settings to get to oFono's liking? I've been fiddling with it for a while, but keep alking in circles around it. It's been too long since I've done emacs config :(

This is my setup:

; from linux/Documentation/CodingStyle
(defun c-lineup-arglist-tabs-only (ignored)
"Line up argument lists by tabs, not spaces" (let* ((anchor (c-langelem-pos c-syntactic-element))

Quoted 5 lines
	 (column (c-langelem-2nd-pos c-syntactic-element))
	 (offset (- (1+ column) anchor))
	 (steps (floor offset c-basic-offset)))
    (* (max steps 1)
       c-basic-offset)))

Thanks! Phew ... this is a handful of lisp! I don't understand anything that is not basic anymore :) -- I gave it a whiz and one thing I saw was that

struct tx_queue_entry *__ofono_sms_txq_submit(struct ofono_sms *sms,
GSList *list,
unsigned int flags, unsigned msg_id, ofono_sms_msg_stch_cb_t stch_cb, void *data, ofono_destroy_func destroy)

is being formatted as:

struct tx_queue_entry *__ofono_sms_txq_submit(struct ofono_sms *sms,
GSList *list,
unsigned int flags, unsigned msg_id, ofono_sms_msg_stch_cb_t stch_cb, void *data, ofono_destroy_func destroy)

ie: one c-basic-offset less than it should -- I really can't figure out where to poke.

Quoted 10 lines

(add-hook 'c-mode-common-hook

          (lambda ()
            ;; Add kernel style
            (c-add-style
             "linux-tabs-only"
             '("linux" (c-offsets-alist
                        (arglist-cont-nonempty
                         c-lineup-gcc-asm-reg
                         c-lineup-arglist-tabs-only))))))
Quoted 4 lines

And whenever I start editing ofono or connman, I run command "C-c . linux-tabs-only" choose the style. But it's not perfect yet, for example I need to manually add tabs when having multi-line function calls.

I have a code snippet for automate the mode setting:

;; Initialization hook
(add-hook 'c-mode-common-hook 'c-select-style)

;; this looks at the path and based on the name, sets a style -- it ;; is setup to my work habits -- I keep all my ofono work in ;; ~/something/ofono/ofono.git, kernel work in ~/something/linux/*..

(defun c-select-style ()
(let

      ((style c-default-style))
    (if (string-match 
         "linux[^/]*"
         buffer-file-truename)
        (progn
          (c-set-style "linux")
          (setq indent-tabs-mode t)
          (setq c-basic-offset 8)
          (setq style "linux")
          )
      (if (string-match "ofono[^/]*/" buffer-file-truename)
          (progn

;; I renamed your c-style to 'ofono' so not to get confused :)
(c-set-style "ofono")
(setq indent-tabs-mode t)
(setq c-basic-offset 8)
(setq style "ofono")
)
;; Default
(progn
(c-set-style "linux")
(setq indent-tabs-mode t)
(setq c-basic-offset 8)
(setq style "ofono")
)
)
)
(setq c-indent-comments-syntactically-p t) (define-key c-mode-map "\C-m" 'c-context-line-break) (c-toggle-auto-hungry-state 1)
(message (concat "C style set to " style))
)
)

author
#10 lore raw

Re: [PATCH v3 2/2] huawei: add gprs context

Quoted 1 line · Inaky Perez-Gonzalez

Hi Kale

Hola,

Quoted 14 lines · Kalle Valo
Quoted 7 lines

This is my setup:

; from linux/Documentation/CodingStyle
(defun c-lineup-arglist-tabs-only (ignored)
"Line up argument lists by tabs, not spaces" (let* ((anchor (c-langelem-pos c-syntactic-element))

Quoted 5 lines
	 (column (c-langelem-2nd-pos c-syntactic-element))
	 (offset (- (1+ column) anchor))
	 (steps (floor offset c-basic-offset)))
    (* (max steps 1)
       c-basic-offset)))
Quoted 2 lines

Thanks! Phew ... this is a handful of lisp! I don't understand anything that is not basic anymore :)

It sure is. I just copied it from Linux CodingStyle document and it seems to work somehow.

Quoted 10 lines

-- I gave it a whiz and one thing I saw was that

struct tx_queue_entry *__ofono_sms_txq_submit(struct ofono_sms *sms,
GSList *list,
unsigned int flags, unsigned msg_id, ofono_sms_msg_stch_cb_t stch_cb, void *data, ofono_destroy_func destroy)

is being formatted as:

Quoted 7 lines

struct tx_queue_entry *__ofono_sms_txq_submit(struct ofono_sms *sms,
GSList *list,
unsigned int flags, unsigned msg_id, ofono_sms_msg_stch_cb_t stch_cb, void *data, ofono_destroy_func destroy)

ie: one c-basic-offset less than it should -- I really can't figure out where to poke.

That's my problem as well. Currently I just manually add one more tab to each line with M-i. If you find a way to fix this, please let me know.

Signature · 1 line
Kalle Valo
#11 lore raw

Re: [PATCH v3 2/2] huawei: add gprs context

Quoted 42 lines · Kalle Valo
Quoted 1 line · Inaky Perez-Gonzalez

Hi Kale

Hola,

Quoted 14 lines · Kalle Valo
Quoted 7 lines

This is my setup:

; from linux/Documentation/CodingStyle
(defun c-lineup-arglist-tabs-only (ignored)
"Line up argument lists by tabs, not spaces" (let* ((anchor (c-langelem-pos c-syntactic-element))

Quoted 5 lines
	 (column (c-langelem-2nd-pos c-syntactic-element))
	 (offset (- (1+ column) anchor))
	 (steps (floor offset c-basic-offset)))
    (* (max steps 1)
       c-basic-offset)))
Quoted 2 lines

Thanks! Phew ... this is a handful of lisp! I don't understand anything that is not basic anymore :)

It sure is. I just copied it from Linux CodingStyle document and it seems to work somehow.

Quoted 16 lines

-- I gave it a whiz and one thing I saw was that

struct tx_queue_entry *__ofono_sms_txq_submit(struct ofono_sms *sms,
GSList *list,
unsigned int flags, unsigned msg_id, ofono_sms_msg_stch_cb_t stch_cb, void *data, ofono_destroy_func destroy)

is being formatted as:

struct tx_queue_entry *__ofono_sms_txq_submit(struct ofono_sms *sms,
GSList *list,
unsigned int flags, unsigned msg_id, ofono_sms_msg_stch_cb_t stch_cb, void *data, ofono_destroy_func destroy)

Quoted 4 lines
Quoted 1 line

ie: one c-basic-offset less than it should -- I really can't figure out where to poke.

That's my problem as well. Currently I just manually add one more tab to each line with M-i. If you find a way to fix this, please let me know.

I think I found it, seems to cut it; replace:

(steps (floor offset c-basic-offset)))

with

         (steps (floor (+ offset (- c-basic-offset 1)) c-basic-offset)))

Lisp nuts me out, but it is doing the:

steps = floor(offset/c-basic-offset);

with

steps = floor((offset + c-basic-offset - 1) / c-basic-offset);

thus making sure there is always one more tab except when the offset is right on a tab boundary that we keep the same.

So far, so good -- probably it fails in some case, because this is totally trial and error as unscientific as it can :)