From 2cb3027dd6c52f800e5905a74357c7e85e79d360 Mon Sep 17 00:00:00 2001 From: Miia Leinonen Date: Wed, 2 Mar 2011 14:56:52 +0200 Subject: [PATCH] atmodem: Add MBM vendor quirk for SIM record update --- drivers/atmodem/sim.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c index d9c0d8db..2690ab47 100644 --- a/drivers/atmodem/sim.c +++ b/drivers/atmodem/sim.c @@ -332,18 +332,29 @@ 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; + int size = 36 + length * 2; + if (sd->vendor == OFONO_VENDOR_MBM) + size += 2; /*Add quotes*/ + + buf = g_try_new(char, size); if (buf == NULL) goto error; len = sprintf(buf, "AT+CRSM=220,%i,%i,4,%i,", fileid, record, length); + if (sd->vendor == OFONO_VENDOR_MBM) + len += sprintf(buf + len, "\""); + for (; length; length--) len += sprintf(buf + len, "%02hhX", *value++); + if (sd->vendor == OFONO_VENDOR_MBM) + sprintf(buf + len, "\""); + ret = g_at_chat_send(sd->chat, buf, crsm_prefix, at_crsm_update_cb, cbd, g_free); @@ -364,17 +375,28 @@ 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; + int size = 36 + length * 2; + if (sd->vendor == OFONO_VENDOR_MBM) + size += 2; /* Add quotes */ + + buf = g_try_new(char, size); if (buf == NULL) goto error; len = sprintf(buf, "AT+CRSM=220,%i,0,3,%i,", fileid, length); + if (sd->vendor == OFONO_VENDOR_MBM) + len += sprintf(buf + len, "\""); + for (; length; length--) len += sprintf(buf + len, "%02hhX", *value++); + if (sd->vendor == OFONO_VENDOR_MBM) + sprintf(buf + len, "\""); + ret = g_at_chat_send(sd->chat, buf, crsm_prefix, at_crsm_update_cb, cbd, g_free);