diff options
author | Denis Kenzior <denkenz@gmail.com> | 2010-08-31 17:55:17 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-09-09 08:50:28 -0500 |
commit | e3bd339e16897e3c57a28bd619c922fcb8c0022a (patch) | |
tree | 71e8c4b8276439b89994d36a65956a61de65e31b /src/sim.c | |
parent | 95d957b62ec79effa9ebe27bea5f4d77a1d8984c (diff) | |
download | ofono-e3bd339e16897e3c57a28bd619c922fcb8c0022a.tar.bz2 |
sim: Unify sim_read and sim_read_bytes
Diffstat (limited to 'src/sim.c')
-rw-r--r-- | src/sim.c | 54 |
1 files changed, 14 insertions, 40 deletions
@@ -2120,9 +2120,10 @@ static gboolean sim_op_next(gpointer user_data) return FALSE; } -int ofono_sim_read_bytes(struct ofono_sim *sim, int id, - unsigned short offset, int num_bytes, - ofono_sim_file_read_cb_t cb, void *data) +static int sim_read_common(struct ofono_sim *sim, int id, + enum ofono_sim_file_structure expected_type, + unsigned short offset, int num_bytes, + ofono_sim_file_read_cb_t cb, void *data) { struct sim_file_op *op; @@ -2148,7 +2149,7 @@ int ofono_sim_read_bytes(struct ofono_sim *sim, int id, op = g_new0(struct sim_file_op, 1); op->id = id; - op->structure = OFONO_SIM_FILE_STRUCTURE_TRANSPARENT; + op->structure = expected_type; op->cb = cb; op->userdata = data; op->is_read = TRUE; @@ -2163,46 +2164,19 @@ int ofono_sim_read_bytes(struct ofono_sim *sim, int id, return 0; } +int ofono_sim_read_bytes(struct ofono_sim *sim, int id, + unsigned short offset, int num_bytes, + ofono_sim_file_read_cb_t cb, void *data) +{ + return sim_read_common(sim, id, OFONO_SIM_FILE_STRUCTURE_TRANSPARENT, + offset, num_bytes, cb, data); +} + int ofono_sim_read(struct ofono_sim *sim, int id, enum ofono_sim_file_structure expected_type, ofono_sim_file_read_cb_t cb, void *data) { - struct sim_file_op *op; - - if (!cb) - return -1; - - if (sim == NULL) - return -1; - - if (!sim->driver) - return -1; - - if (!sim->driver->read_file_info) - return -1; - - /* TODO: We must first check the EFust table to see whether - * this file can be read at all - */ - - if (!sim->simop_q) - sim->simop_q = g_queue_new(); - - op = g_new0(struct sim_file_op, 1); - - op->id = id; - op->structure = expected_type; - op->cb = cb; - op->userdata = data; - op->is_read = TRUE; - op->num_bytes = -1; - - g_queue_push_tail(sim->simop_q, op); - - if (g_queue_get_length(sim->simop_q) == 1) - sim->simop_source = g_timeout_add(0, sim_op_next, sim); - - return 0; + return sim_read_common(sim, id, expected_type, 0, -1, cb, data); } int ofono_sim_write(struct ofono_sim *sim, int id, |