* [PATCH v4 0/5] Support for OOB in mgmt interface
From: Szymon Janc @ 2011-03-21 15:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, henrik.possung, Szymon Janc
Changes since v3:
- fix missing break in switch-case in hci_event_packet()
- remove some not needed empty lines in hci.h
BR,
Szymon Janc
on behalf of ST-Ericsson
Szymon Janc (5):
Bluetooth: Rename cmd to param in pending_cmd
Bluetooth: Allow for NULL data in mgmt_pending_add
Bluetooth: Add read_local_oob_data management command
Bluetooth: Add add/remove_remote_oob_data management commands
Bluetooth: Enable support for out of band association model
include/net/bluetooth/hci.h | 24 +++++
include/net/bluetooth/hci_core.h | 18 ++++
include/net/bluetooth/mgmt.h | 18 ++++
net/bluetooth/hci_core.c | 67 +++++++++++++++
net/bluetooth/hci_event.c | 57 ++++++++++++-
net/bluetooth/mgmt.c | 175 ++++++++++++++++++++++++++++++++++++--
6 files changed, 351 insertions(+), 8 deletions(-)
^ permalink raw reply
* [PATCH] Add release all sessions when adapter is switched off
From: Dmitriy Paliy @ 2011-03-21 15:39 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Dmitriy Paliy
All sessions should be released when adapter is switched off. Then a new
RequestSession method call always results in change from power off to power
on such ensuring operational mode. Otherwise, it is possible to end up in
adapter state being powered off after RequestSession succeded.
---
src/adapter.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index cc4f43e..f1c0e2a 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2507,6 +2507,10 @@ static void set_mode_complete(struct btd_adapter *adapter)
DBG("");
+ if (adapter->mode == MODE_OFF)
+ g_slist_foreach(adapter->mode_sessions, (GFunc) session_free,
+ NULL);
+
if (adapter->pending_mode == NULL)
return;
--
1.7.1
^ permalink raw reply related
* Re: [PATCH v3 4/5] Bluetooth: Add add/remove_remote_oob_data management commands
From: Szymon Janc @ 2011-03-21 14:42 UTC (permalink / raw)
To: Vinicius Costa Gomes
Cc: linux-bluetooth@vger.kernel.org,
par-gunnar.p.hjalmdahl@stericsson.com,
henrik.possung@stericsson.com
In-Reply-To: <20110321142639.GA2685@piper>
> Hi Szymon,
Hi Vinicius,
> > static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
> > {
> > struct hci_ev_le_conn_complete *ev = (void *) skb->data;
> > @@ -2673,6 +2704,9 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
> >
> > case HCI_EV_LE_META:
> > hci_le_meta_evt(hdev, skb);
> > +
>
> Looks like you are missing a "break" here.
Thanks for spotting this, will send v4 soon.
> Cheers,
BR,
Szymon Janc
^ permalink raw reply
* Re: [PATCH v3 4/5] Bluetooth: Add add/remove_remote_oob_data management commands
From: Vinicius Costa Gomes @ 2011-03-21 14:26 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth, par-gunnar.p.hjalmdahl, henrik.possung
In-Reply-To: <1300712821-23172-5-git-send-email-szymon.janc@tieto.com>
Hi Szymon,
On 14:07 Mon 21 Mar, Szymon Janc wrote:
> This patch adds commands to add and remove remote OOB data to the managment
> interface. Remote data is stored in kernel and can be used by corresponding
> HCI commands and events when needed.
>
> Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
> ---
> include/net/bluetooth/hci.h | 19 ++++++++++
> include/net/bluetooth/hci_core.h | 16 ++++++++
> include/net/bluetooth/mgmt.h | 12 ++++++
> net/bluetooth/hci_core.c | 67 ++++++++++++++++++++++++++++++++++
> net/bluetooth/hci_event.c | 34 +++++++++++++++++
> net/bluetooth/mgmt.c | 75 ++++++++++++++++++++++++++++++++++++++
> 6 files changed, 223 insertions(+), 0 deletions(-)
>
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 0ac0804..8c71e88 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -428,6 +428,20 @@ struct hci_rp_user_confirm_reply {
>
> #define HCI_OP_USER_CONFIRM_NEG_REPLY 0x042d
>
> +
> +#define HCI_OP_REMOTE_OOB_DATA_REPLY 0x0430
> +struct hci_cp_remote_oob_data_reply {
> + bdaddr_t bdaddr;
> + __u8 hash[16];
> + __u8 randomizer[16];
> +} __packed;
> +
> +#define HCI_OP_REMOTE_OOB_DATA_NEG_REPLY 0x0433
> +struct hci_cp_remote_oob_data_neg_reply {
> + bdaddr_t bdaddr;
> +} __packed;
> +
> +
> #define HCI_OP_IO_CAPABILITY_NEG_REPLY 0x0434
> struct hci_cp_io_capability_neg_reply {
> bdaddr_t bdaddr;
> @@ -964,6 +978,11 @@ struct hci_ev_user_confirm_req {
> __le32 passkey;
> } __packed;
>
> +#define HCI_EV_REMOTE_OOB_DATA_REQUEST 0x35
> +struct hci_ev_remote_oob_data_request {
> + bdaddr_t bdaddr;
> +} __packed;
> +
> #define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36
> struct hci_ev_simple_pair_complete {
> __u8 status;
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index fd9b8a3..87bff51 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -82,6 +82,13 @@ struct link_key {
> u8 pin_len;
> };
>
> +struct oob_data {
> + struct list_head list;
> + bdaddr_t bdaddr;
> + u8 hash[16];
> + u8 randomizer[16];
> +};
> +
> #define NUM_REASSEMBLY 4
> struct hci_dev {
> struct list_head list;
> @@ -169,6 +176,8 @@ struct hci_dev {
>
> struct list_head link_keys;
>
> + struct list_head remote_oob_data;
> +
> struct hci_dev_stats stat;
>
> struct sk_buff_head driver_init;
> @@ -505,6 +514,13 @@ int hci_add_link_key(struct hci_dev *hdev, int new_key, bdaddr_t *bdaddr,
> u8 *key, u8 type, u8 pin_len);
> int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);
>
> +int hci_remote_oob_data_clear(struct hci_dev *hdev);
> +struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev,
> + bdaddr_t *bdaddr);
> +int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash,
> + u8 *randomizer);
> +int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr);
> +
> void hci_del_off_timer(struct hci_dev *hdev);
>
> void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
> diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
> index 6ebb126..1a6283f 100644
> --- a/include/net/bluetooth/mgmt.h
> +++ b/include/net/bluetooth/mgmt.h
> @@ -183,6 +183,18 @@ struct mgmt_rp_read_local_oob_data {
> __u8 randomizer[16];
> } __packed;
>
> +#define MGMT_OP_ADD_REMOTE_OOB_DATA 0x0019
> +struct mgmt_cp_add_remote_oob_data {
> + bdaddr_t bdaddr;
> + __u8 hash[16];
> + __u8 randomizer[16];
> +} __packed;
> +
> +#define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x001A
> +struct mgmt_cp_remove_remote_oob_data {
> + bdaddr_t bdaddr;
> +} __packed;
> +
> #define MGMT_EV_CMD_COMPLETE 0x0001
> struct mgmt_ev_cmd_complete {
> __le16 opcode;
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 1f11fe3..1fa9ce5 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -1080,6 +1080,70 @@ static void hci_cmd_timer(unsigned long arg)
> tasklet_schedule(&hdev->cmd_task);
> }
>
> +struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev,
> + bdaddr_t *bdaddr)
> +{
> + struct oob_data *data;
> +
> + list_for_each_entry(data, &hdev->remote_oob_data, list)
> + if (bacmp(bdaddr, &data->bdaddr) == 0)
> + return data;
> +
> + return NULL;
> +}
> +
> +int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr)
> +{
> + struct oob_data *data;
> +
> + data = hci_find_remote_oob_data(hdev, bdaddr);
> + if (!data)
> + return -ENOENT;
> +
> + BT_DBG("%s removing %s", hdev->name, batostr(bdaddr));
> +
> + list_del(&data->list);
> + kfree(data);
> +
> + return 0;
> +}
> +
> +int hci_remote_oob_data_clear(struct hci_dev *hdev)
> +{
> + struct oob_data *data, *n;
> +
> + list_for_each_entry_safe(data, n, &hdev->remote_oob_data, list) {
> + list_del(&data->list);
> + kfree(data);
> + }
> +
> + return 0;
> +}
> +
> +int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash,
> + u8 *randomizer)
> +{
> + struct oob_data *data;
> +
> + data = hci_find_remote_oob_data(hdev, bdaddr);
> +
> + if (!data) {
> + data = kmalloc(sizeof(*data), GFP_ATOMIC);
> + if (!data)
> + return -ENOMEM;
> +
> + bacpy(&data->bdaddr, bdaddr);
> + list_add(&data->list, &hdev->remote_oob_data);
> + }
> +
> + memcpy(data->hash, hash, 16);
> + memcpy(data->randomizer, randomizer, 16);
> +
> + BT_DBG("%s for %s", hdev->name, batostr(bdaddr));
> +
> + return 0;
> +}
> +
> /* Register HCI device */
> int hci_register_dev(struct hci_dev *hdev)
> {
> @@ -1144,6 +1208,8 @@ int hci_register_dev(struct hci_dev *hdev)
>
> INIT_LIST_HEAD(&hdev->link_keys);
>
> + INIT_LIST_HEAD(&hdev->remote_oob_data);
> +
> INIT_WORK(&hdev->power_on, hci_power_on);
> INIT_WORK(&hdev->power_off, hci_power_off);
> setup_timer(&hdev->off_timer, hci_auto_off, (unsigned long) hdev);
> @@ -1223,6 +1289,7 @@ int hci_unregister_dev(struct hci_dev *hdev)
> hci_blacklist_clear(hdev);
> hci_uuids_clear(hdev);
> hci_link_keys_clear(hdev);
> + hci_remote_oob_data_clear(hdev);
> hci_dev_unlock_bh(hdev);
>
> __hci_dev_put(hdev);
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index 0223b38..fba5998 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -2473,6 +2473,37 @@ static inline void hci_remote_host_features_evt(struct hci_dev *hdev, struct sk_
> hci_dev_unlock(hdev);
> }
>
> +static inline void hci_remote_oob_data_request_evt(struct hci_dev *hdev,
> + struct sk_buff *skb)
> +{
> + struct hci_ev_remote_oob_data_request *ev = (void *) skb->data;
> + struct oob_data *data;
> +
> + BT_DBG("%s", hdev->name);
> +
> + hci_dev_lock(hdev);
> +
> + data = hci_find_remote_oob_data(hdev, &ev->bdaddr);
> + if (data) {
> + struct hci_cp_remote_oob_data_reply cp;
> +
> + bacpy(&cp.bdaddr, &ev->bdaddr);
> + memcpy(cp.hash, data->hash, 16);
> + memcpy(cp.randomizer, data->randomizer, 16);
> +
> + hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_DATA_REPLY, sizeof(cp),
> + &cp);
> + } else {
> + struct hci_cp_remote_oob_data_neg_reply cp;
> +
> + bacpy(&cp.bdaddr, &ev->bdaddr);
> + hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_DATA_NEG_REPLY, sizeof(cp),
> + &cp);
> + }
> +
> + hci_dev_unlock(hdev);
> +}
> +
> static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
> {
> struct hci_ev_le_conn_complete *ev = (void *) skb->data;
> @@ -2673,6 +2704,9 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
>
> case HCI_EV_LE_META:
> hci_le_meta_evt(hdev, skb);
> +
Looks like you are missing a "break" here.
> + case HCI_EV_REMOTE_OOB_DATA_REQUEST:
> + hci_remote_oob_data_request_evt(hdev, skb);
> break;
>
> default:
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index a72cbf6..46c96b3 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -1349,6 +1349,74 @@ unlock:
> return err;
> }
>
> +static int add_remote_oob_data(struct sock *sk, u16 index, unsigned char *data,
> + u16 len)
> +{
> + struct hci_dev *hdev;
> + struct mgmt_cp_add_remote_oob_data *cp = (void *) data;
> + int err;
> +
> + BT_DBG("hci%u ", index);
> +
> + if (len != sizeof(*cp))
> + return cmd_status(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA,
> + EINVAL);
> +
> + hdev = hci_dev_get(index);
> + if (!hdev)
> + return cmd_status(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA,
> + ENODEV);
> +
> + hci_dev_lock_bh(hdev);
> +
> + err = hci_add_remote_oob_data(hdev, &cp->bdaddr, cp->hash,
> + cp->randomizer);
> + if (err < 0)
> + err = cmd_status(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, -err);
> + else
> + err = cmd_complete(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, NULL,
> + 0);
> +
> + hci_dev_unlock_bh(hdev);
> + hci_dev_put(hdev);
> +
> + return err;
> +}
> +
> +static int remove_remote_oob_data(struct sock *sk, u16 index,
> + unsigned char *data, u16 len)
> +{
> + struct hci_dev *hdev;
> + struct mgmt_cp_remove_remote_oob_data *cp = (void *)data;
> + int err;
> +
> + BT_DBG("hci%u ", index);
> +
> + if (len != sizeof(*cp))
> + return cmd_status(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA,
> + EINVAL);
> +
> + hdev = hci_dev_get(index);
> + if (!hdev)
> + return cmd_status(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA,
> + ENODEV);
> +
> + hci_dev_lock_bh(hdev);
> +
> + err = hci_remove_remote_oob_data(hdev, &cp->bdaddr);
> + if (err < 0)
> + err = cmd_status(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA,
> + -err);
> + else
> + err = cmd_complete(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA,
> + NULL, 0);
> +
> + hci_dev_unlock_bh(hdev);
> + hci_dev_put(hdev);
> +
> + return err;
> +}
> +
> int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
> {
> unsigned char *buf;
> @@ -1450,6 +1518,13 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
> case MGMT_OP_READ_LOCAL_OOB_DATA:
> err = read_local_oob_data(sk, index);
> break;
> + case MGMT_OP_ADD_REMOTE_OOB_DATA:
> + err = add_remote_oob_data(sk, index, buf + sizeof(*hdr), len);
> + break;
> + case MGMT_OP_REMOVE_REMOTE_OOB_DATA:
> + err = remove_remote_oob_data(sk, index, buf + sizeof(*hdr),
> + len);
> + break;
>
> default:
> BT_DBG("Unknown op %u", opcode);
> --
> 1.7.0.4
>
> --
> 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
* crash in rfcomm_check_security()
From: Vitaly Wool @ 2011-03-21 13:58 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org
Hi,
I experienced a kernel crash while downloading pictures using OPP to my device.
The crash turned out to happen in rfcomm_recv_sabm():
/* Notify socket layer about incoming connection */
channel = __srv_channel(dlci);
if (rfcomm_connect_ind(s, channel, &d)) {
d->dlci = dlci;
d->addr = __addr(s->initiator, dlci);
rfcomm_dlc_link(s, d);
rfcomm_check_accept(d); <--- crash point!
} else {
rfcomm_send_dm(s, dlci);
}
Effectively it was the rfcomm_check_security() that crashed because
hci_conn_security(l2cap_pi(sk)->conn was NULL at the moment so
dereferencing it resulted in the crash.
As far as I can see, the flow was the following:
rfcomm_run()
rfcomm_process_sessions()
rfcomm_process_rx()
rfcomm_recv_frame() <-- l2cap_sock_timeout() happens around here
rfcomm_recv_sabm()
rfcomm_check_accept()
rfcomm_check_security()
I verified that session->sock->sk->state == BT_CLOSED and it confirms
the fact that there was a race between processing received frame in a
separate thread (with some latency then, of course) and sock timeout
which is processed almost immediately.
So the basic question is, how to handle that? Is it okay to just add a
NULL check in rfcomm_check_security() and hope it'll get sorted out on
its own? Or should there be an attempt to rewrite the whole sock
timeout handling so that it's race-free?
Thanks,
Vitaly
^ permalink raw reply
* Re: accessing Link key within the Bluetooth module
From: Johan Hedberg @ 2011-03-21 13:48 UTC (permalink / raw)
To: Suraj Sumangala; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <4D870E6F.4050502@Atheros.com>
Hi Suraj,
On Mon, Mar 21, 2011, Suraj Sumangala wrote:
> I am working on a Bluetooth AMP manager module (linked to l2cap
> module) that require access to the Link key of the connected(paired)
> device.
>
> I am trying to use the hci_find_link_key() call with the BDADDR of
> the remote device as parameter without success. It looks like the
> list "hci_dev.link_keys" is not getting populated in the first
> place.
That list only gets populated if you've enabled the management interface
(enable_mgmt=1 module option) and have a matching user space version
with management interface support.
Johan
^ permalink raw reply
* Re: [RFC] Auto Connections
From: Claudio Takahasi @ 2011-03-21 13:26 UTC (permalink / raw)
To: Arun K. Singh; +Cc: BlueZ development, Ville Tervo, Gustavo F. Padovan
In-Reply-To: <AANLkTinVZEW7WrkTRP-cjxrgk8xy=QLgNE2WX0BF+aoC@mail.gmail.com>
Hi Arun,
On Mon, Mar 21, 2011 at 10:55 AM, Arun K. Singh <arunkat@gmail.com> wrote:
> Hi Claudio,
>
>
>>
>> >> It is time to get opinions from some gurus!
>> >>
>> >> We need to implement automatic connections to implement the Profiles.
>> >> At the moment BlueZ supports only dual mode adapters, as consequence
>> >> BlueZ needs to start the LE connection. IMHO, it is better to leave
>> >> the responsibility to the controller, implementing "selective"
>> >> connections will only introduce more code without concrete benefits.
>> >> Configuring the controller to autonomously establish connections seems
>> >> to be the right approach to proceed.
>> >>
>> >> This topic is NOT about StartDiscovery() + CreateDevice.
>> >> StartDiscovery uses active scanning and CreateDevice uses direct
>> >> connection establishment. We need a mechanism to automatically connect
>> >> to "trusted" devices or devices flagged as "AutoConnect".
>> >>
>> >>
>> >> My initial idea is: change the LE server socket to report
>> >> outgoing(host initiated) connections through the server socket.
>> >> Awkward?
>> >> To achieve that we need to manage the LE Create Connection(using
>> >> whitelist) in the kernel, extend the management interface to control
>> >> devices in the whitelist, change the LE Connection Complete Event
>> >> handling to get the Role properly.
>> >> Pros:
>> >> - Controller manage connections
>> >> - Flexible to support connections to "trusted" resolvable address and
>> >> passive scanning
>> >> - Only one "flow" for the connections: LE server socket
>> >> - Maybe we could hide resolvable address from the userspace, mapping
>> >> it directly to public or static random
>> >
>> > This approach have a lot of advantages. It seems the best option to me.
>> >
>> >> Cons:
>> >> - Risky
>> >
>> > Define risky here.
>> More code in the kernel, more time to get the code upstream,
>> additional verification to avoid insufficient resources when scanning
>> and connecting, but to me it seems the best approach.
>>
>> to Jaikumar:
>> The profiles will indirectly manage the connections providing
>> informations such as connection parameters(interval, window, ...) and
>> addresses, but the kernel needs to centralize/manage the connections.
>
>
> As per section 9.3.8, a host can still perform direct connection
> establishment procedure
> by telling controller to "ignore the White List and process connectable
> advertising
> packets from a specific single device specified by the Host". Wouldn't this
> be same
> as letting the host[read profiles] directly manage connections?
There are four Connection Establishment Procedures: Auto, General,
Selective and Direct.
CreateDevice/CreatePairedDevice will use Direct. But after pairing or
create device("known" devices) we need a more transparent procedure. I
am not saying that we will implement straitly Auto procedure, we will
also need to handle the resolvable address, a hybrid approach seems to
be more appropriated.
We could use Direct procedure, managing(serializing) the connection
establishment implementing logic in the kernel or userspace for the
"known" devices. However, I prefer to transfer the responsibility to
the controller. If I choose connections using whitelist, how the STE
controller prioritizes the advertises? Does directed advertises have a
higher priority?
>
>
>> We can't allow the profiles to control the connection directly, a
>> remote can implement more than one profile, maybe with different
>> constraints.
>
> under direct connection establishment procedure, it should be possible for a
> host
> to establish connection with a remote peer device with host selected
> connection
> configurable parameters. Why should we deprive a bluez host of establishing
> such a connection...
> Or did I miss something here?
At API level, what is the benefit of exposing this option to the API users?
Some profiles define the recommended connection parameters, there is
also the Slave Connection Interval Range AD type that may be used to
in the connection establishment.
BR,
Claudio
>
>
>
> Thanks,
> Arun
>
>
^ permalink raw reply
* [PATCH 10/10] Bluetooth: Use kthread API in cmtp
From: Szymon Janc @ 2011-03-21 13:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, henrik.possung, Szymon Janc
In-Reply-To: <1300713606-23523-1-git-send-email-szymon.janc@tieto.com>
kernel_thread() is a low-level implementation detail and
EXPORT_SYMBOL(kernel_thread) is scheduled for removal.
Use the <linux/kthread.h> API instead.
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
---
net/bluetooth/cmtp/capi.c | 6 +++---
net/bluetooth/cmtp/cmtp.h | 9 +--------
net/bluetooth/cmtp/core.c | 16 +++++++++-------
3 files changed, 13 insertions(+), 18 deletions(-)
diff --git a/net/bluetooth/cmtp/capi.c b/net/bluetooth/cmtp/capi.c
index 67cff81..744233c 100644
--- a/net/bluetooth/cmtp/capi.c
+++ b/net/bluetooth/cmtp/capi.c
@@ -35,6 +35,7 @@
#include <linux/ioctl.h>
#include <linux/file.h>
#include <linux/wait.h>
+#include <linux/kthread.h>
#include <net/sock.h>
#include <linux/isdn/capilli.h>
@@ -143,7 +144,7 @@ static void cmtp_send_capimsg(struct cmtp_session *session, struct sk_buff *skb)
skb_queue_tail(&session->transmit, skb);
- cmtp_schedule(session);
+ wake_up_interruptible(sk_sleep(session->sock->sk));
}
static void cmtp_send_interopmsg(struct cmtp_session *session,
@@ -386,8 +387,7 @@ static void cmtp_reset_ctr(struct capi_ctr *ctrl)
capi_ctr_down(ctrl);
- atomic_inc(&session->terminate);
- cmtp_schedule(session);
+ kthread_stop(session->task);
}
static void cmtp_register_appl(struct capi_ctr *ctrl, __u16 appl, capi_register_params *rp)
diff --git a/net/bluetooth/cmtp/cmtp.h b/net/bluetooth/cmtp/cmtp.h
index c6f78f8..db43b54 100644
--- a/net/bluetooth/cmtp/cmtp.h
+++ b/net/bluetooth/cmtp/cmtp.h
@@ -81,7 +81,7 @@ struct cmtp_session {
char name[BTNAMSIZ];
- atomic_t terminate;
+ struct task_struct *task;
wait_queue_head_t wait;
@@ -121,13 +121,6 @@ void cmtp_detach_device(struct cmtp_session *session);
void cmtp_recv_capimsg(struct cmtp_session *session, struct sk_buff *skb);
-static inline void cmtp_schedule(struct cmtp_session *session)
-{
- struct sock *sk = session->sock->sk;
-
- wake_up_interruptible(sk_sleep(sk));
-}
-
/* CMTP init defines */
int cmtp_init_sockets(void);
void cmtp_cleanup_sockets(void);
diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c
index 16aa6bd..cce99b0 100644
--- a/net/bluetooth/cmtp/core.c
+++ b/net/bluetooth/cmtp/core.c
@@ -35,6 +35,7 @@
#include <linux/ioctl.h>
#include <linux/file.h>
#include <linux/init.h>
+#include <linux/kthread.h>
#include <net/sock.h>
#include <linux/isdn/capilli.h>
@@ -287,12 +288,11 @@ static int cmtp_session(void *arg)
BT_DBG("session %p", session);
- daemonize("kcmtpd_ctr_%d", session->num);
set_user_nice(current, -15);
init_waitqueue_entry(&wait, current);
add_wait_queue(sk_sleep(sk), &wait);
- while (!atomic_read(&session->terminate)) {
+ while (!kthread_should_stop()) {
set_current_state(TASK_INTERRUPTIBLE);
if (sk->sk_state != BT_CONNECTED)
@@ -370,9 +370,12 @@ int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock)
__cmtp_link_session(session);
- err = kernel_thread(cmtp_session, session, CLONE_KERNEL);
- if (err < 0)
+ session->task = kthread_run(cmtp_session, session, "kcmtpd_ctr_%d",
+ session->num);
+ if (IS_ERR(session->task)) {
+ err = PTR_ERR(session->task);
goto unlink;
+ }
if (!(session->flags & (1 << CMTP_LOOPBACK))) {
err = cmtp_attach_device(session);
@@ -409,9 +412,8 @@ int cmtp_del_connection(struct cmtp_conndel_req *req)
/* Flush the transmit queue */
skb_queue_purge(&session->transmit);
- /* Kill session thread */
- atomic_inc(&session->terminate);
- cmtp_schedule(session);
+ /* Stop session thread */
+ kthread_stop(session->task);
} else
err = -ENOENT;
--
1.7.0.4
^ permalink raw reply related
* [PATCH 09/10] Bluetooth: Fix checkpatch error in cmtp.h
From: Szymon Janc @ 2011-03-21 13:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, henrik.possung, Szymon Janc
In-Reply-To: <1300713606-23523-1-git-send-email-szymon.janc@tieto.com>
Do not use C99 // comments.
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
---
net/bluetooth/cmtp/cmtp.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/net/bluetooth/cmtp/cmtp.h b/net/bluetooth/cmtp/cmtp.h
index 785e79e..c6f78f8 100644
--- a/net/bluetooth/cmtp/cmtp.h
+++ b/net/bluetooth/cmtp/cmtp.h
@@ -37,7 +37,7 @@
#define CMTP_LOOPBACK 0
struct cmtp_connadd_req {
- int sock; // Connected socket
+ int sock; /* Connected socket */
__u32 flags;
};
--
1.7.0.4
^ permalink raw reply related
* [PATCH 08/10] Bluetooth: Use #include <linux/uaccess.h> instead of <asm/uaccess.h>
From: Szymon Janc @ 2011-03-21 13:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, henrik.possung, Szymon Janc
In-Reply-To: <1300713606-23523-1-git-send-email-szymon.janc@tieto.com>
As warned by checkpatch.pl, use #include <linux/uaccess.h> instead of
<asm/uaccess.h>
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
---
net/bluetooth/cmtp/sock.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/net/bluetooth/cmtp/sock.c b/net/bluetooth/cmtp/sock.c
index 7ea1979..3f2dd5c 100644
--- a/net/bluetooth/cmtp/sock.c
+++ b/net/bluetooth/cmtp/sock.c
@@ -34,12 +34,12 @@
#include <linux/file.h>
#include <linux/compat.h>
#include <linux/gfp.h>
+#include <linux/uaccess.h>
#include <net/sock.h>
#include <linux/isdn/capilli.h>
#include <asm/system.h>
-#include <asm/uaccess.h>
#include "cmtp.h"
--
1.7.0.4
^ permalink raw reply related
* [PATCH 07/10] Bluetooth: Do not use assignments in IF conditions
From: Szymon Janc @ 2011-03-21 13:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, henrik.possung, Szymon Janc
In-Reply-To: <1300713606-23523-1-git-send-email-szymon.janc@tieto.com>
Fix checkpatch warnings concerning assignments in if conditions.
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
---
net/bluetooth/cmtp/core.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c
index 964ea91..16aa6bd 100644
--- a/net/bluetooth/cmtp/core.c
+++ b/net/bluetooth/cmtp/core.c
@@ -235,9 +235,12 @@ static void cmtp_process_transmit(struct cmtp_session *session)
size = min_t(uint, ((tail < 258) ? (tail - 2) : (tail - 3)), skb->len);
- if ((scb->id < 0) && ((scb->id = cmtp_alloc_block_id(session)) < 0)) {
- skb_queue_head(&session->transmit, skb);
- break;
+ if (scb->id < 0) {
+ scb->id = cmtp_alloc_block_id(session);
+ if (scb->id < 0) {
+ skb_queue_head(&session->transmit, skb);
+ break;
+ }
}
if (size < 256) {
--
1.7.0.4
^ permalink raw reply related
* [PATCH 06/10] Bluetooth: Use kthread API in hidp
From: Szymon Janc @ 2011-03-21 13:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, henrik.possung, Szymon Janc
In-Reply-To: <1300713606-23523-1-git-send-email-szymon.janc@tieto.com>
kernel_thread() is a low-level implementation detail and
EXPORT_SYMBOL(kernel_thread) is scheduled for removal.
Use the <linux/kthread.h> API instead.
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
---
net/bluetooth/hidp/core.c | 49 ++++++++++++++++++++------------------------
net/bluetooth/hidp/hidp.h | 2 +-
2 files changed, 23 insertions(+), 28 deletions(-)
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index ba546d4..f61aa80 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -36,6 +36,7 @@
#include <linux/file.h>
#include <linux/init.h>
#include <linux/wait.h>
+#include <linux/kthread.h>
#include <net/sock.h>
#include <linux/input.h>
@@ -342,8 +343,7 @@ static void hidp_idle_timeout(unsigned long arg)
{
struct hidp_session *session = (struct hidp_session *) arg;
- atomic_inc(&session->terminate);
- hidp_schedule(session);
+ kthread_stop(session->task);
}
static void hidp_set_timer(struct hidp_session *session)
@@ -402,9 +402,7 @@ static void hidp_process_hid_control(struct hidp_session *session,
skb_queue_purge(&session->ctrl_transmit);
skb_queue_purge(&session->intr_transmit);
- /* Kill session thread */
- atomic_inc(&session->terminate);
- hidp_schedule(session);
+ kthread_stop(session->task);
}
}
@@ -546,29 +544,17 @@ static int hidp_session(void *arg)
struct sock *ctrl_sk = session->ctrl_sock->sk;
struct sock *intr_sk = session->intr_sock->sk;
struct sk_buff *skb;
- int vendor = 0x0000, product = 0x0000;
wait_queue_t ctrl_wait, intr_wait;
BT_DBG("session %p", session);
- if (session->input) {
- vendor = session->input->id.vendor;
- product = session->input->id.product;
- }
-
- if (session->hid) {
- vendor = session->hid->vendor;
- product = session->hid->product;
- }
-
- daemonize("khidpd_%04x%04x", vendor, product);
set_user_nice(current, -15);
init_waitqueue_entry(&ctrl_wait, current);
init_waitqueue_entry(&intr_wait, current);
add_wait_queue(sk_sleep(ctrl_sk), &ctrl_wait);
add_wait_queue(sk_sleep(intr_sk), &intr_wait);
- while (!atomic_read(&session->terminate)) {
+ while (!kthread_should_stop()) {
set_current_state(TASK_INTERRUPTIBLE);
if (ctrl_sk->sk_state != BT_CONNECTED ||
@@ -821,6 +807,7 @@ fault:
int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, struct socket *intr_sock)
{
struct hidp_session *session, *s;
+ int vendor, product;
int err;
BT_DBG("");
@@ -878,9 +865,23 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
hidp_set_timer(session);
- err = kernel_thread(hidp_session, session, CLONE_KERNEL);
- if (err < 0)
+ if (session->hid) {
+ vendor = session->hid->vendor;
+ product = session->hid->product;
+ } else if (session->input) {
+ vendor = session->input->id.vendor;
+ product = session->input->id.product;
+ } else {
+ vendor = 0x0000;
+ product = 0x0000;
+ }
+
+ session->task = kthread_run(hidp_session, session, "khidpd_%04x%04x",
+ vendor, product);
+ if (IS_ERR(session->task)) {
+ err = PTR_ERR(session->task);
goto unlink;
+ }
if (session->input) {
hidp_send_ctrl_message(session,
@@ -943,13 +944,7 @@ int hidp_del_connection(struct hidp_conndel_req *req)
skb_queue_purge(&session->ctrl_transmit);
skb_queue_purge(&session->intr_transmit);
- /* Wakeup user-space polling for socket errors */
- session->intr_sock->sk->sk_err = EUNATCH;
- session->ctrl_sock->sk->sk_err = EUNATCH;
-
- /* Kill session thread */
- atomic_inc(&session->terminate);
- hidp_schedule(session);
+ kthread_stop(session->task);
}
} else
err = -ENOENT;
diff --git a/net/bluetooth/hidp/hidp.h b/net/bluetooth/hidp/hidp.h
index 28bb9ce..8262acd 100644
--- a/net/bluetooth/hidp/hidp.h
+++ b/net/bluetooth/hidp/hidp.h
@@ -140,7 +140,7 @@ struct hidp_session {
uint ctrl_mtu;
uint intr_mtu;
- atomic_t terminate;
+ struct task_struct *task;
unsigned char keys[8];
unsigned char leds;
--
1.7.0.4
^ permalink raw reply related
* [PATCH 05/10] Bluetooth: Fix checkpatch errors, code style issues and typos in hidp
From: Szymon Janc @ 2011-03-21 13:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, henrik.possung, Szymon Janc
In-Reply-To: <1300713606-23523-1-git-send-email-szymon.janc@tieto.com>
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
---
net/bluetooth/hidp/core.c | 37 ++++++++++++++++++++-----------------
net/bluetooth/hidp/hidp.h | 4 ++--
net/bluetooth/hidp/sock.c | 7 ++++---
3 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index 2429ca2..ba546d4 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -54,22 +54,24 @@ static DECLARE_RWSEM(hidp_session_sem);
static LIST_HEAD(hidp_session_list);
static unsigned char hidp_keycode[256] = {
- 0, 0, 0, 0, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38,
- 50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 2, 3,
- 4, 5, 6, 7, 8, 9, 10, 11, 28, 1, 14, 15, 57, 12, 13, 26,
- 27, 43, 43, 39, 40, 41, 51, 52, 53, 58, 59, 60, 61, 62, 63, 64,
- 65, 66, 67, 68, 87, 88, 99, 70,119,110,102,104,111,107,109,106,
- 105,108,103, 69, 98, 55, 74, 78, 96, 79, 80, 81, 75, 76, 77, 71,
- 72, 73, 82, 83, 86,127,116,117,183,184,185,186,187,188,189,190,
- 191,192,193,194,134,138,130,132,128,129,131,137,133,135,136,113,
- 115,114, 0, 0, 0,121, 0, 89, 93,124, 92, 94, 95, 0, 0, 0,
- 122,123, 90, 91, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 29, 42, 56,125, 97, 54,100,126,164,166,165,163,161,115,114,113,
- 150,158,159,128,136,177,178,176,142,152,173,140
+ 0, 0, 0, 0, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36,
+ 37, 38, 50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45,
+ 21, 44, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 28, 1,
+ 14, 15, 57, 12, 13, 26, 27, 43, 43, 39, 40, 41, 51, 52,
+ 53, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 87, 88,
+ 99, 70, 119, 110, 102, 104, 111, 107, 109, 106, 105, 108, 103, 69,
+ 98, 55, 74, 78, 96, 79, 80, 81, 75, 76, 77, 71, 72, 73,
+ 82, 83, 86, 127, 116, 117, 183, 184, 185, 186, 187, 188, 189, 190,
+ 191, 192, 193, 194, 134, 138, 130, 132, 128, 129, 131, 137, 133, 135,
+ 136, 113, 115, 114, 0, 0, 0, 121, 0, 89, 93, 124, 92, 94,
+ 95, 0, 0, 0, 122, 123, 90, 91, 85, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 29, 42, 56, 125, 97, 54, 100, 126, 164, 166, 165, 163, 161, 115,
+ 114, 113, 150, 158, 159, 128, 136, 177, 178, 176, 142, 152, 173, 140
};
static unsigned char hidp_mkeyspat[] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 };
@@ -569,7 +571,8 @@ static int hidp_session(void *arg)
while (!atomic_read(&session->terminate)) {
set_current_state(TASK_INTERRUPTIBLE);
- if (ctrl_sk->sk_state != BT_CONNECTED || intr_sk->sk_state != BT_CONNECTED)
+ if (ctrl_sk->sk_state != BT_CONNECTED ||
+ intr_sk->sk_state != BT_CONNECTED)
break;
while ((skb = skb_dequeue(&ctrl_sk->sk_receive_queue))) {
diff --git a/net/bluetooth/hidp/hidp.h b/net/bluetooth/hidp/hidp.h
index 8d934a1..28bb9ce 100644
--- a/net/bluetooth/hidp/hidp.h
+++ b/net/bluetooth/hidp/hidp.h
@@ -82,8 +82,8 @@
#define HIDP_BLUETOOTH_VENDOR_ID 9
struct hidp_connadd_req {
- int ctrl_sock; // Connected control socket
- int intr_sock; // Connteted interrupt socket
+ int ctrl_sock; /* Connected control socket */
+ int intr_sock; /* Connected interrupt socket */
__u16 parser;
__u16 rd_size;
__u8 __user *rd_data;
diff --git a/net/bluetooth/hidp/sock.c b/net/bluetooth/hidp/sock.c
index 250dfd4..178ac7f 100644
--- a/net/bluetooth/hidp/sock.c
+++ b/net/bluetooth/hidp/sock.c
@@ -85,7 +85,8 @@ static int hidp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
return err;
}
- if (csock->sk->sk_state != BT_CONNECTED || isock->sk->sk_state != BT_CONNECTED) {
+ if (csock->sk->sk_state != BT_CONNECTED ||
+ isock->sk->sk_state != BT_CONNECTED) {
sockfd_put(csock);
sockfd_put(isock);
return -EBADFD;
@@ -140,8 +141,8 @@ static int hidp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
#ifdef CONFIG_COMPAT
struct compat_hidp_connadd_req {
- int ctrl_sock; // Connected control socket
- int intr_sock; // Connteted interrupt socket
+ int ctrl_sock; /* Connected control socket */
+ int intr_sock; /* Connected interrupt socket */
__u16 parser;
__u16 rd_size;
compat_uptr_t rd_data;
--
1.7.0.4
^ permalink raw reply related
* [PATCH 04/10] Bluetooth: Use kthread API in bnep
From: Szymon Janc @ 2011-03-21 13:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, henrik.possung, Szymon Janc
In-Reply-To: <1300713606-23523-1-git-send-email-szymon.janc@tieto.com>
kernel_thread() is a low-level implementation detail and
EXPORT_SYMBOL(kernel_thread) is scheduled for removal.
Use the <linux/kthread.h> API instead.
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
---
net/bluetooth/bnep/bnep.h | 2 +-
net/bluetooth/bnep/core.c | 21 ++++++++-------------
2 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/net/bluetooth/bnep/bnep.h b/net/bluetooth/bnep/bnep.h
index d768e04..8e6c061 100644
--- a/net/bluetooth/bnep/bnep.h
+++ b/net/bluetooth/bnep/bnep.h
@@ -155,7 +155,7 @@ struct bnep_session {
unsigned int role;
unsigned long state;
unsigned long flags;
- atomic_t killed;
+ struct task_struct *task;
struct ethhdr eh;
struct msghdr msg;
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index 0a2e76b..ca39fcf 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -36,6 +36,7 @@
#include <linux/errno.h>
#include <linux/net.h>
#include <linux/slab.h>
+#include <linux/kthread.h>
#include <net/sock.h>
#include <linux/socket.h>
@@ -479,12 +480,11 @@ static int bnep_session(void *arg)
BT_DBG("");
- daemonize("kbnepd %s", dev->name);
set_user_nice(current, -15);
init_waitqueue_entry(&wait, current);
add_wait_queue(sk_sleep(sk), &wait);
- while (!atomic_read(&s->killed)) {
+ while (!kthread_should_stop()) {
set_current_state(TASK_INTERRUPTIBLE);
/* RX */
@@ -611,11 +611,12 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
__bnep_link_session(s);
- err = kernel_thread(bnep_session, s, CLONE_KERNEL);
- if (err < 0) {
+ s->task = kthread_run(bnep_session, s, "kbnepd %s", dev->name);
+ if (IS_ERR(s->task)) {
/* Session thread start failed, gotta cleanup. */
unregister_netdev(dev);
__bnep_unlink_session(s);
+ err = PTR_ERR(s->task);
goto failed;
}
@@ -639,15 +640,9 @@ int bnep_del_connection(struct bnep_conndel_req *req)
down_read(&bnep_session_sem);
s = __bnep_get_session(req->dst);
- if (s) {
- /* Wakeup user-space which is polling for socket errors.
- * This is temporary hack until we have shutdown in L2CAP */
- s->sock->sk->sk_err = EUNATCH;
-
- /* Kill session thread */
- atomic_inc(&s->killed);
- wake_up_interruptible(sk_sleep(s->sock->sk));
- } else
+ if (s)
+ kthread_stop(s->task);
+ else
err = -ENOENT;
up_read(&bnep_session_sem);
--
1.7.0.4
^ permalink raw reply related
* [PATCH 03/10] Bluetooth: Use #include <linux/uaccess.h> instead of <asm/uaccess.h>
From: Szymon Janc @ 2011-03-21 13:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, henrik.possung, Szymon Janc
In-Reply-To: <1300713606-23523-1-git-send-email-szymon.janc@tieto.com>
As warned by checkpatch.pl, use #include <linux/uaccess.h> instead of
<asm/uaccess.h>
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
---
net/bluetooth/bnep/sock.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/net/bluetooth/bnep/sock.c b/net/bluetooth/bnep/sock.c
index d935da7..17800b1 100644
--- a/net/bluetooth/bnep/sock.c
+++ b/net/bluetooth/bnep/sock.c
@@ -39,10 +39,10 @@
#include <linux/init.h>
#include <linux/compat.h>
#include <linux/gfp.h>
+#include <linux/uaccess.h>
#include <net/sock.h>
#include <asm/system.h>
-#include <asm/uaccess.h>
#include "bnep.h"
--
1.7.0.4
^ permalink raw reply related
* [PATCH 02/10] Bluetooth: Fix checkpatch errors and some code style issues in bnep
From: Szymon Janc @ 2011-03-21 13:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, henrik.possung, Szymon Janc
In-Reply-To: <1300713606-23523-1-git-send-email-szymon.janc@tieto.com>
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
---
net/bluetooth/bnep/bnep.h | 146 ++++++++++++++++++++++----------------------
net/bluetooth/bnep/core.c | 37 +++++++-----
2 files changed, 94 insertions(+), 89 deletions(-)
diff --git a/net/bluetooth/bnep/bnep.h b/net/bluetooth/bnep/bnep.h
index 7067254..d768e04 100644
--- a/net/bluetooth/bnep/bnep.h
+++ b/net/bluetooth/bnep/bnep.h
@@ -23,88 +23,88 @@
#include <linux/crc32.h>
#include <net/bluetooth/bluetooth.h>
-// Limits
-#define BNEP_MAX_PROTO_FILTERS 5
-#define BNEP_MAX_MULTICAST_FILTERS 20
-
-// UUIDs
-#define BNEP_BASE_UUID 0x0000000000001000800000805F9B34FB
-#define BNEP_UUID16 0x02
-#define BNEP_UUID32 0x04
-#define BNEP_UUID128 0x16
-
-#define BNEP_SVC_PANU 0x1115
-#define BNEP_SVC_NAP 0x1116
-#define BNEP_SVC_GN 0x1117
-
-// Packet types
-#define BNEP_GENERAL 0x00
-#define BNEP_CONTROL 0x01
-#define BNEP_COMPRESSED 0x02
-#define BNEP_COMPRESSED_SRC_ONLY 0x03
-#define BNEP_COMPRESSED_DST_ONLY 0x04
-
-// Control types
-#define BNEP_CMD_NOT_UNDERSTOOD 0x00
-#define BNEP_SETUP_CONN_REQ 0x01
-#define BNEP_SETUP_CONN_RSP 0x02
-#define BNEP_FILTER_NET_TYPE_SET 0x03
-#define BNEP_FILTER_NET_TYPE_RSP 0x04
-#define BNEP_FILTER_MULTI_ADDR_SET 0x05
-#define BNEP_FILTER_MULTI_ADDR_RSP 0x06
-
-// Extension types
-#define BNEP_EXT_CONTROL 0x00
-
-// Response messages
-#define BNEP_SUCCESS 0x00
-
-#define BNEP_CONN_INVALID_DST 0x01
-#define BNEP_CONN_INVALID_SRC 0x02
-#define BNEP_CONN_INVALID_SVC 0x03
-#define BNEP_CONN_NOT_ALLOWED 0x04
-
-#define BNEP_FILTER_UNSUPPORTED_REQ 0x01
-#define BNEP_FILTER_INVALID_RANGE 0x02
-#define BNEP_FILTER_INVALID_MCADDR 0x02
-#define BNEP_FILTER_LIMIT_REACHED 0x03
-#define BNEP_FILTER_DENIED_SECURITY 0x04
-
-// L2CAP settings
-#define BNEP_MTU 1691
-#define BNEP_PSM 0x0f
-#define BNEP_FLUSH_TO 0xffff
-#define BNEP_CONNECT_TO 15
-#define BNEP_FILTER_TO 15
-
-// Headers
-#define BNEP_TYPE_MASK 0x7f
-#define BNEP_EXT_HEADER 0x80
+/* Limits */
+#define BNEP_MAX_PROTO_FILTERS 5
+#define BNEP_MAX_MULTICAST_FILTERS 20
+
+/* UUIDs */
+#define BNEP_BASE_UUID 0x0000000000001000800000805F9B34FB
+#define BNEP_UUID16 0x02
+#define BNEP_UUID32 0x04
+#define BNEP_UUID128 0x16
+
+#define BNEP_SVC_PANU 0x1115
+#define BNEP_SVC_NAP 0x1116
+#define BNEP_SVC_GN 0x1117
+
+/* Packet types */
+#define BNEP_GENERAL 0x00
+#define BNEP_CONTROL 0x01
+#define BNEP_COMPRESSED 0x02
+#define BNEP_COMPRESSED_SRC_ONLY 0x03
+#define BNEP_COMPRESSED_DST_ONLY 0x04
+
+/* Control types */
+#define BNEP_CMD_NOT_UNDERSTOOD 0x00
+#define BNEP_SETUP_CONN_REQ 0x01
+#define BNEP_SETUP_CONN_RSP 0x02
+#define BNEP_FILTER_NET_TYPE_SET 0x03
+#define BNEP_FILTER_NET_TYPE_RSP 0x04
+#define BNEP_FILTER_MULTI_ADDR_SET 0x05
+#define BNEP_FILTER_MULTI_ADDR_RSP 0x06
+
+/* Extension types */
+#define BNEP_EXT_CONTROL 0x00
+
+/* Response messages */
+#define BNEP_SUCCESS 0x00
+
+#define BNEP_CONN_INVALID_DST 0x01
+#define BNEP_CONN_INVALID_SRC 0x02
+#define BNEP_CONN_INVALID_SVC 0x03
+#define BNEP_CONN_NOT_ALLOWED 0x04
+
+#define BNEP_FILTER_UNSUPPORTED_REQ 0x01
+#define BNEP_FILTER_INVALID_RANGE 0x02
+#define BNEP_FILTER_INVALID_MCADDR 0x02
+#define BNEP_FILTER_LIMIT_REACHED 0x03
+#define BNEP_FILTER_DENIED_SECURITY 0x04
+
+/* L2CAP settings */
+#define BNEP_MTU 1691
+#define BNEP_PSM 0x0f
+#define BNEP_FLUSH_TO 0xffff
+#define BNEP_CONNECT_TO 15
+#define BNEP_FILTER_TO 15
+
+/* Headers */
+#define BNEP_TYPE_MASK 0x7f
+#define BNEP_EXT_HEADER 0x80
struct bnep_setup_conn_req {
- __u8 type;
- __u8 ctrl;
- __u8 uuid_size;
- __u8 service[0];
+ __u8 type;
+ __u8 ctrl;
+ __u8 uuid_size;
+ __u8 service[0];
} __packed;
struct bnep_set_filter_req {
- __u8 type;
- __u8 ctrl;
+ __u8 type;
+ __u8 ctrl;
__be16 len;
- __u8 list[0];
+ __u8 list[0];
} __packed;
struct bnep_control_rsp {
- __u8 type;
- __u8 ctrl;
+ __u8 type;
+ __u8 ctrl;
__be16 resp;
} __packed;
struct bnep_ext_hdr {
- __u8 type;
- __u8 len;
- __u8 data[0];
+ __u8 type;
+ __u8 len;
+ __u8 data[0];
} __packed;
/* BNEP ioctl defines */
@@ -114,10 +114,10 @@ struct bnep_ext_hdr {
#define BNEPGETCONNINFO _IOR('B', 211, int)
struct bnep_connadd_req {
- int sock; // Connected socket
+ int sock; /* Connected socket */
__u32 flags;
__u16 role;
- char device[16]; // Name of the Ethernet device
+ char device[16]; /* Name of the Ethernet device */
};
struct bnep_conndel_req {
@@ -148,7 +148,7 @@ int bnep_del_connection(struct bnep_conndel_req *req);
int bnep_get_connlist(struct bnep_connlist_req *req);
int bnep_get_conninfo(struct bnep_conninfo *ci);
-// BNEP sessions
+/* BNEP sessions */
struct bnep_session {
struct list_head list;
@@ -173,7 +173,7 @@ void bnep_sock_cleanup(void);
static inline int bnep_mc_hash(__u8 *addr)
{
- return (crc32_be(~0, addr, ETH_ALEN) >> 26);
+ return crc32_be(~0, addr, ETH_ALEN) >> 26;
}
#endif
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index 940b4e1..0a2e76b 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -131,7 +131,8 @@ static int bnep_ctrl_set_netfilter(struct bnep_session *s, __be16 *data, int len
return -EILSEQ;
n = get_unaligned_be16(data);
- data++; len -= 2;
+ data++;
+ len -= 2;
if (len < n)
return -EILSEQ;
@@ -176,7 +177,8 @@ static int bnep_ctrl_set_mcfilter(struct bnep_session *s, u8 *data, int len)
return -EILSEQ;
n = get_unaligned_be16(data);
- data += 2; len -= 2;
+ data += 2;
+ len -= 2;
if (len < n)
return -EILSEQ;
@@ -198,8 +200,10 @@ static int bnep_ctrl_set_mcfilter(struct bnep_session *s, u8 *data, int len)
for (; n > 0; n--) {
u8 a1[6], *a2;
- memcpy(a1, data, ETH_ALEN); data += ETH_ALEN;
- a2 = data; data += ETH_ALEN;
+ memcpy(a1, data, ETH_ALEN);
+ data += ETH_ALEN;
+ a2 = data;
+ data += ETH_ALEN;
BT_DBG("mc filter %s -> %s",
batostr((void *) a1), batostr((void *) a2));
@@ -231,7 +235,8 @@ static int bnep_rx_control(struct bnep_session *s, void *data, int len)
u8 cmd = *(u8 *)data;
int err = 0;
- data++; len--;
+ data++;
+ len--;
switch (cmd) {
case BNEP_CMD_NOT_UNDERSTOOD:
@@ -315,7 +320,8 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
dev->stats.rx_bytes += skb->len;
- type = *(u8 *) skb->data; skb_pull(skb, 1);
+ type = *(u8 *) skb->data;
+ skb_pull(skb, 1);
if ((type & BNEP_TYPE_MASK) >= sizeof(__bnep_rx_hlen))
goto badframe;
@@ -370,14 +376,14 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
case BNEP_COMPRESSED_DST_ONLY:
memcpy(__skb_put(nskb, ETH_ALEN), skb_mac_header(skb),
- ETH_ALEN);
+ ETH_ALEN);
memcpy(__skb_put(nskb, ETH_ALEN + 2), s->eh.h_source,
- ETH_ALEN + 2);
+ ETH_ALEN + 2);
break;
case BNEP_GENERAL:
memcpy(__skb_put(nskb, ETH_ALEN * 2), skb_mac_header(skb),
- ETH_ALEN * 2);
+ ETH_ALEN * 2);
put_unaligned(s->eh.h_proto, (__be16 *) __skb_put(nskb, 2));
break;
}
@@ -481,7 +487,7 @@ static int bnep_session(void *arg)
while (!atomic_read(&s->killed)) {
set_current_state(TASK_INTERRUPTIBLE);
- // RX
+ /* RX */
while ((skb = skb_dequeue(&sk->sk_receive_queue))) {
skb_orphan(skb);
bnep_rx_frame(s, skb);
@@ -490,7 +496,7 @@ static int bnep_session(void *arg)
if (sk->sk_state != BT_CONNECTED)
break;
- // TX
+ /* TX */
while ((skb = skb_dequeue(&sk->sk_write_queue)))
if (bnep_tx_frame(s, skb))
break;
@@ -558,8 +564,8 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
/* session struct allocated as private part of net_device */
dev = alloc_netdev(sizeof(struct bnep_session),
- (*req->device) ? req->device : "bnep%d",
- bnep_net_setup);
+ (*req->device) ? req->device : "bnep%d",
+ bnep_net_setup);
if (!dev)
return -ENOMEM;
@@ -574,7 +580,7 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
s = netdev_priv(dev);
/* This is rx header therefore addresses are swapped.
- * ie eh.h_dest is our local address. */
+ * ie. eh.h_dest is our local address. */
memcpy(s->eh.h_dest, &src, ETH_ALEN);
memcpy(s->eh.h_source, &dst, ETH_ALEN);
memcpy(dev->dev_addr, s->eh.h_dest, ETH_ALEN);
@@ -600,9 +606,8 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
SET_NETDEV_DEVTYPE(dev, &bnep_type);
err = register_netdev(dev);
- if (err) {
+ if (err)
goto failed;
- }
__bnep_link_session(s);
--
1.7.0.4
^ permalink raw reply related
* [PATCH 01/10] Bluetooth: Opencode macros in bnep/core.c
From: Szymon Janc @ 2011-03-21 13:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, henrik.possung, Szymon Janc
In-Reply-To: <1300713606-23523-1-git-send-email-szymon.janc@tieto.com>
BNEP_RX_TYPES and INCA macros have only one user each and don't provide
any benefits compared to opencoding them.
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
---
net/bluetooth/bnep/core.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index 03d4d12..940b4e1 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -187,6 +187,8 @@ static int bnep_ctrl_set_mcfilter(struct bnep_session *s, u8 *data, int len)
n /= (ETH_ALEN * 2);
if (n > 0) {
+ int i;
+
s->mc_filter = 0;
/* Always send broadcast */
@@ -202,12 +204,14 @@ static int bnep_ctrl_set_mcfilter(struct bnep_session *s, u8 *data, int len)
BT_DBG("mc filter %s -> %s",
batostr((void *) a1), batostr((void *) a2));
- #define INCA(a) { int i = 5; while (i >=0 && ++a[i--] == 0); }
-
/* Iterate from a1 to a2 */
set_bit(bnep_mc_hash(a1), (ulong *) &s->mc_filter);
while (memcmp(a1, a2, 6) < 0 && s->mc_filter != ~0LL) {
- INCA(a1);
+ /* Increment a1 */
+ i = 5;
+ while (i >= 0 && ++a1[i--] == 0)
+ ;
+
set_bit(bnep_mc_hash(a1), (ulong *) &s->mc_filter);
}
}
@@ -302,7 +306,6 @@ static u8 __bnep_rx_hlen[] = {
ETH_ALEN + 2, /* BNEP_COMPRESSED_SRC_ONLY */
ETH_ALEN + 2 /* BNEP_COMPRESSED_DST_ONLY */
};
-#define BNEP_RX_TYPES (sizeof(__bnep_rx_hlen) - 1)
static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
{
@@ -314,7 +317,7 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
type = *(u8 *) skb->data; skb_pull(skb, 1);
- if ((type & BNEP_TYPE_MASK) > BNEP_RX_TYPES)
+ if ((type & BNEP_TYPE_MASK) >= sizeof(__bnep_rx_hlen))
goto badframe;
if ((type & BNEP_TYPE_MASK) == BNEP_CONTROL) {
--
1.7.0.4
^ permalink raw reply related
* (no subject)
From: Szymon Janc @ 2011-03-21 13:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, henrik.possung, Szymon Janc
Subject: [PATCH 00/10] Use kthread API instead of kernel_thread in bluetooth
Use kthread API in bnep, hidp and cmtp.
Why: kernel_thread is a low-level implementation detail. Drivers should
use the <linux/kthread.h> API instead which shields them from
implementation details and provides a higherlevel interface that
prevents bugs and code duplication
Rest of patches are just cleanup work in touched files.
Comments are welcome.
BR,
Szymon Janc
on behalf of ST-Ericsson
Szymon Janc (10):
Bluetooth: Opencode macros in bnep/core.c
Bluetooth: Fix checkpatch errors and some code style issues in bnep
Bluetooth: Use #include <linux/uaccess.h> instead of <asm/uaccess.h>
Bluetooth: Use kthread API in bnep
Bluetooth: Fix checkpatch errors, code style issues and typos in hidp
Bluetooth: Use kthread API in hidp
Bluetooth: Do not use assignments in IF conditions
Bluetooth: Use #include <linux/uaccess.h> instead of <asm/uaccess.h>
Bluetooth: Fix checkpatch error in cmtp.h
Bluetooth: Use kthread API in cmtp
net/bluetooth/bnep/bnep.h | 148 ++++++++++++++++++++++----------------------
net/bluetooth/bnep/core.c | 71 +++++++++++----------
net/bluetooth/bnep/sock.c | 2 +-
net/bluetooth/cmtp/capi.c | 6 +-
net/bluetooth/cmtp/cmtp.h | 11 +---
net/bluetooth/cmtp/core.c | 25 +++++---
net/bluetooth/cmtp/sock.c | 2 +-
net/bluetooth/hidp/core.c | 86 +++++++++++++-------------
net/bluetooth/hidp/hidp.h | 6 +-
net/bluetooth/hidp/sock.c | 7 +-
10 files changed, 182 insertions(+), 182 deletions(-)
^ permalink raw reply
* [PATCH v3 5/5] Bluetooth: Enable support for out of band association model
From: Szymon Janc @ 2011-03-21 13:07 UTC (permalink / raw)
To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, henrik.possung, Szymon Janc
In-Reply-To: <1300712821-23172-1-git-send-email-szymon.janc@tieto.com>
If remote side reports oob availability or we are pairing initiator
use oob data for pairing if available.
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
---
net/bluetooth/hci_event.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index fba5998..393b43b 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2373,9 +2373,14 @@ static inline void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff
bacpy(&cp.bdaddr, &ev->bdaddr);
cp.capability = conn->io_capability;
- cp.oob_data = 0;
cp.authentication = hci_get_auth_req(conn);
+ if ((conn->out == 0x01 || conn->remote_oob == 0x01) &&
+ hci_find_remote_oob_data(hdev, &conn->dst))
+ cp.oob_data = 0x01;
+ else
+ cp.oob_data = 0x00;
+
hci_send_cmd(hdev, HCI_OP_IO_CAPABILITY_REPLY,
sizeof(cp), &cp);
} else {
--
1.7.0.4
^ permalink raw reply related
* [PATCH v3 4/5] Bluetooth: Add add/remove_remote_oob_data management commands
From: Szymon Janc @ 2011-03-21 13:07 UTC (permalink / raw)
To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, henrik.possung, Szymon Janc
In-Reply-To: <1300712821-23172-1-git-send-email-szymon.janc@tieto.com>
This patch adds commands to add and remove remote OOB data to the managment
interface. Remote data is stored in kernel and can be used by corresponding
HCI commands and events when needed.
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
---
include/net/bluetooth/hci.h | 19 ++++++++++
include/net/bluetooth/hci_core.h | 16 ++++++++
include/net/bluetooth/mgmt.h | 12 ++++++
net/bluetooth/hci_core.c | 67 ++++++++++++++++++++++++++++++++++
net/bluetooth/hci_event.c | 34 +++++++++++++++++
net/bluetooth/mgmt.c | 75 ++++++++++++++++++++++++++++++++++++++
6 files changed, 223 insertions(+), 0 deletions(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 0ac0804..8c71e88 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -428,6 +428,20 @@ struct hci_rp_user_confirm_reply {
#define HCI_OP_USER_CONFIRM_NEG_REPLY 0x042d
+
+#define HCI_OP_REMOTE_OOB_DATA_REPLY 0x0430
+struct hci_cp_remote_oob_data_reply {
+ bdaddr_t bdaddr;
+ __u8 hash[16];
+ __u8 randomizer[16];
+} __packed;
+
+#define HCI_OP_REMOTE_OOB_DATA_NEG_REPLY 0x0433
+struct hci_cp_remote_oob_data_neg_reply {
+ bdaddr_t bdaddr;
+} __packed;
+
+
#define HCI_OP_IO_CAPABILITY_NEG_REPLY 0x0434
struct hci_cp_io_capability_neg_reply {
bdaddr_t bdaddr;
@@ -964,6 +978,11 @@ struct hci_ev_user_confirm_req {
__le32 passkey;
} __packed;
+#define HCI_EV_REMOTE_OOB_DATA_REQUEST 0x35
+struct hci_ev_remote_oob_data_request {
+ bdaddr_t bdaddr;
+} __packed;
+
#define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36
struct hci_ev_simple_pair_complete {
__u8 status;
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index fd9b8a3..87bff51 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -82,6 +82,13 @@ struct link_key {
u8 pin_len;
};
+struct oob_data {
+ struct list_head list;
+ bdaddr_t bdaddr;
+ u8 hash[16];
+ u8 randomizer[16];
+};
+
#define NUM_REASSEMBLY 4
struct hci_dev {
struct list_head list;
@@ -169,6 +176,8 @@ struct hci_dev {
struct list_head link_keys;
+ struct list_head remote_oob_data;
+
struct hci_dev_stats stat;
struct sk_buff_head driver_init;
@@ -505,6 +514,13 @@ int hci_add_link_key(struct hci_dev *hdev, int new_key, bdaddr_t *bdaddr,
u8 *key, u8 type, u8 pin_len);
int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);
+int hci_remote_oob_data_clear(struct hci_dev *hdev);
+struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev,
+ bdaddr_t *bdaddr);
+int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash,
+ u8 *randomizer);
+int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr);
+
void hci_del_off_timer(struct hci_dev *hdev);
void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index 6ebb126..1a6283f 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -183,6 +183,18 @@ struct mgmt_rp_read_local_oob_data {
__u8 randomizer[16];
} __packed;
+#define MGMT_OP_ADD_REMOTE_OOB_DATA 0x0019
+struct mgmt_cp_add_remote_oob_data {
+ bdaddr_t bdaddr;
+ __u8 hash[16];
+ __u8 randomizer[16];
+} __packed;
+
+#define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x001A
+struct mgmt_cp_remove_remote_oob_data {
+ bdaddr_t bdaddr;
+} __packed;
+
#define MGMT_EV_CMD_COMPLETE 0x0001
struct mgmt_ev_cmd_complete {
__le16 opcode;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 1f11fe3..1fa9ce5 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1080,6 +1080,70 @@ static void hci_cmd_timer(unsigned long arg)
tasklet_schedule(&hdev->cmd_task);
}
+struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev,
+ bdaddr_t *bdaddr)
+{
+ struct oob_data *data;
+
+ list_for_each_entry(data, &hdev->remote_oob_data, list)
+ if (bacmp(bdaddr, &data->bdaddr) == 0)
+ return data;
+
+ return NULL;
+}
+
+int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr)
+{
+ struct oob_data *data;
+
+ data = hci_find_remote_oob_data(hdev, bdaddr);
+ if (!data)
+ return -ENOENT;
+
+ BT_DBG("%s removing %s", hdev->name, batostr(bdaddr));
+
+ list_del(&data->list);
+ kfree(data);
+
+ return 0;
+}
+
+int hci_remote_oob_data_clear(struct hci_dev *hdev)
+{
+ struct oob_data *data, *n;
+
+ list_for_each_entry_safe(data, n, &hdev->remote_oob_data, list) {
+ list_del(&data->list);
+ kfree(data);
+ }
+
+ return 0;
+}
+
+int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash,
+ u8 *randomizer)
+{
+ struct oob_data *data;
+
+ data = hci_find_remote_oob_data(hdev, bdaddr);
+
+ if (!data) {
+ data = kmalloc(sizeof(*data), GFP_ATOMIC);
+ if (!data)
+ return -ENOMEM;
+
+ bacpy(&data->bdaddr, bdaddr);
+ list_add(&data->list, &hdev->remote_oob_data);
+ }
+
+ memcpy(data->hash, hash, 16);
+ memcpy(data->randomizer, randomizer, 16);
+
+ BT_DBG("%s for %s", hdev->name, batostr(bdaddr));
+
+ return 0;
+}
+
/* Register HCI device */
int hci_register_dev(struct hci_dev *hdev)
{
@@ -1144,6 +1208,8 @@ int hci_register_dev(struct hci_dev *hdev)
INIT_LIST_HEAD(&hdev->link_keys);
+ INIT_LIST_HEAD(&hdev->remote_oob_data);
+
INIT_WORK(&hdev->power_on, hci_power_on);
INIT_WORK(&hdev->power_off, hci_power_off);
setup_timer(&hdev->off_timer, hci_auto_off, (unsigned long) hdev);
@@ -1223,6 +1289,7 @@ int hci_unregister_dev(struct hci_dev *hdev)
hci_blacklist_clear(hdev);
hci_uuids_clear(hdev);
hci_link_keys_clear(hdev);
+ hci_remote_oob_data_clear(hdev);
hci_dev_unlock_bh(hdev);
__hci_dev_put(hdev);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 0223b38..fba5998 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2473,6 +2473,37 @@ static inline void hci_remote_host_features_evt(struct hci_dev *hdev, struct sk_
hci_dev_unlock(hdev);
}
+static inline void hci_remote_oob_data_request_evt(struct hci_dev *hdev,
+ struct sk_buff *skb)
+{
+ struct hci_ev_remote_oob_data_request *ev = (void *) skb->data;
+ struct oob_data *data;
+
+ BT_DBG("%s", hdev->name);
+
+ hci_dev_lock(hdev);
+
+ data = hci_find_remote_oob_data(hdev, &ev->bdaddr);
+ if (data) {
+ struct hci_cp_remote_oob_data_reply cp;
+
+ bacpy(&cp.bdaddr, &ev->bdaddr);
+ memcpy(cp.hash, data->hash, 16);
+ memcpy(cp.randomizer, data->randomizer, 16);
+
+ hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_DATA_REPLY, sizeof(cp),
+ &cp);
+ } else {
+ struct hci_cp_remote_oob_data_neg_reply cp;
+
+ bacpy(&cp.bdaddr, &ev->bdaddr);
+ hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_DATA_NEG_REPLY, sizeof(cp),
+ &cp);
+ }
+
+ hci_dev_unlock(hdev);
+}
+
static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
{
struct hci_ev_le_conn_complete *ev = (void *) skb->data;
@@ -2673,6 +2704,9 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
case HCI_EV_LE_META:
hci_le_meta_evt(hdev, skb);
+
+ case HCI_EV_REMOTE_OOB_DATA_REQUEST:
+ hci_remote_oob_data_request_evt(hdev, skb);
break;
default:
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index a72cbf6..46c96b3 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1349,6 +1349,74 @@ unlock:
return err;
}
+static int add_remote_oob_data(struct sock *sk, u16 index, unsigned char *data,
+ u16 len)
+{
+ struct hci_dev *hdev;
+ struct mgmt_cp_add_remote_oob_data *cp = (void *) data;
+ int err;
+
+ BT_DBG("hci%u ", index);
+
+ if (len != sizeof(*cp))
+ return cmd_status(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA,
+ EINVAL);
+
+ hdev = hci_dev_get(index);
+ if (!hdev)
+ return cmd_status(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA,
+ ENODEV);
+
+ hci_dev_lock_bh(hdev);
+
+ err = hci_add_remote_oob_data(hdev, &cp->bdaddr, cp->hash,
+ cp->randomizer);
+ if (err < 0)
+ err = cmd_status(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, -err);
+ else
+ err = cmd_complete(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, NULL,
+ 0);
+
+ hci_dev_unlock_bh(hdev);
+ hci_dev_put(hdev);
+
+ return err;
+}
+
+static int remove_remote_oob_data(struct sock *sk, u16 index,
+ unsigned char *data, u16 len)
+{
+ struct hci_dev *hdev;
+ struct mgmt_cp_remove_remote_oob_data *cp = (void *)data;
+ int err;
+
+ BT_DBG("hci%u ", index);
+
+ if (len != sizeof(*cp))
+ return cmd_status(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA,
+ EINVAL);
+
+ hdev = hci_dev_get(index);
+ if (!hdev)
+ return cmd_status(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA,
+ ENODEV);
+
+ hci_dev_lock_bh(hdev);
+
+ err = hci_remove_remote_oob_data(hdev, &cp->bdaddr);
+ if (err < 0)
+ err = cmd_status(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA,
+ -err);
+ else
+ err = cmd_complete(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA,
+ NULL, 0);
+
+ hci_dev_unlock_bh(hdev);
+ hci_dev_put(hdev);
+
+ return err;
+}
+
int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
{
unsigned char *buf;
@@ -1450,6 +1518,13 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
case MGMT_OP_READ_LOCAL_OOB_DATA:
err = read_local_oob_data(sk, index);
break;
+ case MGMT_OP_ADD_REMOTE_OOB_DATA:
+ err = add_remote_oob_data(sk, index, buf + sizeof(*hdr), len);
+ break;
+ case MGMT_OP_REMOVE_REMOTE_OOB_DATA:
+ err = remove_remote_oob_data(sk, index, buf + sizeof(*hdr),
+ len);
+ break;
default:
BT_DBG("Unknown op %u", opcode);
--
1.7.0.4
^ permalink raw reply related
* [PATCH v3 3/5] Bluetooth: Add read_local_oob_data management command
From: Szymon Janc @ 2011-03-21 13:06 UTC (permalink / raw)
To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, henrik.possung, Szymon Janc
In-Reply-To: <1300712821-23172-1-git-send-email-szymon.janc@tieto.com>
This patch adds a command to read local OOB data to the managment interface.
The command maps directly to the Read Local OOB Data HCI command.
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
---
include/net/bluetooth/hci.h | 7 +++
include/net/bluetooth/hci_core.h | 2 +
include/net/bluetooth/mgmt.h | 6 +++
net/bluetooth/hci_event.c | 15 +++++++
net/bluetooth/mgmt.c | 85 ++++++++++++++++++++++++++++++++++++++
5 files changed, 115 insertions(+), 0 deletions(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 00fdcb7..0ac0804 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -615,6 +615,13 @@ struct hci_cp_write_ssp_mode {
__u8 mode;
} __packed;
+#define HCI_OP_READ_LOCAL_OOB_DATA 0x0c57
+struct hci_rp_read_local_oob_data {
+ __u8 status;
+ __u8 hash[16];
+ __u8 randomizer[16];
+} __packed;
+
#define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58
#define HCI_OP_READ_LOCAL_VERSION 0x1001
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 3912c7a..fd9b8a3 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -768,6 +768,8 @@ int mgmt_user_confirm_neg_reply_complete(u16 index, bdaddr_t *bdaddr,
u8 status);
int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status);
int mgmt_set_local_name_complete(u16 index, u8 *name, u8 status);
+int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer,
+ u8 status);
/* HCI info for socket */
#define hci_pi(sk) ((struct hci_pinfo *) sk)
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index 89e7c82..6ebb126 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -177,6 +177,12 @@ struct mgmt_cp_set_local_name {
__u8 name[MGMT_MAX_NAME_LENGTH];
} __packed;
+#define MGMT_OP_READ_LOCAL_OOB_DATA 0x0018
+struct mgmt_rp_read_local_oob_data {
+ __u8 hash[16];
+ __u8 randomizer[16];
+} __packed;
+
#define MGMT_EV_CMD_COMPLETE 0x0001
struct mgmt_ev_cmd_complete {
__le16 opcode;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 11f0dd8..0223b38 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -824,6 +824,17 @@ static void hci_cc_user_confirm_neg_reply(struct hci_dev *hdev,
rp->status);
}
+static void hci_cc_read_local_oob_data_reply(struct hci_dev *hdev,
+ struct sk_buff *skb)
+{
+ struct hci_rp_read_local_oob_data *rp = (void *) skb->data;
+
+ BT_DBG("%s status 0x%x", hdev->name, rp->status);
+
+ mgmt_read_local_oob_data_reply_complete(hdev->id, rp->hash,
+ rp->randomizer, rp->status);
+}
+
static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status)
{
BT_DBG("%s status 0x%x", hdev->name, status);
@@ -1754,6 +1765,10 @@ static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *sk
hci_cc_pin_code_neg_reply(hdev, skb);
break;
+ case HCI_OP_READ_LOCAL_OOB_DATA:
+ hci_cc_read_local_oob_data_reply(hdev, skb);
+ break;
+
case HCI_OP_LE_READ_BUFFER_SIZE:
hci_cc_le_read_buffer_size(hdev, skb);
break;
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index ebf495d..a72cbf6 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1298,6 +1298,57 @@ failed:
return err;
}
+static int read_local_oob_data(struct sock *sk, u16 index)
+{
+ struct hci_dev *hdev;
+ struct pending_cmd *cmd;
+ int err;
+
+ BT_DBG("hci%u", index);
+
+ hdev = hci_dev_get(index);
+ if (!hdev)
+ return cmd_status(sk, index, MGMT_OP_READ_LOCAL_OOB_DATA,
+ ENODEV);
+
+ hci_dev_lock_bh(hdev);
+
+ if (!test_bit(HCI_UP, &hdev->flags)) {
+ err = cmd_status(sk, index, MGMT_OP_READ_LOCAL_OOB_DATA,
+ ENETDOWN);
+ goto unlock;
+ }
+
+ if (!(hdev->features[6] & LMP_SIMPLE_PAIR)) {
+ err = cmd_status(sk, index, MGMT_OP_READ_LOCAL_OOB_DATA,
+ EOPNOTSUPP);
+ goto unlock;
+ }
+
+ if (mgmt_pending_find(MGMT_OP_READ_LOCAL_OOB_DATA, index)) {
+ err = cmd_status(sk, index, MGMT_OP_READ_LOCAL_OOB_DATA, EBUSY);
+ goto unlock;
+ }
+
+ cmd = mgmt_pending_add(sk, MGMT_OP_READ_LOCAL_OOB_DATA, index, NULL, 0);
+
+ if (!cmd) {
+ err = -ENOMEM;
+ goto unlock;
+ }
+
+ err = hci_send_cmd(hdev, HCI_OP_READ_LOCAL_OOB_DATA, 0, NULL);
+
+ if (err < 0)
+ mgmt_pending_remove(cmd);
+
+unlock:
+ hci_dev_unlock_bh(hdev);
+ hci_dev_put(hdev);
+
+ return err;
+}
+
int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
{
unsigned char *buf;
@@ -1396,6 +1447,10 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
case MGMT_OP_SET_LOCAL_NAME:
err = set_local_name(sk, index, buf + sizeof(*hdr), len);
break;
+ case MGMT_OP_READ_LOCAL_OOB_DATA:
+ err = read_local_oob_data(sk, index);
+ break;
+
default:
BT_DBG("Unknown op %u", opcode);
err = cmd_status(sk, index, opcode, 0x01);
@@ -1725,3 +1780,33 @@ failed:
mgmt_pending_remove(cmd);
return err;
}
+
+int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer,
+ u8 status)
+{
+ struct pending_cmd *cmd;
+ int err;
+
+ BT_DBG("hci%u status %u", index, status);
+
+ cmd = mgmt_pending_find(MGMT_OP_READ_LOCAL_OOB_DATA, index);
+ if (!cmd)
+ return -ENOENT;
+
+ if (status) {
+ err = cmd_status(cmd->sk, index, MGMT_OP_READ_LOCAL_OOB_DATA,
+ EIO);
+ } else {
+ struct mgmt_rp_read_local_oob_data rp;
+
+ memcpy(rp.hash, hash, 16);
+ memcpy(rp.randomizer, randomizer, 16);
+
+ err = cmd_complete(cmd->sk, index, MGMT_OP_READ_LOCAL_OOB_DATA,
+ &rp, sizeof(rp));
+ }
+
+ mgmt_pending_remove(cmd);
+
+ return err;
+}
--
1.7.0.4
^ permalink raw reply related
* [PATCH v3 2/5] Bluetooth: Allow for NULL data in mgmt_pending_add
From: Szymon Janc @ 2011-03-21 13:06 UTC (permalink / raw)
To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, henrik.possung, Szymon Janc
In-Reply-To: <1300712821-23172-1-git-send-email-szymon.janc@tieto.com>
Since index is in mgmt_hdr it is possible to have mgmt command with
no parameters that still needs to add itself to pending list.
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
---
net/bluetooth/mgmt.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 657a02d..ebf495d 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -239,7 +239,8 @@ static struct pending_cmd *mgmt_pending_add(struct sock *sk, u16 opcode,
return NULL;
}
- memcpy(cmd->param, data, len);
+ if (data)
+ memcpy(cmd->param, data, len);
cmd->sk = sk;
sock_hold(sk);
--
1.7.0.4
^ permalink raw reply related
* [PATCH v3 1/5] Bluetooth: Rename cmd to param in pending_cmd
From: Szymon Janc @ 2011-03-21 13:06 UTC (permalink / raw)
To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, henrik.possung, Szymon Janc
In-Reply-To: <1300712821-23172-1-git-send-email-szymon.janc@tieto.com>
This field holds not whole command but only command specific
parameters.
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
---
net/bluetooth/mgmt.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 98988c8..657a02d 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -36,7 +36,7 @@ struct pending_cmd {
struct list_head list;
__u16 opcode;
int index;
- void *cmd;
+ void *param;
struct sock *sk;
void *user_data;
};
@@ -217,7 +217,7 @@ static int read_controller_info(struct sock *sk, u16 index)
static void mgmt_pending_free(struct pending_cmd *cmd)
{
sock_put(cmd->sk);
- kfree(cmd->cmd);
+ kfree(cmd->param);
kfree(cmd);
}
@@ -233,13 +233,13 @@ static struct pending_cmd *mgmt_pending_add(struct sock *sk, u16 opcode,
cmd->opcode = opcode;
cmd->index = index;
- cmd->cmd = kmalloc(len, GFP_ATOMIC);
- if (!cmd->cmd) {
+ cmd->param = kmalloc(len, GFP_ATOMIC);
+ if (!cmd->param) {
kfree(cmd);
return NULL;
}
- memcpy(cmd->cmd, data, len);
+ memcpy(cmd->param, data, len);
cmd->sk = sk;
sock_hold(sk);
@@ -1428,7 +1428,7 @@ struct cmd_lookup {
static void mode_rsp(struct pending_cmd *cmd, void *data)
{
- struct mgmt_mode *cp = cmd->cmd;
+ struct mgmt_mode *cp = cmd->param;
struct cmd_lookup *match = data;
if (cp->val != match->val)
@@ -1527,7 +1527,7 @@ int mgmt_connected(u16 index, bdaddr_t *bdaddr)
static void disconnect_rsp(struct pending_cmd *cmd, void *data)
{
- struct mgmt_cp_disconnect *cp = cmd->cmd;
+ struct mgmt_cp_disconnect *cp = cmd->param;
struct sock **sk = data;
struct mgmt_rp_disconnect rp;
--
1.7.0.4
^ permalink raw reply related
* [PATCH v3 0/5] Support for OOB in mgmt interface
From: Szymon Janc @ 2011-03-21 13:06 UTC (permalink / raw)
To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, henrik.possung, Szymon Janc
Changes since v2:
- include Gustavo comments
- rebase and update commands codes
- move oob enabling part to separate patch
BR,
Szymon Janc
on behalf of ST-Ericsson
Szymon Janc (5):
Bluetooth: Rename cmd to param in pending_cmd
Bluetooth: Allow for NULL data in mgmt_pending_add
Bluetooth: Add read_local_oob_data management command
Bluetooth: Add add/remove_remote_oob_data management commands
Bluetooth: Enable support for out of band association model
include/net/bluetooth/hci.h | 26 ++++++
include/net/bluetooth/hci_core.h | 18 ++++
include/net/bluetooth/mgmt.h | 18 ++++
net/bluetooth/hci_core.c | 67 +++++++++++++++
net/bluetooth/hci_event.c | 56 ++++++++++++-
net/bluetooth/mgmt.c | 175 ++++++++++++++++++++++++++++++++++++--
6 files changed, 352 insertions(+), 8 deletions(-)
^ permalink raw reply
* [PATCH] Fix crash when unregistering a2dp driver before media driver
From: Luiz Augusto von Dentz @ 2011-03-21 12:18 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
Since media driver uses a2dp to register its sep and store a pointer,
this pointer may be invalid/freed when media driver is unregistered.
To fix this now a2dp will also release any sep registered using media
API.
It also protect from future changes on the order of drivers removal by
checking if pointers (sep or endpoint) are still available in the list
before removing them.
---
audio/a2dp.c | 7 +++++++
audio/media.c | 3 +++
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/audio/a2dp.c b/audio/a2dp.c
index ea4805c..8595350 100644
--- a/audio/a2dp.c
+++ b/audio/a2dp.c
@@ -1517,6 +1517,9 @@ proceed:
static void a2dp_unregister_sep(struct a2dp_sep *sep)
{
+ if (sep->endpoint)
+ media_endpoint_release(sep->endpoint);
+
avdtp_unregister_sep(sep->lsep);
g_free(sep);
}
@@ -1648,12 +1651,16 @@ void a2dp_remove_sep(struct a2dp_sep *sep)
struct a2dp_server *server = sep->server;
if (sep->type == AVDTP_SEP_TYPE_SOURCE) {
+ if (g_slist_find(server->sources, sep) == NULL)
+ return;
server->sources = g_slist_remove(server->sources, sep);
if (server->sources == NULL && server->source_record_id) {
remove_record_from_server(server->source_record_id);
server->source_record_id = 0;
}
} else {
+ if (g_slist_find(server->sinks, sep) == NULL)
+ return;
server->sinks = g_slist_remove(server->sinks, sep);
if (server->sinks == NULL && server->sink_record_id) {
remove_record_from_server(server->sink_record_id);
diff --git a/audio/media.c b/audio/media.c
index d5fb29c..4b389c6 100644
--- a/audio/media.c
+++ b/audio/media.c
@@ -108,6 +108,9 @@ static void media_endpoint_remove(struct media_endpoint *endpoint)
{
struct media_adapter *adapter = endpoint->adapter;
+ if (g_slist_find(adapter->endpoints, endpoint) == NULL)
+ return;
+
info("Endpoint unregistered: sender=%s path=%s", endpoint->sender,
endpoint->path);
--
1.7.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