Open Source Telephony
 help / color / mirror / Atom feed
* [PATCH 1/2] modem.h: ofono_modem_set_powered_timeout_hint
@ 2018-10-24  5:28 Giacinto Cifelli
  2018-10-24  5:28 ` [PATCH 2/2] src/modem - timeout_hint Giacinto Cifelli
  2018-10-24 19:32 ` [PATCH 1/2] modem.h: ofono_modem_set_powered_timeout_hint Denis Kenzior
  0 siblings, 2 replies; 3+ messages in thread
From: Giacinto Cifelli @ 2018-10-24  5:28 UTC (permalink / raw)
  To: ofono

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

function to set the powered timeout dynamically.

The function is effective if called before Powered=true,
so it is best called in udevng.
If not called, the timeout is set by default to 20 seconds.
---
 include/modem.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/modem.h b/include/modem.h
index bed46c2b..9b12cfad 100644
--- a/include/modem.h
+++ b/include/modem.h
@@ -127,6 +127,9 @@ void ofono_modem_driver_unregister(const struct ofono_modem_driver *);
 struct ofono_modem *ofono_modem_find(ofono_modem_compare_cb_t func,
 					void *user_data);
 
+void ofono_modem_set_powered_timeout_hint(struct ofono_modem *modem,
+							unsigned int seconds);
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.17.1


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

* [PATCH 2/2] src/modem - timeout_hint
  2018-10-24  5:28 [PATCH 1/2] modem.h: ofono_modem_set_powered_timeout_hint Giacinto Cifelli
@ 2018-10-24  5:28 ` Giacinto Cifelli
  2018-10-24 19:32 ` [PATCH 1/2] modem.h: ofono_modem_set_powered_timeout_hint Denis Kenzior
  1 sibling, 0 replies; 3+ messages in thread
From: Giacinto Cifelli @ 2018-10-24  5:28 UTC (permalink / raw)
  To: ofono

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

this patch provides the handling for the modem-depending powered timeout

It provides the trivial implementation for
ofono_modem_set_powered_timeout_hint, introducing the ofono_modem
variable timeout_hint, used together with the existing ofono_modem
variable timeout.

The default value, previously hardcoded as a magic number, is provided
by the DEFAULT__POWERED_TIMEOUT define and set as soon as the
ofono_modem struct is created, and then can be overwritten by the
aforementioned ofono_modem_set_powered_timeout_hint.
---
 src/modem.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/modem.c b/src/modem.c
index 9e254482..49e306ac 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -34,6 +34,8 @@
 
 #include "common.h"
 
+#define DEFAULT__POWERED_TIMEOUT (20)
+
 static GSList *g_devinfo_drivers = NULL;
 static GSList *g_driver_list = NULL;
 static GSList *g_modem_list = NULL;
@@ -75,6 +77,7 @@ struct ofono_modem {
 	char			*lock_owner;
 	guint			lock_watch;
 	guint			timeout;
+	guint			timeout_hint;
 	ofono_bool_t		online;
 	struct ofono_watchlist	*online_watches;
 	struct ofono_watchlist	*powered_watches;
@@ -1055,7 +1058,7 @@ static DBusMessage *set_property_lockdown(struct ofono_modem *modem,
 		}
 
 		modem->pending = dbus_message_ref(msg);
-		modem->timeout = g_timeout_add_seconds(20,
+		modem->timeout = g_timeout_add_seconds(modem->timeout_hint,
 						set_powered_timeout, modem);
 		return NULL;
 	}
@@ -1133,7 +1136,8 @@ static DBusMessage *modem_set_property(DBusConnection *conn,
 				return __ofono_error_failed(msg);
 
 			modem->pending = dbus_message_ref(msg);
-			modem->timeout = g_timeout_add_seconds(20,
+			modem->timeout = g_timeout_add_seconds(
+						modem->timeout_hint,
 						set_powered_timeout, modem);
 			return NULL;
 		}
@@ -1843,6 +1847,13 @@ ofono_bool_t ofono_modem_get_boolean(struct ofono_modem *modem, const char *key)
 	return value;
 }
 
+void ofono_modem_set_powered_timeout_hint(struct ofono_modem *modem,
+							unsigned int seconds)
+{
+	modem->timeout_hint = seconds;
+}
+
+
 void ofono_modem_set_name(struct ofono_modem *modem, const char *name)
 {
 	if (modem->name)
@@ -1904,6 +1915,7 @@ struct ofono_modem *ofono_modem_create(const char *name, const char *type)
 	modem->driver_type = g_strdup(type);
 	modem->properties = g_hash_table_new_full(g_str_hash, g_str_equal,
 						g_free, unregister_property);
+	modem->timeout_hint = DEFAULT__POWERED_TIMEOUT;
 
 	g_modem_list = g_slist_prepend(g_modem_list, modem);
 
-- 
2.17.1


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

* Re: [PATCH 1/2] modem.h: ofono_modem_set_powered_timeout_hint
  2018-10-24  5:28 [PATCH 1/2] modem.h: ofono_modem_set_powered_timeout_hint Giacinto Cifelli
  2018-10-24  5:28 ` [PATCH 2/2] src/modem - timeout_hint Giacinto Cifelli
@ 2018-10-24 19:32 ` Denis Kenzior
  1 sibling, 0 replies; 3+ messages in thread
From: Denis Kenzior @ 2018-10-24 19:32 UTC (permalink / raw)
  To: ofono

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

Hi Giacinto,

On 10/24/2018 12:28 AM, Giacinto Cifelli wrote:
> function to set the powered timeout dynamically.
> 
> The function is effective if called before Powered=true,
> so it is best called in udevng.
> If not called, the timeout is set by default to 20 seconds.
> ---
>   include/modem.h | 3 +++
>   1 file changed, 3 insertions(+)
> 

Both applied after tweaking some style issues & the commit description.

Regards,
-Denis


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

end of thread, other threads:[~2018-10-24 19:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-24  5:28 [PATCH 1/2] modem.h: ofono_modem_set_powered_timeout_hint Giacinto Cifelli
2018-10-24  5:28 ` [PATCH 2/2] src/modem - timeout_hint Giacinto Cifelli
2018-10-24 19:32 ` [PATCH 1/2] modem.h: ofono_modem_set_powered_timeout_hint Denis Kenzior

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