Message ID | 1441891302-12014-5-git-send-email-clabbe.montjoie@gmail.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Herbert Xu |
Headers | show |
On Thu, Sep 10, 2015 at 03:21:39PM +0200, LABBE Corentin wrote: > Some driver use a modified version of sg_nents_for_len with an > additional parameter bool *chained for knowing if the scatterlist is > chained or not. > > So, for removing duplicate code, add sg_nents_for_len2 in > lib/scatterlist.c This name is rather awkward. Perhaps sg_nents_len_chained? Thanks,
On Fri, Sep 18, 2015 at 07:53:00PM +0800, Herbert Xu wrote: > On Thu, Sep 10, 2015 at 03:21:39PM +0200, LABBE Corentin wrote: > > Some driver use a modified version of sg_nents_for_len with an > > additional parameter bool *chained for knowing if the scatterlist is > > chained or not. > > > > So, for removing duplicate code, add sg_nents_for_len2 in > > lib/scatterlist.c > > This name is rather awkward. Perhaps sg_nents_len_chained? Perfect, thanks I will send the modified patch series with this function name soon. Regards -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Fri, Sep 18, 2015 at 02:20:48PM +0200, LABBE Corentin wrote: > > I will send the modified patch series with this function name soon. You only need to resend patches 4-7. Thanks,
On Fri, Sep 18, 2015 at 08:22:13PM +0800, Herbert Xu wrote: > On Fri, Sep 18, 2015 at 02:20:48PM +0200, LABBE Corentin wrote: > > > > I will send the modified patch series with this function name soon. > > You only need to resend patches 4-7. > Since I have used badly get_maintainer.pl, I need to resend all patchs with all proper recipient. And I have respelled some patch. (like for sahara which have an empty commit log). Regards -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Fri, Sep 18, 2015 at 02:42:34PM +0200, LABBE Corentin wrote: > Since I have used badly get_maintainer.pl, I need to resend all patchs with all proper recipient. > And I have respelled some patch. (like for sahara which have an empty commit log). OK. Cheers,
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 556ec1e..316c5c4 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -243,6 +243,7 @@ static inline void *sg_virt(struct scatterlist *sg) int sg_nents(struct scatterlist *sg); int sg_nents_for_len(struct scatterlist *sg, u64 len); +int sg_nents_for_len2(struct scatterlist *sg, u64 len, bool *chained); struct scatterlist *sg_next(struct scatterlist *); struct scatterlist *sg_last(struct scatterlist *s, unsigned int); void sg_init_table(struct scatterlist *, unsigned int); diff --git a/lib/scatterlist.c b/lib/scatterlist.c index bafa993..0d1f746 100644 --- a/lib/scatterlist.c +++ b/lib/scatterlist.c @@ -90,6 +90,45 @@ int sg_nents_for_len(struct scatterlist *sg, u64 len) EXPORT_SYMBOL(sg_nents_for_len); /** + * sg_nents_for_len - return total count of entries in scatterlist + * needed to satisfy the supplied length + * @sg: The scatterlist + * @len: The total required length + * @chained A pointer where to store if SG is chaind or not + * + * Description: + * Determines the number of entries in sg that are required to meet + * the supplied length, taking into acount chaining as well + * + * Returns: + * the number of sg entries needed, negative error on failure + * + **/ +int sg_nents_for_len2(struct scatterlist *sg, u64 len, bool *chained) +{ + int nents; + u64 total; + + if (chained) + *chained = false; + + if (!len) + return 0; + + for (nents = 0, total = 0; sg; sg = sg_next(sg)) { + nents++; + total += sg->length; + if (!sg_is_last(sg) && (sg + 1)->length == 0 && chained) + *chained = true; + if (total >= len) + return nents; + } + + return -EINVAL; +} +EXPORT_SYMBOL(sg_nents_for_len2); + +/** * sg_last - return the last scatterlist entry in a list * @sgl: First entry in the scatterlist * @nents: Number of entries in the scatterlist
Some driver use a modified version of sg_nents_for_len with an additional parameter bool *chained for knowing if the scatterlist is chained or not. So, for removing duplicate code, add sg_nents_for_len2 in lib/scatterlist.c Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com> --- include/linux/scatterlist.h | 1 + lib/scatterlist.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+)