diff mbox series

[4/7] qmi: gprs-context: Convert QMI_WDS_AUTHENTICATION to an enum

Message ID 20240416151448.3359644-4-denkenz@gmail.com (mailing list archive)
State Accepted
Commit acb8d77ba97bb3133ae21a0deea91f8f0888edcf
Headers show
Series [1/7] qmimodem: wds: Introduce qmi_wds_ip_family enum | expand

Commit Message

Denis Kenzior April 16, 2024, 3:14 p.m. UTC
QMI uses authentication type as a bitmap, with both PAP and CHAP support
being selectable independently.  Convert QMI_WDS_AUTHENTICATION* defines
to an enumeration, removing QMI_WDS_AUTHENTICATION_NONE.
---
 drivers/qmimodem/gprs-context.c | 9 +++++----
 drivers/qmimodem/wds.h          | 8 +++++---
 2 files changed, 10 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c
index ef49e1bcf421..e726382a223a 100644
--- a/drivers/qmimodem/gprs-context.c
+++ b/drivers/qmimodem/gprs-context.c
@@ -220,16 +220,17 @@  static void qmi_gprs_read_settings(struct ofono_gprs_context* gc,
 
 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 QMI_WDS_AUTHENTICATION_NONE;
+		return 0;
 	}
 
-	return QMI_WDS_AUTHENTICATION_NONE;
+	return 0;
 }
 
 static void qmi_activate_primary(struct ofono_gprs_context *gc,
@@ -271,11 +272,11 @@  static void qmi_activate_primary(struct ofono_gprs_context *gc,
 	qmi_param_append_uint8(param, QMI_WDS_PARAM_AUTHENTICATION_PREFERENCE,
 					auth);
 
-	if (auth != QMI_WDS_AUTHENTICATION_NONE && ctx->username[0] != '\0')
+	if (auth && ctx->username[0] != '\0')
 		qmi_param_append(param, QMI_WDS_PARAM_USERNAME,
 					strlen(ctx->username), ctx->username);
 
-	if (auth != QMI_WDS_AUTHENTICATION_NONE &&  ctx->password[0] != '\0')
+	if (auth && ctx->password[0] != '\0')
 		qmi_param_append(param, QMI_WDS_PARAM_PASSWORD,
 					strlen(ctx->password), ctx->password);
 
diff --git a/drivers/qmimodem/wds.h b/drivers/qmimodem/wds.h
index 398f77c74672..0e30a0cca8c7 100644
--- a/drivers/qmimodem/wds.h
+++ b/drivers/qmimodem/wds.h
@@ -26,9 +26,11 @@ 
 #define QMI_WDS_PARAM_PASSWORD			0x18	/* string */
 #define QMI_WDS_PARAM_AUTHENTICATION_PREFERENCE	0x16	/* uint8 */
 
-#define QMI_WDS_AUTHENTICATION_NONE		0x0
-#define QMI_WDS_AUTHENTICATION_PAP		0x1
-#define QMI_WDS_AUTHENTICATION_CHAP		0x2
+
+enum qmi_wds_authentication {
+	QMI_WDS_AUTHENTICATION_PAP	= 0x1,
+	QMI_WDS_AUTHENTICATION_CHAP	= 0x2,
+};
 
 /* Packet data connection status indication */
 struct qmi_wds_notify_conn_status {