From 198e79f0e8f0b24c1e36ab6032d348f40de20262 Mon Sep 17 00:00:00 2001 From: Dominik Sliwa Date: Fri, 22 Dec 2017 12:07:34 +0000 Subject: backports: bluetooth: Support 4.9 kernels Signed-off-by: Dominik Sliwa --- backport-include/linux/kernel.h | 4 ++++ backport-include/linux/kref.h | 13 +++++++++++++ backport-include/linux/skbuff.h | 17 +++++++++++++++++ backport-include/linux/string.h | 4 ++++ backport-include/linux/uio.h | 7 +++++++ 5 files changed, 45 insertions(+) create mode 100644 backport-include/linux/kref.h create mode 100644 backport-include/linux/uio.h (limited to 'backport-include/linux') diff --git a/backport-include/linux/kernel.h b/backport-include/linux/kernel.h index 3ddeb13..4b2f153 100644 --- a/backport-include/linux/kernel.h +++ b/backport-include/linux/kernel.h @@ -206,6 +206,10 @@ int __must_check kstrtobool_from_user(const char __user *s, size_t count, bool * #endif +#if LINUX_VERSION_IS_LESS(4,5,0) +const char *kvasprintf_const(gfp_t gfp, const char *fmt, va_list args); +#endif /* < 4.4 */ + #if LINUX_VERSION_IS_LESS(3,14,0) static inline u32 reciprocal_scale(u32 val, u32 ep_ro) { diff --git a/backport-include/linux/kref.h b/backport-include/linux/kref.h new file mode 100644 index 0000000..631488f --- /dev/null +++ b/backport-include/linux/kref.h @@ -0,0 +1,13 @@ +#ifndef __BACKPORT_LINUX_KREF_H +#define __BACKPORT_LINUX_KREF_H +#include_next + +#if LINUX_VERSION_IS_LESS(4,11,0) +#include +static inline unsigned int kref_read(const struct kref *kref) +{ + return refcount_read((const refcount_t *)&kref->refcount); +} +#endif /* < 4.11 */ + +#endif /* __BACKPORT_LINUX_KREF_H */ diff --git a/backport-include/linux/skbuff.h b/backport-include/linux/skbuff.h index 034206b..af40b8d 100644 --- a/backport-include/linux/skbuff.h +++ b/backport-include/linux/skbuff.h @@ -371,6 +371,23 @@ static inline void skb_put_u8(struct sk_buff *skb, u8 val) { *(u8 *)skb_put(skb, 1) = val; } + +static inline void *__skb_put_zero(struct sk_buff *skb, unsigned int len) +{ + void *tmp = __skb_put(skb, len); + + memset(tmp, 0, len); + return tmp; +} + +static inline void *__skb_put_data(struct sk_buff *skb, const void *data, + unsigned int len) +{ + void *tmp = __skb_put(skb, len); + + memcpy(tmp, data, len); + return tmp; +} #endif #endif /* __BACKPORT_SKBUFF_H */ diff --git a/backport-include/linux/string.h b/backport-include/linux/string.h index b85d9c7..b1d26d1 100644 --- a/backport-include/linux/string.h +++ b/backport-include/linux/string.h @@ -29,4 +29,8 @@ void memzero_explicit(void *s, size_t count); ssize_t strscpy(char *dest, const char *src, size_t count); #endif +#if LINUX_VERSION_IS_LESS(4,0,0) +extern void kfree_const(const void *x); +extern const char *kstrdup_const(const char *s, gfp_t gfp); +#endif #endif /* __BACKPORT_LINUX_STRING_H */ diff --git a/backport-include/linux/uio.h b/backport-include/linux/uio.h new file mode 100644 index 0000000..fe27e68 --- /dev/null +++ b/backport-include/linux/uio.h @@ -0,0 +1,7 @@ +#ifndef _BP_LINUX_UIO_H +#define _BP_LINUX_UIO_H +#include_next + +bool _copy_from_iter_full(void *addr, size_t bytes, struct iov_iter *i); + +#endif /* _BP_LINUX_UIO_H */ -- cgit v1.2.3