Commit 89eb6e09 authored by David S. Miller's avatar David S. Miller

Merge branch 'for-upstream' of...

Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next

Johan Hedberg says:

====================
pull request: bluetooth-next 2019-04-25

Here's the main bluetooth-next pull request for the 5.2 kernel.

 - Added support for Mediatek SDIO controllers
 - Added support for Broadcom BCM2076B1 UART controller
 - Added support for Marvel SD8987 chipset
 - Fix buffer overflow bug in hidp protocol
 - Various other smaller fixes & improvements

Please let me know if there are any issues pulling. Thanks.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 8b448365 d5bb334a
...@@ -336,7 +336,7 @@ config BT_MRVL ...@@ -336,7 +336,7 @@ config BT_MRVL
The core driver to support Marvell Bluetooth devices. The core driver to support Marvell Bluetooth devices.
This driver is required if you want to support This driver is required if you want to support
Marvell Bluetooth devices, such as 8688/8787/8797/8887/8897/8977/8997. Marvell Bluetooth devices, such as 8688/8787/8797/8887/8897/8977/8987/8997.
Say Y here to compile Marvell Bluetooth driver Say Y here to compile Marvell Bluetooth driver
into the kernel or say M to compile it as module. into the kernel or say M to compile it as module.
...@@ -350,7 +350,7 @@ config BT_MRVL_SDIO ...@@ -350,7 +350,7 @@ config BT_MRVL_SDIO
The driver for Marvell Bluetooth chipsets with SDIO interface. The driver for Marvell Bluetooth chipsets with SDIO interface.
This driver is required if you want to use Marvell Bluetooth This driver is required if you want to use Marvell Bluetooth
devices with SDIO interface. Currently SD8688/SD8787/SD8797/SD8887/SD8897/SD8977/SD8997 devices with SDIO interface. Currently SD8688/SD8787/SD8797/SD8887/SD8897/SD8977/SD8987/SD8997
chipsets are supported. chipsets are supported.
Say Y here to compile support for Marvell BT-over-SDIO driver Say Y here to compile support for Marvell BT-over-SDIO driver
...@@ -379,6 +379,17 @@ config BT_WILINK ...@@ -379,6 +379,17 @@ config BT_WILINK
Say Y here to compile support for Texas Instrument's WiLink7 driver Say Y here to compile support for Texas Instrument's WiLink7 driver
into the kernel or say M to compile it as module (btwilink). into the kernel or say M to compile it as module (btwilink).
config BT_MTKSDIO
tristate "MediaTek HCI SDIO driver"
depends on MMC
help
MediaTek Bluetooth HCI SDIO driver.
This driver is required if you want to use MediaTek Bluetooth
with SDIO interface.
Say Y here to compile support for MediaTek Bluetooth SDIO devices
into the kernel or say M to compile it as module (btmtksdio).
config BT_MTKUART config BT_MTKUART
tristate "MediaTek HCI UART driver" tristate "MediaTek HCI UART driver"
depends on SERIAL_DEV_BUS depends on SERIAL_DEV_BUS
......
...@@ -20,6 +20,7 @@ obj-$(CONFIG_BT_ATH3K) += ath3k.o ...@@ -20,6 +20,7 @@ obj-$(CONFIG_BT_ATH3K) += ath3k.o
obj-$(CONFIG_BT_MRVL) += btmrvl.o obj-$(CONFIG_BT_MRVL) += btmrvl.o
obj-$(CONFIG_BT_MRVL_SDIO) += btmrvl_sdio.o obj-$(CONFIG_BT_MRVL_SDIO) += btmrvl_sdio.o
obj-$(CONFIG_BT_WILINK) += btwilink.o obj-$(CONFIG_BT_WILINK) += btwilink.o
obj-$(CONFIG_BT_MTKSDIO) += btmtksdio.o
obj-$(CONFIG_BT_MTKUART) += btmtkuart.o obj-$(CONFIG_BT_MTKUART) += btmtkuart.o
obj-$(CONFIG_BT_QCOMSMD) += btqcomsmd.o obj-$(CONFIG_BT_QCOMSMD) += btqcomsmd.o
obj-$(CONFIG_BT_BCM) += btbcm.o obj-$(CONFIG_BT_BCM) += btbcm.o
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#define BDADDR_BCM43430A0 (&(bdaddr_t) {{0xac, 0x1f, 0x12, 0xa0, 0x43, 0x43}}) #define BDADDR_BCM43430A0 (&(bdaddr_t) {{0xac, 0x1f, 0x12, 0xa0, 0x43, 0x43}})
#define BDADDR_BCM4324B3 (&(bdaddr_t) {{0x00, 0x00, 0x00, 0xb3, 0x24, 0x43}}) #define BDADDR_BCM4324B3 (&(bdaddr_t) {{0x00, 0x00, 0x00, 0xb3, 0x24, 0x43}})
#define BDADDR_BCM4330B1 (&(bdaddr_t) {{0x00, 0x00, 0x00, 0xb1, 0x30, 0x43}}) #define BDADDR_BCM4330B1 (&(bdaddr_t) {{0x00, 0x00, 0x00, 0xb1, 0x30, 0x43}})
#define BDADDR_BCM43341B (&(bdaddr_t) {{0xac, 0x1f, 0x00, 0x1b, 0x34, 0x43}})
int btbcm_check_bdaddr(struct hci_dev *hdev) int btbcm_check_bdaddr(struct hci_dev *hdev)
{ {
...@@ -82,7 +83,8 @@ int btbcm_check_bdaddr(struct hci_dev *hdev) ...@@ -82,7 +83,8 @@ int btbcm_check_bdaddr(struct hci_dev *hdev)
!bacmp(&bda->bdaddr, BDADDR_BCM20702A1) || !bacmp(&bda->bdaddr, BDADDR_BCM20702A1) ||
!bacmp(&bda->bdaddr, BDADDR_BCM4324B3) || !bacmp(&bda->bdaddr, BDADDR_BCM4324B3) ||
!bacmp(&bda->bdaddr, BDADDR_BCM4330B1) || !bacmp(&bda->bdaddr, BDADDR_BCM4330B1) ||
!bacmp(&bda->bdaddr, BDADDR_BCM43430A0)) { !bacmp(&bda->bdaddr, BDADDR_BCM43430A0) ||
!bacmp(&bda->bdaddr, BDADDR_BCM43341B)) {
bt_dev_info(hdev, "BCM: Using default device address (%pMR)", bt_dev_info(hdev, "BCM: Using default device address (%pMR)",
&bda->bdaddr); &bda->bdaddr);
set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks); set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
...@@ -333,6 +335,7 @@ struct bcm_subver_table { ...@@ -333,6 +335,7 @@ struct bcm_subver_table {
static const struct bcm_subver_table bcm_uart_subver_table[] = { static const struct bcm_subver_table bcm_uart_subver_table[] = {
{ 0x4103, "BCM4330B1" }, /* 002.001.003 */ { 0x4103, "BCM4330B1" }, /* 002.001.003 */
{ 0x410e, "BCM43341B0" }, /* 002.001.014 */ { 0x410e, "BCM43341B0" }, /* 002.001.014 */
{ 0x4204, "BCM2076B1" }, /* 002.002.004 */
{ 0x4406, "BCM4324B3" }, /* 002.004.006 */ { 0x4406, "BCM4324B3" }, /* 002.004.006 */
{ 0x6109, "BCM4335C0" }, /* 003.001.009 */ { 0x6109, "BCM4335C0" }, /* 003.001.009 */
{ 0x610c, "BCM4354" }, /* 003.001.012 */ { 0x610c, "BCM4354" }, /* 003.001.012 */
......
...@@ -235,6 +235,29 @@ static const struct btmrvl_sdio_card_reg btmrvl_reg_8977 = { ...@@ -235,6 +235,29 @@ static const struct btmrvl_sdio_card_reg btmrvl_reg_8977 = {
.fw_dump_end = 0xf8, .fw_dump_end = 0xf8,
}; };
static const struct btmrvl_sdio_card_reg btmrvl_reg_8987 = {
.cfg = 0x00,
.host_int_mask = 0x08,
.host_intstatus = 0x0c,
.card_status = 0x5c,
.sq_read_base_addr_a0 = 0xf8,
.sq_read_base_addr_a1 = 0xf9,
.card_revision = 0xc8,
.card_fw_status0 = 0xe8,
.card_fw_status1 = 0xe9,
.card_rx_len = 0xea,
.card_rx_unit = 0xeb,
.io_port_0 = 0xe4,
.io_port_1 = 0xe5,
.io_port_2 = 0xe6,
.int_read_to_clear = true,
.host_int_rsr = 0x04,
.card_misc_cfg = 0xd8,
.fw_dump_ctrl = 0xf0,
.fw_dump_start = 0xf1,
.fw_dump_end = 0xf8,
};
static const struct btmrvl_sdio_card_reg btmrvl_reg_8997 = { static const struct btmrvl_sdio_card_reg btmrvl_reg_8997 = {
.cfg = 0x00, .cfg = 0x00,
.host_int_mask = 0x08, .host_int_mask = 0x08,
...@@ -312,6 +335,15 @@ static const struct btmrvl_sdio_device btmrvl_sdio_sd8977 = { ...@@ -312,6 +335,15 @@ static const struct btmrvl_sdio_device btmrvl_sdio_sd8977 = {
.supports_fw_dump = true, .supports_fw_dump = true,
}; };
static const struct btmrvl_sdio_device btmrvl_sdio_sd8987 = {
.helper = NULL,
.firmware = "mrvl/sd8987_uapsta.bin",
.reg = &btmrvl_reg_8987,
.support_pscan_win_report = true,
.sd_blksz_fw_dl = 256,
.supports_fw_dump = true,
};
static const struct btmrvl_sdio_device btmrvl_sdio_sd8997 = { static const struct btmrvl_sdio_device btmrvl_sdio_sd8997 = {
.helper = NULL, .helper = NULL,
.firmware = "mrvl/sd8997_uapsta.bin", .firmware = "mrvl/sd8997_uapsta.bin",
...@@ -343,6 +375,9 @@ static const struct sdio_device_id btmrvl_sdio_ids[] = { ...@@ -343,6 +375,9 @@ static const struct sdio_device_id btmrvl_sdio_ids[] = {
/* Marvell SD8977 Bluetooth device */ /* Marvell SD8977 Bluetooth device */
{ SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x9146), { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x9146),
.driver_data = (unsigned long)&btmrvl_sdio_sd8977 }, .driver_data = (unsigned long)&btmrvl_sdio_sd8977 },
/* Marvell SD8987 Bluetooth device */
{ SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x914A),
.driver_data = (unsigned long)&btmrvl_sdio_sd8987 },
/* Marvell SD8997 Bluetooth device */ /* Marvell SD8997 Bluetooth device */
{ SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x9142), { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x9142),
.driver_data = (unsigned long)&btmrvl_sdio_sd8997 }, .driver_data = (unsigned long)&btmrvl_sdio_sd8997 },
...@@ -1797,4 +1832,5 @@ MODULE_FIRMWARE("mrvl/sd8797_uapsta.bin"); ...@@ -1797,4 +1832,5 @@ MODULE_FIRMWARE("mrvl/sd8797_uapsta.bin");
MODULE_FIRMWARE("mrvl/sd8887_uapsta.bin"); MODULE_FIRMWARE("mrvl/sd8887_uapsta.bin");
MODULE_FIRMWARE("mrvl/sd8897_uapsta.bin"); MODULE_FIRMWARE("mrvl/sd8897_uapsta.bin");
MODULE_FIRMWARE("mrvl/sd8977_uapsta.bin"); MODULE_FIRMWARE("mrvl/sd8977_uapsta.bin");
MODULE_FIRMWARE("mrvl/sd8987_uapsta.bin");
MODULE_FIRMWARE("mrvl/sd8997_uapsta.bin"); MODULE_FIRMWARE("mrvl/sd8997_uapsta.bin");
This diff is collapsed.
...@@ -661,7 +661,7 @@ static int btmtkuart_change_baudrate(struct hci_dev *hdev) ...@@ -661,7 +661,7 @@ static int btmtkuart_change_baudrate(struct hci_dev *hdev)
{ {
struct btmtkuart_dev *bdev = hci_get_drvdata(hdev); struct btmtkuart_dev *bdev = hci_get_drvdata(hdev);
struct btmtk_hci_wmt_params wmt_params; struct btmtk_hci_wmt_params wmt_params;
u32 baudrate; __le32 baudrate;
u8 param; u8 param;
int err; int err;
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#define QCA_WCN3990_POWERON_PULSE 0xFC #define QCA_WCN3990_POWERON_PULSE 0xFC
#define QCA_WCN3990_POWEROFF_PULSE 0xC0 #define QCA_WCN3990_POWEROFF_PULSE 0xC0
enum qca_bardrate { enum qca_baudrate {
QCA_BAUDRATE_115200 = 0, QCA_BAUDRATE_115200 = 0,
QCA_BAUDRATE_57600, QCA_BAUDRATE_57600,
QCA_BAUDRATE_38400, QCA_BAUDRATE_38400,
......
...@@ -376,20 +376,7 @@ static struct sdio_driver btsdio_driver = { ...@@ -376,20 +376,7 @@ static struct sdio_driver btsdio_driver = {
.id_table = btsdio_table, .id_table = btsdio_table,
}; };
static int __init btsdio_init(void) module_sdio_driver(btsdio_driver);
{
BT_INFO("Generic Bluetooth SDIO driver ver %s", VERSION);
return sdio_register_driver(&btsdio_driver);
}
static void __exit btsdio_exit(void)
{
sdio_unregister_driver(&btsdio_driver);
}
module_init(btsdio_init);
module_exit(btsdio_exit);
MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
MODULE_DESCRIPTION("Generic Bluetooth SDIO driver ver " VERSION); MODULE_DESCRIPTION("Generic Bluetooth SDIO driver ver " VERSION);
......
...@@ -228,9 +228,15 @@ static int bcm_gpio_set_power(struct bcm_device *dev, bool powered) ...@@ -228,9 +228,15 @@ static int bcm_gpio_set_power(struct bcm_device *dev, bool powered)
int err; int err;
if (powered && !dev->res_enabled) { if (powered && !dev->res_enabled) {
err = regulator_bulk_enable(BCM_NUM_SUPPLIES, dev->supplies); /* Intel Macs use bcm_apple_get_resources() and don't
if (err) * have regulator supplies configured.
return err; */
if (dev->supplies[0].supply) {
err = regulator_bulk_enable(BCM_NUM_SUPPLIES,
dev->supplies);
if (err)
return err;
}
/* LPO clock needs to be 32.768 kHz */ /* LPO clock needs to be 32.768 kHz */
err = clk_set_rate(dev->lpo_clk, 32768); err = clk_set_rate(dev->lpo_clk, 32768);
...@@ -259,7 +265,13 @@ static int bcm_gpio_set_power(struct bcm_device *dev, bool powered) ...@@ -259,7 +265,13 @@ static int bcm_gpio_set_power(struct bcm_device *dev, bool powered)
if (!powered && dev->res_enabled) { if (!powered && dev->res_enabled) {
clk_disable_unprepare(dev->txco_clk); clk_disable_unprepare(dev->txco_clk);
clk_disable_unprepare(dev->lpo_clk); clk_disable_unprepare(dev->lpo_clk);
regulator_bulk_disable(BCM_NUM_SUPPLIES, dev->supplies);
/* Intel Macs use bcm_apple_get_resources() and don't
* have regulator supplies configured.
*/
if (dev->supplies[0].supply)
regulator_bulk_disable(BCM_NUM_SUPPLIES,
dev->supplies);
} }
/* wait for device to power on and come out of reset */ /* wait for device to power on and come out of reset */
......
...@@ -536,7 +536,7 @@ static void h5_unslip_one_byte(struct h5 *h5, unsigned char c) ...@@ -536,7 +536,7 @@ static void h5_unslip_one_byte(struct h5 *h5, unsigned char c)
skb_put_data(h5->rx_skb, byte, 1); skb_put_data(h5->rx_skb, byte, 1);
h5->rx_pending--; h5->rx_pending--;
BT_DBG("unsliped 0x%02hhx, rx_pending %zu", *byte, h5->rx_pending); BT_DBG("unslipped 0x%02hhx, rx_pending %zu", *byte, h5->rx_pending);
} }
static void h5_reset_rx(struct h5 *h5) static void h5_reset_rx(struct h5 *h5)
......
...@@ -174,6 +174,21 @@ static int qca_power_setup(struct hci_uart *hu, bool on); ...@@ -174,6 +174,21 @@ static int qca_power_setup(struct hci_uart *hu, bool on);
static void qca_power_shutdown(struct hci_uart *hu); static void qca_power_shutdown(struct hci_uart *hu);
static int qca_power_off(struct hci_dev *hdev); static int qca_power_off(struct hci_dev *hdev);
static enum qca_btsoc_type qca_soc_type(struct hci_uart *hu)
{
enum qca_btsoc_type soc_type;
if (hu->serdev) {
struct qca_serdev *qsd = serdev_device_get_drvdata(hu->serdev);
soc_type = qsd->btsoc_type;
} else {
soc_type = QCA_ROME;
}
return soc_type;
}
static void __serial_clock_on(struct tty_struct *tty) static void __serial_clock_on(struct tty_struct *tty)
{ {
/* TODO: Some chipset requires to enable UART clock on client /* TODO: Some chipset requires to enable UART clock on client
...@@ -508,6 +523,8 @@ static int qca_open(struct hci_uart *hu) ...@@ -508,6 +523,8 @@ static int qca_open(struct hci_uart *hu)
qcadev = serdev_device_get_drvdata(hu->serdev); qcadev = serdev_device_get_drvdata(hu->serdev);
if (qcadev->btsoc_type != QCA_WCN3990) { if (qcadev->btsoc_type != QCA_WCN3990) {
gpiod_set_value_cansleep(qcadev->bt_en, 1); gpiod_set_value_cansleep(qcadev->bt_en, 1);
/* Controller needs time to bootup. */
msleep(150);
} else { } else {
hu->init_speed = qcadev->init_speed; hu->init_speed = qcadev->init_speed;
hu->oper_speed = qcadev->oper_speed; hu->oper_speed = qcadev->oper_speed;
...@@ -963,7 +980,6 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate) ...@@ -963,7 +980,6 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)
{ {
struct hci_uart *hu = hci_get_drvdata(hdev); struct hci_uart *hu = hci_get_drvdata(hdev);
struct qca_data *qca = hu->priv; struct qca_data *qca = hu->priv;
struct qca_serdev *qcadev;
struct sk_buff *skb; struct sk_buff *skb;
u8 cmd[] = { 0x01, 0x48, 0xFC, 0x01, 0x00 }; u8 cmd[] = { 0x01, 0x48, 0xFC, 0x01, 0x00 };
...@@ -985,18 +1001,17 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate) ...@@ -985,18 +1001,17 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)
skb_queue_tail(&qca->txq, skb); skb_queue_tail(&qca->txq, skb);
hci_uart_tx_wakeup(hu); hci_uart_tx_wakeup(hu);
qcadev = serdev_device_get_drvdata(hu->serdev);
/* Wait for the baudrate change request to be sent */ /* Wait for the baudrate change request to be sent */
while (!skb_queue_empty(&qca->txq)) while (!skb_queue_empty(&qca->txq))
usleep_range(100, 200); usleep_range(100, 200);
serdev_device_wait_until_sent(hu->serdev, if (hu->serdev)
serdev_device_wait_until_sent(hu->serdev,
msecs_to_jiffies(CMD_TRANS_TIMEOUT_MS)); msecs_to_jiffies(CMD_TRANS_TIMEOUT_MS));
/* Give the controller time to process the request */ /* Give the controller time to process the request */
if (qcadev->btsoc_type == QCA_WCN3990) if (qca_soc_type(hu) == QCA_WCN3990)
msleep(10); msleep(10);
else else
msleep(300); msleep(300);
...@@ -1072,10 +1087,7 @@ static unsigned int qca_get_speed(struct hci_uart *hu, ...@@ -1072,10 +1087,7 @@ static unsigned int qca_get_speed(struct hci_uart *hu,
static int qca_check_speeds(struct hci_uart *hu) static int qca_check_speeds(struct hci_uart *hu)
{ {
struct qca_serdev *qcadev; if (qca_soc_type(hu) == QCA_WCN3990) {
qcadev = serdev_device_get_drvdata(hu->serdev);
if (qcadev->btsoc_type == QCA_WCN3990) {
if (!qca_get_speed(hu, QCA_INIT_SPEED) && if (!qca_get_speed(hu, QCA_INIT_SPEED) &&
!qca_get_speed(hu, QCA_OPER_SPEED)) !qca_get_speed(hu, QCA_OPER_SPEED))
return -EINVAL; return -EINVAL;
...@@ -1091,7 +1103,6 @@ static int qca_check_speeds(struct hci_uart *hu) ...@@ -1091,7 +1103,6 @@ static int qca_check_speeds(struct hci_uart *hu)
static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type) static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type)
{ {
unsigned int speed, qca_baudrate; unsigned int speed, qca_baudrate;
struct qca_serdev *qcadev;
int ret = 0; int ret = 0;
if (speed_type == QCA_INIT_SPEED) { if (speed_type == QCA_INIT_SPEED) {
...@@ -1099,6 +1110,8 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type) ...@@ -1099,6 +1110,8 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type)
if (speed) if (speed)
host_set_baudrate(hu, speed); host_set_baudrate(hu, speed);
} else { } else {
enum qca_btsoc_type soc_type = qca_soc_type(hu);
speed = qca_get_speed(hu, QCA_OPER_SPEED); speed = qca_get_speed(hu, QCA_OPER_SPEED);
if (!speed) if (!speed)
return 0; return 0;
...@@ -1106,8 +1119,7 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type) ...@@ -1106,8 +1119,7 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type)
/* Disable flow control for wcn3990 to deassert RTS while /* Disable flow control for wcn3990 to deassert RTS while
* changing the baudrate of chip and host. * changing the baudrate of chip and host.
*/ */
qcadev = serdev_device_get_drvdata(hu->serdev); if (soc_type == QCA_WCN3990)
if (qcadev->btsoc_type == QCA_WCN3990)
hci_uart_set_flow_control(hu, true); hci_uart_set_flow_control(hu, true);
qca_baudrate = qca_get_baudrate_value(speed); qca_baudrate = qca_get_baudrate_value(speed);
...@@ -1119,7 +1131,7 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type) ...@@ -1119,7 +1131,7 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type)
host_set_baudrate(hu, speed); host_set_baudrate(hu, speed);
error: error:
if (qcadev->btsoc_type == QCA_WCN3990) if (soc_type == QCA_WCN3990)
hci_uart_set_flow_control(hu, false); hci_uart_set_flow_control(hu, false);
} }
...@@ -1181,12 +1193,10 @@ static int qca_setup(struct hci_uart *hu) ...@@ -1181,12 +1193,10 @@ static int qca_setup(struct hci_uart *hu)
struct hci_dev *hdev = hu->hdev; struct hci_dev *hdev = hu->hdev;
struct qca_data *qca = hu->priv; struct qca_data *qca = hu->priv;
unsigned int speed, qca_baudrate = QCA_BAUDRATE_115200; unsigned int speed, qca_baudrate = QCA_BAUDRATE_115200;
struct qca_serdev *qcadev; enum qca_btsoc_type soc_type = qca_soc_type(hu);
int ret; int ret;
int soc_ver = 0; int soc_ver = 0;
qcadev = serdev_device_get_drvdata(hu->serdev);
ret = qca_check_speeds(hu); ret = qca_check_speeds(hu);
if (ret) if (ret)
return ret; return ret;
...@@ -1194,7 +1204,7 @@ static int qca_setup(struct hci_uart *hu) ...@@ -1194,7 +1204,7 @@ static int qca_setup(struct hci_uart *hu)
/* Patch downloading has to be done without IBS mode */ /* Patch downloading has to be done without IBS mode */
clear_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags); clear_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
if (qcadev->btsoc_type == QCA_WCN3990) { if (soc_type == QCA_WCN3990) {
bt_dev_info(hdev, "setting up wcn3990"); bt_dev_info(hdev, "setting up wcn3990");
/* Enable NON_PERSISTENT_SETUP QUIRK to ensure to execute /* Enable NON_PERSISTENT_SETUP QUIRK to ensure to execute
...@@ -1225,7 +1235,7 @@ static int qca_setup(struct hci_uart *hu) ...@@ -1225,7 +1235,7 @@ static int qca_setup(struct hci_uart *hu)
qca_baudrate = qca_get_baudrate_value(speed); qca_baudrate = qca_get_baudrate_value(speed);
} }
if (qcadev->btsoc_type != QCA_WCN3990) { if (soc_type != QCA_WCN3990) {
/* Get QCA version information */ /* Get QCA version information */
ret = qca_read_soc_version(hdev, &soc_ver); ret = qca_read_soc_version(hdev, &soc_ver);
if (ret) if (ret)
...@@ -1234,7 +1244,7 @@ static int qca_setup(struct hci_uart *hu) ...@@ -1234,7 +1244,7 @@ static int qca_setup(struct hci_uart *hu)
bt_dev_info(hdev, "QCA controller version 0x%08x", soc_ver); bt_dev_info(hdev, "QCA controller version 0x%08x", soc_ver);
/* Setup patch / NVM configurations */ /* Setup patch / NVM configurations */
ret = qca_uart_setup(hdev, qca_baudrate, qcadev->btsoc_type, soc_ver); ret = qca_uart_setup(hdev, qca_baudrate, soc_type, soc_ver);
if (!ret) { if (!ret) {
set_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags); set_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
qca_debugfs_init(hdev); qca_debugfs_init(hdev);
...@@ -1250,7 +1260,7 @@ static int qca_setup(struct hci_uart *hu) ...@@ -1250,7 +1260,7 @@ static int qca_setup(struct hci_uart *hu)
} }
/* Setup bdaddr */ /* Setup bdaddr */
if (qcadev->btsoc_type == QCA_WCN3990) if (soc_type == QCA_WCN3990)
hu->hdev->set_bdaddr = qca_set_bdaddr; hu->hdev->set_bdaddr = qca_set_bdaddr;
else else
hu->hdev->set_bdaddr = qca_set_bdaddr_rome; hu->hdev->set_bdaddr = qca_set_bdaddr_rome;
......
...@@ -111,6 +111,18 @@ struct sdio_driver { ...@@ -111,6 +111,18 @@ struct sdio_driver {
extern int sdio_register_driver(struct sdio_driver *); extern int sdio_register_driver(struct sdio_driver *);
extern void sdio_unregister_driver(struct sdio_driver *); extern void sdio_unregister_driver(struct sdio_driver *);
/**
* module_sdio_driver() - Helper macro for registering a SDIO driver
* @__sdio_driver: sdio_driver struct
*
* Helper macro for SDIO drivers which do not do anything special in module
* init/exit. This eliminates a lot of boilerplate. Each module may only
* use this macro once, and calling it replaces module_init() and module_exit()
*/
#define module_sdio_driver(__sdio_driver) \
module_driver(__sdio_driver, sdio_register_driver, \
sdio_unregister_driver)
/* /*
* SDIO I/O operations * SDIO I/O operations
*/ */
......
...@@ -59,6 +59,8 @@ ...@@ -59,6 +59,8 @@
#define SDIO_DEVICE_ID_MARVELL_8797_F0 0x9128 #define SDIO_DEVICE_ID_MARVELL_8797_F0 0x9128
#define SDIO_DEVICE_ID_MARVELL_8887WLAN 0x9134 #define SDIO_DEVICE_ID_MARVELL_8887WLAN 0x9134
#define SDIO_VENDOR_ID_MEDIATEK 0x037a
#define SDIO_VENDOR_ID_SIANO 0x039a #define SDIO_VENDOR_ID_SIANO 0x039a
#define SDIO_DEVICE_ID_SIANO_NOVA_B0 0x0201 #define SDIO_DEVICE_ID_SIANO_NOVA_B0 0x0201
#define SDIO_DEVICE_ID_SIANO_NICE 0x0202 #define SDIO_DEVICE_ID_SIANO_NICE 0x0202
......
...@@ -190,6 +190,9 @@ struct adv_info { ...@@ -190,6 +190,9 @@ struct adv_info {
#define HCI_MAX_SHORT_NAME_LENGTH 10 #define HCI_MAX_SHORT_NAME_LENGTH 10
/* Min encryption key size to match with SMP */
#define HCI_MIN_ENC_KEY_SIZE 7
/* Default LE RPA expiry time, 15 minutes */ /* Default LE RPA expiry time, 15 minutes */
#define HCI_DEFAULT_RPA_TIMEOUT (15 * 60) #define HCI_DEFAULT_RPA_TIMEOUT (15 * 60)
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "nhc.h" #include "nhc.h"
static struct rb_root rb_root = RB_ROOT; static struct rb_root rb_root = RB_ROOT;
static struct lowpan_nhc *lowpan_nexthdr_nhcs[NEXTHDR_MAX]; static struct lowpan_nhc *lowpan_nexthdr_nhcs[NEXTHDR_MAX + 1];
static DEFINE_SPINLOCK(lowpan_nhc_lock); static DEFINE_SPINLOCK(lowpan_nhc_lock);
static int lowpan_nhc_insert(struct lowpan_nhc *nhc) static int lowpan_nhc_insert(struct lowpan_nhc *nhc)
......
...@@ -1276,6 +1276,14 @@ int hci_conn_check_link_mode(struct hci_conn *conn) ...@@ -1276,6 +1276,14 @@ int hci_conn_check_link_mode(struct hci_conn *conn)
!test_bit(HCI_CONN_ENCRYPT, &conn->flags)) !test_bit(HCI_CONN_ENCRYPT, &conn->flags))
return 0; return 0;
/* The minimum encryption key size needs to be enforced by the
* host stack before establishing any L2CAP connections. The
* specification in theory allows a minimum of 1, but to align
* BR/EDR and LE transports, a minimum of 7 is chosen.
*/
if (conn->enc_key_size < HCI_MIN_ENC_KEY_SIZE)
return 0;
return 1; return 1;
} }
......
...@@ -1460,8 +1460,6 @@ static int hci_dev_do_open(struct hci_dev *hdev) ...@@ -1460,8 +1460,6 @@ static int hci_dev_do_open(struct hci_dev *hdev)
hdev->set_bdaddr) hdev->set_bdaddr)
ret = hdev->set_bdaddr(hdev, ret = hdev->set_bdaddr(hdev,
&hdev->public_addr); &hdev->public_addr);
else
ret = -EADDRNOTAVAIL;
} }
setup_failed: setup_failed:
......
...@@ -5433,7 +5433,7 @@ static void hci_le_ext_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -5433,7 +5433,7 @@ static void hci_le_ext_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb)
ev->data, ev->length); ev->data, ev->length);
} }
ptr += sizeof(*ev) + ev->length + 1; ptr += sizeof(*ev) + ev->length;
} }
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
......
...@@ -75,6 +75,7 @@ static int do_hidp_sock_ioctl(struct socket *sock, unsigned int cmd, void __user ...@@ -75,6 +75,7 @@ static int do_hidp_sock_ioctl(struct socket *sock, unsigned int cmd, void __user
sockfd_put(csock); sockfd_put(csock);
return err; return err;
} }
ca.name[sizeof(ca.name)-1] = 0;
err = hidp_connection_add(&ca, csock, isock); err = hidp_connection_add(&ca, csock, isock);
if (!err && copy_to_user(argp, &ca, sizeof(ca))) if (!err && copy_to_user(argp, &ca, sizeof(ca)))
......
...@@ -510,12 +510,12 @@ void l2cap_chan_set_defaults(struct l2cap_chan *chan) ...@@ -510,12 +510,12 @@ void l2cap_chan_set_defaults(struct l2cap_chan *chan)
} }
EXPORT_SYMBOL_GPL(l2cap_chan_set_defaults); EXPORT_SYMBOL_GPL(l2cap_chan_set_defaults);
static void l2cap_le_flowctl_init(struct l2cap_chan *chan) static void l2cap_le_flowctl_init(struct l2cap_chan *chan, u16 tx_credits)
{ {
chan->sdu = NULL; chan->sdu = NULL;
chan->sdu_last_frag = NULL; chan->sdu_last_frag = NULL;
chan->sdu_len = 0; chan->sdu_len = 0;
chan->tx_credits = 0; chan->tx_credits = tx_credits;
/* Derive MPS from connection MTU to stop HCI fragmentation */ /* Derive MPS from connection MTU to stop HCI fragmentation */
chan->mps = min_t(u16, chan->imtu, chan->conn->mtu - L2CAP_HDR_SIZE); chan->mps = min_t(u16, chan->imtu, chan->conn->mtu - L2CAP_HDR_SIZE);
/* Give enough credits for a full packet */ /* Give enough credits for a full packet */
...@@ -1281,7 +1281,7 @@ static void l2cap_le_connect(struct l2cap_chan *chan) ...@@ -1281,7 +1281,7 @@ static void l2cap_le_connect(struct l2cap_chan *chan)
if (test_and_set_bit(FLAG_LE_CONN_REQ_SENT, &chan->flags)) if (test_and_set_bit(FLAG_LE_CONN_REQ_SENT, &chan->flags))
return; return;
l2cap_le_flowctl_init(chan); l2cap_le_flowctl_init(chan, 0);
req.psm = chan->psm; req.psm = chan->psm;
req.scid = cpu_to_le16(chan->scid); req.scid = cpu_to_le16(chan->scid);
...@@ -5532,11 +5532,10 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn, ...@@ -5532,11 +5532,10 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn,
chan->dcid = scid; chan->dcid = scid;
chan->omtu = mtu; chan->omtu = mtu;
chan->remote_mps = mps; chan->remote_mps = mps;
chan->tx_credits = __le16_to_cpu(req->credits);
__l2cap_chan_add(conn, chan); __l2cap_chan_add(conn, chan);
l2cap_le_flowctl_init(chan); l2cap_le_flowctl_init(chan, __le16_to_cpu(req->credits));
dcid = chan->scid; dcid = chan->scid;
credits = chan->rx_credits; credits = chan->rx_credits;
......
...@@ -791,10 +791,13 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ...@@ -791,10 +791,13 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
conn = chan->conn; conn = chan->conn;
/*change security for LE channels */ /* change security for LE channels */
if (chan->scid == L2CAP_CID_ATT) { if (chan->scid == L2CAP_CID_ATT) {
if (smp_conn_security(conn->hcon, sec.level)) if (smp_conn_security(conn->hcon, sec.level)) {
err = -EINVAL;
break; break;
}
set_bit(FLAG_PENDING_SECURITY, &chan->flags); set_bit(FLAG_PENDING_SECURITY, &chan->flags);
sk->sk_state = BT_CONFIG; sk->sk_state = BT_CONFIG;
chan->state = BT_CONFIG; chan->state = BT_CONFIG;
......
...@@ -2301,8 +2301,7 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data, ...@@ -2301,8 +2301,7 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
} }
expected_len = sizeof(*cp) + key_count * expected_len = struct_size(cp, keys, key_count);
sizeof(struct mgmt_link_key_info);
if (expected_len != len) { if (expected_len != len) {
bt_dev_err(hdev, "load_link_keys: expected %u bytes, got %u bytes", bt_dev_err(hdev, "load_link_keys: expected %u bytes, got %u bytes",
expected_len, len); expected_len, len);
...@@ -5030,7 +5029,7 @@ static int load_irks(struct sock *sk, struct hci_dev *hdev, void *cp_data, ...@@ -5030,7 +5029,7 @@ static int load_irks(struct sock *sk, struct hci_dev *hdev, void *cp_data,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
} }
expected_len = sizeof(*cp) + irk_count * sizeof(struct mgmt_irk_info); expected_len = struct_size(cp, irks, irk_count);
if (expected_len != len) { if (expected_len != len) {
bt_dev_err(hdev, "load_irks: expected %u bytes, got %u bytes", bt_dev_err(hdev, "load_irks: expected %u bytes, got %u bytes",
expected_len, len); expected_len, len);
...@@ -5112,8 +5111,7 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev, ...@@ -5112,8 +5111,7 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
} }
expected_len = sizeof(*cp) + key_count * expected_len = struct_size(cp, keys, key_count);
sizeof(struct mgmt_ltk_info);
if (expected_len != len) { if (expected_len != len) {
bt_dev_err(hdev, "load_keys: expected %u bytes, got %u bytes", bt_dev_err(hdev, "load_keys: expected %u bytes, got %u bytes",
expected_len, len); expected_len, len);
...@@ -5847,8 +5845,7 @@ static int load_conn_param(struct sock *sk, struct hci_dev *hdev, void *data, ...@@ -5847,8 +5845,7 @@ static int load_conn_param(struct sock *sk, struct hci_dev *hdev, void *data,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
} }
expected_len = sizeof(*cp) + param_count * expected_len = struct_size(cp, params, param_count);
sizeof(struct mgmt_conn_param);
if (expected_len != len) { if (expected_len != len) {
bt_dev_err(hdev, "load_conn_param: expected %u bytes, got %u bytes", bt_dev_err(hdev, "load_conn_param: expected %u bytes, got %u bytes",
expected_len, len); expected_len, len);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment