From: Kalle Valo <kalle.valo@canonical.com>
To: ofono@ofono.org
Subject: [PATCH v5 2/3] Move report_signal_strength to atutil
Date: Thu, 20 May 2010 13:53:21 +0300 [thread overview]
Message-ID: <20100520105321.20968.95696.stgit@potku.valot.fi> (raw)
In-Reply-To: <20100520105215.20968.59029.stgit@potku.valot.fi>
[-- Attachment #1: Type: text/plain, Size: 2658 bytes --]
The function is needed in two different places, better to move it
to atutil.h.
---
drivers/atmodem/atutil.h | 12 ++++++++++++
drivers/atmodem/network-registration.c | 22 ++++++----------------
2 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/drivers/atmodem/atutil.h b/drivers/atmodem/atutil.h
index 9303ed4..265a5ad 100644
--- a/drivers/atmodem/atutil.h
+++ b/drivers/atmodem/atutil.h
@@ -55,6 +55,18 @@ static inline struct cb_data *cb_data_new(void *cb, void *data)
return ret;
}
+static inline int at_util_convert_signal_strength(int strength)
+{
+ int result;
+
+ if (strength == 99)
+ result = -1;
+ else
+ result = (strength * 100) / 31;
+
+ return result;
+}
+
#define DECLARE_FAILURE(e) \
struct ofono_error e; \
e.type = OFONO_ERROR_TYPE_FAILURE; \
diff --git a/drivers/atmodem/network-registration.c b/drivers/atmodem/network-registration.c
index f7aafbe..f137d94 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -463,19 +463,6 @@ error:
CALLBACK_WITH_FAILURE(cb, data);
}
-static inline void report_signal_strength(struct ofono_netreg *netreg,
- int strength)
-{
- DBG("csq_notify: %d", strength);
-
- if (strength == 99)
- strength = -1;
- else
- strength = (strength * 100) / 31;
-
- ofono_netreg_strength_notify(netreg, strength);
-}
-
static void csq_notify(GAtResult *result, gpointer user_data)
{
struct ofono_netreg *netreg = user_data;
@@ -490,7 +477,8 @@ static void csq_notify(GAtResult *result, gpointer user_data)
if (!g_at_result_iter_next_number(&iter, &strength))
return;
- report_signal_strength(netreg, strength);
+ ofono_netreg_strength_notify(netreg,
+ at_util_convert_signal_strength(strength));
}
static void calypso_csq_notify(GAtResult *result, gpointer user_data)
@@ -507,7 +495,8 @@ static void calypso_csq_notify(GAtResult *result, gpointer user_data)
if (!g_at_result_iter_next_number(&iter, &strength))
return;
- report_signal_strength(netreg, strength);
+ ofono_netreg_strength_notify(netreg,
+ at_util_convert_signal_strength(strength));
}
static void option_osigq_notify(GAtResult *result, gpointer user_data)
@@ -524,7 +513,8 @@ static void option_osigq_notify(GAtResult *result, gpointer user_data)
if (!g_at_result_iter_next_number(&iter, &strength))
return;
- report_signal_strength(netreg, strength);
+ ofono_netreg_strength_notify(netreg,
+ at_util_convert_signal_strength(strength));
}
static void option_owcti_notify(GAtResult *result, gpointer user_data)
next prev parent reply other threads:[~2010-05-20 10:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-20 10:53 [PATCH v5 0/3] Huawei GPRS support Kalle Valo
2010-05-20 4:15 ` Denis Kenzior
2010-05-20 10:53 ` [PATCH v5 1/3] huawei: detect possible secondary device Kalle Valo
2010-05-20 10:53 ` Kalle Valo [this message]
2010-05-20 10:53 ` [PATCH v5 3/3] huawei: add gprs context Kalle Valo
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=20100520105321.20968.95696.stgit@potku.valot.fi \
--to=kalle.valo@canonical.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