On Thu, Sep 03, 2020 at 03:18:52PM +0300, Leon Romanovsky wrote:
+struct sg_append {I don't really see the point in this structure. Either pass it as
+ struct scatterlist *prv; /* Previous entry to append */
+ unsigned int left_pages; /* Left pages to add to table */
+};
two separate arguments, or switch sg_alloc_table_append and the
internal helper to pass all arguments as a struct.
+ * A user may provide an offset at a start and a size of valid data in a bufferThis adds a few pointles > 80 char lines.
+ * specified by the page array. A user may provide @append to chain pages to
+struct scatterlist *Which makes this API entirely useless for !CONFIG_ARCH_NO_SG_CHAIN,
+sg_alloc_table_append(struct sg_table *sgt, struct page **pages,
+ unsigned int n_pages, unsigned int offset,
+ unsigned long size, unsigned int max_segment,
+ gfp_t gfp_mask, struct sg_append *append)
+{
+#ifdef CONFIG_ARCH_NO_SG_CHAIN
+ if (append->left_pages)
+ return ERR_PTR(-EOPNOTSUPP);
+#endif
doesn't it? Wouldn't it make more sense to not provide it for that
case and add an explicitl dependency in the callers?
+ return alloc_from_pages_common(sgt, pages, n_pages, offset, size,And if we somehow manage to sort that out we can merge
+ max_segment, gfp_mask, append);
sg_alloc_table_append and alloc_from_pages_common, reducing the amount
of wrappers that just make it too hard to follow the code.
+EXPORT_SYMBOL(sg_alloc_table_append);EXPORT_SYMBOL_GPL, please.