public inbox for ofono@lists.linux.dev
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@lists.linux.dev
Cc: Denis Kenzior <denkenz@gmail.com>
Subject: [PATCH 2/6] qmi: wds: Move enum conversion into wds.c
Date: Mon, 29 Apr 2024 10:56:54 -0500	[thread overview]
Message-ID: <20240429155726.51479-2-denkenz@gmail.com> (raw)
In-Reply-To: <20240429155726.51479-1-denkenz@gmail.com>

Introduce a new wds.c file which will house various utilities, such as
enumeration conversion, that could be shared between multiple QMI based
atom drivers.  Move ofono_gprs_auth_method conversion here.
---
 Makefile.am                     |  1 +
 drivers/qmimodem/gprs-context.c | 17 +----------------
 drivers/qmimodem/wds.c          | 25 +++++++++++++++++++++++++
 drivers/qmimodem/wds.h          |  2 ++
 4 files changed, 29 insertions(+), 16 deletions(-)
 create mode 100644 drivers/qmimodem/wds.c

diff --git a/Makefile.am b/Makefile.am
index b5a32fac1c89..815d96904943 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -362,6 +362,7 @@ qmi_sources = drivers/qmimodem/qmi.h drivers/qmimodem/qmi.c \
 					drivers/qmimodem/pds.h \
 					drivers/qmimodem/common.h \
 					drivers/qmimodem/wda.h \
+					drivers/qmimodem/wds.c \
 					drivers/qmimodem/voice.h
 
 builtin_sources += $(qmi_sources) \
diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c
index 4004876bab87..9ac57c893725 100644
--- a/drivers/qmimodem/gprs-context.c
+++ b/drivers/qmimodem/gprs-context.c
@@ -239,21 +239,6 @@ static void qmi_gprs_read_settings(struct ofono_gprs_context* gc,
 	l_free(cbd);
 }
 
-static uint8_t auth_method_to_qmi_auth(enum ofono_gprs_auth_method method)
-{
-	/* QMI uses a bitmap */
-	switch (method) {
-	case OFONO_GPRS_AUTH_METHOD_CHAP:
-		return QMI_WDS_AUTHENTICATION_CHAP;
-	case OFONO_GPRS_AUTH_METHOD_PAP:
-		return QMI_WDS_AUTHENTICATION_PAP;
-	case OFONO_GPRS_AUTH_METHOD_NONE:
-		return 0;
-	}
-
-	return 0;
-}
-
 static void qmi_activate_primary(struct ofono_gprs_context *gc,
 				const struct ofono_gprs_primary_context *ctx,
 				ofono_gprs_context_cb_t cb, void *user_data)
@@ -288,7 +273,7 @@ static void qmi_activate_primary(struct ofono_gprs_context *gc,
 
 	qmi_param_append_uint8(param, QMI_WDS_PARAM_IP_FAMILY, ip_family);
 
-	auth = auth_method_to_qmi_auth(ctx->auth_method);
+	auth = qmi_wds_auth_from_ofono(ctx->auth_method);
 
 	qmi_param_append_uint8(param, QMI_WDS_PARAM_AUTHENTICATION_PREFERENCE,
 					auth);
diff --git a/drivers/qmimodem/wds.c b/drivers/qmimodem/wds.c
new file mode 100644
index 000000000000..748ad867c2cc
--- /dev/null
+++ b/drivers/qmimodem/wds.c
@@ -0,0 +1,25 @@
+/*
+ * oFono - Open Source Telephony
+ * Copyright (C) 2024  Cruise, LLC
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include "src/common.h"
+
+#include "wds.h"
+
+int qmi_wds_auth_from_ofono(enum ofono_gprs_auth_method method)
+{
+	/* QMI uses a bitmap */
+	switch (method) {
+	case OFONO_GPRS_AUTH_METHOD_CHAP:
+		return QMI_WDS_AUTHENTICATION_CHAP;
+	case OFONO_GPRS_AUTH_METHOD_PAP:
+		return QMI_WDS_AUTHENTICATION_PAP;
+	case OFONO_GPRS_AUTH_METHOD_NONE:
+		return 0;
+	}
+
+	return -ENOENT;
+}
diff --git a/drivers/qmimodem/wds.h b/drivers/qmimodem/wds.h
index 6d7071fe244f..c8aeefe430bb 100644
--- a/drivers/qmimodem/wds.h
+++ b/drivers/qmimodem/wds.h
@@ -108,3 +108,5 @@ enum qmi_wds_command {
 	QMI_WDS_CONFIGURE_PROFILE_EVENT_LIST		= 0xA7,
 	QMI_WDS_PROFILE_CHANGED				= 0xA8,
 };
+
+int qmi_wds_auth_from_ofono(enum ofono_gprs_auth_method method);
-- 
2.44.0


  reply	other threads:[~2024-04-29 15:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-29 15:56 [PATCH 1/6] qmi: lte: Remove magic number use Denis Kenzior
2024-04-29 15:56 ` Denis Kenzior [this message]
2024-04-29 15:56 ` [PATCH 3/6] qmi: lte: Support additional attributes Denis Kenzior
2024-04-29 15:56 ` [PATCH 4/6] qmi: gprs: Query default profile number at init Denis Kenzior
2024-04-29 15:56 ` [PATCH 5/6] udevng: Add "option" module managed ports to gobi driver Denis Kenzior
2024-04-29 15:56 ` [PATCH 6/6] udevng: Support Quectel RM502Q Denis Kenzior
2024-04-29 19:10 ` [PATCH 1/6] qmi: lte: Remove magic number use patchwork-bot+ofono

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=20240429155726.51479-2-denkenz@gmail.com \
    --to=denkenz@gmail.com \
    --cc=ofono@lists.linux.dev \
    /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