Open Source Telephony
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 3/6] plugins: new driver for u-blox SARA-U270 modems
Date: Thu, 26 Jun 2014 09:29:51 -0500	[thread overview]
Message-ID: <53AC2E5F.4010100@gmail.com> (raw)
In-Reply-To: <1403629813-62204-4-git-send-email-philip@paeps.cx>

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

Hi Philip,

> +static void ublox_remove(struct ofono_modem *modem)
> +{
> +	struct ublox_data *data = ofono_modem_get_data(modem);
> +
> +	DBG("%p", modem);
> +
> +	ofono_modem_set_data(modem, NULL);
> +	g_at_chat_unref(data->aux);

Any reason data->modem is not being unrefed? e.g in the case of hot-unplug?

> +	g_free(data);
> +}
> +
> +static GAtChat *open_device(struct ofono_modem *modem,
> +				const char *key, char *debug)
> +{
> +	const char *device;
> +	GAtSyntax *syntax;
> +	GIOChannel *channel;
> +	GAtChat *chat;
> +
> +	device = ofono_modem_get_string(modem, key);
> +	if (device == NULL)
> +		return NULL;
> +
> +	DBG("%s %s", key, device);
> +
> +	channel = g_at_tty_open(device, NULL);
> +	if (channel == NULL)
> +		return NULL;
> +
> +	syntax = g_at_syntax_new_gsm_permissive();
> +	chat = g_at_chat_new(channel, syntax);
> +	g_at_syntax_unref(syntax);
> +
> +	g_io_channel_unref(channel);
> +
> +	if (chat == NULL)
> +		return NULL;
> +
> +	if (getenv("OFONO_AT_DEBUG"))
> +		g_at_chat_set_debug(chat, ublox_debug, debug);
> +
> +	return chat;
> +}
> +
> +

Please remove one whitespace.  Our coding style likes to use a single
empty line to separate functions.

> +static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
> +{
> +	struct ofono_modem *modem = user_data;
> +	struct ublox_data * data = ofono_modem_get_data(modem);
> +
> +	DBG("ok %d", (int)ok);

No need to cast

> +
> +	if (!ok) {
> +		g_at_chat_unref(data->aux);
> +		data->aux = NULL;
> +		g_at_chat_unref(data->modem);
> +		data->modem = NULL;
> +	}
> +
> +	ofono_modem_set_powered(modem, TRUE);
> +
> +	g_at_chat_send(data->modem, "AT&C0", NULL, NULL, NULL, NULL);
> +	g_at_chat_send(data->aux, "AT&C0", NULL, NULL, NULL, NULL);

Might want to use prefixes here

> +}
> +
> +static int ublox_enable(struct ofono_modem *modem)
> +{
> +	struct ublox_data *data = ofono_modem_get_data(modem);
> +
> +	DBG("%p", modem);
> +
> +	data->modem = open_device(modem, "Modem", "Modem: ");
> +	if (data->modem == NULL)
> +		return -EINVAL;
> +
> +	data->aux = open_device(modem, "Aux", "Aux: ");
> +	if (data->aux == NULL) {
> +		g_at_chat_unref(data->modem);
> +		data->modem = NULL;
> +		return -EIO;
> +	}
> +	g_at_chat_set_slave(data->modem, data->aux);
> +
> +	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);

Prefix should probably be used.  Also, should this be CFUN=4 and not 1?
 enable() callback should be putting the modem in the SIM powered, RX/TX
off mode (e.g. Offline).

> +
> +	return -EINPROGRESS;
> +}
> +
> +static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
> +{
> +	struct ofono_modem *modem = user_data;
> +	struct ublox_data *data = ofono_modem_get_data(modem);
> +
> +	DBG("");
> +
> +	g_at_chat_unref(data->aux);
> +	data->aux = NULL;
> +
> +	if (ok)
> +		ofono_modem_set_powered(modem, FALSE);
> +}
> +
> +static int ublox_disable(struct ofono_modem *modem)
> +{
> +	struct ublox_data *data = ofono_modem_get_data(modem);
> +
> +	DBG("%p", modem);
> +
> +	g_at_chat_cancel_all(data->modem);
> +	g_at_chat_unregister_all(data->modem);
> +	g_at_chat_unref(data->modem);
> +	data->modem = NULL;
> +
> +	g_at_chat_cancel_all(data->aux);
> +	g_at_chat_unregister_all(data->aux);
> +
> +	g_at_chat_send(data->aux, "AT+CFUN=0", NULL,
> +					cfun_disable, modem, NULL);

This modem doesn't jump off the bus on CFUN=0, right?

> +
> +	return -EINPROGRESS;
> +}
> +

<snip>

Regards,
-Denis


  reply	other threads:[~2014-06-26 14:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-24 17:10 [PATCH 0/6] Add a driver for u-blox modems Philip Paeps
2014-06-24 17:10 ` [PATCH 1/6] atmodem: add vendor u-blox Philip Paeps
2014-06-24 17:10 ` [PATCH 2/6] udevng: add detection logic for u-blox modems Philip Paeps
2014-06-24 17:10 ` [PATCH 3/6] plugins: new driver for u-blox SARA-U270 modems Philip Paeps
2014-06-26 14:29   ` Denis Kenzior [this message]
2014-06-26 14:49     ` Philip Paeps
2014-06-26 15:35       ` Denis Kenzior
2014-06-24 17:10 ` [PATCH 4/6] sim: query u-blox PIN retries with AT+UPINCNT Philip Paeps
2014-06-24 17:10 ` [PATCH 5/6] gprs: add support for u-blox +UREG URCs Philip Paeps
2014-06-24 17:10 ` [PATCH 6/6] atmodem: set the auth method for u-blox modems Philip Paeps
  -- strict thread matches above, loose matches on Subject: below --
2014-06-26 18:28 [PATCH v2 0/6] Add a driver " Philip Paeps
2014-06-26 18:28 ` [PATCH 3/6] plugins: new driver for u-blox SARA-U270 modems Philip Paeps

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=53AC2E5F.4010100@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox