Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761020AbXEJLle (ORCPT ); Thu, 10 May 2007 07:41:34 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758633AbXEJLlJ (ORCPT ); Thu, 10 May 2007 07:41:09 -0400 Received: from brick.kernel.dk ([80.160.20.94]:4876 "EHLO kernel.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757229AbXEJLlH (ORCPT ); Thu, 10 May 2007 07:41:07 -0400 From: Jens Axboe To: linux-kernel@vger.kernel.org Cc: Jens Axboe Subject: [PATCH 2/12] Add sg helpers for iterating over a scatterlist table Date: Thu, 10 May 2007 13:40:27 +0200 Message-Id: <11787972373916-git-send-email-jens.axboe@oracle.com> X-Mailer: git-send-email 1.5.2.rc1 In-Reply-To: <11787972373654-git-send-email-jens.axboe@oracle.com> References: <11787972373654-git-send-email-jens.axboe@oracle.com> Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1130 Lines: 34 First step to being able to change the scatterlist setup without having to modify drivers (a lot :-) Signed-off-by: Jens Axboe --- include/linux/scatterlist.h | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 4efbd9c..bed5ab4 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -20,4 +20,13 @@ static inline void sg_init_one(struct scatterlist *sg, const void *buf, sg_set_buf(sg, buf, buflen); } +#define sg_next(sg) ((sg) + 1) +#define sg_last(sg, nents) (&(sg[(nents) - 1])) + +/* + * Loop over each sg element, following the pointer to a new list if necessary + */ +#define for_each_sg(sglist, sg, nr, __i) \ + for (__i = 0, sg = (sglist); __i < (nr); __i++, sg = sg_next(sg)) + #endif /* _LINUX_SCATTERLIST_H */ -- 1.5.2.rc1 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/