Skip to content

Commit efc5b2e

Browse files
tursulinjgunthorpe
authored andcommitted
tools/testing/scatterlist: Rejuvenate bit-rotten test
A couple small tweaks are needed to make the test build and run on current kernels. Link: https://lore.kernel.org/r/20201004154340.1080481-3-leon@kernel.org Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Maor Gottlieb <maorg@nvidia.com> Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 549738f commit efc5b2e

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

tools/testing/scatterlist/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ targets: include $(TARGETS)
1414
main: $(OFILES)
1515

1616
clean:
17-
$(RM) $(TARGETS) $(OFILES) scatterlist.c linux/scatterlist.h linux/highmem.h linux/kmemleak.h asm/io.h
17+
$(RM) $(TARGETS) $(OFILES) scatterlist.c linux/scatterlist.h linux/highmem.h linux/kmemleak.h linux/slab.h asm/io.h
1818
@rmdir asm
1919

2020
scatterlist.c: ../../../lib/scatterlist.c
@@ -28,4 +28,5 @@ include: ../../../include/linux/scatterlist.h
2828
@touch asm/io.h
2929
@touch linux/highmem.h
3030
@touch linux/kmemleak.h
31+
@touch linux/slab.h
3132
@cp $< linux/scatterlist.h

tools/testing/scatterlist/linux/mm.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ static inline void *kmalloc(unsigned int size, unsigned int flags)
114114
return malloc(size);
115115
}
116116

117+
static inline void *
118+
kmalloc_array(unsigned int n, unsigned int size, unsigned int flags)
119+
{
120+
return malloc(n * size);
121+
}
122+
117123
#define kfree(x) free(x)
118124

119125
#define kmemleak_alloc(a, b, c, d)
@@ -122,4 +128,33 @@ static inline void *kmalloc(unsigned int size, unsigned int flags)
122128
#define PageSlab(p) (0)
123129
#define flush_kernel_dcache_page(p)
124130

131+
#define MAX_ERRNO 4095
132+
133+
#define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO)
134+
135+
static inline void * __must_check ERR_PTR(long error)
136+
{
137+
return (void *) error;
138+
}
139+
140+
static inline long __must_check PTR_ERR(__force const void *ptr)
141+
{
142+
return (long) ptr;
143+
}
144+
145+
static inline bool __must_check IS_ERR(__force const void *ptr)
146+
{
147+
return IS_ERR_VALUE((unsigned long)ptr);
148+
}
149+
150+
static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
151+
{
152+
if (IS_ERR(ptr))
153+
return PTR_ERR(ptr);
154+
else
155+
return 0;
156+
}
157+
158+
#define IS_ENABLED(x) (0)
159+
125160
#endif

0 commit comments

Comments
 (0)