All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] network: allow drivers to generate more specific error codes
@ 2017-12-05 18:20 Alexander Couzens
  2017-12-05 18:20 ` [PATCH 2/4] qmimodem: add define CALLBACK_WITH_CME_ERROR(cb, err, args..) Alexander Couzens
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Alexander Couzens @ 2017-12-05 18:20 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 756 bytes --]

For certain modems it's not clear if they support all actions or not.
In such cases use CME errors which allows generate NotSupported
messages.
---
 src/network.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/network.c b/src/network.c
index 6e69b078495f..ae3175d4a7e9 100644
--- a/src/network.c
+++ b/src/network.c
@@ -222,7 +222,7 @@ static void register_callback(const struct ofono_error *error, void *data)
 	if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
 		reply = dbus_message_new_method_return(netreg->pending);
 	else
-		reply = __ofono_error_failed(netreg->pending);
+		reply = __ofono_error_from_error(error, netreg->pending);
 
 	__ofono_dbus_pending_reply(&netreg->pending, reply);
 
-- 
2.15.1


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

* [PATCH 2/4] qmimodem: add define CALLBACK_WITH_CME_ERROR(cb, err, args..)
  2017-12-05 18:20 [PATCH 1/4] network: allow drivers to generate more specific error codes Alexander Couzens
@ 2017-12-05 18:20 ` Alexander Couzens
  2017-12-05 18:20 ` [PATCH 3/4] qmimodem: add translator qmi_error_to_ofono_cme() Alexander Couzens
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Alexander Couzens @ 2017-12-05 18:20 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 693 bytes --]

---
 drivers/qmimodem/util.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/qmimodem/util.h b/drivers/qmimodem/util.h
index cf053f0fe840..974160234af5 100644
--- a/drivers/qmimodem/util.h
+++ b/drivers/qmimodem/util.h
@@ -39,6 +39,15 @@ static inline struct cb_data *cb_data_new(void *cb, void *data)
 	return ret;
 }
 
+#define CALLBACK_WITH_CME_ERROR(cb, err, args...)	\
+	do {						\
+		struct ofono_error cb_e;		\
+		cb_e.type = OFONO_ERROR_TYPE_CME;	\
+		cb_e.error = err;			\
+							\
+		cb(&cb_e, ##args);			\
+	} while (0)					\
+
 #define CALLBACK_WITH_FAILURE(cb, args...)		\
 	do {						\
 		struct ofono_error cb_e;		\
-- 
2.15.1


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

* [PATCH 3/4] qmimodem: add translator qmi_error_to_ofono_cme()
  2017-12-05 18:20 [PATCH 1/4] network: allow drivers to generate more specific error codes Alexander Couzens
  2017-12-05 18:20 ` [PATCH 2/4] qmimodem: add define CALLBACK_WITH_CME_ERROR(cb, err, args..) Alexander Couzens
