All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 2/6] gemalto: support ALS3 in gemalto's plugin
Date: Fri, 16 Mar 2018 11:08:53 -0500	[thread overview]
Message-ID: <b30564c9-8a92-4fa9-eb3c-a0f01597f12e@gmail.com> (raw)
In-Reply-To: <1521215975-19944-1-git-send-email-gabriel.lucas@smile.fr>

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

Hi Gabriel,
<snip>

> @@ -300,29 +322,24 @@ static int gemalto_hardware_monitor_enable(struct ofono_modem *modem)
>   	return 0;
>   }
>   
> -static int gemalto_enable(struct ofono_modem *modem)
> +static void gemalto_initialize(struct ofono_modem *modem)
>   {
>   	struct gemalto_data *data = ofono_modem_get_data(modem);
> -	const char *app, *mdm;
> +	const char *mdm;
>   
> -	DBG("%p", modem);
> +	DBG("");
>   
> -	app = ofono_modem_get_string(modem, "Application");
>   	mdm = ofono_modem_get_string(modem, "Modem");
>   
> -	if (app == NULL || mdm == NULL)
> -		return -EINVAL;
> +	if (mdm == NULL)
> +		return;
>   
>   	/* Open devices */
> -	data->app = open_device(app);
> -	if (data->app == NULL)
> -		return -EINVAL;
> -
>   	data->mdm = open_device(mdm);
>   	if (data->mdm == NULL) {
>   		g_at_chat_unref(data->app);
>   		data->app = NULL;
> -		return -EINVAL;
> +		return;
>   	}
>   
>   	if (getenv("OFONO_AT_DEBUG")) {
> @@ -340,6 +357,67 @@ static int gemalto_enable(struct ofono_modem *modem)
>   			cfun_enable, modem, NULL);
>   
>   	gemalto_hardware_monitor_enable(modem);
> +}
> +
> +static void gemalto_modem_ready(GAtResult *result, gpointer user_data)
> +{
> +	struct ofono_modem *modem = user_data;
> +	struct gemalto_data *data = ofono_modem_get_data(modem);
> +	const char *app = ofono_modem_get_string(modem, "Application");
> +
> +	DBG("");
> +
> +	g_at_chat_unregister(data->app, data->modem_ready_id);
> +	g_at_chat_cancel(data->app, data->trial_cmd_id);

Since you're unrefing data->app below, this isn't really necessary.  You 
might want to reset the ids to zero here though.

> +
> +	/*!
> +	 * As the modem wasn't ready to handle AT commands when we opened
> +	 * it, we have to close and reopen the device app.
> +	 */ 
> +	g_at_chat_unref(data->app);
> +
> +	if(app == NULL)
> +		return;

Not our coding style.  Also, the "Application" property should not 
disappear under you, so I would leave this check out.

> +
> +	data->app = open_device(app);
> +	if (data->app == NULL)
> +		return;

You might want to tell the core that the enable operation failed.  So 
ofono_modem_set_powered(modem, FALSE);

> +
> +	gemalto_initialize(modem);
> +}
> +
> +static void gemalto_at_cb(gboolean ok, GAtResult *result, gpointer user_data)
> +{
> +	struct ofono_modem *modem = user_data;
> +	struct gemalto_data *data = ofono_modem_get_data(modem);
> +
> +	g_at_chat_unregister(data->app, data->modem_ready_id);
> +	gemalto_initialize(modem);

Do you also want to reset modem_ready_id to 0 as well?  And trial_cmd_id

> +}
> +
> +static int gemalto_enable(struct ofono_modem *modem)
> +{
> +	struct gemalto_data *data = ofono_modem_get_data(modem);
> +	const char *app, *mdm;
> +
> +	DBG("%p", modem);
> +
> +	app = ofono_modem_get_string(modem, "Application");
> +	mdm = ofono_modem_get_string(modem, "Modem");
> +
> +	if (app == NULL || mdm == NULL)
> +		return -EINVAL;
> +
> +	/* Open devices */
> +	data->app = open_device(app);
> +	if (data->app == NULL)
> +		return -EINVAL;
> +
> +	/* Try the AT command. If it doesn't work, wait for ^SYSSTART */
> +	data->modem_ready_id = g_at_chat_register(data->app, "^SYSSTART",
> +				gemalto_modem_ready, FALSE, modem, NULL);
> +	data->trial_cmd_id = g_at_chat_send(data->app, "ATE0 AT",
> +				none_prefix, gemalto_at_cb, modem, NULL);
>   
>   	return -EINPROGRESS;
>   }
> @@ -432,6 +510,7 @@ static void gemalto_post_sim(struct ofono_modem *modem)
>   	struct gemalto_data *data = ofono_modem_get_data(modem);
>   	struct ofono_gprs *gprs;
>   	struct ofono_gprs_context *gc;
> +	const char *model = ofono_modem_get_string(modem, "Model");
>   
>   	DBG("%p", modem);
>   
> @@ -444,6 +523,9 @@ static void gemalto_post_sim(struct ofono_modem *modem)
>   
>   	if (gprs && gc)
>   		ofono_gprs_add_context(gprs, gc);
> +
> +	if (!g_strcmp0(model, GEMALTO_MODEL_ALS3))
> +		ofono_lte_create(modem, OFONO_VENDOR_CINTERION, "atmodem", data->app);

