diff mbox series

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

Message ID 20241011101839.3646442-1-sean@geanix.com (mailing list archive)
State Accepted
Commit fbd6743d14786cc65a7c37461c27fa8f5fe77d97
Headers show
Series [v2,1/3] drivers: simcommodem: create rat to radio_access_mode function | expand

Commit Message

Sean Nyekjaer Oct. 11, 2024, 10:18 a.m. UTC
This is done in preparation for querying available rat modes
---
Changes since v1:
 - fixed function name
 - changed mode variable to int, to allow negative numbers

 drivers/simcommodem/radio-settings.c | 47 +++++++++++++++++-----------
 1 file changed, 28 insertions(+), 19 deletions(-)

Comments

Denis Kenzior Oct. 14, 2024, 3:57 p.m. UTC | #1
Hi Sean,

On 10/11/24 5:18 AM, Sean Nyekjaer wrote:
> This is done in preparation for querying available rat modes
> ---
> Changes since v1:
>   - fixed function name
>   - changed mode variable to int, to allow negative numbers
> 
>   drivers/simcommodem/radio-settings.c | 47 +++++++++++++++++-----------
>   1 file changed, 28 insertions(+), 19 deletions(-)
> 

Applied with a couple amends in patches 2 & 3 to comply with the 80 character / 
line limit.  See doc/coding-style.txt for more details.

Regards,
-Denis
patchwork-bot+ofono@kernel.org Oct. 14, 2024, 4 p.m. UTC | #2
Hello:

This series was applied to ofono.git (master)
by Denis Kenzior <denkenz@gmail.com>:

On Fri, 11 Oct 2024 12:18:34 +0200 you wrote:
> This is done in preparation for querying available rat modes
> ---
> Changes since v1:
>  - fixed function name
>  - changed mode variable to int, to allow negative numbers
> 
>  drivers/simcommodem/radio-settings.c | 47 +++++++++++++++++-----------
>  1 file changed, 28 insertions(+), 19 deletions(-)

Here is the summary with links:
  - [v2,1/3] drivers: simcommodem: create rat to radio_access_mode function
    https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=fbd6743d1478
  - [v2,2/3] drivers: simcommodem: query modem for available rat modes
    (no matching commit)
  - [v2,3/3] sim7100: create lte atom in post_sim()
    (no matching commit)

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/simcommodem/radio-settings.c b/drivers/simcommodem/radio-settings.c
index 0feba960..bf78c748 100644
--- a/drivers/simcommodem/radio-settings.c
+++ b/drivers/simcommodem/radio-settings.c
@@ -33,13 +33,36 @@  struct radio_settings_data {
 	GAtChat *chat;
 };
 
+static int cnmp_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;
 	ofono_radio_settings_rat_mode_query_cb_t cb = cbd->cb;
-	unsigned int mode;
 	struct ofono_error error;
-	int r_mode;
+	int r_mode, mode;
 	GAtResultIter iter;
 
 	DBG("ok %d", ok);
@@ -61,23 +84,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 = cnmp_mode_to_radio_access_mode(r_mode);
+	if (mode < 0)
+		goto error;
 
 	cb(&error, mode, cbd->data);