[PATCH 1/3] drivers: simcommodem: create rat to radio_access_mode function

Sean Nyekjaer <[email protected]>
Newsgroups dev.linux.lists.ofono
Message-ID <[email protected]>
This is done in preparation for querying available rat modes
---
 drivers/simcommodem/radio-settings.c | 44 +++++++++++++++++-----------
 1 file changed, 27 insertions(+), 17 deletions(-)

diff --git a/drivers/simcommodem/radio-settings.c b/drivers/simcommodem/radio-settings.c
index 0feba960..2a9dbaa2 100644
--- a/drivers/simcommodem/radio-settings.c
+++ b/drivers/simcommodem/radio-settings.c
@@ -33,6 +33,30 @@ struct radio_settings_data {
 	GAtChat *chat;
 };
 
+int r_mode_to_radio_access_mode(int r_mode)
+{
+	int mode;
+
+	switch (r_mode) {
+	case 2:
+		mode = OFONO_RADIO_ACCESS_MODE_ANY;
+		break;
+	case 13:
+		mode = OFONO_RADIO_ACCESS_MODE_GSM;
+		break;
+	case 14:
+		mode = OFONO_RADIO_ACCESS_MODE_UMTS;
+		break;
+	case 38:
+		mode = OFONO_RADIO_ACCESS_MODE_LTE;
+		break;
+	default:
+		return -1;
+	}
+
+	return mode;
+}
+
 static void cnmp_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct cb_data *cbd = user_data;
@@ -61,23 +85,9 @@ static void cnmp_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
 
 	DBG("r_mode %d", r_mode);
 
-	switch (r_mode) {
-	case 2:
-		mode = OFONO_RADIO_ACCESS_MODE_ANY;
-		break;
-	case 13:
-		mode = OFONO_RADIO_ACCESS_MODE_GSM;
-		break;
-	case 14:
-		mode = OFONO_RADIO_ACCESS_MODE_UMTS;
-		break;
-	case 38:
-		mode = OFONO_RADIO_ACCESS_MODE_LTE;
-		break;
-	default:
-		CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
-		return;
-	}
+	mode = r_mode_to_radio_access_mode(r_mode);
+	if (mode < 0)
+		goto error;
 
 	cb(&error, mode, cbd->data);
 
-- 
2.46.2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.