[PATCH v2 01/13] scatterlist: introduce sg_nents_for_dma() helper
Bjorn Andersson
andersson at kernel.org
Mon Nov 10 08:34:10 PST 2025
On Mon, Nov 10, 2025 at 05:33:29PM +0200, Andy Shevchenko wrote:
> On Mon, Nov 10, 2025 at 09:21:18AM -0600, Bjorn Andersson wrote:
> > On Mon, Nov 10, 2025 at 09:05:26AM -0600, Bjorn Andersson wrote:
> > > On Mon, Nov 10, 2025 at 11:23:28AM +0100, Andy Shevchenko wrote:
>
> ...
>
> > > > int sg_nents(struct scatterlist *sg);
> > > > int sg_nents_for_len(struct scatterlist *sg, u64 len);
> > > > +int sg_nents_for_dma(struct scatterlist *sgl, unsigned int sglen, size_t len);
>
>
> ^^^
>
> > > > +int sg_nents_for_dma(struct scatterlist *sgl, unsigned int sglen, size_t len)
> >
> > All but two clients store the value in an unsigned int. Changing the
> > return type to unsigned int also signals that the function is just
> > returning a count (no errors).
>
> The type is chosen for the consistency with the existing APIs.
> So, I prefer consistency in this case, if we need to change type, we need to do
> that for all above APIs I believe. And this is out of the scope here.
>
That makes sense, after a second look I agree with your decision.
Regards,
Bjorn
> Personally I was also puzzled of the choice as *nents members are all unsigned
> int in the scatterlist.h.
>
> ...
>
> > > We need an EXPORT_SYMBOL() here.
>
> Good catch! I'll add it in next version.
>
> > > With that, this looks good to me.
> > >
> > > Reviewed-by: Bjorn Andersson <andersson at kernel.org>
>
> Thanks!
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
More information about the linux-arm-kernel
mailing list