platform/kernel/linux-exynos.git
12 years agoBluetooth: Fix wrong set of skb fragments
Gustavo Padovan [Tue, 15 May 2012 16:22:55 +0000 (13:22 -0300)]
Bluetooth: Fix wrong set of skb fragments

If alloc() fails we let the frags linked list with garbage value (the
err ptr value) in its last element.

Reported-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoMerge git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth
Gustavo Padovan [Wed, 16 May 2012 19:11:44 +0000 (16:11 -0300)]
Merge git://git./linux/kernel/git/bluetooth/bluetooth

12 years agoBluetooth: Initialize the transmit queue for L2CAP streaming mode
Mat Martineau [Mon, 14 May 2012 21:49:27 +0000 (14:49 -0700)]
Bluetooth: Initialize the transmit queue for L2CAP streaming mode

Commit 105bdf9ec19e729bacdb33861c74fcf3eb39eb37 introduced a
regression in L2CAP streaming mode due to rearranged initialization
code that is shared between ERTM and streaming mode.  This change
makes sure the transmit queue is initialized in both modes.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Acked-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Update tx_send_head when sending ERTM data
Mat Martineau [Mon, 14 May 2012 18:24:33 +0000 (11:24 -0700)]
Bluetooth: Update tx_send_head when sending ERTM data

Commit 94122bbe9c8c4ad7ba9f02f9a30bfc95672c404e introduced a problem
where tx_send_head was not set to point to the first skb in the ERTM
transmit queue, which stalled data transmission.  This change sets
that pointer when transmission is not already in progress.

Reported-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: mgmt: Fix device_connected sending order
Johan Hedberg [Sat, 12 May 2012 19:11:50 +0000 (16:11 -0300)]
Bluetooth: mgmt: Fix device_connected sending order

The mgmt_ev_device_connected signal must be sent before any event
indications happen for sockets associated with the connection. Otherwise
e.g. device authorization for the sockets will fail with ENOTCONN as
user space things that there is no baseband link.

