diff --git a/scst/include/scst.h b/scst/include/scst.h index 66cb6d685..57a48d998 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -79,6 +79,14 @@ typedef _Bool bool; #define __aligned __attribute__((aligned)) #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) +char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap); +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32) +#define lockdep_assert_held(l) do { (void)(l); } while (0) +#endif + #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 32) #ifndef O_DSYNC #define O_DSYNC O_SYNC diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index ef3a7c111..369686ae1 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -76,6 +76,27 @@ static int strncasecmp(const char *s1, const char *s2, size_t n) } #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) +char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap) +{ + unsigned int len; + char *p; + va_list aq; + + va_copy(aq, ap); + len = vsnprintf(NULL, 0, fmt, aq); + va_end(aq); + + p = kmalloc_track_caller(len + 1, gfp); + if (!p) + return NULL; + + vsnprintf(p, len + 1, fmt, ap); + + return p; +} +#endif + #if !((LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)) && defined(SCSI_EXEC_REQ_FIFO_DEFINED)) && !defined(HAVE_SG_COPY) static int sg_copy(struct scatterlist *dst_sg, struct scatterlist *src_sg, #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0)