/** * sg_split - split a scatterlist into several scatterlists * @in: the input sg list * @in_mapped_nents: the result of a dma_map_sg(in, ...), or 0 if not mapped. * @skip: the number of bytes to skip in the input sg list * @nb_splits: the number of desired sg outputs * @split_sizes: the respective size of each output sg list in bytes * @out: an array where to store the allocated output sg lists * @out_mapped_nents: the resulting sg lists mapped number of sg entries. Might * be NULL if sglist not already mapped (in_mapped_nents = 0) * @gfp_mask: the allocation flag * * This function splits the input sg list into nb_splits sg lists, which are * allocated and stored into out. * The @in is split into : * - @out[0], which covers bytes [@skip .. @skip + @split_sizes[0] - 1] of @in * - @out[1], which covers bytes [@skip + split_sizes[0] .. * @skip + @split_sizes[0] + @split_sizes[1] -1] * etc ... * It will be the caller's duty to kfree() out array members. * * Returns 0 upon success, or error code
*/ int sg_split(struct scatterlist *in, constint in_mapped_nents, const off_t skip, constint nb_splits, const size_t *split_sizes, struct scatterlist **out, int *out_mapped_nents,
gfp_t gfp_mask)
{ int i, ret; struct sg_splitter *splitters;
splitters = kcalloc(nb_splits, sizeof(*splitters), gfp_mask); if (!splitters) return -ENOMEM;
ret = sg_calculate_split(in, sg_nents(in), nb_splits, skip, split_sizes,
splitters, false); if (ret < 0) goto err;
ret = -ENOMEM; for (i = 0; i < nb_splits; i++) {
splitters[i].out_sg = kmalloc_array(splitters[i].nents, sizeof(struct scatterlist),
gfp_mask); if (!splitters[i].out_sg) goto err;
}
/* * The order of these 3 calls is important and should be kept.
*/
sg_split_phys(splitters, nb_splits); if (in_mapped_nents) {
ret = sg_calculate_split(in, in_mapped_nents, nb_splits, skip,
split_sizes, splitters, true); if (ret < 0) goto err;
sg_split_mapped(splitters, nb_splits);
}
for (i = 0; i < nb_splits; i++) {
out[i] = splitters[i].out_sg; if (out_mapped_nents)
out_mapped_nents[i] = splitters[i].nents;
}
kfree(splitters); return 0;
err: for (i = 0; i < nb_splits; i++)
kfree(splitters[i].out_sg);
kfree(splitters); return ret;
}
EXPORT_SYMBOL(sg_split);
Messung V0.5
¤ Dauer der Verarbeitung: 0.16 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.