Over 80 characters here

>   }
>   
>   static void gemalto_post_online(struct ofono_modem *modem)
> 

Regards,
-Denis

  parent reply	other threads:[~2018-03-16 16:08 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-15 12:49 [PATCH 0/6] gemalto's ALS3 and PHS8P support Gabriel Lucas
2018-03-15 12:49 ` [PATCH 1/6] gemalto: add detection of ALS3 modem Gabriel Lucas
2018-03-15 17:22   ` Denis Kenzior
2018-03-15 12:49 ` [PATCH 2/6] gemalto: support ALS3 in gemalto's plugin Gabriel Lucas
2018-03-15 17:11   ` Denis Kenzior
2018-03-16 10:30     ` Gabriel Lucas
2018-03-16 14:23       ` Denis Kenzior
2018-03-16 15:53         ` Gabriel Lucas
2018-03-16 15:59           ` Gabriel Lucas
2018-03-16 16:08             ` Gabriel Lucas
2018-03-16 16:08             ` Denis Kenzior [this message]
2018-03-19  9:45               ` Gabriel Lucas
2018-03-19 13:50                 ` Denis Kenzior
2018-03-19 15:15                   ` Gabriel Lucas
2018-03-19 15:24                     ` Denis Kenzior
2018-03-15 12:49 ` [PATCH 3/6] gemalto: acquire the network technology Gabriel Lucas
2018-03-15 17:19   ` Denis Kenzior
2018-03-16 12:04     ` Gabriel Lucas
2018-03-16 12:59     ` Gabriel Lucas
2018-03-16 14:27       ` Denis Kenzior
2018-03-16 15:30         ` Gabriel LUCAS
2018-03-15 12:49 ` [PATCH 4/6] gemalto: handle sim is inserted or removed URCs Gabriel Lucas
2018-03-15 17:26   ` Denis Kenzior
2018-03-16 13:28     ` Gabriel Lucas
2018-03-16 14:03       ` Denis Kenzior
2018-03-19 15:57         ` Gabriel Lucas
2018-03-19 16:08           ` Denis Kenzior
2018-03-19 16:26             ` Gabriel Lucas
2018-03-19 17:10               ` Denis Kenzior
2018-03-20  8:37                 ` Gabriel Lucas
2018-03-15 12:49 ` [PATCH 5/6] sim: give access to the driver Gabriel Lucas
2018-03-15 17:27   ` Denis Kenzior
2018-03-15 12:49 ` [PATCH 6/6] gemalto: fix sim reinsertion issue Gabriel Lucas
2018-03-15 17:29   ` Denis Kenzior
2018-03-16 13:30     ` Gabriel Lucas
2018-03-19 16:01     ` Gabriel Lucas
  -- strict thread matches above, loose matches on Subject: below --
2018-03-12 12:57 [PATCH 0/6] gemalto's ALS3 and PHS8P support Gabriel Lucas
2018-03-12 12:57 ` [PATCH 2/6] gemalto: support ALS3 in gemalto's plugin Gabriel Lucas

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=b30564c9-8a92-4fa9-eb3c-a0f01597f12e@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.