From 7a3dbdd43f142f7f94a19ff6a320e589f0b23324 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Tue, 19 Sep 2017 15:28:00 -0700 Subject: gpu: nvgpu: Add for_each construct for nvgpu_sgts Add a macro to iterate across nvgpu_sgts. This makes it easier on developers who may accidentally forget to move to the next SGL. JIRA NVGPU-243 Change-Id: I90154a5d23f0014cb79bbcd5b6e8d8dbda303820 Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/1566627 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers/gpu/nvgpu/include') diff --git a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h index c2f0e37b..23a1bad7 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h +++ b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h @@ -104,6 +104,14 @@ struct nvgpu_mem_sgl { u64 length; }; +/* + * Iterate over the SGL entries in an SGT. + */ +#define nvgpu_sgt_for_each_sgl(__sgl__, __sgt__) \ + for ((__sgl__) = (__sgt__)->sgl; \ + (__sgl__) != NULL; \ + (__sgl__) = nvgpu_sgt_get_next(__sgt__, __sgl__)) + struct nvgpu_mem { /* * Populated for all nvgpu_mem structs - vidmem or system. -- cgit v1.2.2