This patch fixes the issue by ensuring that the device_connected event
if sent (if it hasn't been so already) as soon as the first ACL data
packet arrives from the remote device.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
12 years agoBluetooth: notify userspace of security level change
Gustavo Padovan [Sun, 13 May 2012 06:20:07 +0000 (03:20 -0300)]
Bluetooth: notify userspace of security level change

It fixes L2CAP socket based security level elevation during a
connection. The HID profile needs this (for keyboards) and it is the only
way to achieve the security level elevation when using the management
interface to talk to the kernel (hence the management enabling patch
being the one that exposes this issue).

It enables the userspace a security level change when the socket is
already connected and create a way to notify the socket the result of the
request. At the moment of the request the socket is made non writable, if
the request fails the connections closes, otherwise the socket is made
writable again, POLL_OUT is emmited.

Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
12 years agortlwifi: fix for race condition when firmware is cached
Larry Finger [Fri, 4 May 2012 13:27:43 +0000 (08:27 -0500)]
rtlwifi: fix for race condition when firmware is cached

In commit b0302ab, the rtlwifi family of drivers was converted to use
asynchronous firmware loading. Unfortumately, the implementation was
racy, and the ieee80211 routines could be started before rtl_init_core()
was called to setup the data.

This patch fixes the bug noted in https://bugzilla.kernel.org/show_bug.cgi?id=43187.

Reported-by: Joshua Roys <Joshua.Roys@gtri.gatech.edu>
Tested-by: Neptune Ning <frostyplanet@gmail.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Stable <stable@vger.kernel.org> [3.3]
Signed-off-by: John W. Linville <linville@tuxdriver.com>
12 years agoBluetooth: Fixed checkpatch warnings
Cristian Chilipirea [Wed, 9 May 2012 05:44:52 +0000 (08:44 +0300)]
Bluetooth: Fixed checkpatch warnings

Fixed some checkpatch warnings in mgmt.c.

Signed-off-by: Cristian Chilipirea <cristian.chilipirea@gmail.com>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: bnep: use constant for ethertype
Eldad Zack [Mon, 7 May 2012 22:09:35 +0000 (00:09 +0200)]
Bluetooth: bnep: use constant for ethertype

The dot1q ethertype number (0x8100) is embedded in the code, although
it is already defined in included headers.

Signed-off-by: Eldad Zack <eldad@fogrefinery.com>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Refactor L2CAP ERTM and streaming transmit segmentation
Mat Martineau [Wed, 2 May 2012 16:42:02 +0000 (09:42 -0700)]
Bluetooth: Refactor L2CAP ERTM and streaming transmit segmentation

Use more common code for ERTM and streaming mode segmentation and
transmission, and begin using skb control block data for delaying
extended or enhanced header generation until just before the packet is
transmitted.  This code is also better suited for resegmentation,
which is needed when L2CAP links are reconfigured after an AMP channel
move.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Reviewed-by: Ulisses Furquim <ulisses@profusion.mobi>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Remove unneeded calculation and magic number
Andrei Emeltchenko [Thu, 3 May 2012 07:55:52 +0000 (10:55 +0300)]
Bluetooth: Remove unneeded calculation and magic number

Remove magic number unneeded calculation since
hlen = L2CAP_HDR_SIZE + L2CAP_PSMLEN_SIZE

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Remove hlen variable
Gustavo Padovan [Thu, 3 May 2012 07:54:21 +0000 (04:54 -0300)]
Bluetooth: Remove hlen variable

hlen has a fixed size of L2CAP_HDR_SIZE, use this instead.

Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Enable Low Energy support by default
Marcel Holtmann [Thu, 3 May 2012 05:12:31 +0000 (07:12 +0200)]
Bluetooth: Enable Low Energy support by default

The Bluetooth Low Energy support so far was disabled by default via
a module parameter. With this change the module parameter will be removed
and Low Energy is enabled by default.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Remove unused hci_le_ltk_neg_reply()
Syam Sidhardhan [Fri, 20 Apr 2012 16:42:31 +0000 (22:12 +0530)]
Bluetooth: Remove unused hci_le_ltk_neg_reply()

No one is using hci_le_ltk_neg_reply() in bluetooth subsystem.

Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: btmrvl: add support for SDIO suspend/resume callbacks
Amitkumar Karwar [Wed, 25 Apr 2012 18:43:54 +0000 (11:43 -0700)]
Bluetooth: btmrvl: add support for SDIO suspend/resume callbacks

Host sleep is activated using already configured host sleep
parameters in suspend handler and it is cancelled in resume
handler.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Remove unneeded elements from size calculation
Gustavo Padovan [Wed, 2 May 2012 14:56:17 +0000 (11:56 -0300)]
Bluetooth: Remove unneeded elements from size calculation

hlen - L2CAP_HDR_SIZE = 0, so we don't need to add them in the
calculation.

Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Remove unused hci_le_ltk_reply()
Syam Sidhardhan [Thu, 12 Apr 2012 15:03:17 +0000 (20:33 +0530)]
Bluetooth: Remove unused hci_le_ltk_reply()

In this API, we were using sizeof operator for an array
given as function argument, which is invalid.
However this API is not used anywhere.

Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Add Code Aurora Forum copyright
Mat Martineau [Fri, 27 Apr 2012 23:50:55 +0000 (16:50 -0700)]
Bluetooth: Add Code Aurora Forum copyright

Adding Code Aurora Forum copyright information due to significant
additions of code.

Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Make better use of l2cap_chan reference counting
Mat Martineau [Fri, 27 Apr 2012 23:50:50 +0000 (16:50 -0700)]
Bluetooth: Make better use of l2cap_chan reference counting

L2CAP sockets contain a pointer to l2cap_chan that needs to be
reference counted in order to prevent a possible dangling pointer when
the channel is freed.

There were a few other cases where an l2cap_chan pointer on the stack
was dereferenced after a call to l2cap_chan_del. Those pointers are
also now reference counted.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Remove unused function
Mat Martineau [Fri, 27 Apr 2012 23:50:49 +0000 (16:50 -0700)]
Bluetooth: Remove unused function

l2cap_get_chan_by_ident was not used, but didn't generate a compiler
warning because it was an inline function.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Initialize new l2cap_chan structure members
Mat Martineau [Fri, 27 Apr 2012 23:50:48 +0000 (16:50 -0700)]
Bluetooth: Initialize new l2cap_chan structure members

Structure members used by ERTM or streaming mode need to be
initialized when an ERTM or streaming mode link is configured.  Some
duplicate code is also eliminated by moving in to the ERTM init
function.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Move recently-added ERTM header packing functions
Mat Martineau [Wed, 25 Apr 2012 23:36:15 +0000 (16:36 -0700)]
Bluetooth: Move recently-added ERTM header packing functions

Moving these functions simplifies future patches by eliminating
forward declarations, makes future patches easier to review, and
better preserves 'git blame' information.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Remove duplicate structure members from bt_skb_cb
Mat Martineau [Wed, 25 Apr 2012 23:36:14 +0000 (16:36 -0700)]
Bluetooth: Remove duplicate structure members from bt_skb_cb

These values are now in the nested l2cap_ctrl struct.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Improve ERTM sequence number offset calculation
Mat Martineau [Wed, 25 Apr 2012 23:36:12 +0000 (16:36 -0700)]
Bluetooth: Improve ERTM sequence number offset calculation

Instead of using modular division, the offset can be calculated using
only addition and subtraction.  The previous calculation did not work
as intended and was more difficult to understand, involving unsigned
integer underflow and a check for a negative value where one was not
possible.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: btmrvl: configure default host sleep parameters
Amitkumar Karwar [Tue, 24 Apr 2012 23:31:40 +0000 (16:31 -0700)]
Bluetooth: btmrvl: configure default host sleep parameters

Currently debugfs commands "hscfgcmd" and "gpiogap" are provided
for host sleep configuration. But if user doesn't configure host
sleep parameters using these commands, host sleep activation is
failed during suspend (support for suspend and resume handlers is
added in next patch).

Default host sleep configuration is done during driver initialisation
in this patch.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Remove advertising cache
Andre Guedes [Wed, 25 Apr 2012 00:02:56 +0000 (21:02 -0300)]
Bluetooth: Remove advertising cache

User-space pass the remote device address type to kernel through
struct sockaddr_l2 what makes the advertising useless. This patch
removes all advertising cache code.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Use address type info from user-space
Andre Guedes [Wed, 25 Apr 2012 00:02:55 +0000 (21:02 -0300)]
Bluetooth: Use address type info from user-space

In order to establish a LE connection we need the address type
information. User-space already pass this information to kernel
through struct sockaddr_l2.

This patch adds the dst_type parameter to l2cap_chan_connect so we
are able to pass the address type info from user-space down to
hci_conn layer.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Add dst_type parameter to hci_connect
Andre Guedes [Wed, 25 Apr 2012 00:02:54 +0000 (21:02 -0300)]
Bluetooth: Add dst_type parameter to hci_connect

This patch adds the dst_type parameter to hci_connect function.
Instead of searching the address type in advertising cache, we
use the dst_type parameter to establish LE connections.

The dst_type is ignored for BR/EDR connection establishment.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Move bdaddr_to_le to hci_core
Andre Guedes [Wed, 25 Apr 2012 00:02:53 +0000 (21:02 -0300)]
Bluetooth: Move bdaddr_to_le to hci_core

This patch moves the helper function bdaddr_to_le to hci_core, so it
can be used in mgmt.c and hci_conn.c.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Rename mgmt_to_le to bdaddr_to_le
Andre Guedes [Wed, 25 Apr 2012 00:02:51 +0000 (21:02 -0300)]
Bluetooth: Rename mgmt_to_le to bdaddr_to_le

Since address type macros are not only related to Management
Interface anymore, it makes sense to rename the helper function
mgmt_to_le to bdaddr_to_le.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Add address type to struct sockaddr_l2
Andre Guedes [Wed, 25 Apr 2012 00:02:52 +0000 (21:02 -0300)]
Bluetooth: Add address type to struct sockaddr_l2

This patch adds the address type info to struct sockaddr_l2 so
user-space can inform the remote device address type required
to establish LE connections.

Soon, instead of looking the advertising cache up to discover the
address type, we'll use this address type info to establish LE
connections.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Rename link_to_mgmt to link_to_bdaddr
Andre Guedes [Wed, 25 Apr 2012 00:02:50 +0000 (21:02 -0300)]
Bluetooth: Rename link_to_mgmt to link_to_bdaddr

Since address type macros are not only related to Management
Interface anymore, it makes sense to rename the helper function
link_to_mgmt to link_to_bdaddr.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Move address type macros to bluetooth.h
Andre Guedes [Wed, 25 Apr 2012 00:02:49 +0000 (21:02 -0300)]
Bluetooth: Move address type macros to bluetooth.h

This patch moves address type macros to bluetooth.h since they will be
used by management interface and Bluetooth socket interface. It also
replaces the macro prefix MGMT_ADDR_ by BDADDR_.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: trivial: Remove empty line
Andrei Emeltchenko [Mon, 16 Apr 2012 13:32:03 +0000 (16:32 +0300)]
Bluetooth: trivial: Remove empty line

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Remove useless code in hci_connect
Andre Guedes [Tue, 24 Apr 2012 19:11:11 +0000 (16:11 -0300)]
Bluetooth: Remove useless code in hci_connect

This patch removes unneeded variable assignments in hci_connect.
'sec_level' is already assigned to BT_SECURITY_LOW in hci_le_connect
and 'pending_sec_level' and 'auth_type' are assigned right after
if statement.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Add support for reusing the same hci_conn for LE links
Vinicius Costa Gomes [Fri, 20 Apr 2012 18:46:08 +0000 (15:46 -0300)]
Bluetooth: Add support for reusing the same hci_conn for LE links

As most LE devices leave advertising mode when they enter the connected
state, we may want to "pass" that connection to other users.

The first user will be the pairing procedure, the connection is
established without an associated socket, after the pairing is
complete, userspace may want to discover via GATT what services the
newly bonded device has.

If userspace establishes the connection while the timeout still
hasn't expired, the connection will be re-used.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Tested-by: João Paulo Rechi Vita <jprvita@openbossa.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Search global l2cap channels by src/dst addresses
Ido Yariv [Fri, 20 Apr 2012 18:46:07 +0000 (15:46 -0300)]
Bluetooth: Search global l2cap channels by src/dst addresses

The cid or psm and the source address might not be enough to uniquely
identify a global channel, especially when the source address is our
own.

For instance, when trying to communicate with two LE devices in master
mode, data received from the both devices is sent to the same socket.

Fix this by taking the destination address into account when choosing
the socket.

Signed-off-by: Ido Yariv <ido@wizery.com>
Signed-off-by: Arik Nemtsov <arik@wizery.com>
Tested-by: João Paulo Rechi Vita <jprvita@openbossa.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Remove unneeded initialization in hci_alloc_dev()
David Herrmann [Sun, 22 Apr 2012 12:39:59 +0000 (14:39 +0200)]
Bluetooth: Remove unneeded initialization in hci_alloc_dev()

We allocate memory with kzalloc() so there is no need to call
memset(..., 0, ...) or similar.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Move device initialization to hci_alloc_dev()
David Herrmann [Sun, 22 Apr 2012 12:39:58 +0000 (14:39 +0200)]
Bluetooth: Move device initialization to hci_alloc_dev()

We currently initialize locks, lists, works, etc. in hci_register_dev()
(hci_alloc_dev() was added later) which is bogus because an hdev is in an
invalid state if it is not registered.
This patch moves all memory initialization to hci_alloc_dev(). Device
registering and registration of sub-modules is still left in
hci_register_dev() as it belongs there.

The benefit is (despite cleaning up the code-base) we can now always be
sure that an hdev is a valid object and can be locked and worked on even
though it may not be registered.

This patch also reorders the initialization to be easier to understand.
First the memory is initialized, then all generic structures and as last
step the sub-init functions are called. This guarantees that all
dependencies are initialized in the right order and makes it also easier
to find a specific line. We previously initialized it in the same order as
the "struct hci_dev" is declared which seems pretty random.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Move hci_alloc/free_dev close to hci_register/unregister_dev
David Herrmann [Sun, 22 Apr 2012 12:39:57 +0000 (14:39 +0200)]
Bluetooth: Move hci_alloc/free_dev close to hci_register/unregister_dev

alloc() and register() (and free() and unregister()) are closely related
so move them more closely together. This will also allow to move
functionality from register() to alloc() without needing
forward-declarations.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Restrict to one SCO listening socket
Marcel Holtmann [Thu, 19 Apr 2012 12:37:58 +0000 (14:37 +0200)]
Bluetooth: Restrict to one SCO listening socket

The SCO sockets are only identified by its address. So only allow one
SCO socket in listening state per address or BDADDR_ANY.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Don't check source address in SCO bind function
Marcel Holtmann [Thu, 19 Apr 2012 11:43:53 +0000 (13:43 +0200)]
Bluetooth: Don't check source address in SCO bind function

Checking the source address in SCO bind function will prevent from
having an incoming and outgoing SCO socket. However that might be
needed in case of multiple SCO connections on a single device.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Fix registering hci with duplicate name
Ulisses Furquim [Wed, 18 Apr 2012 15:13:04 +0000 (12:13 -0300)]
Bluetooth: Fix registering hci with duplicate name

When adding HCI devices hci_register_dev assigns the same name
hci1 for subsequently added AMP devices.

...
[ 6958.381886] sysfs: cannot create duplicate filename
       '/devices/virtual/bluetooth/hci1
...

We assume id starts with the number we'll try to add the new device
and keep iterating until we find the proper place. The only difference
is we start with 0 for BR/EDR device and 1 for AMP devices (thus AMP
devices will never receive register as index 0). Then every hdev->id in
the _ordered_ list <= to the id we want we increment id and move the
variable head. In the end we'll have id as the first available one and
head is where you need to add hdev after to keep the list ordered.

Reported-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Ulisses Furquim <ulisses@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Remove not needed status parameter
Lukasz Rymanowski [Thu, 19 Apr 2012 14:12:28 +0000 (16:12 +0200)]
Bluetooth: Remove not needed status parameter

Sco_conn_add is called from two places and always with status = 0.

Signed-off-by: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Split error handling for SCO listen sockets
Marcel Holtmann [Thu, 19 Apr 2012 11:43:52 +0000 (13:43 +0200)]
Bluetooth: Split error handling for SCO listen sockets

Split the checks for sk->sk_state and sk->sk_type for SCO listen
sockets. This makes the code more readable.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Split error handling for L2CAP listen sockets
Marcel Holtmann [Thu, 19 Apr 2012 11:43:51 +0000 (13:43 +0200)]
Bluetooth: Split error handling for L2CAP listen sockets

Split the checks for sk->sk_state and sk->sk_type for L2CAP listen
sockets. This makes the code more readable.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Don't distribute keys in case of Encryption Failure
Hemant Gupta [Wed, 18 Apr 2012 09:16:26 +0000 (14:46 +0530)]
Bluetooth: Don't distribute keys in case of Encryption Failure

SMP Keys should only be distributeed when encryption is successful.

Signed-off-by: Hemant Gupta <hemant.gupta@stericsson.com>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: btusb: Dynamic alternate setting
Mikel Astiz [Wed, 11 Apr 2012 06:48:51 +0000 (08:48 +0200)]
Bluetooth: btusb: Dynamic alternate setting

The alternate setting must be dynamically set according to the number of
active SCO links, and the bit depth of the audio. The possible values
for the alternate setting are described in the Bluetooth Core
Specification, Volume 4, Part B, section 2.1.1.

Signed-off-by: Mikel Astiz <mikel.astiz.oss@gmail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Fix debug printing unallocated name
Andrei Emeltchenko [Mon, 16 Apr 2012 13:32:04 +0000 (16:32 +0300)]
Bluetooth: Fix debug printing unallocated name

It does make sense to print hdev name after allocation.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Remove strtoba header declared but not defined
Syam Sidhardhan [Thu, 12 Apr 2012 15:03:20 +0000 (20:33 +0530)]
Bluetooth: Remove strtoba header declared but not defined

No one is using strtoba() in the bluetooth subsystem.

Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: remove header declared but not defined
Syam Sidhardhan [Thu, 12 Apr 2012 15:03:19 +0000 (20:33 +0530)]
Bluetooth: remove header declared but not defined

hci_del_off_timer() doesn't exist anymore.

Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: mgmt: Fix address type while loading Long Term Key
Hemant Gupta [Mon, 16 Apr 2012 09:27:40 +0000 (14:57 +0530)]
Bluetooth: mgmt: Fix address type while loading Long Term Key

This patch fixes the address type while loading long term keys when BT is
switched on. Without this fix pairing is reinitated even though LTK
exists for remote device because of mismatch of address type.

Signed-off-by: Hemant Gupta <hemant.gupta@stericsson.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: mgmt: Remove unwanted goto statements
Syam Sidhardhan [Thu, 12 Apr 2012 15:03:21 +0000 (20:33 +0530)]
Bluetooth: mgmt: Remove unwanted goto statements

Remove goto statements that do nothing else than jump to the next line
of code.

Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: remove unneeded declaration of sco_conn_del()
Gustavo Padovan [Fri, 13 Apr 2012 22:52:27 +0000 (19:52 -0300)]
Bluetooth: remove unneeded declaration of sco_conn_del()

By some reason this is not needed anymore.

Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Remove unnecessary check
Mikel Astiz [Wed, 11 Apr 2012 06:48:48 +0000 (08:48 +0200)]
Bluetooth: Remove unnecessary check

The function already fails if the given size is greater than the MTU, so
there is no need to consider that case afterwards.

Signed-off-by: Mikel Astiz <mikel.astiz.oss@gmail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Use unsigned int instead of signed int
Mikel Astiz [Wed, 11 Apr 2012 06:48:47 +0000 (08:48 +0200)]
Bluetooth: Use unsigned int instead of signed int

The involved values are all unsigned and thus unsigned int should be
used instead of signed int. Assigning ~0 to a signed int results in -1,
which is confusing and error-prone, while the code is trying to set the
maximum value possible.

The code still works because the C standard defines that unsigned
comparison will be performed in these cases, when comparing an unsigned
int and a signed int.

Signed-off-by: Mikel Astiz <mikel.astiz.oss@gmail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: btmrvl_sdio: remove pointless conditional before release_firmware()
Jesper Juhl [Mon, 9 Apr 2012 20:49:49 +0000 (22:49 +0200)]
Bluetooth: btmrvl_sdio: remove pointless conditional before release_firmware()

release_firmware() deals gracefullt with NULL pointers so there's no
reason to test for one prior to calling the function.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Functions for handling ERTM control fields
Mat Martineau [Wed, 11 Apr 2012 17:48:43 +0000 (10:48 -0700)]
Bluetooth: Functions for handling ERTM control fields

These functions encode or decode ERTM control fields (extended or
enhanced) to or from the new l2cap_ctrl structure.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Acked-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Add the l2cap_seq_list structure for tracking frames
Mat Martineau [Wed, 11 Apr 2012 17:48:42 +0000 (10:48 -0700)]
Bluetooth: Add the l2cap_seq_list structure for tracking frames

A sequence list is a data structure used to track frames that need to
be retransmitted, and frames that have been requested for
retransmission by the remote device.  It can compactly represent a
list of sequence numbers within the ERTM transmit window.  Memory for
the list is allocated once at connection time, and common operations
in ERTM are O(1).

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
12 years agoBluetooth: Remove err parameter from alloc_skb()
Gustavo Padovan [Fri, 6 Apr 2012 23:15:47 +0000 (20:15 -0300)]
Bluetooth: Remove err parameter from alloc_skb()

Use ERR_PTR maginc instead.

Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Adds set_default function in L2CAP setup
Andrei Emeltchenko [Wed, 28 Mar 2012 13:31:25 +0000 (16:31 +0300)]
Bluetooth: Adds set_default function in L2CAP setup

Some parameters in L2CAP chan are set to default similar way in
socket based channels and A2MP channels. Adds common function which
sets all defaults.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Add Read Local AMP Info to init
Andrei Emeltchenko [Wed, 28 Mar 2012 13:31:24 +0000 (16:31 +0300)]
Bluetooth: Add Read Local AMP Info to init

AMP Info will be used in Discovery Response.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: mgmt: Fix missing connect failed event for LE
Hemant Gupta [Thu, 5 Apr 2012 11:21:04 +0000 (16:51 +0530)]
Bluetooth: mgmt: Fix missing connect failed event for LE

This patch adds management connect failed event when LE Create Connection
Command fails to inform user space that LE Connection failed to get
established.

Signed-off-by: Hemant Gupta <hemant.gupta@stericsson.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Fix clearing discovery type when stopping discovery
Hemant Gupta [Thu, 5 Apr 2012 04:57:21 +0000 (10:27 +0530)]
Bluetooth: Fix clearing discovery type when stopping discovery

This patch prevents resetting of discovery type while stopping
discovery, since otherwise the wrong type might be send in case of
discovery failure. It also doesn't matter that we are "lazy" with
updating the type since it is anyway reset when starting discovery again
and it's not needed to know the current discovery state.

Signed-off-by: Hemant Gupta <hemant.gupta@stericsson.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Remove MGMT_ADDR_INVALID macro
Andre Guedes [Tue, 3 Apr 2012 11:46:54 +0000 (08:46 -0300)]
Bluetooth: Remove MGMT_ADDR_INVALID macro

This patch removes the MGMT_ADDR_INVALID macro. If the address type
isn't LE, we consider it is BR/EDR type.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Send correct address type for LTK
Hemant Gupta [Fri, 30 Mar 2012 11:53:35 +0000 (17:23 +0530)]
Bluetooth: Send correct address type for LTK

This patch updates the address type sent from kernel to management
interface of BlueZ while sending the Long Term Key.

Signed-off-by: Hemant Gupta <hemant.gupta@stericsson.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Remove unneeded zero initialization
Andrei Emeltchenko [Wed, 28 Mar 2012 13:06:41 +0000 (16:06 +0300)]
Bluetooth: Remove unneeded zero initialization

Remove zero initialization since channel is allocated with kzalloc
in l2cap_chan_create.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: vhci: Ignore return code of nonseekable_open()
David Herrmann [Wed, 28 Mar 2012 09:48:42 +0000 (11:48 +0200)]
Bluetooth: vhci: Ignore return code of nonseekable_open()

The comment in ./fs/open.c clearly states that nonseekable_open() will
never fail. Therefore, we can safely ignore the return code. This is the
recommended way to deal with nonseekable_open().
Our current code looks like nonseekable_open() is checked for the return
code. However, if we check the return code, we must also kfree() our
private data if the open fails. To avoid this overhead and to avoid
confusion, we simply drop the return code and return 0.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Update management interface revision
Marcel Holtmann [Tue, 27 Mar 2012 16:49:02 +0000 (18:49 +0200)]
Bluetooth: Update management interface revision

For each kernel release where commands or events are added to the
management interface, the revision field should be increment by one.

The increment should only happen once per kernel release and not
for every command/event that gets added. The revision value is for
informational purposes only, but this simple policy would make any
future debugging a lot simple.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Remove sk parameter from l2cap_chan_create()
Gustavo Padovan [Sun, 25 Mar 2012 16:59:16 +0000 (13:59 -0300)]
Bluetooth: Remove sk parameter from l2cap_chan_create()

Following the separation if core and sock code this change avoid
manipulation of sk inside l2cap_chan_create().

Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Make L2CAP chan_add functions static
Andrei Emeltchenko [Fri, 23 Mar 2012 14:31:49 +0000 (16:31 +0200)]
Bluetooth: Make L2CAP chan_add functions static

Remove sparse warnings below:

...
net/bluetooth/l2cap_core.c:302:6: warning: symbol '__l2cap_chan_add' was
not declared. Should it be static?
net/bluetooth/l2cap_core.c:351:6: warning: symbol 'l2cap_chan_add' was
not declared. Should it be static?
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Remove unneeded timer clear
Andrei Emeltchenko [Wed, 21 Mar 2012 08:34:32 +0000 (10:34 +0200)]
Bluetooth: Remove unneeded timer clear

set_chan_timer clears timer itself

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Add a structure to carry ERTM data in skb control blocks
Mat Martineau [Fri, 23 Mar 2012 23:56:56 +0000 (16:56 -0700)]
Bluetooth: Add a structure to carry ERTM data in skb control blocks

Every field from ERTM control headers is now carried in the control
block so it only has to be parsed or generated once, and can be
efficiently accessed throughout the ERTM code.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Add definitions and struct members for new ERTM state machine
Mat Martineau [Fri, 23 Mar 2012 23:56:55 +0000 (16:56 -0700)]
Bluetooth: Add definitions and struct members for new ERTM state machine

Adds some missing values for control field parsing, additional data
for the new state machine, and enumerations for states, incoming
packet classification, and state machine events.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Comments and style fixes
Andrei Emeltchenko [Fri, 23 Mar 2012 14:31:50 +0000 (16:31 +0200)]
Bluetooth: Comments and style fixes

Add comments to timer implementation and style fixes.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Add HCI_PERIODIC_INQ to dev_flags
Andre Guedes [Wed, 21 Mar 2012 03:03:36 +0000 (00:03 -0300)]
Bluetooth: Add HCI_PERIODIC_INQ to dev_flags

This patch adds the HCI_PERIODIC_INQ flag to dev_flags. This flag
tracks if periodic inquiry is enabled or not.

Signed-off-by: Andre Guedes <aguedespe@gmail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Add Periodic Inquiry command complete handler
Andre Guedes [Wed, 21 Mar 2012 03:03:35 +0000 (00:03 -0300)]
Bluetooth: Add Periodic Inquiry command complete handler

This patch adds a handler function to Periodic Inquiry command
complete event.

Signed-off-by: Andre Guedes <aguedespe@gmail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Ignore inquiry results from periodic inquiry
Andre Guedes [Wed, 21 Mar 2012 03:03:38 +0000 (00:03 -0300)]
Bluetooth: Ignore inquiry results from periodic inquiry

This patch changes inquiry result function handlers so they ignore
inquiry result events if periodic inquiry is enabled.

Signed-off-by: Andre Guedes <aguedespe@gmail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Check HCI_PERIODIC_INQ in start_discovery
Andre Guedes [Wed, 21 Mar 2012 03:03:37 +0000 (00:03 -0300)]
Bluetooth: Check HCI_PERIODIC_INQ in start_discovery

This patch adds a HCI_PERIODIC_INQ check to start_discovery.
If periodic inquiry is enabled, we fail MGMT Start Discovery
command with MGMT_STATUS_BUSY code.

Signed-off-by: Andre Guedes <aguedespe@gmail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Add HCI_PERIODIC_INQ to dev_flags
Andre Guedes [Wed, 21 Mar 2012 03:03:36 +0000 (00:03 -0300)]
Bluetooth: Add HCI_PERIODIC_INQ to dev_flags

This patch adds the HCI_PERIODIC_INQ flag to dev_flags. This flag
tracks if periodic inquiry is enabled or not.

Signed-off-by: Andre Guedes <aguedespe@gmail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Add Periodic Inquiry command complete handler
Andre Guedes [Wed, 21 Mar 2012 03:03:35 +0000 (00:03 -0300)]
Bluetooth: Add Periodic Inquiry command complete handler

This patch adds a handler function to Periodic Inquiry command
complete event.

Signed-off-by: Andre Guedes <aguedespe@gmail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Refactor stop_discovery
Andre Guedes [Tue, 20 Mar 2012 18:15:36 +0000 (15:15 -0300)]
Bluetooth: Refactor stop_discovery

This patch does a trivial code refactoring in stop_discovery
function by using a switch statement instead of an if-return-else
approach.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Replace EPERM by EALREADY in hci_cancel_inquiry
Andre Guedes [Tue, 20 Mar 2012 03:13:38 +0000 (00:13 -0300)]
Bluetooth: Replace EPERM by EALREADY in hci_cancel_inquiry

We should return -EALREADY in hci_cancel_inquiry since it is more
suitable than -EPERM error code.

Signed-off-by: Andre Guedes <aguedespe@gmail.com>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: Silence sparse warning
Andrei Emeltchenko [Tue, 20 Mar 2012 08:32:25 +0000 (10:32 +0200)]
Bluetooth: Silence sparse warning

Silence sparse warning shown below:
...
net/bluetooth/mgmt.c:448:15: warning: cast to restricted __le32
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
12 years agoBluetooth: mgmt: Don't allow to set invalid value to DeviceID source
Szymon Janc [Fri, 16 Mar 2012 15:02:57 +0000 (16:02 +0100)]
Bluetooth: mgmt: Don't allow to set invalid value to DeviceID source

Reply with MGMT_STATUS_INVALID_PARAMS when userspace is trying to set
source with out-of-scope value.

Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
Acked-by: Gustavo Padovan <gustavo@padovan.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: mgmt: Fix some code style and indentation issues
Szymon Janc [Fri, 16 Mar 2012 15:02:56 +0000 (16:02 +0100)]
Bluetooth: mgmt: Fix some code style and indentation issues

Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
Acked-by: Gustavo Padovan <gustavo@padovan.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: LE support for MGMT stop discovery
Andre Guedes [Thu, 15 Mar 2012 19:52:08 +0000 (16:52 -0300)]
Bluetooth: LE support for MGMT stop discovery

This patch adds LE support to MGMT stop discovery command. So,
now we are able to cancel LE discovery procedures (LE-only and
interleaved).

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Add hci_cancel_le_scan() to hci_core
Andre Guedes [Thu, 15 Mar 2012 19:52:07 +0000 (16:52 -0300)]
Bluetooth: Add hci_cancel_le_scan() to hci_core

This patch adds to hci_core the hci_cancel_le_scan function which
should be used to cancel an ongoing LE scan.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: trivial: Remove sparse warnings
Andrei Emeltchenko [Wed, 14 Mar 2012 16:54:15 +0000 (18:54 +0200)]
Bluetooth: trivial: Remove sparse warnings

Fix sparse warnings related to incorrect type in assignment and static
symbol.  Also use const keyword. Warnings are shown below:

...
net/bluetooth/mgmt.c:305:28: warning: incorrect type in assignment
(different base types)
net/bluetooth/mgmt.c:305:28:    expected unsigned short [usertype] *opcode
net/bluetooth/mgmt.c:305:28:    got restricted __le16 *<noident>
...
net/bluetooth/mgmt.c:2609:3: warning: symbol 'mgmt_handlers' was not declared.
Should it be static?
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Fix broken usage of get_unaligned_le16
Marcel Holtmann [Tue, 13 Mar 2012 03:31:08 +0000 (20:31 -0700)]
Bluetooth: Fix broken usage of get_unaligned_le16

In case the struct is already __packed, there is no need to use unaligned
access to the data. So just use __le16_to_cpu in these cases.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Fix opcode access in hci_complete
Andrei Emeltchenko [Mon, 12 Mar 2012 13:59:33 +0000 (15:59 +0200)]
Bluetooth: Fix opcode access in hci_complete

opcode to be accessed is in le16 format so convert it
first to cpu byte order.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Fix type in cpu_to_le conversion
Andrei Emeltchenko [Mon, 12 Mar 2012 13:59:32 +0000 (15:59 +0200)]
Bluetooth: Fix type in cpu_to_le conversion

Use struct hci_cp_write_def_link_policy to overcome sparse
warnigs below:

...
net/bluetooth/hci_event.c:633:21: warning: incorrect type in assignment
(different base types)
net/bluetooth/hci_event.c:633:21:    expected unsigned short [unsigned]
[assigned] [usertype] link_policy
net/bluetooth/hci_event.c:633:21:    got restricted __le16 [usertype] <noident>
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: trivial: Correct types
Andrei Emeltchenko [Mon, 12 Mar 2012 13:59:31 +0000 (15:59 +0200)]
Bluetooth: trivial: Correct types

Fix sparse warnigns below:
...
net/bluetooth/hci_sysfs.c:458:33: warning: cast to restricted __be32
net/bluetooth/hci_sysfs.c:458:47: warning: cast to restricted __be16
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: trivial: Fix endian conversion mode
Andrei Emeltchenko [Mon, 12 Mar 2012 10:13:10 +0000 (12:13 +0200)]
Bluetooth: trivial: Fix endian conversion mode

In L2CAP we use le16 format so change direction of conversion
from le16_to_cpu to cpu_to_le16.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Convert error codes to le16
Andrei Emeltchenko [Mon, 12 Mar 2012 10:13:09 +0000 (12:13 +0200)]
Bluetooth: Convert error codes to le16

Create Chan Rsp shall put result and status in le format.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Correct CID endian notation
Andrei Emeltchenko [Mon, 12 Mar 2012 10:13:08 +0000 (12:13 +0200)]
Bluetooth: Correct CID endian notation

L2CAP channel id is used in host format in internal L2CAP code.
Fix sparse warnings about wrong endian conversion.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Correct length calc in L2CAP conf rsp
Andrei Emeltchenko [Mon, 12 Mar 2012 10:13:07 +0000 (12:13 +0200)]
Bluetooth: Correct length calc in L2CAP conf rsp

cmd->len is in le format so convert it to host format before use.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Correct ediv in SMP
Andrei Emeltchenko [Mon, 12 Mar 2012 10:13:06 +0000 (12:13 +0200)]
Bluetooth: Correct ediv in SMP

ediv is already in little endian order.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Fix broken usage of put_unaligned_le16
Marcel Holtmann [Wed, 14 Mar 2012 16:08:46 +0000 (18:08 +0200)]
Bluetooth: Fix broken usage of put_unaligned_le16

In case the struct is already __packed, there is no need to use
unaligned access to the data. So just use cpu_to_le16 or
__constant_cpu_to_le16 in these cases.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
12 years agoBluetooth: Add management command for setting Device ID
Marcel Holtmann [Mon, 12 Mar 2012 03:00:29 +0000 (20:00 -0700)]
Bluetooth: Add management command for setting Device ID

The Device ID details need to be programmed into the kernel for every
controller at least once. So provide management command for this.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>