summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Sliwa <dominik.sliwa@toradex.com>2019-02-21 11:35:20 +0100
committerDominik Sliwa <dominik.sliwa@toradex.com>2019-02-21 14:07:51 +0100
commit36735bb86a5e144603743bb800d7f69362d2ee2d (patch)
tree363158c7f80f3fc5a7690ca9d9ff6e5fcd7fa52e
parente7720369ef69376d1244b49373e34663eaa6b5a1 (diff)
backports: reintroduce bluetooth support
Signed-off-by: Dominik Sliwa <dominik.sliwa@toradex.com>
-rw-r--r--backport/Kconfig.sources2
-rw-r--r--backport/Makefile.kernel2
-rw-r--r--backport/backport-include/linux/kref.h13
-rw-r--r--backport/backport-include/linux/of_device.h5
-rw-r--r--backport/backport-include/linux/skbuff.h18
-rw-r--r--backport/compat/Makefile1
-rw-r--r--backport/compat/backport-4.12.c22
-rw-r--r--copy-list11
-rw-r--r--patches/0020-tty-termios/net_bluetooth_hci_ldisc.patch12
-rw-r--r--patches/0030-qdisc_tx_busylock/bluetooth.patch22
-rw-r--r--patches/0047-write_iter/bluetooth.patch2
-rw-r--r--patches/0050-iov_iter/bluetooth.patch6
-rw-r--r--patches/0062-acpi-gpio-remove/hci_bcm.patch47
-rw-r--r--patches/0062-acpi-gpio-remove/hci_intel.patch9
-rw-r--r--patches/0089-serdev-h-config.patch22
-rw-r--r--patches/0090-bluetooth-compilation.patch324
16 files changed, 428 insertions, 90 deletions
diff --git a/backport/Kconfig.sources b/backport/Kconfig.sources
index 11e27df9..c2713a14 100644
--- a/backport/Kconfig.sources
+++ b/backport/Kconfig.sources
@@ -12,6 +12,8 @@ source "$BACKPORT_DIR/drivers/net/usb/Kconfig"
source "$BACKPORT_DIR/drivers/ssb/Kconfig"
source "$BACKPORT_DIR/drivers/bcma/Kconfig"
+source "$BACKPORT_DIR/drivers/tty/serdev/Kconfig"
+
source "$BACKPORT_DIR/drivers/usb/class/Kconfig"
source "$BACKPORT_DIR/drivers/staging/Kconfig"
diff --git a/backport/Makefile.kernel b/backport/Makefile.kernel
index 8156b1ea..4264ebb1 100644
--- a/backport/Makefile.kernel
+++ b/backport/Makefile.kernel
@@ -50,4 +50,6 @@ obj-$(CPTCFG_USB_NET_RNDIS_WLAN) += drivers/net/usb/
obj-$(CPTCFG_USB_WDM) += drivers/usb/class/
obj-$(CPTCFG_USB_USBNET) += drivers/net/usb/
+obj-$(CPTCFG_SERIAL_DEV_BUS) += drivers/tty/serdev/
+
obj-$(CPTCFG_STAGING) += drivers/staging/
diff --git a/backport/backport-include/linux/kref.h b/backport/backport-include/linux/kref.h
new file mode 100644
index 00000000..631488f5
--- /dev/null
+++ b/backport/backport-include/linux/kref.h
@@ -0,0 +1,13 @@
+#ifndef __BACKPORT_LINUX_KREF_H
+#define __BACKPORT_LINUX_KREF_H
+#include_next <linux/kref.h>
+
+#if LINUX_VERSION_IS_LESS(4,11,0)
+#include <linux/refcount.h>
+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/backport-include/linux/of_device.h b/backport/backport-include/linux/of_device.h
index cdd366e3..2178a338 100644
--- a/backport/backport-include/linux/of_device.h
+++ b/backport/backport-include/linux/of_device.h
@@ -23,4 +23,9 @@ static inline int backport_of_dma_configure(struct device *dev,
#define of_dma_configure LINUX_BACKPORT(of_dma_configure)
#endif /* < 4.18 */
+#if LINUX_VERSION_IS_LESS(4,12,0)
+ssize_t bp_of_device_modalias(struct device *dev, char *str, ssize_t len);
+#define of_device_modalias bp_of_device_modalias
+#endif /* < 4.12 */
+
#endif /* __BP_OF_DEVICE_H */
diff --git a/backport/backport-include/linux/skbuff.h b/backport/backport-include/linux/skbuff.h
index 44b2a5de..7b1fe6ed 100644
--- a/backport/backport-include/linux/skbuff.h
+++ b/backport/backport-include/linux/skbuff.h
@@ -380,6 +380,24 @@ 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
#if LINUX_VERSION_IS_LESS(4,20,0)
diff --git a/backport/compat/Makefile b/backport/compat/Makefile
index 99b52faa..69106de4 100644
--- a/backport/compat/Makefile
+++ b/backport/compat/Makefile
@@ -36,6 +36,7 @@ compat-$(CPTCFG_KERNEL_4_6) += backport-4.6.o
compat-$(CPTCFG_KERNEL_4_7) += backport-4.7.o
compat-$(CPTCFG_KERNEL_4_8) += backport-4.8.o
compat-$(CPTCFG_KERNEL_4_10) += backport-4.10.o
+compat-$(CPTCFG_KERNEL_4_12) += backport-4.12.o
compat-$(CPTCFG_KERNEL_4_18) += backport-4.18.o
compat-$(CPTCFG_KERNEL_4_20) += backport-4.20.o
diff --git a/backport/compat/backport-4.12.c b/backport/compat/backport-4.12.c
new file mode 100644
index 00000000..413ae7f1
--- /dev/null
+++ b/backport/compat/backport-4.12.c
@@ -0,0 +1,22 @@
+#ifdef CONFIG_OF
+#include <linux/of_device.h>
+#endif
+
+#ifdef CONFIG_OF
+/**
+ * of_device_modalias - Fill buffer with newline terminated modalias string
+ */
+ssize_t bp_of_device_modalias(struct device *dev, char *str, ssize_t len)
+{
+ ssize_t sl = of_device_get_modalias(dev, str, len - 2);
+ if (sl < 0)
+ return sl;
+ if (sl > len - 2)
+ return -ENOMEM;
+
+ str[sl++] = '\n';
+ str[sl] = 0;
+ return sl;
+}
+EXPORT_SYMBOL_GPL(bp_of_device_modalias);
+#endif
diff --git a/copy-list b/copy-list
index 1ad03985..815cc110 100644
--- a/copy-list
+++ b/copy-list
@@ -132,3 +132,14 @@ drivers/net/usb/cdc_mbim.c
drivers/net/usb/cdc_ncm.c
drivers/net/usb/sierra_net.c
drivers/net/usb/qmi_wwan.c
+
+
+#Bluetooth
+net/bluetooth/
+drivers/bluetooth/
+include/net/bluetooth/
+
+#Serdev
+drivers/tty/serdev/
+include/linux/serdev.h
+
diff --git a/patches/0020-tty-termios/net_bluetooth_hci_ldisc.patch b/patches/0020-tty-termios/net_bluetooth_hci_ldisc.patch
index 81371523..9292f330 100644
--- a/patches/0020-tty-termios/net_bluetooth_hci_ldisc.patch
+++ b/patches/0020-tty-termios/net_bluetooth_hci_ldisc.patch
@@ -32,18 +32,6 @@
ktermios.c_cflag |= CRTSCTS;
status = tty_set_termios(tty, &ktermios);
BT_DBG("Enabling hardware flow control: %s",
-@@ -324,7 +333,11 @@ void hci_uart_init_tty(struct hci_uart *
- struct ktermios ktermios;
-
- /* Bring the UART into a known 8 bits no parity hw fc state */
-+#if LINUX_VERSION_IS_GEQ(3,7,0)
- ktermios = tty->termios;
-+#else
-+ ktermios = *tty->termios;
-+#endif
- ktermios.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP |
- INLCR | IGNCR | ICRNL | IXON);
- ktermios.c_oflag &= ~OPOST;
@@ -342,7 +355,11 @@ void hci_uart_set_baudrate(struct hci_ua
struct tty_struct *tty = hu->tty;
struct ktermios ktermios;
diff --git a/patches/0030-qdisc_tx_busylock/bluetooth.patch b/patches/0030-qdisc_tx_busylock/bluetooth.patch
deleted file mode 100644
index 1025f03b..00000000
--- a/patches/0030-qdisc_tx_busylock/bluetooth.patch
+++ /dev/null
@@ -1,22 +0,0 @@
---- a/net/bluetooth/6lowpan.c
-+++ b/net/bluetooth/6lowpan.c
-@@ -628,7 +628,9 @@ static netdev_tx_t bt_xmit(struct sk_buf
- return err < 0 ? NET_XMIT_DROP : err;
- }
-
-+#if LINUX_VERSION_IS_GEQ(3,7,0)
- static struct lock_class_key bt_tx_busylock;
-+#endif
- static struct lock_class_key bt_netdev_xmit_lock_key;
-
- static void bt_set_lockdep_class_one(struct net_device *dev,
-@@ -641,7 +643,9 @@ static void bt_set_lockdep_class_one(str
- static int bt_dev_init(struct net_device *dev)
- {
- netdev_for_each_tx_queue(dev, bt_set_lockdep_class_one, NULL);
-+#if LINUX_VERSION_IS_GEQ(3,7,0)
- dev->qdisc_tx_busylock = &bt_tx_busylock;
-+#endif
-
- return 0;
- }
diff --git a/patches/0047-write_iter/bluetooth.patch b/patches/0047-write_iter/bluetooth.patch
index 093b526c..5d4ee94c 100644
--- a/patches/0047-write_iter/bluetooth.patch
+++ b/patches/0047-write_iter/bluetooth.patch
@@ -31,7 +31,7 @@
return -ENOMEM;
+#if LINUX_VERSION_IS_GEQ(3,18,0)
- if (copy_from_iter(skb_put(skb, len), len, from) != len) {
+ if (!copy_from_iter_full(skb_put(skb, len), len, from)) {
kfree_skb(skb);
return -EFAULT;
}
diff --git a/patches/0050-iov_iter/bluetooth.patch b/patches/0050-iov_iter/bluetooth.patch
index 87506ff1..453723a0 100644
--- a/patches/0050-iov_iter/bluetooth.patch
+++ b/patches/0050-iov_iter/bluetooth.patch
@@ -110,7 +110,7 @@
int sent = 0;
+#if LINUX_VERSION_IS_GEQ(3,19,0)
- if (copy_from_iter(skb_put(skb, count), count, &msg->msg_iter) != count)
+ if (!copy_from_iter_full(skb_put(skb, count), count, &msg->msg_iter))
+#else
+ if (chan->ops->memcpy_fromiovec(chan, skb_put(skb, count),
+ msg->msg_iov, count))
@@ -123,8 +123,8 @@
*frag = tmp;
+#if LINUX_VERSION_IS_GEQ(3,19,0)
- if (copy_from_iter(skb_put(*frag, count), count,
- &msg->msg_iter) != count)
+ if (!copy_from_iter_full(skb_put(*frag, count), count,
+ &msg->msg_iter))
+#else
+ if (chan->ops->memcpy_fromiovec(chan, skb_put(*frag, count),
+ msg->msg_iov, count))
diff --git a/patches/0062-acpi-gpio-remove/hci_bcm.patch b/patches/0062-acpi-gpio-remove/hci_bcm.patch
index 77e343ee..92f2245e 100644
--- a/patches/0062-acpi-gpio-remove/hci_bcm.patch
+++ b/patches/0062-acpi-gpio-remove/hci_bcm.patch
@@ -10,53 +10,6 @@
#include <linux/tty.h>
#include <linux/interrupt.h>
#include <linux/dmi.h>
-@@ -148,8 +150,10 @@ static int bcm_gpio_set_power(struct bcm
- if (powered && !IS_ERR(dev->clk) && !dev->clk_enabled)
- clk_enable(dev->clk);
-
-+#if LINUX_VERSION_IS_GEQ(3,13,0)
- gpiod_set_value(dev->shutdown, powered);
- gpiod_set_value(dev->device_wakeup, powered);
-+#endif
-
- if (!powered && !IS_ERR(dev->clk) && dev->clk_enabled)
- clk_disable(dev->clk);
-@@ -520,7 +524,9 @@ static int bcm_suspend_device(struct dev
-
- /* Suspend the device */
- if (bdev->device_wakeup) {
-+#if LINUX_VERSION_IS_GEQ(3,13,0)
- gpiod_set_value(bdev->device_wakeup, false);
-+#endif
- bt_dev_dbg(bdev, "suspend, delaying 15 ms");
- mdelay(15);
- }
-@@ -535,7 +541,9 @@ static int bcm_resume_device(struct devi
- bt_dev_dbg(bdev, "");
-
- if (bdev->device_wakeup) {
-+#if LINUX_VERSION_IS_GEQ(3,13,0)
- gpiod_set_value(bdev->device_wakeup, true);
-+#endif
- bt_dev_dbg(bdev, "resume, delaying 15 ms");
- mdelay(15);
- }
-@@ -618,6 +626,7 @@ unlock:
- }
- #endif
-
-+#if defined(CONFIG_ACPI) && LINUX_VERSION_IS_GEQ(3,19,0)
- static const struct acpi_gpio_params device_wakeup_gpios = { 0, 0, false };
- static const struct acpi_gpio_params shutdown_gpios = { 1, 0, false };
- static const struct acpi_gpio_params host_wakeup_gpios = { 2, 0, false };
-@@ -629,7 +638,6 @@ static const struct acpi_gpio_mapping ac
- { },
- };
-
--#ifdef CONFIG_ACPI
- static u8 acpi_active_low = ACPI_ACTIVE_LOW;
-
- /* IRQ polarity of some chipsets are not defined correctly in ACPI table. */
@@ -812,7 +820,7 @@ static const struct hci_uart_proto bcm_p
.dequeue = bcm_dequeue,
};
diff --git a/patches/0062-acpi-gpio-remove/hci_intel.patch b/patches/0062-acpi-gpio-remove/hci_intel.patch
index 9237ce97..32dfa6de 100644
--- a/patches/0062-acpi-gpio-remove/hci_intel.patch
+++ b/patches/0062-acpi-gpio-remove/hci_intel.patch
@@ -20,13 +20,12 @@
/* Provide to idev a hu reference which is used to run LPM
* transactions (lpm suspend/resume) from PM callbacks.
-@@ -1306,14 +1310,17 @@ static int intel_probe(struct platform_d
-
- idev->pdev = pdev;
+@@ -1306,13 +1310,16 @@ static int intel_probe(struct platform_d
+ if (ret)
+ dev_dbg(&pdev->dev, "Unable to add GPIO mapping table\n");
+#if LINUX_VERSION_IS_GEQ(3,17,0)
- idev->reset = devm_gpiod_get_optional(&pdev->dev, "reset",
- GPIOD_OUT_LOW);
+ idev->reset = devm_gpiod_get(&pdev->dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(idev->reset)) {
dev_err(&pdev->dev, "Unable to retrieve gpio\n");
return PTR_ERR(idev->reset);
diff --git a/patches/0089-serdev-h-config.patch b/patches/0089-serdev-h-config.patch
new file mode 100644
index 00000000..cd98ff06
--- /dev/null
+++ b/patches/0089-serdev-h-config.patch
@@ -0,0 +1,22 @@
+diff --git a/include/linux/serdev.h b/include/linux/serdev.h
+index f153b2c7f0cd..95ec24902864 100644
+--- a/include/linux/serdev.h
++++ b/include/linux/serdev.h
+@@ -198,7 +198,7 @@ static inline int serdev_controller_receive_buf(struct serdev_controller *ctrl,
+ return serdev->ops->receive_buf(serdev, data, count);
+ }
+
+-#if IS_ENABLED(CONFIG_SERIAL_DEV_BUS)
++#if IS_ENABLED(CPTCFG_SERIAL_DEV_BUS)
+
+ int serdev_device_open(struct serdev_device *);
+ void serdev_device_close(struct serdev_device *);
+@@ -317,7 +317,7 @@ int serdev_device_set_parity(struct serdev_device *serdev,
+ struct tty_port;
+ struct tty_driver;
+
+-#ifdef CONFIG_SERIAL_DEV_CTRL_TTYPORT
++#ifdef CPTCFG_SERIAL_DEV_CTRL_TTYPORT
+ struct device *serdev_tty_port_register(struct tty_port *port,
+ struct device *parent,
+ struct tty_driver *drv, int idx);
diff --git a/patches/0090-bluetooth-compilation.patch b/patches/0090-bluetooth-compilation.patch
new file mode 100644
index 00000000..7ec8d35d
--- /dev/null
+++ b/patches/0090-bluetooth-compilation.patch
@@ -0,0 +1,324 @@
+From b72939f55d0615b43720568c47ce34bd372624f8 Mon Sep 17 00:00:00 2001
+From: Dominik Sliwa <dominik.sliwa@toradex.com>
+Date: Thu, 21 Feb 2019 14:06:40 +0100
+Subject: [PATCH] bluetooth: bluetooth compilation
+
+---
+ net/bluetooth/a2mp.c | 4 ++--
+ net/bluetooth/af_bluetooth.c | 37 ++++++++++++++++++++++++++++++++++++-
+ net/bluetooth/hci_sock.c | 9 +++++++++
+ net/bluetooth/l2cap_core.c | 9 +++++++--
+ net/bluetooth/l2cap_sock.c | 16 ++++++++++++++++
+ net/bluetooth/rfcomm/core.c | 2 +-
+ net/bluetooth/rfcomm/sock.c | 19 ++++++++++++++++++-
+ net/bluetooth/sco.c | 15 +++++++++++++++
+ 8 files changed, 104 insertions(+), 7 deletions(-)
+
+diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c
+index 6554607..3e48459 100644
+--- a/net/bluetooth/a2mp.c
++++ b/net/bluetooth/a2mp.c
+@@ -244,7 +244,7 @@ static int a2mp_discover_rsp(struct amp_mgr *mgr, struct sk_buff *skb,
+ }
+
+ len -= sizeof(*cl);
+- cl = skb_pull(skb, sizeof(*cl));
++ cl = (void *)skb_pull(skb, sizeof(*cl));
+ }
+
+ /* Fall back to L2CAP init sequence */
+@@ -284,7 +284,7 @@ static int a2mp_change_notify(struct amp_mgr *mgr, struct sk_buff *skb,
+ while (skb->len >= sizeof(*cl)) {
+ BT_DBG("Controller id %d type %d status %d", cl->id, cl->type,
+ cl->status);
+- cl = skb_pull(skb, sizeof(*cl));
++ cl = (void *)skb_pull(skb, sizeof(*cl));
+ }
+
+ /* TODO send A2MP_CHANGE_RSP */
+diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
+index deacc52..a8269f8 100644
+--- a/net/bluetooth/af_bluetooth.c
++++ b/net/bluetooth/af_bluetooth.c
+@@ -649,7 +649,11 @@ static int bt_seq_show(struct seq_file *seq, void *v)
+ seq_printf(seq,
+ "%pK %-6d %-6u %-6u %-6u %-6lu %-6lu",
+ sk,
++#if LINUX_VERSION_IS_GEQ(4,13,0)
+ refcount_read(&sk->sk_refcnt),
++#else
++ atomic_read(&sk->sk_refcnt),
++#endif
+ sk_rmem_alloc_get(sk),
+ sk_wmem_alloc_get(sk),
+ from_kuid(seq_user_ns(seq), sock_i_uid(sk)),
+@@ -673,14 +677,45 @@ static const struct seq_operations bt_seq_ops = {
+ .show = bt_seq_show,
+ };
+
++#if LINUX_VERSION_IS_LESS(4,18,0)
++struct bt_seq_state {
++ struct bt_sock_list *l;
++};
++static int bt_seq_open(struct inode *inode, struct file *file)
++{
++ struct bt_sock_list *sk_list;
++ struct bt_seq_state *s;
++
++ sk_list = PDE_DATA(inode);
++ s = __seq_open_private(file, &bt_seq_ops,
++ sizeof(struct bt_seq_state));
++ if (!s)
++ return -ENOMEM;
++
++ s->l = sk_list;
++ return 0;
++}
++
++static const struct file_operations bt_fops = {
++ .open = bt_seq_open,
++ .read = seq_read,
++ .llseek = seq_lseek,
++ .release = seq_release_private
++};
++#endif
++
+ int bt_procfs_init(struct net *net, const char *name,
+ struct bt_sock_list *sk_list,
+ int (* seq_show)(struct seq_file *, void *))
+ {
+ sk_list->custom_seq_show = seq_show;
+-
++#if LINUX_VERSION_IS_GEQ(4,18,0)
+ if (!proc_create_seq_data(name, 0, net->proc_net, &bt_seq_ops, sk_list))
+ return -ENOMEM;
++#else
++ if (!proc_create_data(name, 0, net->proc_net, &bt_fops, sk_list))
++ return -ENOMEM;
++#endif
+ return 0;
+ }
+
+diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
+index 3d3b23d..542fb36 100644
+--- a/net/bluetooth/hci_sock.c
++++ b/net/bluetooth/hci_sock.c
+@@ -1339,8 +1339,13 @@ done:
+ return err;
+ }
+
++#if LINUX_VERSION_IS_LESS(4,17,0)
++static int hci_sock_getname(struct socket *sock, struct sockaddr *addr,
++ int *sockaddr_len, int peer)
++#else
+ static int hci_sock_getname(struct socket *sock, struct sockaddr *addr,
+ int peer)
++#endif
+ {
+ struct sockaddr_hci *haddr = (struct sockaddr_hci *)addr;
+ struct sock *sk = sock->sk;
+@@ -1363,7 +1368,11 @@ static int hci_sock_getname(struct socket *sock, struct sockaddr *addr,
+ haddr->hci_family = AF_BLUETOOTH;
+ haddr->hci_dev = hdev->id;
+ haddr->hci_channel= hci_pi(sk)->channel;
++#if LINUX_VERSION_IS_LESS(4,17,0)
++ *sockaddr_len = sizeof(*haddr);
++#else
+ err = sizeof(*haddr);
++#endif
+
+ done:
+ release_sock(sk);
+diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
+index 3bbc440..61cb929 100644
+--- a/net/bluetooth/l2cap_core.c
++++ b/net/bluetooth/l2cap_core.c
+@@ -2127,8 +2127,10 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan,
+ struct sk_buff **frag;
+ int sent = 0;
+
+-#if LINUX_VERSION_IS_GEQ(3,19,0)
++#if LINUX_VERSION_IS_GEQ(4,10,0)
+ if (!copy_from_iter_full(skb_put(skb, count), count, &msg->msg_iter))
++#elif LINUX_VERSION_IS_GEQ(3,19,0)
++ if (copy_from_iter(skb_put(skb, count), count, &msg->msg_iter) != count)
+ #else
+ if (chan->ops->memcpy_fromiovec(chan, skb_put(skb, count),
+ msg->msg_iov, count))
+@@ -2152,9 +2154,12 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan,
+
+ *frag = tmp;
+
+-#if LINUX_VERSION_IS_GEQ(3,19,0)
++#if LINUX_VERSION_IS_GEQ(4,10,0)
+ if (!copy_from_iter_full(skb_put(*frag, count), count,
+ &msg->msg_iter))
++#elif LINUX_VERSION_IS_GEQ(3,19,0)
++ if (copy_from_iter(skb_put(*frag, count), count,
++ &msg->msg_iter) != count)
+ #else
+ if (chan->ops->memcpy_fromiovec(chan, skb_put(*frag, count),
+ msg->msg_iov, count))
+diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
+index 406638d..04c3e00 100644
+--- a/net/bluetooth/l2cap_sock.c
++++ b/net/bluetooth/l2cap_sock.c
+@@ -301,8 +301,13 @@ done:
+ return err;
+ }
+
++#if LINUX_VERSION_IS_LESS(4,12,0)
++static int l2cap_sock_accept(struct socket *sock, struct socket *newsock,
++ int flags)
++#else
+ static int l2cap_sock_accept(struct socket *sock, struct socket *newsock,
+ int flags, bool kern)
++#endif
+ {
+ DEFINE_WAIT_FUNC(wait, woken_wake_function);
+ struct sock *sk = sock->sk, *nsk;
+@@ -357,8 +362,14 @@ done:
+ return err;
+ }
+
++
++#if LINUX_VERSION_IS_LESS(4,17,0)
++static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr,
++ int *len, int peer)
++#else
+ static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr,
+ int peer)
++#endif
+ {
+ struct sockaddr_l2 *la = (struct sockaddr_l2 *) addr;
+ struct sock *sk = sock->sk;
+@@ -386,7 +397,12 @@ static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr,
+ la->l2_bdaddr_type = chan->src_type;
+ }
+
++#if LINUX_VERSION_IS_LESS(4,17,0)
++ *len = sizeof(struct sockaddr_l2);
++ return 0;
++#else
+ return sizeof(struct sockaddr_l2);
++#endif
+ }
+
+ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname,
+diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
+index 2289d6c..8e7a632 100644
+--- a/net/bluetooth/rfcomm/core.c
++++ b/net/bluetooth/rfcomm/core.c
+@@ -872,7 +872,7 @@ static int rfcomm_queue_disc(struct rfcomm_dlc *d)
+ if (!skb)
+ return -ENOMEM;
+
+- cmd = __skb_put(skb, sizeof(*cmd));
++ cmd = (void *)__skb_put(skb, sizeof(*cmd));
+ cmd->addr = d->addr;
+ cmd->ctrl = __ctrl(RFCOMM_DISC, 1);
+ cmd->len = __len8(0);
+diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
+index 90e1c3b..604cf98 100644
+--- a/net/bluetooth/rfcomm/sock.c
++++ b/net/bluetooth/rfcomm/sock.c
+@@ -204,8 +204,11 @@ static void rfcomm_sock_kill(struct sock *sk)
+ {
+ if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket)
+ return;
+-
++#if LINUX_VERSION_IS_GEQ(4,13,0)
+ BT_DBG("sk %p state %d refcnt %d", sk, sk->sk_state, refcount_read(&sk->sk_refcnt));
++#else
++ BT_DBG("sk %p state %d refcnt %d", sk, sk->sk_state, atomic_read(&sk->sk_refcnt));
++#endif
+
+ /* Kill poor orphan */
+ bt_sock_unlink(&rfcomm_sk_list, sk);
+@@ -481,8 +484,12 @@ done:
+ return err;
+ }
+
++#if LINUX_VERSION_IS_LESS(4,12,0)
++static int rfcomm_sock_accept(struct socket *sock, struct socket *newsock, int flags)
++#else
+ static int rfcomm_sock_accept(struct socket *sock, struct socket *newsock, int flags,
+ bool kern)
++#endif
+ {
+ DEFINE_WAIT_FUNC(wait, woken_wake_function);
+ struct sock *sk = sock->sk, *nsk;
+@@ -542,7 +549,12 @@ done:
+ return err;
+ }
+
++#if LINUX_VERSION_IS_LESS(4,17,0)
++static int rfcomm_sock_getname(struct socket *sock, struct sockaddr *addr,
++ int *len, int peer)
++#else
+ static int rfcomm_sock_getname(struct socket *sock, struct sockaddr *addr, int peer)
++#endif
+ {
+ struct sockaddr_rc *sa = (struct sockaddr_rc *) addr;
+ struct sock *sk = sock->sk;
+@@ -561,7 +573,12 @@ static int rfcomm_sock_getname(struct socket *sock, struct sockaddr *addr, int p
+ else
+ bacpy(&sa->rc_bdaddr, &rfcomm_pi(sk)->src);
+
++#if LINUX_VERSION_IS_LESS(4,17,0)
++ *len = sizeof(struct sockaddr_rc);
++ return 0;
++#else
+ return sizeof(struct sockaddr_rc);
++#endif
+ }
+
+ static int rfcomm_sock_sendmsg(struct socket *sock, struct msghdr *msg,
+diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
+index c719f08..aafe828 100644
+--- a/net/bluetooth/sco.c
++++ b/net/bluetooth/sco.c
+@@ -625,8 +625,13 @@ done:
+ return err;
+ }
+
++#if LINUX_VERSION_IS_LESS(4,12,0)
++static int sco_sock_accept(struct socket *sock, struct socket *newsock,
++ int flags)
++#else
+ static int sco_sock_accept(struct socket *sock, struct socket *newsock,
+ int flags, bool kern)
++#endif
+ {
+ DEFINE_WAIT_FUNC(wait, woken_wake_function);
+ struct sock *sk = sock->sk, *ch;
+@@ -680,8 +685,13 @@ done:
+ return err;
+ }
+
++#if LINUX_VERSION_IS_LESS(4,17,0)
++static int sco_sock_getname(struct socket *sock, struct sockaddr *addr,
++ int *len, int peer)
++#else
+ static int sco_sock_getname(struct socket *sock, struct sockaddr *addr,
+ int peer)
++#endif
+ {
+ struct sockaddr_sco *sa = (struct sockaddr_sco *) addr;
+ struct sock *sk = sock->sk;
+@@ -695,7 +705,12 @@ static int sco_sock_getname(struct socket *sock, struct sockaddr *addr,
+ else
+ bacpy(&sa->sco_bdaddr, &sco_pi(sk)->src);
+
++#if LINUX_VERSION_IS_LESS(4,17,0)
++ *len = sizeof(struct sockaddr_sco);
++ return 0;
++#else
+ return sizeof(struct sockaddr_sco);
++#endif
+ }
+
+ static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg,
+--
+2.13.6
+