Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 10c95ed9 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe
Browse files

scatterlist: allow limited chaining without ARCH_HAS_SG_CHAIN



There are a couple of uses of struct scatterlist that never go to
the dma_map_sg() helper and thus don't care about ARCH_HAS_SG_CHAIN
which indicates that we can map chained S/G list.

The most important one is the crypto code, which currently has
to open code a few helpers to always allow chaining.  This patch
removes a few #ifdef ARCH_HAS_SG_CHAIN statements so that we can
switch the crypto code to these common helpers.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 0048b483
Loading
Loading
Loading
Loading
+0 −4
Original line number Original line Diff line number Diff line
@@ -161,10 +161,6 @@ static inline void sg_set_buf(struct scatterlist *sg, const void *buf,
static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents,
static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents,
			    struct scatterlist *sgl)
			    struct scatterlist *sgl)
{
{
#ifndef CONFIG_ARCH_HAS_SG_CHAIN
	BUG();
#endif

	/*
	/*
	 * offset and length are unused for chain entry.  Clear them.
	 * offset and length are unused for chain entry.  Clear them.
	 */
	 */
+0 −4
Original line number Original line Diff line number Diff line
@@ -105,16 +105,12 @@ EXPORT_SYMBOL(sg_nents_for_len);
 **/
 **/
struct scatterlist *sg_last(struct scatterlist *sgl, unsigned int nents)
struct scatterlist *sg_last(struct scatterlist *sgl, unsigned int nents)
{
{
#ifndef CONFIG_ARCH_HAS_SG_CHAIN
	struct scatterlist *ret = &sgl[nents - 1];
#else
	struct scatterlist *sg, *ret = NULL;
	struct scatterlist *sg, *ret = NULL;
	unsigned int i;
	unsigned int i;


	for_each_sg(sgl, sg, nents, i)
	for_each_sg(sgl, sg, nents, i)
		ret = sg;
		ret = sg;


#endif
#ifdef CONFIG_DEBUG_SG
#ifdef CONFIG_DEBUG_SG
	BUG_ON(sgl[0].sg_magic != SG_MAGIC);
	BUG_ON(sgl[0].sg_magic != SG_MAGIC);
	BUG_ON(!sg_is_last(ret));
	BUG_ON(!sg_is_last(ret));