Re: [PATCH v2 5/8] lib: introduce sg_nents_len_chained

2015-09-21 Thread Herbert Xu
On Fri, Sep 18, 2015 at 05:25:47PM -0400, Tony Battersby wrote: > > So instead of adding a new function sg_nents_len_chained(), a better > cleanup would be: > 1) replace the driver-specific functions with calls to sg_nents_for_len() > 2) get rid of the "chained" variables > 3) always call

Re: [PATCH v2 5/8] lib: introduce sg_nents_len_chained

2015-09-21 Thread LABBE Corentin
On Mon, Sep 21, 2015 at 10:19:17PM +0800, Herbert Xu wrote: > On Fri, Sep 18, 2015 at 05:25:47PM -0400, Tony Battersby wrote: > > > > So instead of adding a new function sg_nents_len_chained(), a better > > cleanup would be: > > 1) replace the driver-specific functions with calls to

Re: [PATCH v2 5/8] lib: introduce sg_nents_len_chained

2015-09-18 Thread Tony Battersby
On 09/18/2015 12:19 PM, Tony Battersby wrote: > But why do drivers even need this at all? Here is a typical usage: > > int qce_mapsg(struct device *dev, struct scatterlist *sg, int nents, > enum dma_data_direction dir, bool chained) > { > int err; > > if (chained) { >

Re: [PATCH v2 5/8] lib: introduce sg_nents_len_chained

2015-09-18 Thread Tom Lendacky
On 09/18/2015 07:57 AM, 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_len_chained in lib/scatterlist.c Signed-off-by: LABBE

[PATCH v2 5/8] lib: introduce sg_nents_len_chained

2015-09-18 Thread LABBE Corentin
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_len_chained in lib/scatterlist.c Signed-off-by: LABBE Corentin ---

Re: [PATCH v2 5/8] lib: introduce sg_nents_len_chained

2015-09-18 Thread Tony Battersby
On 09/18/2015 08:57 AM, LABBE Corentin wrote: > + 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; > +