All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 2/5] speedup: Check for supported modem capabilities first
Date: Sat, 07 Jan 2012 12:26:19 -0600	[thread overview]
Message-ID: <4F088E4B.7010708@gmail.com> (raw)
In-Reply-To: <1326114660-10111-3-git-send-email-guillaume.zajac@linux.intel.com>

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

Hi Guillaume,

On 01/09/2012 07:10 AM, Guillaume Zajac wrote:
> ---
>  plugins/speedup.c |   40 ++++++++++++++++++++++++++++++++++++++--
>  1 files changed, 38 insertions(+), 2 deletions(-)
> 
> diff --git a/plugins/speedup.c b/plugins/speedup.c
> index a90dfe3..f03f8f3 100644
> --- a/plugins/speedup.c
> +++ b/plugins/speedup.c
> @@ -25,6 +25,7 @@
>  
>  #include <errno.h>
>  #include <stdlib.h>
> +#include <string.h>
>  
>  #include <glib.h>
>  #include <gatchat.h>
> @@ -47,11 +48,15 @@
>  #include <drivers/atmodem/atutil.h>
>  #include <drivers/atmodem/vendor.h>
>  
> +static const char *gcap_prefix[] = { "+GCAP:", NULL };
> +
>  struct speedup_data {
>  	GAtChat *modem;
>  	GAtChat *aux;
>  	gboolean have_sim;
>  	struct at_util_sim_state_query *sim_state_query;
> +	gboolean have_gsm;
> +	gboolean have_cdma;

It might be a good idea to use a single gboolean, or better yet an enum
here instead.  There's no point to waste 8 bytes when a single byte can do.

>  };
>  
>  static int speedup_probe(struct ofono_modem *modem)
> @@ -165,6 +170,36 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
>  						2, 20, sim_state_cb, modem);
>  }
>  
> +static void gcap_support(gboolean ok, GAtResult *result, gpointer user_data)
> +{
> +	struct ofono_modem *modem = user_data;
> +	struct speedup_data *data = ofono_modem_get_data(modem);
> +	GAtResultIter iter;
> +	const char *gcap;
> +
> +	if (!ok)
> +		goto done;
> +
> +	g_at_result_iter_init(&iter, result);
> +
> +	if (!g_at_result_iter_next(&iter, "+GCAP:"))
> +		goto done;
> +
> +	while (g_at_result_iter_next_unquoted_string(&iter, &gcap)) {
> +		if (*gcap == '\0')
> +			break;
> +
> +		if (!strcmp(gcap, "+CGSM"))
> +			data->have_gsm = TRUE;
> +		else if (!strcmp(gcap, "+CIS707-A"))
> +			data->have_cdma = TRUE;
> +	}

First of all, this really belongs in atutil as a convenience function.

Second, why don't we fail on the obvious condition that neither CDMA nor
GSM is detected?

> +
> +done:
> +	g_at_chat_send(data->aux, "AT+CFUN=1", NULL,
> +					cfun_enable, modem, NULL);
> +}
> +
>  static int speedup_enable(struct ofono_modem *modem)
>  {
>  	struct speedup_data *data = ofono_modem_get_data(modem);
> @@ -185,8 +220,9 @@ static int speedup_enable(struct ofono_modem *modem)
>  	g_at_chat_send(data->modem, "ATE0 +CMEE=1", NULL, NULL, NULL, NULL);
>  	g_at_chat_send(data->aux, "ATE0 +CMEE=1", NULL, NULL, NULL, NULL);
>  
> -	g_at_chat_send(data->aux, "AT+CFUN=1", NULL,
> -					cfun_enable, modem, NULL);
> +	/* Check for GSM/CDMA capabilities */
> +	g_at_chat_send(data->aux, "ATI", gcap_prefix,
> +					gcap_support, modem, NULL);
>  
>  	return -EINPROGRESS;
>  }

Regards,
-Denis

  reply	other threads:[~2012-01-07 18:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-09 13:10 [PATCH 0/5] Unify SpeedUp plugin Guillaume Zajac
2012-01-09 13:10 ` [PATCH 1/5] udevng: Remove huaweicdma label from driver_list Guillaume Zajac
2012-01-07 18:26   ` Denis Kenzior
2012-01-09 13:10 ` [PATCH 2/5] speedup: Check for supported modem capabilities first Guillaume Zajac
2012-01-07 18:26   ` Denis Kenzior [this message]
2012-01-09 19:36     ` Marcel Holtmann
2012-01-07 19:26       ` Denis Kenzior
2012-01-10 13:43         ` Guillaume Zajac
2012-01-08 10:12           ` Denis Kenzior
2012-01-10 15:37             ` Guillaume Zajac
2012-01-08 14:27               ` Denis Kenzior
2012-01-11 10:48                 ` Guillaume Zajac
2012-01-11 11:06                   ` Denis Kenzior
2012-01-11 15:12                     ` Guillaume Zajac
2012-01-09 13:10 ` [PATCH 3/5] speedup: Create GSM/UMTS atoms only if support has been detected Guillaume Zajac
2012-01-09 13:10 ` [PATCH 4/5] speedup: Create CDMA atoms " Guillaume Zajac
2012-01-09 13:11 ` [PATCH 5/5] udevng: Simplify vendor and driver list for SpeedUp Guillaume Zajac
2012-01-09 13:14 ` [PATCH] speedupcdma: Delete unused plugin Guillaume Zajac
2012-01-12 10:00 ` [PATCH 0/5] Unify SpeedUp plugin Guillaume Zajac

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=4F088E4B.7010708@gmail.com \
    --to=denkenz@gmail.com \
    --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.