diff mbox series

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

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

Commit Message

Sean Nyekjaer Oct. 8, 2024, 9:10 a.m. UTC
This is done in preparation for querying available rat modes
---
 drivers/simcommodem/radio-settings.c | 44 +++++++++++++++++-----------
 1 file changed, 27 insertions(+), 17 deletions(-)

Comments

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

On 10/8/24 4:10 AM, Sean Nyekjaer wrote:
> This is done in preparation for querying available rat modes
> ---
>   drivers/simcommodem/radio-settings.c | 44 +++++++++++++++++-----------
>   1 file changed, 27 insertions(+), 17 deletions(-)
> 

CI complains about this set:

Build Failed:
drivers/simcommodem/radio-settings.c:36:5: error: no previous declaration for 
'r_mode_to_radio_access_mode' [-Werror=missing-declarations]
36 | int r_mode_to_radio_access_mode(int r_mode)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/simcommodem/radio-settings.c: In function 'cnmp_query_cb':
drivers/simcommodem/radio-settings.c:89:18: error: comparison of unsigned 
expression in '< 0' is always false [-Werror=type-limits]
89 | if (mode < 0)
| ^
cc1: all warnings being treated as errors
make[1]: *** [Makefile:4073: drivers/simcommodem/radio-settings.o] Error 1
make[1]: Target 'all-am' not remade because of errors.
make: *** [Makefile:2383: all] Error 2

> 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)

Naming might need some work.  Maybe cnmp_mode_to_radio_access_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);
>   

Regards,
-Denis
diff mbox series

Patch

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);