[PATCH 1/2] huawei: store modem model in MMBroadbandModemHuaweiPrivate

Ben Chan benchan at chromium.org
Tue Aug 13 09:58:46 PDT 2013


Is mm_gdbus_* expected to be called from a plugin?  I don't find any plugin
using mm_gdbus_* and wonder if there is a reason for that.


On Tue, Aug 13, 2013 at 7:58 AM, Dan Williams <dcbw at redhat.com> wrote:

> On Tue, 2013-08-13 at 00:54 -0700, Ben Chan wrote:
> > This patch adds a field in MMBroadbandModemHuaweiPrivate to keep the
> > modem model, which can be used later by the plugin to alter the
> > implementation based on model. The modem model is used instead of USB
> > product ID because different models of Huawei modems often share the
> > same USB product ID.
>
> I'm not sure, but would it be easier to retrieve and cache the return
> value of mm_gdbus_modem_get_model()?  Since the Huawei modem is a
> subclass of MMBroadbandModem, after init is complete the plugin could do
> something like:
>
> GObject *skeleton = NULL;
> const char *model;
>
> g_object_get (G_OBJECT (<huawei modem object>),
> MM_IFACE_MODEM_DBUS_SKELETON, &skeleton, NULL);
> model = mm_gdbus_modem_get_model (MM_GDBUS_MODEM (skeleton));
>
> Or something like that I believe.
>
> Dan
>
> > ---
> >  plugins/huawei/mm-broadband-modem-huawei.c | 55
> ++++++++++++++++++++++++++++++
> >  1 file changed, 55 insertions(+)
> >
> > diff --git a/plugins/huawei/mm-broadband-modem-huawei.c
> b/plugins/huawei/mm-broadband-modem-huawei.c
> > index c34acc2..3cd3201 100644
> > --- a/plugins/huawei/mm-broadband-modem-huawei.c
> > +++ b/plugins/huawei/mm-broadband-modem-huawei.c
> > @@ -74,6 +74,8 @@ typedef enum {
> >  } RfswitchSupport;
> >
> >  struct _MMBroadbandModemHuaweiPrivate {
> > +    gchar *model;
> > +
> >      /* Regex for signal quality related notifications */
> >      GRegex *rssi_regex;
> >      GRegex *rssilvl_regex;
> > @@ -446,6 +448,56 @@ reset (MMIfaceModem *self,
> >  }
> >
> >
>  /*****************************************************************************/
> > +/* Model loading (Modem interface) */
> > +
> > +static gchar *
> > +load_model_finish (MMIfaceModem *self,
> > +                   GAsyncResult *res,
> > +                   GError **error)
> > +{
> > +    if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT
> (res), error))
> > +        return NULL;
> > +
> > +    return g_simple_async_result_get_op_res_gpointer
> (G_SIMPLE_ASYNC_RESULT (res));
> > +}
> > +
> > +static void
> > +parent_load_model_ready (MMIfaceModem *_self,
> > +                         GAsyncResult *res,
> > +                         GSimpleAsyncResult *simple)
> > +{
> > +    MMBroadbandModemHuawei *self = MM_BROADBAND_MODEM_HUAWEI (_self);
> > +    GError *error = NULL;
> > +    gchar *model;
> > +
> > +    model = iface_modem_parent->load_model_finish (_self, res, &error);
> > +    if (model) {
> > +        g_assert (!self->priv->model);
> > +        self->priv->model = g_strdup (model);
> > +        g_simple_async_result_set_op_res_gpointer (simple, model, NULL);
> > +    } else
> > +        g_simple_async_result_take_error (simple, error);
> > +
> > +    g_simple_async_result_complete (simple);
> > +    g_object_unref (simple);
> > +}
> > +
> > +static void
> > +load_model (MMIfaceModem *self,
> > +            GAsyncReadyCallback callback,
> > +            gpointer user_data)
> > +{
> > +    /* Run parent's loading */
> > +    iface_modem_parent->load_model (
> > +        MM_IFACE_MODEM (self),
> > +        (GAsyncReadyCallback)parent_load_model_ready,
> > +        g_simple_async_result_new (G_OBJECT (self),
> > +                                   callback,
> > +                                   user_data,
> > +                                   load_model));
> > +}
> > +
> >
> +/*****************************************************************************/
> >  /* Load access technologies (Modem interface) */
> >
> >  static MMModemAccessTechnology
> > @@ -2953,6 +3005,7 @@ finalize (GObject *object)
> >  {
> >      MMBroadbandModemHuawei *self = MM_BROADBAND_MODEM_HUAWEI (object);
> >
> > +    g_free (self->priv->model);
> >      g_regex_unref (self->priv->rssi_regex);
> >      g_regex_unref (self->priv->rssilvl_regex);
> >      g_regex_unref (self->priv->hrssilvl_regex);
> > @@ -2977,6 +3030,8 @@ iface_modem_init (MMIfaceModem *iface)
> >
> >      iface->reset = reset;
> >      iface->reset_finish = reset_finish;
> > +    iface->load_model = load_model;
> > +    iface->load_model_finish = load_model_finish;
> >      iface->load_access_technologies = load_access_technologies;
> >      iface->load_access_technologies_finish =
> load_access_technologies_finish;
> >      iface->load_unlock_retries = load_unlock_retries;
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/modemmanager-devel/attachments/20130813/aa81dbb9/attachment-0001.html>


More information about the ModemManager-devel mailing list