[PATCH 1/2] scatterlist: add sg_nents

2012-09-25 Thread Maxim Levitsky
Useful helper to know the number of entries in scatterlist. Signed-off-by: Maxim Levitsky --- include/linux/scatterlist.h |1 + lib/scatterlist.c | 22 ++ 2 files changed, 23 insertions(+) diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h

[PATCH 1/2] scatterlist: add sg_nents

2012-09-26 Thread Maxim Levitsky
Useful helper to know the number of entries in scatterlist. Signed-off-by: Maxim Levitsky --- include/linux/scatterlist.h |1 + lib/scatterlist.c | 22 ++ 2 files changed, 23 insertions(+) diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h

Re: [PATCH 1/2] scatterlist: add sg_nents

2012-09-26 Thread Tejun Heo
(cc'ing Jens) On Wed, Sep 26, 2012 at 11:49:00AM +0200, Maxim Levitsky wrote: > Useful helper to know the number of entries in scatterlist. > > Signed-off-by: Maxim Levitsky > --- > include/linux/scatterlist.h |1 + > lib/scatterlist.c | 22 ++ > 2 files chan

Re: [PATCH 1/2] scatterlist: add sg_nents

2012-09-27 Thread Jens Axboe
On 09/26/2012 06:38 PM, Tejun Heo wrote: > (cc'ing Jens) > > On Wed, Sep 26, 2012 at 11:49:00AM +0200, Maxim Levitsky wrote: >> Useful helper to know the number of entries in scatterlist. >> >> Signed-off-by: Maxim Levitsky >> --- >> include/linux/scatterlist.h |1 + >> lib/scatterlist.c

Re: [PATCH 1/2] scatterlist: add sg_nents

2012-10-11 Thread Geert Uytterhoeven
On Wed, Sep 26, 2012 at 11:49 AM, Maxim Levitsky wrote: > +int sg_nents(struct scatterlist *sg) unsigned int? > +{ > + int nents = 0; > + while (sg) { > + nents++; > + sg = sg_next(sg); > + } > + > + return nents; > +} Gr{oetje,eeting}s,

Re: [PATCH 1/2] scatterlist: add sg_nents

2012-10-11 Thread Geert Uytterhoeven
On Thu, Oct 11, 2012 at 12:27 PM, Geert Uytterhoeven wrote: > On Wed, Sep 26, 2012 at 11:49 AM, Maxim Levitsky > wrote: >> +int sg_nents(struct scatterlist *sg) > > unsigned int? and "const struct scatterlist *sg"? Ah no, that won't work as sg_next() treats non-const pointers :-( >> +{ >> +