Open Source Telephony
 help / color / mirror / Atom feed
* [PATCH 1/6] qmi: lte: Remove magic number use
@ 2024-04-29 15:56 Denis Kenzior
  2024-04-29 15:56 ` [PATCH 2/6] qmi: wds: Move enum conversion into wds.c Denis Kenzior
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Denis Kenzior @ 2024-04-29 15:56 UTC (permalink / raw)
  To: ofono; +Cc: Denis Kenzior

Several commands were invoked using magic numbers, even though they're
defined inside wds.h.  Remove magic numbers from enumerations by
introducing appropriate enums to wds.h.  Similarly, use defined
constants for parameter and result ids.
---
 drivers/qmimodem/lte.c | 29 +++++++++++++++--------------
 drivers/qmimodem/wds.h | 14 +++++++++++++-
 2 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/drivers/qmimodem/lte.c b/drivers/qmimodem/lte.c
index 6c08c312b3cb..7633572b39ef 100644
--- a/drivers/qmimodem/lte.c
+++ b/drivers/qmimodem/lte.c
@@ -73,24 +73,23 @@ static void qmimodem_lte_set_default_attach_info(const struct ofono_lte *lte,
 		uint8_t type;
 		uint8_t index;
 	} __attribute__((packed)) p = {
-		.type = 0, /* 3GPP */
+		.type = QMI_WDS_PROFILE_TYPE_3GPP,
+		.index = ldd->default_profile,
 	};
 
 	DBG("");
 
-	p.index = ldd->default_profile;
-
 	param = qmi_param_new();
 
 	/* Profile selector */
-	qmi_param_append(param, 0x01, sizeof(p), &p);
+	qmi_param_append(param, QMI_WDS_PARAM_PROFILE_TYPE, sizeof(p), &p);
 
 	/* WDS APN Name */
 	qmi_param_append(param, QMI_WDS_PARAM_APN,
 				strlen(info->apn), info->apn);
 
 	/* Modify profile */
-	if (qmi_service_send(ldd->wds, 0x28, param,
+	if (qmi_service_send(ldd->wds, QMI_WDS_MODIFY_PROFILE, param,
 					modify_profile_cb, cbd, l_free) > 0)
 		return;
 
@@ -114,6 +113,7 @@ static void reset_profile_cb(struct qmi_result *result, void *user_data)
 
 static void get_default_profile_cb(struct qmi_result *result, void *user_data)
 {
+	static const uint8_t RESULT_DEFAULT_PROFILE_NUMBER = 0x1;
 	struct ofono_lte *lte = user_data;
 	struct lte_data *ldd = ofono_lte_get_data(lte);
 	uint16_t error;
@@ -123,7 +123,7 @@ static void get_default_profile_cb(struct qmi_result *result, void *user_data)
 		uint8_t type;
 		uint8_t index;
 	} __attribute__((packed)) p = {
-		.type = 0, /* 3GPP */
+		.type = QMI_WDS_PROFILE_TYPE_3GPP,
 	};
 
 	DBG("");
@@ -134,7 +134,8 @@ static void get_default_profile_cb(struct qmi_result *result, void *user_data)
 	}
 
 	/* Profile index */
-	if (!qmi_result_get_uint8(result, 0x01, &index)) {
+	if (!qmi_result_get_uint8(result, RESULT_DEFAULT_PROFILE_NUMBER,
+								&index)) {
 		ofono_error("Failed query default profile");
 		goto error;
 	}
@@ -148,10 +149,10 @@ static void get_default_profile_cb(struct qmi_result *result, void *user_data)
 	param = qmi_param_new();
 
 	/* Profile selector */
-	qmi_param_append(param, 0x01, sizeof(p), &p);
+	qmi_param_append(param, QMI_WDS_PARAM_PROFILE_TYPE, sizeof(p), &p);
 
 	/* Reset profile */
-	if (qmi_service_send(ldd->wds, 0x4b, param,
+	if (qmi_service_send(ldd->wds, QMI_WDS_RESET_PROFILE, param,
 				reset_profile_cb, lte, NULL) > 0)
 		return;
 
@@ -171,8 +172,8 @@ static void create_wds_cb(struct qmi_service *service, void *user_data)
 		uint8_t type;
 		uint8_t family;
 	} __attribute((packed)) p = {
-		.type = 0,   /* 3GPP */
-		.family = 0, /* embedded */
+		.type = QMI_WDS_PROFILE_TYPE_3GPP,
+		.family = QMI_WDS_PROFILE_FAMILY_EMBEDDED,
 	};
 
 	DBG("");
@@ -189,11 +190,11 @@ static void create_wds_cb(struct qmi_service *service, void *user_data)
 	param = qmi_param_new();
 
 	/* Profile type */
-	qmi_param_append(param, 0x1, sizeof(p), &p);
+	qmi_param_append(param, QMI_WDS_PARAM_PROFILE_TYPE, sizeof(p), &p);
 
 	/* Get default profile */
-	if (qmi_service_send(ldd->wds, 0x49, param,
-				get_default_profile_cb, lte, NULL) > 0)
+	if (qmi_service_send(ldd->wds, QMI_WDS_GET_DEFAULT_PROFILE_NUMBER,
+				param, get_default_profile_cb, lte, NULL) > 0)
 		return;
 
 	qmi_param_free(param);
diff --git a/drivers/qmimodem/wds.h b/drivers/qmimodem/wds.h
index 3c9b534c1f82..6d7071fe244f 100644
--- a/drivers/qmimodem/wds.h
+++ b/drivers/qmimodem/wds.h
@@ -20,13 +20,13 @@
  */
 
 /* Start WDS network interface */
+#define QMI_WDS_PARAM_PROFILE_TYPE		0x01
 #define QMI_WDS_PARAM_APN			0x14	/* string */
 #define QMI_WDS_PARAM_IP_FAMILY			0x19	/* uint8 */
 #define QMI_WDS_PARAM_USERNAME			0x17	/* string */
 #define QMI_WDS_PARAM_PASSWORD			0x18	/* string */
 #define QMI_WDS_PARAM_AUTHENTICATION_PREFERENCE	0x16	/* uint8 */
 
-
 enum qmi_wds_authentication {
 	QMI_WDS_AUTHENTICATION_PAP	= 0x1,
 	QMI_WDS_AUTHENTICATION_CHAP	= 0x2,
@@ -57,6 +57,17 @@ enum qmi_wds_client_type {
 	QMI_WDS_CLIENT_TYPE_TETHERED = 0x01,
 };
 
+enum qmi_wds_profile_type {
+	QMI_WDS_PROFILE_TYPE_3GPP =	0x00,
+	QMI_WDS_PROFILE_TYPE_3GPP2 =	0x01,
+	QMI_WDS_PROFILE_TYPE_EPC =	0x02,
+};
+
+enum qmi_wds_profile_family {
+	QMI_WDS_PROFILE_FAMILY_EMBEDDED =	0x00,
+	QMI_WDS_PROFILE_FAMILY_TETHERED =	0x01,
+};
+
 enum qmi_wds_command {
 	QMI_WDS_RESET					= 0x00,
 	QMI_WDS_EVENT_REPORT				= 0x01,
@@ -83,6 +94,7 @@ enum qmi_wds_command {
 	QMI_WDS_GET_CURRENT_DATA_BEARER_TECHNOLOGY 	= 0x44,
 	QMI_WDS_GET_DEFAULT_PROFILE_NUMBER		= 0x49,
 	QMI_WDS_SET_DEFAULT_PROFILE_NUMBER		= 0x4A,
+	QMI_WDS_RESET_PROFILE				= 0x4B,
 	QMI_WDS_SET_IP_FAMILY				= 0x4D,
 	QMI_WDS_SET_AUTOCONNECT_SETTINGS		= 0x51,
 	QMI_WDS_GET_PDN_THROTTLE_INFO			= 0x6C,
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-04-29 19:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-29 15:56 [PATCH 1/6] qmi: lte: Remove magic number use Denis Kenzior
2024-04-29 15:56 ` [PATCH 2/6] qmi: wds: Move enum conversion into wds.c Denis Kenzior
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox