All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gustavo F. Padovan <padovan@profusion.mobi>
To: ofono@ofono.org
Subject: Re: [PATCH 1/2] modem: add Lockdown property to Modem interface
Date: Wed, 22 Dec 2010 16:19:41 -0200	[thread overview]
Message-ID: <20101222181941.GA16612@vigoh> (raw)
In-Reply-To: <4D0C0709.9050305@gmail.com>

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

Hi Denis,

* Denis Kenzior <denkenz@gmail.com> [2010-12-17 18:57:45 -0600]:

> Hi Gustavo,
> 
> On 12/03/2010 03:59 PM, Gustavo F. Padovan wrote:
> > Setting Lockdown to TRUE means power down the modem and hold a lock that
> > only permits the lock's owner power up the modem back. When released
> > it restores the last state of the modem before holding the lock.
> > ---
> >  doc/modem-api.txt |    9 ++++
> >  src/modem.c       |  129 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 138 insertions(+), 0 deletions(-)
> 
> Can you break this up into two patches, one for doc and one for src?
> 
> > 
> > diff --git a/doc/modem-api.txt b/doc/modem-api.txt
> > index b92e53c..45043b0 100644
> > --- a/doc/modem-api.txt
> > +++ b/doc/modem-api.txt
> > @@ -37,6 +37,15 @@ Properties	boolean Powered [readwrite]
> >  			Boolean representing the rf state of the modem.
> >  			Online is false in flight mode.
> >  
> > +		boolean Lockdown [readwrite]
> > +
> > +			Boolean representing the lock state of the modem.
> > +			Setting it to true, makes the calling application hold
> > +			the modem lock and power it down. Setting to false
> > +			makes the it release the modem lock. Only the
> > +			application that holds the lock can power up the modem.
> > +			If the the application exits Lockdown is set to false.
> > +
> >  		boolean Emergency [readonly, optional, experimental]
> >  
> >  			Boolean representing the emergency mode of the
> > diff --git a/src/modem.c b/src/modem.c
> > index b334b58..a9a6e87 100644
> > --- a/src/modem.c
> > +++ b/src/modem.c
> > @@ -71,6 +71,9 @@ struct ofono_modem {
> >  	ofono_bool_t		powered;
> >  	ofono_bool_t		powered_pending;
> >  	ofono_bool_t		get_online;
> > +	ofono_bool_t		lockdown;
> > +	char			*lock_owner;
> > +	guint			lock_watch;
> >  	guint			timeout;
> >  	ofono_bool_t		online;
> >  	struct ofono_watchlist	*online_watches;
> > @@ -583,6 +586,9 @@ void __ofono_modem_append_properties(struct ofono_modem *modem,
> >  	ofono_dbus_dict_append(dict, "Powered", DBUS_TYPE_BOOLEAN,
> >  				&modem->powered);
> >  
> > +	ofono_dbus_dict_append(dict, "Lockdown", DBUS_TYPE_BOOLEAN,
> > +				&modem->lockdown);
> > +
> >  	devinfo_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_DEVINFO);
> >  
> >  	/* We cheat a little here and don't check the registered status */
> > @@ -686,6 +692,16 @@ static int set_powered(struct ofono_modem *modem, ofono_bool_t powered)
> >  	return err;
> >  }
> >  
> > +static void lockdown_remove(struct ofono_modem *modem)
> > +{
> > +	DBusConnection *conn =ofono_dbus_get_connection();
> > +
> > +	g_free(modem->lock_owner);
> > +	g_dbus_remove_watch(conn, modem->lock_watch);
> > +	modem->lock_watch = 0;
> > +	modem->lockdown = FALSE;
> > +}
> > +
> >  static gboolean set_powered_timeout(gpointer user)
> >  {
> >  	struct ofono_modem *modem = user;
> > @@ -712,11 +728,107 @@ static gboolean set_powered_timeout(gpointer user)
> >  
> >  		reply = __ofono_error_timed_out(modem->pending);
> >  		__ofono_dbus_pending_reply(&modem->pending, reply);
> > +
> > +		if (modem->lockdown)
> > +			lockdown_remove(modem);
> >  	}
> >  
> >  	return FALSE;
> >  }
> >  
> > +static void lockdown_disconnect(DBusConnection *conn, void *user_data)
> > +{
> > +	struct ofono_modem *modem = user_data;
> > +
> > +	DBG("");
> > +
> > +	g_free(modem->lock_owner);
> > +
> > +	modem->lockdown = FALSE;
> > +
> > +	ofono_dbus_signal_property_changed(conn, modem->path,
> > +					OFONO_MODEM_INTERFACE,
> > +					"Lockdown", DBUS_TYPE_BOOLEAN,
> > +					&modem->lockdown);
> 
> Should you also be removing the lock_watch here?  Since the lock_watch
> is no longer relevant and you'll be leaking it otherwise.

gdbus remove the watch for us in this case. So no leak here.

-- 
Gustavo F. Padovan
http://profusion.mobi

      reply	other threads:[~2010-12-22 18:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-03 21:59 [PATCH 1/2] modem: add Lockdown property to Modem interface Gustavo F. Padovan
2010-12-03 21:59 ` [PATCH 2/2] modem: Add test script for the Lockdown property Gustavo F. Padovan
2010-12-18  0:57 ` [PATCH 1/2] modem: add Lockdown property to Modem interface Denis Kenzior
2010-12-22 18:19   ` Gustavo F. Padovan [this message]

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=20101222181941.GA16612@vigoh \
    --to=padovan@profusion.mobi \
    --cc=ofono@ofono.org \
    /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 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.