* Re: [PATCH] Fix setting of mode after discovery times out.
From: Johan Hedberg @ 2011-04-09 17:35 UTC (permalink / raw)
To: Jaikumar Ganesh; +Cc: linux-bluetooth
In-Reply-To: <1302050692-24497-1-git-send-email-jaikumar@google.com>
Hi Jaikumar,
On Tue, Apr 05, 2011, Jaikumar Ganesh wrote:
> diff --git a/src/adapter.c b/src/adapter.c
> index c400bfd..014cc0c 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -156,6 +156,8 @@ struct btd_adapter {
>
> static void adapter_set_pairable_timeout(struct btd_adapter *adapter,
> guint interval);
> +static DBusMessage *set_discoverable(DBusConnection *conn, DBusMessage *msg,
> + gboolean discoverable, void *data);
>
> static int found_device_cmp(const struct remote_dev_info *d1,
> const struct remote_dev_info *d2)
> @@ -374,7 +376,7 @@ static gboolean discov_timeout_handler(gpointer user_data)
>
> adapter->discov_timeout_id = 0;
>
> - adapter_ops->set_discoverable(adapter->dev_id, FALSE);
> + set_discoverable(NULL, NULL, FALSE, user_data);
>
> return FALSE;
I don't think it's appropriate to reuse set_discoverable here since it's
a D-Bus method callback. It can e.g. result in passing the DBusMessage
parameter to btd_error_failed which might cause a crash with a NULL
pointer. I think duplicating some code from set_discoverable would make
more sense, either within discov_timeout_handler or as a separate static
function.
Johan
^ permalink raw reply
* Re: [PATCH] Fixing characteristic read by uuid
From: Johan Hedberg @ 2011-04-09 17:28 UTC (permalink / raw)
To: Sheldon Demario; +Cc: linux-bluetooth
In-Reply-To: <1302028684-5267-1-git-send-email-sheldon.demario@openbossa.org>
Hi Sheldon,
On Tue, Apr 05, 2011, Sheldon Demario wrote:
> When the charecteristic to be read was the last one of a given range,
> it was not being listed.
> ---
> src/attrib-server.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
This one has also been pushed. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] Fix Characteristic read by UUID on gatttool
From: Johan Hedberg @ 2011-04-09 17:27 UTC (permalink / raw)
To: Sheldon Demario; +Cc: linux-bluetooth
In-Reply-To: <1302028665-5227-1-git-send-email-sheldon.demario@openbossa.org>
Hi Sheldon,
On Tue, Apr 05, 2011, Sheldon Demario wrote:
> The Characteristic read by UUID GATT procedure is not incremental,
> i.e. it returns the entire list in a single Read By Type request.
> Therefore it should not be called recursively.
> ---
> attrib/gatttool.c | 6 ------
> attrib/interactive.c | 6 ------
> 2 files changed, 0 insertions(+), 12 deletions(-)
Pushed upstream. Thanks.
Johan
^ permalink raw reply
* Re: 2.6.39-rc2 regression: X201s fails to resume b77dcf8460ae57d4eb9fd3633eb4f97b8fb20716
From: Keith Packard @ 2011-04-09 2:03 UTC (permalink / raw)
To: Vinicius Costa Gomes; +Cc: Thomas Gleixner, linux-kernel, linux-bluetooth
In-Reply-To: <20110409000857.GB25581@piper>
[-- Attachment #1: Type: text/plain, Size: 533 bytes --]
On Fri, 8 Apr 2011 21:08:57 -0300, Vinicius Costa Gomes <vinicius.gomes@openbossa.org> wrote:
> I took a shot at it and just sent a patch (also attached for convenience)
> that should solve the problem.
Thanks much! I applied this to -rc2 and it appears to work fine in some
brief testing (a dozen suspend/resume cycles)
> Reported-by: Keith Packard <keithp@keithp.com>
> Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Tested-by: Keith Packard <keithp@keithp.com>
--
keith.packard@intel.com
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply
* [PATCH] Bluetooth: btmrvl: support Marvell Bluetooth device SD8787
From: Bing Zhao @ 2011-04-09 1:19 UTC (permalink / raw)
To: linux-bluetooth
Cc: Kevin Gan, Tristan Xu, Gustavo F. Padovan, Marcel Holtmann,
Stefan A. Popa, Bing Zhao
From: Kevin Gan <ganhy@marvell.com>
The SD8787 firmware image is shared with mwifiex driver.
Whoever gets loaded first will be responsible for firmware
downloading.
Signed-off-by: Kevin Gan <ganhy@marvell.com>
Signed-off-by: Tristan Xu <xurf@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
---
drivers/bluetooth/Kconfig | 4 +-
drivers/bluetooth/btmrvl_sdio.c | 124 +++++++++++++++++++++++++++++---------
drivers/bluetooth/btmrvl_sdio.h | 68 +++++++++++----------
3 files changed, 132 insertions(+), 64 deletions(-)
diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
index 8e0de9a..11b41fd 100644
--- a/drivers/bluetooth/Kconfig
+++ b/drivers/bluetooth/Kconfig
@@ -188,7 +188,7 @@ config BT_MRVL
The core driver to support Marvell Bluetooth devices.
This driver is required if you want to support
- Marvell Bluetooth devices, such as 8688.
+ Marvell Bluetooth devices, such as 8688/8787.
Say Y here to compile Marvell Bluetooth driver
into the kernel or say M to compile it as module.
@@ -201,7 +201,7 @@ config BT_MRVL_SDIO
The driver for Marvell Bluetooth chipsets with SDIO interface.
This driver is required if you want to use Marvell Bluetooth
- devices with SDIO interface. Currently only SD8688 chipset is
+ devices with SDIO interface. Currently SD8688/SD8787 chipsets are
supported.
Say Y here to compile support for Marvell BT-over-SDIO driver
diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
index dcc2a6e..7f521d4 100644
--- a/drivers/bluetooth/btmrvl_sdio.c
+++ b/drivers/bluetooth/btmrvl_sdio.c
@@ -49,15 +49,59 @@
static u8 user_rmmod;
static u8 sdio_ireg;
+static const struct btmrvl_sdio_card_reg btmrvl_reg_8688 = {
+ .cfg = 0x03,
+ .host_int_mask = 0x04,
+ .host_intstatus = 0x05,
+ .card_status = 0x20,
+ .sq_read_base_addr_a0 = 0x10,
+ .sq_read_base_addr_a1 = 0x11,
+ .card_fw_status0 = 0x40,
+ .card_fw_status1 = 0x41,
+ .card_rx_len = 0x42,
+ .card_rx_unit = 0x43,
+ .io_port_0 = 0x00,
+ .io_port_1 = 0x01,
+ .io_port_2 = 0x02,
+};
+static const struct btmrvl_sdio_card_reg btmrvl_reg_8787 = {
+ .cfg = 0x00,
+ .host_int_mask = 0x02,
+ .host_intstatus = 0x03,
+ .card_status = 0x30,
+ .sq_read_base_addr_a0 = 0x40,
+ .sq_read_base_addr_a1 = 0x41,
+ .card_revision = 0x5c,
+ .card_fw_status0 = 0x60,
+ .card_fw_status1 = 0x61,
+ .card_rx_len = 0x62,
+ .card_rx_unit = 0x63,
+ .io_port_0 = 0x78,
+ .io_port_1 = 0x79,
+ .io_port_2 = 0x7a,
+};
+
static const struct btmrvl_sdio_device btmrvl_sdio_sd6888 = {
.helper = "sd8688_helper.bin",
.firmware = "sd8688.bin",
+ .reg = &btmrvl_reg_8688,
+ .sd_blksz_fw_dl = 64,
+};
+
+static const struct btmrvl_sdio_device btmrvl_sdio_sd8787 = {
+ .helper = NULL,
+ .firmware = "mrvl/sd8787_uapsta.bin",
+ .reg = &btmrvl_reg_8787,
+ .sd_blksz_fw_dl = 256,
};
static const struct sdio_device_id btmrvl_sdio_ids[] = {
/* Marvell SD8688 Bluetooth device */
{ SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x9105),
.driver_data = (unsigned long) &btmrvl_sdio_sd6888 },
+ /* Marvell SD8787 Bluetooth device */
+ { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x911A),
+ .driver_data = (unsigned long) &btmrvl_sdio_sd8787 },
{ } /* Terminating entry */
};
@@ -69,7 +113,7 @@ static int btmrvl_sdio_get_rx_unit(struct btmrvl_sdio_card *card)
u8 reg;
int ret;
- reg = sdio_readb(card->func, CARD_RX_UNIT_REG, &ret);
+ reg = sdio_readb(card->func, card->reg->card_rx_unit, &ret);
if (!ret)
card->rx_unit = reg;
@@ -83,11 +127,11 @@ static int btmrvl_sdio_read_fw_status(struct btmrvl_sdio_card *card, u16 *dat)
*dat = 0;
- fws0 = sdio_readb(card->func, CARD_FW_STATUS0_REG, &ret);
+ fws0 = sdio_readb(card->func, card->reg->card_fw_status0, &ret);
if (ret)
return -EIO;
- fws1 = sdio_readb(card->func, CARD_FW_STATUS1_REG, &ret);
+ fws1 = sdio_readb(card->func, card->reg->card_fw_status1, &ret);
if (ret)
return -EIO;
@@ -101,7 +145,7 @@ static int btmrvl_sdio_read_rx_len(struct btmrvl_sdio_card *card, u16 *dat)
u8 reg;
int ret;
- reg = sdio_readb(card->func, CARD_RX_LEN_REG, &ret);
+ reg = sdio_readb(card->func, card->reg->card_rx_len, &ret);
if (!ret)
*dat = (u16) reg << card->rx_unit;
@@ -113,7 +157,7 @@ static int btmrvl_sdio_enable_host_int_mask(struct btmrvl_sdio_card *card,
{
int ret;
- sdio_writeb(card->func, mask, HOST_INT_MASK_REG, &ret);
+ sdio_writeb(card->func, mask, card->reg->host_int_mask, &ret);
if (ret) {
BT_ERR("Unable to enable the host interrupt!");
ret = -EIO;
@@ -128,13 +172,13 @@ static int btmrvl_sdio_disable_host_int_mask(struct btmrvl_sdio_card *card,
u8 host_int_mask;
int ret;
- host_int_mask = sdio_readb(card->func, HOST_INT_MASK_REG, &ret);
+ host_int_mask = sdio_readb(card->func, card->reg->host_int_mask, &ret);
if (ret)
return -EIO;
host_int_mask &= ~mask;
- sdio_writeb(card->func, host_int_mask, HOST_INT_MASK_REG, &ret);
+ sdio_writeb(card->func, host_int_mask, card->reg->host_int_mask, &ret);
if (ret < 0) {
BT_ERR("Unable to disable the host interrupt!");
return -EIO;
@@ -150,7 +194,7 @@ static int btmrvl_sdio_poll_card_status(struct btmrvl_sdio_card *card, u8 bits)
int ret;
for (tries = 0; tries < MAX_POLL_TRIES * 1000; tries++) {
- status = sdio_readb(card->func, CARD_STATUS_REG, &ret);
+ status = sdio_readb(card->func, card->reg->card_status, &ret);
if (ret)
goto failed;
if ((status & bits) == bits)
@@ -299,7 +343,7 @@ static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card *card)
u8 base0, base1;
void *tmpfwbuf = NULL;
u8 *fwbuf;
- u16 len;
+ u16 len, blksz_dl = card->sd_blksz_fw_dl;
int txlen = 0, tx_blocks = 0, count = 0;
ret = request_firmware(&fw_firmware, card->firmware,
@@ -345,7 +389,7 @@ static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card *card)
for (tries = 0; tries < MAX_POLL_TRIES; tries++) {
base0 = sdio_readb(card->func,
- SQ_READ_BASE_ADDRESS_A0_REG, &ret);
+ card->reg->sq_read_base_addr_a0, &ret);
if (ret) {
BT_ERR("BASE0 register read failed:"
" base0 = 0x%04X(%d)."
@@ -355,7 +399,7 @@ static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card *card)
goto done;
}
base1 = sdio_readb(card->func,
- SQ_READ_BASE_ADDRESS_A1_REG, &ret);
+ card->reg->sq_read_base_addr_a1, &ret);
if (ret) {
BT_ERR("BASE1 register read failed:"
" base1 = 0x%04X(%d)."
@@ -403,20 +447,19 @@ static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card *card)
if (firmwarelen - offset < txlen)
txlen = firmwarelen - offset;
- tx_blocks =
- (txlen + SDIO_BLOCK_SIZE - 1) / SDIO_BLOCK_SIZE;
+ tx_blocks = (txlen + blksz_dl - 1) / blksz_dl;
memcpy(fwbuf, &firmware[offset], txlen);
}
ret = sdio_writesb(card->func, card->ioport, fwbuf,
- tx_blocks * SDIO_BLOCK_SIZE);
+ tx_blocks * blksz_dl);
if (ret < 0) {
BT_ERR("FW download, writesb(%d) failed @%d",
count, offset);
- sdio_writeb(card->func, HOST_CMD53_FIN, CONFIG_REG,
- &ret);
+ sdio_writeb(card->func, HOST_CMD53_FIN,
+ card->reg->cfg, &ret);
if (ret)
BT_ERR("writeb failed (CFG)");
}
@@ -597,7 +640,7 @@ static void btmrvl_sdio_interrupt(struct sdio_func *func)
priv = card->priv;
- ireg = sdio_readb(card->func, HOST_INTSTATUS_REG, &ret);
+ ireg = sdio_readb(card->func, card->reg->host_intstatus, &ret);
if (ret) {
BT_ERR("sdio_readb: read int status register failed");
return;
@@ -613,7 +656,7 @@ static void btmrvl_sdio_interrupt(struct sdio_func *func)
sdio_writeb(card->func, ~(ireg) & (DN_LD_HOST_INT_STATUS |
UP_LD_HOST_INT_STATUS),
- HOST_INTSTATUS_REG, &ret);
+ card->reg->host_intstatus, &ret);
if (ret) {
BT_ERR("sdio_writeb: clear int status register failed");
return;
@@ -664,7 +707,7 @@ static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card *card)
goto release_irq;
}
- reg = sdio_readb(func, IO_PORT_0_REG, &ret);
+ reg = sdio_readb(func, card->reg->io_port_0, &ret);
if (ret < 0) {
ret = -EIO;
goto release_irq;
@@ -672,7 +715,7 @@ static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card *card)
card->ioport = reg;
- reg = sdio_readb(func, IO_PORT_1_REG, &ret);
+ reg = sdio_readb(func, card->reg->io_port_1, &ret);
if (ret < 0) {
ret = -EIO;
goto release_irq;
@@ -680,7 +723,7 @@ static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card *card)
card->ioport |= (reg << 8);
- reg = sdio_readb(func, IO_PORT_2_REG, &ret);
+ reg = sdio_readb(func, card->reg->io_port_2, &ret);
if (ret < 0) {
ret = -EIO;
goto release_irq;
@@ -815,6 +858,8 @@ exit:
static int btmrvl_sdio_download_fw(struct btmrvl_sdio_card *card)
{
int ret = 0;
+ u8 fws0;
+ int pollnum = MAX_POLL_TRIES;
if (!card || !card->func) {
BT_ERR("card or function is NULL!");
@@ -827,20 +872,36 @@ static int btmrvl_sdio_download_fw(struct btmrvl_sdio_card *card)
goto done;
}
- ret = btmrvl_sdio_download_helper(card);
+ /* Check if other function driver is downloading the firmware */
+ fws0 = sdio_readb(card->func, card->reg->card_fw_status0, &ret);
if (ret) {
- BT_ERR("Failed to download helper!");
+ BT_ERR("Failed to read FW downloading status!");
ret = -EIO;
goto done;
}
+ if (fws0) {
+ BT_DBG("BT not the winner (%#x). Skip FW downloading", fws0);
+
+ /* Give other function more time to download the firmware */
+ pollnum *= 10;
+ } else {
+ if (card->helper) {
+ ret = btmrvl_sdio_download_helper(card);
+ if (ret) {
+ BT_ERR("Failed to download helper!");
+ ret = -EIO;
+ goto done;
+ }
+ }
- if (btmrvl_sdio_download_fw_w_helper(card)) {
- BT_ERR("Failed to download firmware!");
- ret = -EIO;
- goto done;
+ if (btmrvl_sdio_download_fw_w_helper(card)) {
+ BT_ERR("Failed to download firmware!");
+ ret = -EIO;
+ goto done;
+ }
}
- if (btmrvl_sdio_verify_fw_download(card, MAX_POLL_TRIES)) {
+ if (btmrvl_sdio_verify_fw_download(card, pollnum)) {
BT_ERR("FW failed to be active in time!");
ret = -ETIMEDOUT;
goto done;
@@ -864,7 +925,7 @@ static int btmrvl_sdio_wakeup_fw(struct btmrvl_private *priv)
sdio_claim_host(card->func);
- sdio_writeb(card->func, HOST_POWER_UP, CONFIG_REG, &ret);
+ sdio_writeb(card->func, HOST_POWER_UP, card->reg->cfg, &ret);
sdio_release_host(card->func);
@@ -893,8 +954,10 @@ static int btmrvl_sdio_probe(struct sdio_func *func,
if (id->driver_data) {
struct btmrvl_sdio_device *data = (void *) id->driver_data;
- card->helper = data->helper;
+ card->helper = data->helper;
card->firmware = data->firmware;
+ card->reg = data->reg;
+ card->sd_blksz_fw_dl = data->sd_blksz_fw_dl;
}
if (btmrvl_sdio_register_dev(card) < 0) {
@@ -1011,3 +1074,4 @@ MODULE_VERSION(VERSION);
MODULE_LICENSE("GPL v2");
MODULE_FIRMWARE("sd8688_helper.bin");
MODULE_FIRMWARE("sd8688.bin");
+MODULE_FIRMWARE("mrvl/sd8787_uapsta.bin");
diff --git a/drivers/bluetooth/btmrvl_sdio.h b/drivers/bluetooth/btmrvl_sdio.h
index 27329f1..43d35a6 100644
--- a/drivers/bluetooth/btmrvl_sdio.h
+++ b/drivers/bluetooth/btmrvl_sdio.h
@@ -47,44 +47,46 @@
/* Max retry number of CMD53 write */
#define MAX_WRITE_IOMEM_RETRY 2
-/* Host Control Registers */
-#define IO_PORT_0_REG 0x00
-#define IO_PORT_1_REG 0x01
-#define IO_PORT_2_REG 0x02
-
-#define CONFIG_REG 0x03
-#define HOST_POWER_UP BIT(1)
-#define HOST_CMD53_FIN BIT(2)
-
-#define HOST_INT_MASK_REG 0x04
-#define HIM_DISABLE 0xff
-#define HIM_ENABLE (BIT(0) | BIT(1))
-
-#define HOST_INTSTATUS_REG 0x05
-#define UP_LD_HOST_INT_STATUS BIT(0)
-#define DN_LD_HOST_INT_STATUS BIT(1)
-
-/* Card Control Registers */
-#define SQ_READ_BASE_ADDRESS_A0_REG 0x10
-#define SQ_READ_BASE_ADDRESS_A1_REG 0x11
-
-#define CARD_STATUS_REG 0x20
-#define DN_LD_CARD_RDY BIT(0)
-#define CARD_IO_READY BIT(3)
-
-#define CARD_FW_STATUS0_REG 0x40
-#define CARD_FW_STATUS1_REG 0x41
-#define FIRMWARE_READY 0xfedc
-
-#define CARD_RX_LEN_REG 0x42
-#define CARD_RX_UNIT_REG 0x43
-
+/* register bitmasks */
+#define HOST_POWER_UP BIT(1)
+#define HOST_CMD53_FIN BIT(2)
+
+#define HIM_DISABLE 0xff
+#define HIM_ENABLE (BIT(0) | BIT(1))
+
+#define UP_LD_HOST_INT_STATUS BIT(0)
+#define DN_LD_HOST_INT_STATUS BIT(1)
+
+#define DN_LD_CARD_RDY BIT(0)
+#define CARD_IO_READY BIT(3)
+
+#define FIRMWARE_READY 0xfedc
+
+
+struct btmrvl_sdio_card_reg {
+ u8 cfg;
+ u8 host_int_mask;
+ u8 host_intstatus;
+ u8 card_status;
+ u8 sq_read_base_addr_a0;
+ u8 sq_read_base_addr_a1;
+ u8 card_revision;
+ u8 card_fw_status0;
+ u8 card_fw_status1;
+ u8 card_rx_len;
+ u8 card_rx_unit;
+ u8 io_port_0;
+ u8 io_port_1;
+ u8 io_port_2;
+};
struct btmrvl_sdio_card {
struct sdio_func *func;
u32 ioport;
const char *helper;
const char *firmware;
+ const struct btmrvl_sdio_card_reg *reg;
+ u16 sd_blksz_fw_dl;
u8 rx_unit;
struct btmrvl_private *priv;
};
@@ -92,6 +94,8 @@ struct btmrvl_sdio_card {
struct btmrvl_sdio_device {
const char *helper;
const char *firmware;
+ const struct btmrvl_sdio_card_reg *reg;
+ u16 sd_blksz_fw_dl;
};
--
1.6.2.5
^ permalink raw reply related
* Re: 2.6.39-rc2 regression: X201s fails to resume b77dcf8460ae57d4eb9fd3633eb4f97b8fb20716
From: Vinicius Costa Gomes @ 2011-04-09 0:08 UTC (permalink / raw)
To: Keith Packard; +Cc: Thomas Gleixner, linux-kernel, linux-bluetooth
In-Reply-To: <yunaag0tjzb.fsf@aiko.keithp.com>
[-- Attachment #1: Type: text/plain, Size: 594 bytes --]
Hi Keith,
On 16:13 Fri 08 Apr, Keith Packard wrote:
> On Fri, 8 Apr 2011 23:44:51 +0200 (CEST), Thomas Gleixner <tglx@linutronix.de> wrote:
>
> > Can the bluetooth folks please have a look at that ASAP? The obvious
> > fast fix for Linus tree is to revert the second hunk for now, but this
> > needs to be fixed proper.
>
> Who will submit this patch? I'd rather have your name on it so that
> people come complain at you...
I took a shot at it and just sent a patch (also attached for convenience)
that should solve the problem.
>
> --
> keith.packard@intel.com
Cheers,
--
Vinicius
[-- Attachment #2: 0001-Bluetooth-Fix-keeping-the-command-timer-running.patch --]
[-- Type: text/plain, Size: 1335 bytes --]
>From 1a617e2dde807ae932531ddd9b451011f236546c Mon Sep 17 00:00:00 2001
From: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Date: Fri, 8 Apr 2011 20:33:17 -0300
Subject: [PATCH] Bluetooth: Fix keeping the command timer running
In the teardown path the reset command is sent to the controller,
this event causes the command timer to be reactivated.
Now we remove the timer after the reset command is sent.
Reported-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
---
net/bluetooth/hci_core.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index a80bc1c..7467eaa 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -586,9 +586,6 @@ static int hci_dev_do_close(struct hci_dev *hdev)
hci_req_cancel(hdev, ENODEV);
hci_req_lock(hdev);
- /* Stop timer, it might be running */
- del_timer_sync(&hdev->cmd_timer);
-
if (!test_and_clear_bit(HCI_UP, &hdev->flags)) {
hci_req_unlock(hdev);
return 0;
@@ -618,6 +615,9 @@ static int hci_dev_do_close(struct hci_dev *hdev)
clear_bit(HCI_INIT, &hdev->flags);
}
+ /* Stop timer, it might be running */
+ del_timer_sync(&hdev->cmd_timer);
+
/* Kill cmd task */
tasklet_kill(&hdev->cmd_task);
--
1.7.4.3
^ permalink raw reply related
* [PATCH] Bluetooth: Fix keeping the command timer running
From: vinicius.gomes @ 2011-04-09 0:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Vinicius Costa Gomes
From: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
In the teardown path the reset command is sent to the controller,
this event causes the command timer to be reactivated.
Now we remove the timer after the reset command is sent.
Reported-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
---
net/bluetooth/hci_core.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index a80bc1c..7467eaa 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -586,9 +586,6 @@ static int hci_dev_do_close(struct hci_dev *hdev)
hci_req_cancel(hdev, ENODEV);
hci_req_lock(hdev);
- /* Stop timer, it might be running */
- del_timer_sync(&hdev->cmd_timer);
-
if (!test_and_clear_bit(HCI_UP, &hdev->flags)) {
hci_req_unlock(hdev);
return 0;
@@ -618,6 +615,9 @@ static int hci_dev_do_close(struct hci_dev *hdev)
clear_bit(HCI_INIT, &hdev->flags);
}
+ /* Stop timer, it might be running */
+ del_timer_sync(&hdev->cmd_timer);
+
/* Kill cmd task */
tasklet_kill(&hdev->cmd_task);
--
1.7.4.3
^ permalink raw reply related
* Re: 2.6.39-rc2 regression: X201s fails to resume b77dcf8460ae57d4eb9fd3633eb4f97b8fb20716
From: Keith Packard @ 2011-04-08 23:13 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: linux-kernel, linux-bluetooth
In-Reply-To: <alpine.LFD.2.00.1104082340020.2724@localhost6.localdomain6>
[-- Attachment #1: Type: text/plain, Size: 399 bytes --]
On Fri, 8 Apr 2011 23:44:51 +0200 (CEST), Thomas Gleixner <tglx@linutronix.de> wrote:
> Can the bluetooth folks please have a look at that ASAP? The obvious
> fast fix for Linus tree is to revert the second hunk for now, but this
> needs to be fixed proper.
Who will submit this patch? I'd rather have your name on it so that
people come complain at you...
--
keith.packard@intel.com
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply
* Re: [bluetooth-next 06/15] Bluetooth: Add SMP confirmation structs
From: Vinicius Costa Gomes @ 2011-04-08 21:55 UTC (permalink / raw)
To: linux-bluetooth, Anderson Briglia
In-Reply-To: <20110406233605.GD2228@joana>
Hi Gustavo,
On 20:36 Wed 06 Apr, Gustavo F. Padovan wrote:
> Hi Vinicius,
>
> * Vinicius Costa Gomes <vinicius.gomes@openbossa.org> [2011-04-05 22:51:47 -0300]:
>
> > From: Anderson Briglia <anderson.briglia@openbossa.org>
> >
> > This patch adds initial support for verifying the confirmation value
> > that the remote side has sent.
> >
> > Signed-off-by: Anderson Briglia <anderson.briglia@openbossa.org>
> > Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
> > ---
> > include/net/bluetooth/l2cap.h | 5 +++++
> > net/bluetooth/smp.c | 17 +++++++++++++++++
> > 2 files changed, 22 insertions(+), 0 deletions(-)
> >
> > diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
> > index 2b9ca0d..dc4aa63 100644
> > --- a/include/net/bluetooth/l2cap.h
> > +++ b/include/net/bluetooth/l2cap.h
> > @@ -305,6 +305,11 @@ struct l2cap_conn {
> >
> > __u8 disc_reason;
> >
> > + __u8 preq[7]; /* SMP Pairing Request */
> > + __u8 prsp[7]; /* SMP Pairing Response */
> > + __u8 prnd[16]; /* SMP Pairing Random */
> > + __u8 pcnf[16]; /* SMP Pairing Confirm */
> > +
> > struct l2cap_chan_list chan_list;
> > };
> >
> > diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
> > index 58047e8..7fa3542 100644
> > --- a/net/bluetooth/smp.c
> > +++ b/net/bluetooth/smp.c
> > @@ -192,6 +192,8 @@ static void smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)
> >
> > BT_DBG("conn %p", conn);
> >
> > + conn->preq[0] = SMP_CMD_PAIRING_REQ;
> > + memcpy(&conn->preq[1], rp, sizeof(*rp));
> > skb_pull(skb, sizeof(*rp));
> >
> > rp->io_capability = 0x00;
> > @@ -201,17 +203,25 @@ static void smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)
> > rp->resp_key_dist = 0x00;
> > rp->auth_req &= (SMP_AUTH_BONDING | SMP_AUTH_MITM);
> >
> > + conn->prsp[0] = SMP_CMD_PAIRING_RSP;
> > + memcpy(&conn->prsp[1], rp, sizeof(*rp));
> > +
> > smp_send_cmd(conn, SMP_CMD_PAIRING_RSP, sizeof(*rp), rp);
> > }
> >
> > static void smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb)
> > {
> > + struct smp_cmd_pairing *rp = (void *) skb->data;
>
> No need for cast here.
Yes, the cast is needed. The pointers types are incompatible.
>
> --
> Gustavo F. Padovan
> http://profusion.mobi
Cheers,
--
Vinicius
^ permalink raw reply
* Re: 2.6.39-rc2 regression: X201s fails to resume b77dcf8460ae57d4eb9fd3633eb4f97b8fb20716
From: Thomas Gleixner @ 2011-04-08 21:44 UTC (permalink / raw)
To: Keith Packard; +Cc: linux-kernel, linux-bluetooth
In-Reply-To: <alpine.LFD.2.00.1104070022280.3971@localhost6.localdomain6>
On Thu, 7 Apr 2011, Thomas Gleixner wrote:
> On Wed, 6 Apr 2011, Keith Packard wrote:
> > -rc2 was causing resume failures on my X201s -- the video mode would get
> > reset, but the system would then lock up. I bisected the failure down to:
> >
> > commit b77dcf8460ae57d4eb9fd3633eb4f97b8fb20716
> > Author: Thomas Gleixner <tglx@linutronix.de>
> > Date: Thu Mar 24 20:16:42 2011 +0100
> >
> > Bluetooth: Fix warning with hci_cmd_timer
> >
> > Reverting this on top of -rc2 makes resume reliable again.
>
> Huch. I really have a hard time to connect this. Can you revert the
> two hunks seperately?
Keith confirmed that reverting the second hunk fixes the
problem. Heck, so that timer is rearmed somewhere in the teardown
path?
Can the bluetooth folks please have a look at that ASAP? The obvious
fast fix for Linus tree is to revert the second hunk for now, but this
needs to be fixed proper.
Thanks,
tglx
^ permalink raw reply
* Re: [bluetooth-next 10/15] Bluetooth: Add support for resuming socket when SMP is finished
From: Marcel Holtmann @ 2011-04-08 16:34 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: Vinicius Costa Gomes, linux-bluetooth
In-Reply-To: <20110407001100.GE2228@joana>
Hi Gustavo,
> > This adds support for resuming the user space traffic when SMP
> > negotiation is complete.
> >
> > Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
> > ---
> > net/bluetooth/l2cap_core.c | 61 ++++++++++++++++++++++---------------------
> > net/bluetooth/l2cap_sock.c | 16 +++++++++++
> > net/bluetooth/smp.c | 40 ++++++++++++++++++++--------
> > 3 files changed, 75 insertions(+), 42 deletions(-)
> >
> > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> > index 0cec292..a5062f14 100644
> > --- a/net/bluetooth/l2cap_core.c
> > +++ b/net/bluetooth/l2cap_core.c
> > @@ -665,6 +665,22 @@ clean:
> > bh_unlock_sock(parent);
> > }
> >
> > +static void l2cap_chan_ready(struct sock *sk)
> > +{
> > + struct sock *parent = bt_sk(sk)->parent;
> > +
> > + BT_DBG("sk %p, parent %p", sk, parent);
> > +
> > + l2cap_pi(sk)->conf_state = 0;
> > + l2cap_sock_clear_timer(sk);
> > +
> > + sk->sk_state = BT_CONNECTED;
> > + sk->sk_state_change(sk);
> > +
> > + if (parent)
> > + parent->sk_data_ready(parent, 0);
> > +}
> > +
> > static void l2cap_conn_ready(struct l2cap_conn *conn)
> > {
> > struct l2cap_chan_list *l = &conn->chan_list;
> > @@ -680,15 +696,11 @@ static void l2cap_conn_ready(struct l2cap_conn *conn)
> > for (sk = l->head; sk; sk = l2cap_pi(sk)->next_c) {
> > bh_lock_sock(sk);
> >
> > - if (conn->hcon->type == LE_LINK) {
> > - l2cap_sock_clear_timer(sk);
> > - sk->sk_state = BT_CONNECTED;
> > - sk->sk_state_change(sk);
> > + if (l2cap_pi(sk)->scid == L2CAP_CID_LE_DATA) {
> > if (smp_conn_security(conn, l2cap_pi(sk)->sec_level))
> > - BT_DBG("Insufficient security");
> > - }
> > + l2cap_chan_ready(sk);
> >
> > - if (sk->sk_type != SOCK_SEQPACKET &&
> > + } else if (sk->sk_type != SOCK_SEQPACKET &&
> > sk->sk_type != SOCK_STREAM) {
> > l2cap_sock_clear_timer(sk);
> > sk->sk_state = BT_CONNECTED;
> > @@ -1362,29 +1374,6 @@ int l2cap_sar_segment_sdu(struct sock *sk, struct msghdr *msg, size_t len)
> > return size;
> > }
> >
> > -static void l2cap_chan_ready(struct sock *sk)
> > -{
> > - struct sock *parent = bt_sk(sk)->parent;
> > -
> > - BT_DBG("sk %p, parent %p", sk, parent);
> > -
> > - l2cap_pi(sk)->conf_state = 0;
> > - l2cap_sock_clear_timer(sk);
> > -
> > - if (!parent) {
> > - /* Outgoing channel.
> > - * Wake up socket sleeping on connect.
> > - */
> > - sk->sk_state = BT_CONNECTED;
> > - sk->sk_state_change(sk);
> > - } else {
> > - /* Incoming channel.
> > - * Wake up socket sleeping on accept.
> > - */
> > - parent->sk_data_ready(parent, 0);
> > - }
> > -}
> > -
> > /* Copy frame to all raw sockets on that connection */
> > static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb)
> > {
> > @@ -3810,6 +3799,18 @@ static int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
> > for (sk = l->head; sk; sk = l2cap_pi(sk)->next_c) {
> > bh_lock_sock(sk);
> >
> > + BT_DBG("sk->scid %d", l2cap_pi(sk)->scid);
> > +
> > + if (l2cap_pi(sk)->scid == L2CAP_CID_LE_DATA) {
> > + if (!status && encrypt) {
> > + l2cap_pi(sk)->sec_level = hcon->sec_level;
> > + l2cap_chan_ready(sk);
> > + }
> > +
> > + bh_unlock_sock(sk);
> > + continue;
> > + }
> > +
> > if (l2cap_pi(sk)->conf_state & L2CAP_CONF_CONNECT_PEND) {
> > bh_unlock_sock(sk);
> > continue;
> > diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
> > index f77308e..14e491a 100644
> > --- a/net/bluetooth/l2cap_sock.c
> > +++ b/net/bluetooth/l2cap_sock.c
> > @@ -29,6 +29,7 @@
> > #include <net/bluetooth/bluetooth.h>
> > #include <net/bluetooth/hci_core.h>
> > #include <net/bluetooth/l2cap.h>
> > +#include <net/bluetooth/smp.h>
> >
> > /* ---- L2CAP timers ---- */
> > static void l2cap_sock_timeout(unsigned long arg)
> > @@ -614,6 +615,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
> > {
> > struct sock *sk = sock->sk;
> > struct bt_security sec;
> > + struct l2cap_conn *conn;
> > int len, err = 0;
> > u32 opt;
> >
> > @@ -650,6 +652,20 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
> > }
> >
> > l2cap_pi(sk)->sec_level = sec.level;
> > +
> > + conn = l2cap_pi(sk)->conn;
> > + if (conn && l2cap_pi(sk)->scid == L2CAP_CID_LE_DATA) {
> > + if (!conn->hcon->out) {
> > + err = -EINVAL;
> > + break;
> > + }
> > +
> > + if (smp_conn_security(conn, sec.level))
> > + break;
> > +
> > + err = 0;
> > + sk->sk_state = BT_CONFIG;
> > + }
>
> I don't like the idea of bring SMP stuff to l2cap_sock.c, we are working now
> to clean up that file and keep only socket related stuff there, and only
> channel related stuff in l2cap_core.c. I've already sent a patchset on that
> direction to mailing list. However, I don't have any idea now on how to remove
> smp_conn_security() from here.
I don't think we have much choice here. We could abstract this out with
drivers, but in the end we want direct functions call and not some heavy
abstracted framework. Since lets face it, this is all pretty static.
However we might need some better function naming for this. Some of the
naming inside L2CAP is a bit odd and not really clear what it does.
Regards
Marcel
^ permalink raw reply
* [PATCH] bluetooth: fix shutdown on SCO sockets
From: Luiz Augusto von Dentz @ 2011-04-08 14:10 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
shutdown should wait for SCO link to be properly disconnected before
detroying the socket, otherwise an application using the socket may
assume link is properly disconnected before it really happens which
can be a problem when e.g synchronizing profile switch.
Signed-off-by: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
---
net/bluetooth/sco.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 42fdffd..94954c7 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -369,6 +369,15 @@ static void __sco_sock_close(struct sock *sk)
case BT_CONNECTED:
case BT_CONFIG:
+ if (sco_pi(sk)->conn) {
+ sk->sk_state = BT_DISCONN;
+ sco_sock_set_timer(sk, SCO_DISCONN_TIMEOUT);
+ hci_conn_put(sco_pi(sk)->conn->hcon);
+ sco_pi(sk)->conn = NULL;
+ } else
+ sco_chan_del(sk, ECONNRESET);
+ break;
+
case BT_CONNECT:
case BT_DISCONN:
sco_chan_del(sk, ECONNRESET);
--
1.7.1
^ permalink raw reply related
* [PATCH v2] Add test/test-oob for testing Out Of Band pairing
From: Szymon Janc @ 2011-04-08 9:37 UTC (permalink / raw)
To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, henrik.possung, Szymon Janc
This test utilizes D-Bus Out Of Band API so bluetoothd must be
compiled with dbusoob plugin.
---
Makefile.tools | 4 +-
test/test-oob | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 82 insertions(+), 2 deletions(-)
create mode 100755 test/test-oob
diff --git a/Makefile.tools b/Makefile.tools
index f6d7b13..364db37 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -205,8 +205,8 @@ EXTRA_DIST += test/apitest test/sap-client test/hsplay test/hsmicro \
test/test-telephony test/test-network test/simple-agent \
test/simple-service test/simple-endpoint test/test-audio \
test/test-input test/test-attrib test/test-sap-server \
- test/service-record.dtd test/service-did.xml test/service-spp.xml \
- test/service-opp.xml test/service-ftp.xml
+ test/test-oob test/service-record.dtd test/service-did.xml \
+ test/service-spp.xml test/service-opp.xml test/service-ftp.xml
if HIDD
diff --git a/test/test-oob b/test/test-oob
new file mode 100755
index 0000000..3340c00
--- /dev/null
+++ b/test/test-oob
@@ -0,0 +1,80 @@
+#!/usr/bin/python
+
+import gobject
+
+import dbus.mainloop.glib
+
+def create_device_reply(device):
+ print "Pairing succeed!"
+ mainloop.quit()
+
+def create_device_error(error):
+ print "Pairing failed."
+ mainloop.quit()
+
+if __name__ == '__main__':
+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+ mainloop = gobject.MainLoop()
+
+ bus = dbus.SystemBus()
+ manager = dbus.Interface(bus.get_object("org.bluez", "/"),
+ "org.bluez.Manager")
+
+ adapter0_path = manager.FindAdapter("hci0")
+ adapter1_path = manager.FindAdapter("hci1")
+
+ adapter0 = dbus.Interface(bus.get_object("org.bluez", adapter0_path),
+ "org.bluez.Adapter")
+ adapter1 = dbus.Interface(bus.get_object("org.bluez", adapter1_path),
+ "org.bluez.Adapter")
+
+ adapter0_address = adapter0.GetProperties()["Address"]
+ adapter1_address = adapter1.GetProperties()["Address"]
+ print "Adapters:"
+ print " hci0: " + adapter0_address
+ print " hci1: " + adapter1_address
+ print
+
+ print "Removing any existing bond..."
+
+ try:
+ device = adapter0.FindDevice(adapter1_address)
+ adapter0.RemoveDevice(device)
+ except:
+ pass
+
+ try:
+ device = adapter1.FindDevice(adapter0_address)
+ adapter1.RemoveDevice(device)
+ except:
+ pass
+
+ print "Done."
+ print
+ print "Reading local Out of Band data..."
+
+ oob_adapter0 = dbus.Interface(bus.get_object("org.bluez",
+ adapter0_path), "org.bluez.OutOfBand")
+ oob_adapter1 = dbus.Interface(bus.get_object("org.bluez",
+ adapter1_path), "org.bluez.OutOfBand")
+
+ oob0 = oob_adapter0.ReadLocalData()
+ oob1 = oob_adapter1.ReadLocalData()
+
+ print "Done."
+ print
+ print "Exchanging Out of Band data..."
+
+ oob_adapter0.AddRemoteData(adapter1_address, oob1[0], oob1[1])
+ oob_adapter1.AddRemoteData(adapter0_address, oob0[0], oob0[1])
+
+ print "Done."
+ print
+ print "Starting to pair."
+ adapter1.CreatePairedDevice(adapter0_address, "/test/agent_oob",
+ "DisplayYesNo",
+ reply_handler=create_device_reply,
+ error_handler=create_device_error)
+
+ mainloop.run()
--
1.7.0.4
on behalf of ST-Ericsson
^ permalink raw reply related
* How to configure bluetooth? (iscan, pscan, lm accept,master)
From: Alexey @ 2011-04-08 7:42 UTC (permalink / raw)
To: linux-bluetooth
Hello!
I can not configure bluetooth. In older versions of bluez was hcid.conf file, through which i can set options iscan, pscan and lm (link mode). In new versions of bluez 4.xx instead of this file is used main.conf and these parameters there is not provided.
How apply these settings to the bluetooth adapter at system startup and when i connect the adapter to the usb port?
In general, the system behaves is not clear. Sometimes the adapter after the system is turned on, and sometimes it turns off.
^ permalink raw reply
* Re: HDP, can't read data from fd which Acquire from HealthChannel
From: Jose Antonio Santos Cadenas @ 2011-04-08 7:38 UTC (permalink / raw)
To: Yi Hui Fan; +Cc: linux-bluetooth
In-Reply-To: <OF863AA7F4.5F9948F5-ON4825786C.0028E48A-4825786C.002969DE@cn.ibm.com>
2011/4/8 Yi Hui Fan <yihuifan@cn.ibm.com>:
> Jose,
>
>
>> Jose Antonio Santos Cadenas <santoscadenas@gmail.com>
>> Sent by: linux-bluetooth-owner@vger.kernel.org
>>
>> 2011-04-08 15:04
>>
>> To
>>
>> Yi Hui Fan/China/IBM@IBMCN
>>
>> cc
>>
>> linux-bluetooth@vger.kernel.org
>>
>> Subject
>>
>> Re: HDP, can't read data from fd which Acquire from HealthChannel
>>
>> Hi,
>>
>> 2011/4/8 Yi Hui Fan <yihuifan@cn.ibm.com>:
>> > Dears
>> >
>> > I'd like to build a demo for HDP sink. I try to use the DBUS API
> provided
>> > by Bluez. But there is a problem with unix fd to receive data.
>> >
>> > I can get fd by calling HealthChannel.Acquire method. following is
> the
>> > code I write to read data according the sock I got.
>> >
>> > fd_set rfds;
>> > struct timeval tv;
>> > int rv;
>> > char buff[1024];
>> >
>> > FD_ZERO(&rfds);
>> > FD_SET(sock, &rfds);
>> > tv.tv_sec = 10;
>> > tv.tv_usec = 500;
>> >
>> > rv = select(sock+1, &rfds, NULL, NULL, &tv);
>> >
>> > rv = recv(sock, buff, 1024, 0);
>> >
>> > rv is always return 0 when I call select method. I can't get anything.
>> >
>> > Any problem with these codes?
>>
>> It seems that you don't have a valid file descriptor. How are you
>> getting the file descriptor? Are you using Dbus 1.4?
>>
>
> Yes, I am using Dbus 1.4.
> I got the file descriptor by calling Acquire method of HealthChannel. Here
> is the code I wrote to get file descriptor.
>
> DBusConnection* conn;
> DBusError err;
> DBusMessage* msg;
> DBusMessage* reply;
> DBusMessageIter *iter;
>
> int sock;
>
> dbus_error_init(&err);
> printf("start get dbus connection\n");
> conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
> if (dbus_error_is_set(&err)) {
> fprintf(stderr, "Connection Error (%s)\n", err.message);
> dbus_error_free(&err);
> return -1;
> }
>
> if((msg = dbus_message_new_method_call("org.bluez", channel_path,
> "org.bluez.HealthChannel",
> "Acquire"))==NULL)
> {
> dbus_message_unref(msg);
> printf("initial msg failed!");
> return -1;
> }
>
> reply = dbus_connection_send_with_reply_and_block(conn, msg, -1,
> &err);
>
> dbus_message_get_args(reply, &err, DBUS_TYPE_UNIX_FD, &sock,
> DBUS_TYPE_INVALID);
The err variable should be initialized each time you use it and you
should also check the ret value of the previous function if fail, err
will contain a description.
You can also use dbus_error_is_set(&err) in order to check for errors.
>
> dbus_message_unref(msg);
> dbus_message_unref(reply);
> dbus_connection_unref(conn);
>
> return sock;
>
>>
>> >
>> > Thanks &
>> > Best regards,
>>
>> Regards
>>
>> Jose.
>>
>> >
>> > Yihui,Fan
>> --
>> To unsubscribe from this list: send the line "unsubscribe
> linux-bluetooth" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
^ permalink raw reply
* Re: HDP, can't read data from fd which Acquire from HealthChannel
From: Yi Hui Fan @ 2011-04-08 7:32 UTC (permalink / raw)
To: Jose Antonio Santos Cadenas; +Cc: linux-bluetooth
In-Reply-To: <BANLkTim72aKHWTvQOjfbFwyxP1j4v2MFWg@mail.gmail.com>
Jose,
> Jose Antonio Santos Cadenas <santoscadenas@gmail.com>
> Sent by: linux-bluetooth-owner@vger.kernel.org
>
> 2011-04-08 15:04
>
> To
>
> Yi Hui Fan/China/IBM@IBMCN
>
> cc
>
> linux-bluetooth@vger.kernel.org
>
> Subject
>
> Re: HDP, can't read data from fd which Acquire from HealthChannel
>
> Hi,
>
> 2011/4/8 Yi Hui Fan <yihuifan@cn.ibm.com>:
> > Dears
> >
> > I'd like to build a demo for HDP sink. I try to use the DBUS API
provided
> > by Bluez. But there is a problem with unix fd to receive data.
> >
> > I can get fd by calling HealthChannel.Acquire method. following is
the
> > code I write to read data according the sock I got.
> >
> > fd_set rfds;
> > struct timeval tv;
> > int rv;
> > char buff[1024];
> >
> > FD_ZERO(&rfds);
> > FD_SET(sock, &rfds);
> > tv.tv_sec = 10;
> > tv.tv_usec = 500;
> >
> > rv = select(sock+1, &rfds, NULL, NULL, &tv);
> >
> > rv = recv(sock, buff, 1024, 0);
> >
> > rv is always return 0 when I call select method. I can't get anything.
> >
> > Any problem with these codes?
>
> It seems that you don't have a valid file descriptor. How are you
> getting the file descriptor? Are you using Dbus 1.4?
>
Yes, I am using Dbus 1.4.
I got the file descriptor by calling Acquire method of HealthChannel. Here
is the code I wrote to get file descriptor.
DBusConnection* conn;
DBusError err;
DBusMessage* msg;
DBusMessage* reply;
DBusMessageIter *iter;
int sock;
dbus_error_init(&err);
printf("start get dbus connection\n");
conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
if (dbus_error_is_set(&err)) {
fprintf(stderr, "Connection Error (%s)\n", err.message);
dbus_error_free(&err);
return -1;
}
if((msg = dbus_message_new_method_call("org.bluez", channel_path,
"org.bluez.HealthChannel",
"Acquire"))==NULL)
{
dbus_message_unref(msg);
printf("initial msg failed!");
return -1;
}
reply = dbus_connection_send_with_reply_and_block(conn, msg, -1,
&err);
dbus_message_get_args(reply, &err, DBUS_TYPE_UNIX_FD, &sock,
DBUS_TYPE_INVALID);
dbus_message_unref(msg);
dbus_message_unref(reply);
dbus_connection_unref(conn);
return sock;
>
> >
> > Thanks &
> > Best regards,
>
> Regards
>
> Jose.
>
> >
> > Yihui,Fan
> --
> To unsubscribe from this list: send the line "unsubscribe
linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: HDP, can't read data from fd which Acquire from HealthChannel
From: Jose Antonio Santos Cadenas @ 2011-04-08 7:04 UTC (permalink / raw)
To: Yi Hui Fan; +Cc: linux-bluetooth
In-Reply-To: <OF2953F661.C5E1B3A9-ON4825786C.000D1F6C-4825786C.000D35E6@cn.ibm.com>
Hi,
2011/4/8 Yi Hui Fan <yihuifan@cn.ibm.com>:
> Dears
>
> I'd like to build a demo for HDP sink. I try to use the DBUS API provided
> by Bluez. But there is a problem with unix fd to receive data.
>
> I can get fd by calling HealthChannel.Acquire method. following is the
> code I write to read data according the sock I got.
>
> fd_set rfds;
> struct timeval tv;
> int rv;
> char buff[1024];
>
> FD_ZERO(&rfds);
> FD_SET(sock, &rfds);
> tv.tv_sec = 10;
> tv.tv_usec = 500;
>
> rv = select(sock+1, &rfds, NULL, NULL, &tv);
>
> rv = recv(sock, buff, 1024, 0);
>
> rv is always return 0 when I call select method. I can't get anything.
>
> Any problem with these codes?
It seems that you don't have a valid file descriptor. How are you
getting the file descriptor? Are you using Dbus 1.4?
>
> Thanks &
> Best regards,
Regards
Jose.
>
> Yihui,Fan
^ permalink raw reply
* HDP, can't read data from fd which Acquire from HealthChannel
From: Yi Hui Fan @ 2011-04-08 2:24 UTC (permalink / raw)
To: linux-bluetooth
Dears
I'd like to build a demo for HDP sink. I try to use the DBUS API provided
by Bluez. But there is a problem with unix fd to receive data.
I can get fd by calling HealthChannel.Acquire method. following is the
code I write to read data according the sock I got.
fd_set rfds;
struct timeval tv;
int rv;
char buff[1024];
FD_ZERO(&rfds);
FD_SET(sock, &rfds);
tv.tv_sec = 10;
tv.tv_usec = 500;
rv = select(sock+1, &rfds, NULL, NULL, &tv);
rv = recv(sock, buff, 1024, 0);
rv is always return 0 when I call select method. I can't get anything.
Any problem with these codes?
Thanks &
Best regards,
Yihui,Fan
^ permalink raw reply
* Re: [PATCH] Bluetooth: hci_uart: check the return value of recv()
From: Gustavo F. Padovan @ 2011-04-07 21:48 UTC (permalink / raw)
To: Jiejing Zhang; +Cc: Marcel Holtmann, linux-bluetooth, Jiejing Zhang
In-Reply-To: <1302179826-15745-1-git-send-email-kzjeef@gmail.com>
Hi Jiejing,
* Jiejing Zhang <kzjeef@gmail.com> [2011-04-07 20:37:06 +0800]:
> Check the return value of hu->proto->recv() in hci_uart_tty_receive()
> the recv() may return error, check it, not add this to statistics.
>
> Signed-off-by: Jiejing Zhang <jiejing.zhang@freescale.com>
> ---
> drivers/bluetooth/hci_ath.c | 6 +++++-
> drivers/bluetooth/hci_ldisc.c | 6 ++++--
> 2 files changed, 9 insertions(+), 3 deletions(-)
Patch has been applied. Thanks.
--
Gustavo F. Padovan
http://profusion.mobi
^ permalink raw reply
* Re: [PATCH] Bluetooth: Fix Out Of Band pairing when mgmt interface is disabled
From: Gustavo F. Padovan @ 2011-04-07 21:47 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth, par-gunnar.p.hjalmdahl, henrik.possung
In-Reply-To: <1302087719-18197-1-git-send-email-szymon.janc@tieto.com>
Hi Szymon,
* Szymon Janc <szymon.janc@tieto.com> [2011-04-06 13:01:59 +0200]:
> Use kernel stored remote Out Of Band data only if management interface
> is enabled. Otherwise HCI_OP_REMOTE_OOB_DATA_NEG_REPLY was sent to
> controller even if remote Out Of Band data was present in bluetoothd.
>
> Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
> ---
> net/bluetooth/hci_event.c | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
Applied, thanks.
--
Gustavo F. Padovan
http://profusion.mobi
^ permalink raw reply
* Re: Bluetooth Mighty Mouse buttons do not work
From: Gustavo F. Padovan @ 2011-04-07 18:25 UTC (permalink / raw)
To: Mark Szentes-Wanner; +Cc: linux-bluetooth
In-Reply-To: <201102162252.55503.mark2005@szentes.org>
Hi Mark,
* Mark Szentes-Wanner <mark2005@szentes.org> [2011-02-16 22:52:54 +0100]:
> Hello,
>
> my Apple Wireless Mighty Mouse stopped working years ago after a
> kernel&userland tools upgrade. More exactly, button 1, button 2 and button 3
> register no klicks, the rest works perfectly. There is an extensive bug
> report at Ubuntu's Launchpad:
> https://bugs.launchpad.net/ubuntu/+source/linux/+bug/319053?comments=all
>
> The bug was filed more than 2 years ago. Is it worth waiting for a solution
> or will it never be fixed? Is it a lack of hardware to test? (Apple
> discontinued the product in 2009.)
I'm using this mouse right now (Apple modem A1197) and it is fully working for
me. Something in the last two years fixed this bug, but I don't know what.
I'm using 2.6.39-rc1 here.
Regards,
--
Gustavo F. Padovan
http://profusion.mobi
^ permalink raw reply
* Re: [PATCH 1/9] Register primary services exported over basic rate
From: Claudio Takahasi @ 2011-04-07 18:15 UTC (permalink / raw)
To: Vinicius Costa Gomes; +Cc: linux-bluetooth
In-Reply-To: <20110407175818.GB29191@piper>
Hi Vinicius & Johan,
I will fix this error and move the GATT SDP record functions to gatt.c
BR,
Claudio
On Thu, Apr 7, 2011 at 5:58 PM, Vinicius Costa Gomes
<vinicius.gomes@openbossa.org> wrote:
> Hi Claudio,
>
> On 14:30 Thu 07 Apr, Claudio Takahasi wrote:
>> This patch registers the object paths for primary services exported
>> through SDP. PSM, start and end handle information are available in
>> the Protocol Descriptor List.
>> ---
>> src/device.c | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>> 1 files changed, 129 insertions(+), 1 deletions(-)
>>
>> diff --git a/src/device.c b/src/device.c
>> index d567952..32eb643 100644
>> --- a/src/device.c
>> +++ b/src/device.c
>> @@ -1367,6 +1367,127 @@ static void create_device_reply(struct btd_device *device, struct browse_req *re
>> g_dbus_send_message(req->conn, reply);
>> }
>>
>> +static sdp_data_t *proto_seq_find(sdp_list_t *proto_list)
>> +{
>> + sdp_list_t *list;
>> + uuid_t proto;
>> +
>> + sdp_uuid16_create(&proto, ATT_UUID);
>> +
>> + for (;list = proto_list, list; list = list->next) {
>
> The first ";" doesn't look right.
>
>> + sdp_list_t *p;
>> + for (p = list->data; p; p = p->next) {
>> + sdp_data_t *seq = p->data;
>> + if (seq && seq->dtd == SDP_UUID16 &&
>> + sdp_uuid16_cmp(&proto, &seq->val.uuid) == 0)
>> + return seq->next;
>> + }
>> + }
>> +
>> + return NULL;
>> +}
>> +
>> +static gboolean parse_proto_params(sdp_list_t *proto_list, uint16_t *psm,
>> + uint16_t *start, uint16_t *end)
>> +{
>> + sdp_data_t *seq1, *seq2;
>> +
>> + if (psm)
>> + *psm = sdp_get_proto_port(proto_list, L2CAP_UUID);
>> +
>> + /* Getting start and end handle */
>> + seq1 = proto_seq_find(proto_list);
>> + if (!seq1 || seq1->dtd != SDP_UINT16)
>> + return FALSE;
>> +
>> + seq2 = seq1->next;
>> + if (!seq2 || seq2->dtd != SDP_UINT16)
>> + return FALSE;
>> +
>> + if (start)
>> + *start = seq1->val.uint16;
>> +
>> + if (end)
>> + *end = seq2->val.uint16;
>> +
>> + return TRUE;
>> +}
>> +
>> +static gboolean parse_primary_record(const sdp_record_t *rec,
>> + uuid_t *prim_uuid, uint16_t *psm,
>> + uint16_t *start, uint16_t *end)
>> +{
>> + sdp_list_t *list;
>> + uuid_t uuid;
>> + gboolean ret;
>> +
>> + if (sdp_get_service_classes(rec, &list) < 0)
>> + return FALSE;
>> +
>> + memcpy(&uuid, list->data, sizeof(uuid));
>> + sdp_list_free(list, free);
>> +
>> + if (sdp_get_access_protos(rec, &list) < 0)
>> + return FALSE;
>> +
>> + ret = parse_proto_params(list, psm, start, end);
>> +
>> + sdp_list_foreach(list, (sdp_list_func_t) sdp_list_free, NULL);
>> + sdp_list_free(list, NULL);
>> +
>> + if (ret && prim_uuid)
>> + memcpy(prim_uuid, &uuid, sizeof(uuid_t));
>> +
>> + return ret;
>> +}
>> +
>> +static GSList *primary_from_record(struct btd_device *device, GSList *profiles)
>> +{
>> + GSList *l, *prim_list = NULL;
>> + char *att_uuid;
>> + uuid_t proto_uuid;
>> +
>> + sdp_uuid16_create(&proto_uuid, ATT_UUID);
>> + att_uuid = bt_uuid2string(&proto_uuid);
>> +
>> + for (l = profiles; l; l = l->next) {
>> + const char *profile_uuid = l->data;
>> + const sdp_record_t *rec;
>> + struct att_primary *prim;
>> + uint16_t start = 0, end = 0, psm = 0;
>> + uuid_t prim_uuid;
>> +
>> + rec = btd_device_get_record(device, profile_uuid);
>> + if (!rec)
>> + continue;
>> +
>> + if (!record_has_uuid(rec, att_uuid))
>> + continue;
>> +
>> + if (!parse_primary_record(rec, &prim_uuid, &psm, &start, &end))
>> + continue;
>> +
>> + prim = g_new0(struct att_primary, 1);
>> + prim->start = start;
>> + prim->end = end;
>> + sdp_uuid2strn(&prim_uuid, prim->uuid, sizeof(prim->uuid));
>> +
>> + prim_list = g_slist_append(prim_list, prim);
>> + }
>> +
>> + g_free(att_uuid);
>> +
>> + return prim_list;
>> +}
>> +
>> +static void register_primary_services(DBusConnection *conn,
>> + struct btd_device *device, GSList *prim_list)
>> +{
>> + /* TODO: PSM is hardcoded */
>> + attrib_client_register(conn, device, 31, NULL, prim_list);
>> + device->primaries = g_slist_concat(device->primaries, prim_list);
>> +}
>> +
>> static void search_cb(sdp_list_t *recs, int err, gpointer user_data)
>> {
>> struct browse_req *req = user_data;
>> @@ -1396,9 +1517,16 @@ static void search_cb(sdp_list_t *recs, int err, gpointer user_data)
>> }
>>
>> /* Probe matching drivers for services added */
>> - if (req->profiles_added)
>> + if (req->profiles_added) {
>> + GSList *list;
>> +
>> device_probe_drivers(device, req->profiles_added);
>>
>> + list = primary_from_record(device, req->profiles_added);
>> + if (list)
>> + register_primary_services(req->conn, device, list);
>> + }
>> +
>> /* Remove drivers for services removed */
>> if (req->profiles_removed)
>> device_remove_drivers(device, req->profiles_removed);
>> --
>> 1.7.4.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
> Cheers,
> --
> Vinicius
>
--
--
Claudio Takahasi
Instituto Nokia de Tecnologia
Recife - Pernambuco - Brasil
+55 81 30879999
^ permalink raw reply
* Re: [PATCH 1/9] Register primary services exported over basic rate
From: Vinicius Costa Gomes @ 2011-04-07 17:58 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
In-Reply-To: <1302197414-833-1-git-send-email-claudio.takahasi@openbossa.org>
Hi Claudio,
On 14:30 Thu 07 Apr, Claudio Takahasi wrote:
> This patch registers the object paths for primary services exported
> through SDP. PSM, start and end handle information are available in
> the Protocol Descriptor List.
> ---
> src/device.c | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 files changed, 129 insertions(+), 1 deletions(-)
>
> diff --git a/src/device.c b/src/device.c
> index d567952..32eb643 100644
> --- a/src/device.c
> +++ b/src/device.c
> @@ -1367,6 +1367,127 @@ static void create_device_reply(struct btd_device *device, struct browse_req *re
> g_dbus_send_message(req->conn, reply);
> }
>
> +static sdp_data_t *proto_seq_find(sdp_list_t *proto_list)
> +{
> + sdp_list_t *list;
> + uuid_t proto;
> +
> + sdp_uuid16_create(&proto, ATT_UUID);
> +
> + for (;list = proto_list, list; list = list->next) {
The first ";" doesn't look right.
> + sdp_list_t *p;
> + for (p = list->data; p; p = p->next) {
> + sdp_data_t *seq = p->data;
> + if (seq && seq->dtd == SDP_UUID16 &&
> + sdp_uuid16_cmp(&proto, &seq->val.uuid) == 0)
> + return seq->next;
> + }
> + }
> +
> + return NULL;
> +}
> +
> +static gboolean parse_proto_params(sdp_list_t *proto_list, uint16_t *psm,
> + uint16_t *start, uint16_t *end)
> +{
> + sdp_data_t *seq1, *seq2;
> +
> + if (psm)
> + *psm = sdp_get_proto_port(proto_list, L2CAP_UUID);
> +
> + /* Getting start and end handle */
> + seq1 = proto_seq_find(proto_list);
> + if (!seq1 || seq1->dtd != SDP_UINT16)
> + return FALSE;
> +
> + seq2 = seq1->next;
> + if (!seq2 || seq2->dtd != SDP_UINT16)
> + return FALSE;
> +
> + if (start)
> + *start = seq1->val.uint16;
> +
> + if (end)
> + *end = seq2->val.uint16;
> +
> + return TRUE;
> +}
> +
> +static gboolean parse_primary_record(const sdp_record_t *rec,
> + uuid_t *prim_uuid, uint16_t *psm,
> + uint16_t *start, uint16_t *end)
> +{
> + sdp_list_t *list;
> + uuid_t uuid;
> + gboolean ret;
> +
> + if (sdp_get_service_classes(rec, &list) < 0)
> + return FALSE;
> +
> + memcpy(&uuid, list->data, sizeof(uuid));
> + sdp_list_free(list, free);
> +
> + if (sdp_get_access_protos(rec, &list) < 0)
> + return FALSE;
> +
> + ret = parse_proto_params(list, psm, start, end);
> +
> + sdp_list_foreach(list, (sdp_list_func_t) sdp_list_free, NULL);
> + sdp_list_free(list, NULL);
> +
> + if (ret && prim_uuid)
> + memcpy(prim_uuid, &uuid, sizeof(uuid_t));
> +
> + return ret;
> +}
> +
> +static GSList *primary_from_record(struct btd_device *device, GSList *profiles)
> +{
> + GSList *l, *prim_list = NULL;
> + char *att_uuid;
> + uuid_t proto_uuid;
> +
> + sdp_uuid16_create(&proto_uuid, ATT_UUID);
> + att_uuid = bt_uuid2string(&proto_uuid);
> +
> + for (l = profiles; l; l = l->next) {
> + const char *profile_uuid = l->data;
> + const sdp_record_t *rec;
> + struct att_primary *prim;
> + uint16_t start = 0, end = 0, psm = 0;
> + uuid_t prim_uuid;
> +
> + rec = btd_device_get_record(device, profile_uuid);
> + if (!rec)
> + continue;
> +
> + if (!record_has_uuid(rec, att_uuid))
> + continue;
> +
> + if (!parse_primary_record(rec, &prim_uuid, &psm, &start, &end))
> + continue;
> +
> + prim = g_new0(struct att_primary, 1);
> + prim->start = start;
> + prim->end = end;
> + sdp_uuid2strn(&prim_uuid, prim->uuid, sizeof(prim->uuid));
> +
> + prim_list = g_slist_append(prim_list, prim);
> + }
> +
> + g_free(att_uuid);
> +
> + return prim_list;
> +}
> +
> +static void register_primary_services(DBusConnection *conn,
> + struct btd_device *device, GSList *prim_list)
> +{
> + /* TODO: PSM is hardcoded */
> + attrib_client_register(conn, device, 31, NULL, prim_list);
> + device->primaries = g_slist_concat(device->primaries, prim_list);
> +}
> +
> static void search_cb(sdp_list_t *recs, int err, gpointer user_data)
> {
> struct browse_req *req = user_data;
> @@ -1396,9 +1517,16 @@ static void search_cb(sdp_list_t *recs, int err, gpointer user_data)
> }
>
> /* Probe matching drivers for services added */
> - if (req->profiles_added)
> + if (req->profiles_added) {
> + GSList *list;
> +
> device_probe_drivers(device, req->profiles_added);
>
> + list = primary_from_record(device, req->profiles_added);
> + if (list)
> + register_primary_services(req->conn, device, list);
> + }
> +
> /* Remove drivers for services removed */
> if (req->profiles_removed)
> device_remove_drivers(device, req->profiles_removed);
> --
> 1.7.4.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Cheers,
--
Vinicius
^ permalink raw reply
* [PATCH] Add temporary workaround to skip wrong OMTU for basic rate
From: Claudio Takahasi @ 2011-04-07 17:31 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
This patch is required until MTU kernel patch is not integrated. Kernel
is returning zero for basic rate OMTU.
---
attrib/gattrib.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 290cd96..8c15e52 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -409,7 +409,7 @@ GAttrib *g_attrib_new(GIOChannel *io)
if (bt_io_get(attrib->io, BT_IO_L2CAP, NULL,
BT_IO_OPT_OMTU, &omtu,
BT_IO_OPT_INVALID)) {
- if (omtu > ATT_MAX_MTU)
+ if (omtu == 0 || omtu > ATT_MAX_MTU)
omtu = ATT_MAX_MTU;
} else
omtu = ATT_DEFAULT_LE_MTU;
--
1.7.4.1
^ permalink raw reply related
* [PATCH 9/9] TODO: Add hard-coded PSM for GATT over basic rate
From: Claudio Takahasi @ 2011-04-07 17:30 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1302197414-833-1-git-send-email-claudio.takahasi@openbossa.org>
---
TODO | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/TODO b/TODO
index 461b179..fab3ec0 100644
--- a/TODO
+++ b/TODO
@@ -136,6 +136,11 @@ ATT/GATT
Priority: Medium
Complexity: C1
+- Fix hard-coded PSM for GATT services over basic rate.
+
+ Priority: Low
+ Complexity: C1
+
- Refactor read_by_group() and read_by_type() in src/attrib-server.c
(they've grown simply too big). First step could be to move out the
long for-loops to new functions called e.g. get_groups() and get_types().
--
1.7.4.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox