/** * gf_copy_to() - copy a chunk of data to the flash * @map: MTD map state * @to: flash offset to copy to * @from: memory to copy from * @len: how much to copy * * See gf_copy_from() caveat. */ static void gf_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len) { struct async_state *state = gf_map_info_to_state(map); gf_set_gpios(state, to); /* BUG if operation crosses the win_size */ BUG_ON(!((to + len) % state->win_size <= (to + len))); /* operation does not cross the win_size, so one shot it */ memcpy_toio(map->virt + (to % state->win_size), from, len); }
/** * gf_copy_from() - copy a chunk of data from the flash * @map: MTD map state * @to: memory to copy to * @from: flash offset to copy from * @len: how much to copy * * The "from" region may straddle more than one window, so toggle the GPIOs for * each window region before reading its data. */ static void gf_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len) { struct async_state *state = gf_map_info_to_state(map); int this_len; while (len) { if ((from % state->win_size) + len > state->win_size) this_len = state->win_size - (from % state->win_size); else this_len = len; gf_set_gpios(state, from); memcpy_fromio(to, map->virt + (from % state->win_size), this_len); len -= this_len; from += this_len; to += this_len; } }
/** * gf_copy_to() - copy a chunk of data to the flash * @map: MTD map state * @to: flash offset to copy to * @from: memory to copy from * @len: how much to copy * * See gf_copy_from() caveat. */ static void gf_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len) { struct async_state *state = gf_map_info_to_state(map); int this_len; while (len) { if ((to % state->win_size) + len > state->win_size) this_len = state->win_size - (to % state->win_size); else this_len = len; gf_set_gpios(state, to); memcpy_toio(map->virt + (to % state->win_size), from, len); len -= this_len; to += this_len; from += this_len; } }