All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH] atmodem: Add MBM/STE quirk for SIM record update
Date: Tue, 01 Mar 2011 15:30:59 -0600	[thread overview]
Message-ID: <4D6D6593.2020309@gmail.com> (raw)
In-Reply-To: <1298448563-5033-1-git-send-email-miia.leinonen@tieto.com>

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

Hi Miia,

On 02/23/2011 02:09 AM, Miia Leinonen wrote:
> Fixed the <data> string to be set inside quotes for STE/MBM.
> 
> ---
> 
> Hi,
> 
> This fix has been tested with STE modem only due the lack of MBM HW.
> 
> Would it be possible that someone checks this with MBM modem? The problem is 
> likely to appear also there - therefore OFONO_VENDOR_MBM used. Could fix this 
> also to cover all modems, but that might cause some backward compatibility 
> issues.

This does seem to be required on MBM

> 
> BR,
> Miia
> 
> 
>  drivers/atmodem/sim.c |   59 ++++++++++++++++++++++++++++++++++++++----------
>  1 files changed, 46 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
> index d9c0d8d..7a0100a 100644
> --- a/drivers/atmodem/sim.c
> +++ b/drivers/atmodem/sim.c
> @@ -332,17 +332,34 @@ static void at_sim_update_record(struct ofono_sim *sim, int fileid,
>  {
>  	struct sim_data *sd = ofono_sim_get_data(sim);
>  	struct cb_data *cbd = cb_data_new(cb, data);
> -	char *buf = g_try_new(char, 36 + length * 2);
> +	char *buf;
>  	int len, ret;
>  
> -	if (buf == NULL)
> -		goto error;
> +	if (sd->vendor == OFONO_VENDOR_MBM) {
> +		buf = g_try_new(char, 36 + 2 + length * 2);
>  
> -	len = sprintf(buf, "AT+CRSM=220,%i,%i,4,%i,", fileid,
> -			record, length);
> +		if (buf == NULL)
> +			goto error;
>  
> -	for (; length; length--)
> -		len += sprintf(buf + len, "%02hhX", *value++);
> +		len = sprintf(buf, "AT+CRSM=220,%i,%i,4,%i,\"", fileid,
> +					record, length);
> +
> +		for (; length; length--)
> +			len += sprintf(buf + len, "%02hhX", *value++);
> +
> +		sprintf(buf + len, "\"");
> +	} else {
> +		buf = g_try_new(char, 36 + length * 2);
> +
> +		if (buf == NULL)
> +			goto error;
> +
> +		len = sprintf(buf, "AT+CRSM=220,%i,%i,4,%i,", fileid,
> +				record, length);
> +
> +		for (; length; length--)
> +			len += sprintf(buf + len, "%02hhX", *value++);
> +	}
>  

Please don't duplicate code like this.  It is much better written
something like this:

int size = 36 + 2 + length * 2;

if (vendor == VENDOR_MBM)
	size += 2; /* Add quotes */

buf = g_try_new(char, size);

len = sprintf(buf, "AT+CRSM=220,%i,%i,4,%i,", fileid, record, length);

if (vendor == VENDOR_MBM)
	len += sprint(buf + len, "\"");

for (; length; length--)
	...

if (vendor == VENDOR_MBM)
	...

etc.

>  	ret = g_at_chat_send(sd->chat, buf, crsm_prefix,
>  				at_crsm_update_cb, cbd, g_free);
> @@ -364,16 +381,32 @@ static void at_sim_update_cyclic(struct ofono_sim *sim, int fileid,
>  {
>  	struct sim_data *sd = ofono_sim_get_data(sim);
>  	struct cb_data *cbd = cb_data_new(cb, data);
> -	char *buf = g_try_new(char, 36 + length * 2);
> +	char *buf;
>  	int len, ret;
>  
> -	if (buf == NULL)
> -		goto error;
> +	if (sd->vendor == OFONO_VENDOR_MBM) {
> +		buf = g_try_new(char, 36 + 2 + length * 2);
>  
> -	len = sprintf(buf, "AT+CRSM=220,%i,0,3,%i,", fileid, length);
> +		if (buf == NULL)
> +			goto error;
>  
> -	for (; length; length--)
> -		len += sprintf(buf + len, "%02hhX", *value++);
> +		len = sprintf(buf, "AT+CRSM=220,%i,0,3,%i,\"", fileid, length);
> +
> +		for (; length; length--)
> +			len += sprintf(buf + len, "%02hhX", *value++);
> +
> +		sprintf(buf + len, "\"");
> +	} else {
> +		buf = g_try_new(char, 36 + length * 2);
> +
> +		if (buf == NULL)
> +			goto error;
> +
> +		len = sprintf(buf, "AT+CRSM=220,%i,0,3,%i,", fileid, length);
> +
> +		for (; length; length--)
> +			len += sprintf(buf + len, "%02hhX", *value++);
> +	}
>  
>  	ret = g_at_chat_send(sd->chat, buf, crsm_prefix,
>  				at_crsm_update_cb, cbd, g_free);

Regards,
-Denis

  parent reply	other threads:[~2011-03-01 21:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-23  8:09 [PATCH] atmodem: Add MBM/STE quirk for SIM record update Miia Leinonen
2011-02-28  7:22 ` Miia Leinonen
2011-03-01 21:30 ` Denis Kenzior [this message]
2011-03-02 12:56   ` [PATCH v2] atmodem: Add MBM vendor " Miia Leinonen
2011-03-03  4:55     ` Denis Kenzior

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=4D6D6593.2020309@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.