@ 2017-12-05 18:20 ` Alexander Couzens
  2017-12-05 18:20 ` [PATCH 4/4] qmimodem: convert register_net_cb errors into CMEs Alexander Couzens
  2017-12-06  4:07 ` [PATCH 1/4] network: allow drivers to generate more specific error codes Denis Kenzior
  3 siblings, 0 replies; 5+ messages in thread
From: Alexander Couzens @ 2017-12-05 18:20 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1272 bytes --]

Translates qmi error codes into ofono cme errors
---
 drivers/qmimodem/qmi.c | 11 +++++++++++
 drivers/qmimodem/qmi.h |  2 ++
 2 files changed, 13 insertions(+)

diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index a0632ca54025..90349db61964 100644
--- a/drivers/qmimodem/qmi.c
+++ b/drivers/qmimodem/qmi.c
@@ -476,6 +476,17 @@ static const char *__error_to_string(uint16_t error)
 	return NULL;
 }
 
+int qmi_error_to_ofono_cme(int qmi_error) {
+	switch (qmi_error) {
+	case 0x0019:
+		return 4; /* Not Supported */
+	case 0x0052:
+		return 32; /* Access Denied */
+	default:
+		return -1;
+	}
+}
+
 static void __debug_msg(const char dir, const void *buf, size_t len,
 				qmi_debug_func_t function, void *user_data)
 {
diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h
index b4955b40b1fb..4f2d5bdf59c5 100644
--- a/drivers/qmimodem/qmi.h
+++ b/drivers/qmimodem/qmi.h
@@ -140,6 +140,8 @@ bool qmi_result_get_uint64(struct qmi_result *result, uint8_t type,
 							uint64_t *value);
 void qmi_result_print_tlvs(struct qmi_result *result);
 
+int qmi_error_to_ofono_cme(int qmi_error);
+
 struct qmi_service;
 
 typedef void (*qmi_result_func_t)(struct qmi_result *result, void *user_data);
-- 
2.15.1


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

* [PATCH 4/4] qmimodem: convert register_net_cb errors into CMEs
  2017-12-05 18:20 [PATCH 1/4] network: allow drivers to generate more specific error codes Alexander Couzens
  2017-12-05 18:20 ` [PATCH 2/4] qmimodem: add define CALLBACK_WITH_CME_ERROR(cb, err, args..) Alexander Couzens
  2017-12-05 18:20 ` [PATCH 3/4] qmimodem: add translator qmi_error_to_ofono_cme() Alexander Couzens
@ 2017-12-05 18:20 ` Alexander Couzens
  2017-12-06  4:07 ` [PATCH 1/4] network: allow drivers to generate more specific error codes Denis Kenzior
  3 siblings, 0 replies; 5+ messages in thread
From: Alexander Couzens @ 2017-12-05 18:20 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1018 bytes --]

Certain modems doesn't support manual registering (gobi 2000).
Translate the error code into ofono error to report a
more detailed debug error message.
---
 drivers/qmimodem/network-registration.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/qmimodem/network-registration.c b/drivers/qmimodem/network-registration.c
index c1760b83ee40..6c1f50ba0416 100644
--- a/drivers/qmimodem/network-registration.c
+++ b/drivers/qmimodem/network-registration.c
@@ -332,6 +332,7 @@ static void register_net_cb(struct qmi_result *result, void *user_data)
 	struct cb_data *cbd = user_data;
 	ofono_netreg_register_cb_t cb = cbd->cb;
 	uint16_t error;
+	int cme_error;
 
 	DBG("");
 
@@ -341,7 +342,8 @@ static void register_net_cb(struct qmi_result *result, void *user_data)
 			goto done;
 		}
 
-		CALLBACK_WITH_FAILURE(cb, cbd->data);
+		cme_error = qmi_error_to_ofono_cme(error);
+		CALLBACK_WITH_CME_ERROR(cb, cme_error, cbd->data);
 		return;
 	}
 
-- 
2.15.1


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

* Re: [PATCH 1/4] network: allow drivers to generate more specific error codes
  2017-12-05 18:20 [PATCH 1/4] network: allow drivers to generate more specific error codes Alexander Couzens
                   ` (2 preceding siblings ...)
  2017-12-05 18:20 ` [PATCH 4/4] qmimodem: convert register_net_cb errors into CMEs Alexander Couzens
@ 2017-12-06  4:07 ` Denis Kenzior
  3 siblings, 0 replies; 5+ messages in thread
From: Denis Kenzior @ 2017-12-06  4:07 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 356 bytes --]

Hi Alexander,

On 12/05/2017 12:20 PM, Alexander Couzens wrote:
> For certain modems it's not clear if they support all actions or not.
> In such cases use CME errors which allows generate NotSupported
> messages.
> ---
>   src/network.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 

All 4 applied, thanks.

Regards,
-Denis


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

end of thread, other threads:[~2017-12-06  4:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-05 18:20 [PATCH 1/4] network: allow drivers to generate more specific error codes Alexander Couzens
2017-12-05 18:20 ` [PATCH 2/4] qmimodem: add define CALLBACK_WITH_CME_ERROR(cb, err, args..) Alexander Couzens
2017-12-05 18:20 ` [PATCH 3/4] qmimodem: add translator qmi_error_to_ofono_cme() Alexander Couzens
2017-12-05 18:20 ` [PATCH 4/4] qmimodem: convert register_net_cb errors into CMEs Alexander Couzens
2017-12-06  4:07 ` [PATCH 1/4] network: allow drivers to generate more specific error codes Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.