@@ -397,7 +397,7 @@ static struct scatterlist *get_next_sg(struct sg_table *table,
397397}
398398
399399/**
400- * __sg_alloc_table_from_pages - Allocate and initialize an sg table from
400+ * sg_alloc_append_table_from_pages - Allocate and initialize an sg table from
401401 * an array of pages
402402 * @sgt: The sg table header to use
403403 * @pages: Pointer to an array of page pointers
@@ -425,7 +425,7 @@ static struct scatterlist *get_next_sg(struct sg_table *table,
425425 * If this function returns non-0 (eg failure), the caller must call
426426 * sg_free_table() to cleanup any leftover allocations.
427427 */
428- struct scatterlist * __sg_alloc_table_from_pages (struct sg_table * sgt ,
428+ struct scatterlist * sg_alloc_append_table_from_pages (struct sg_table * sgt ,
429429 struct page * * pages , unsigned int n_pages , unsigned int offset ,
430430 unsigned long size , unsigned int max_segment ,
431431 struct scatterlist * prv , unsigned int left_pages ,
@@ -520,36 +520,40 @@ struct scatterlist *__sg_alloc_table_from_pages(struct sg_table *sgt,
520520 sg_mark_end (s );
521521 return s ;
522522}
523- EXPORT_SYMBOL (__sg_alloc_table_from_pages );
523+ EXPORT_SYMBOL (sg_alloc_append_table_from_pages );
524524
525525/**
526- * sg_alloc_table_from_pages - Allocate and initialize an sg table from
527- * an array of pages
526+ * sg_alloc_table_from_pages_segment - Allocate and initialize an sg table from
527+ * an array of pages and given maximum
528+ * segment.
528529 * @sgt: The sg table header to use
529530 * @pages: Pointer to an array of page pointers
530531 * @n_pages: Number of pages in the pages array
531532 * @offset: Offset from start of the first page to the start of a buffer
532533 * @size: Number of valid bytes in the buffer (after offset)
534+ * @max_segment: Maximum size of a scatterlist element in bytes
533535 * @gfp_mask: GFP allocation mask
534536 *
535537 * Description:
536538 * Allocate and initialize an sg table from a list of pages. Contiguous
537- * ranges of the pages are squashed into a single scatterlist node. A user
538- * may provide an offset at a start and a size of valid data in a buffer
539- * specified by the page array. The returned sg table is released by
540- * sg_free_table.
539+ * ranges of the pages are squashed into a single scatterlist node up to the
540+ * maximum size specified in @max_segment. A user may provide an offset at a
541+ * start and a size of valid data in a buffer specified by the page array.
541542 *
542- * Returns:
543+ * The returned sg table is released by sg_free_table.
544+ *
545+ * Returns:
543546 * 0 on success, negative error on failure
544547 */
545- int sg_alloc_table_from_pages (struct sg_table * sgt , struct page * * pages ,
546- unsigned int n_pages , unsigned int offset ,
547- unsigned long size , gfp_t gfp_mask )
548+ int sg_alloc_table_from_pages_segment (struct sg_table * sgt , struct page * * pages ,
549+ unsigned int n_pages , unsigned int offset ,
550+ unsigned long size , unsigned int max_segment ,
551+ gfp_t gfp_mask )
548552{
549- return PTR_ERR_OR_ZERO (__sg_alloc_table_from_pages (sgt , pages , n_pages ,
550- offset , size , UINT_MAX , NULL , 0 , gfp_mask ));
553+ return PTR_ERR_OR_ZERO (sg_alloc_append_table_from_pages (sgt , pages ,
554+ n_pages , offset , size , max_segment , NULL , 0 , gfp_mask ));
551555}
552- EXPORT_SYMBOL (sg_alloc_table_from_pages );
556+ EXPORT_SYMBOL (sg_alloc_table_from_pages_segment );
553557
554558#ifdef CONFIG_SGL_ALLOC
555559
0 commit comments