Andre Guedes [Thu, 23 Feb 2012 21:09:27 +0000 (18:09 -0300)]
Bluetooth: Check capabilities in BR/EDR and LE-Only discovery
This patch add an extra check for BR/EDR and LE-Only discovery.
This way, we are able to return error immediately if the discovery
type requested is not supported by the device.
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>
Johan Hedberg [Thu, 1 Mar 2012 03:55:35 +0000 (19:55 -0800)]
Bluetooth: mgmt: Add missing hci_dev locking to set_le()
The set_le() function was missing hci_dev locking which is e.g. critical
for the mgmt pending command adding/removing.
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Gustavo F. Padovan [Thu, 1 Mar 2012 03:37:10 +0000 (00:37 -0300)]
Bluetooth: Fix coding style with breaking lines
Our limit is 80 and broken lines should as right as possible.
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Andre Guedes [Wed, 29 Feb 2012 19:38:13 +0000 (16:38 -0300)]
Bluetooth: Fix Kconfig help description
SMP is not a kernel module, it is part of Bluetooth Core (as already
described in lines above).
Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Szymon Janc [Sun, 12 Feb 2012 12:55:35 +0000 (13:55 +0100)]
Bluetooth: Use NULL instead of integer for mgmt_device_connected param
Last param of mgmt_device_connected is of pointer type, so use NULL
instead of 0 for it. This fix following sparse warning:
CHECK net/bluetooth/hci_event.c
net/bluetooth/hci_event.c:3262:74: warning: Using plain integer as NULL pointer
Signed-off-by: Szymon Janc <szymon@janc.net.pl>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Andre Guedes [Fri, 24 Feb 2012 14:41:04 +0000 (11:41 -0300)]
Bluetooth: Change interleaved discovery behavior
According to last discussion on IRC, if an interleaved discovery is
issued, but the device is not dual mode, we should return error
instead of performing a regular BR/EDR or LE-only discovery.
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>
Andrei Emeltchenko [Wed, 29 Feb 2012 08:41:41 +0000 (10:41 +0200)]
Bluetooth: Save remote L2CAP fixed channel mask
Fixed channel mask needs to be stored to decide whether to
use A2MP for example. So far save only one relevant byte which
keeps all information we need.
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>
Dan Carpenter [Tue, 28 Feb 2012 06:57:59 +0000 (09:57 +0300)]
Bluetooth: change min_t() cast in hci_reassembly()
"count" is type int so the cast to __u16 truncates the high bits away
and triggers a Smatch static checker warning. It looks like a high
value of count could cause a forever loop, but I didn't follow it
through to see if count is capped somewhere.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Dan Carpenter [Tue, 28 Feb 2012 06:52:46 +0000 (09:52 +0300)]
Bluetooth: use kfree_skb() instead of kfree()
sk_buffs should be freed using kfree_skb().
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Johan Hedberg [Tue, 28 Feb 2012 00:28:43 +0000 (02:28 +0200)]
Bluetooth: Use LMP_HOST_SSP define instead of magic values
This patch fixes the code to use the proper LMP_HOST_SSP define instead
of magic values and thereby makes the code more readable.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Tue, 28 Feb 2012 00:03:24 +0000 (02:03 +0200)]
Bluetooth: Add missing host features definitions
This patch adds missing SSP and "Simultaneous LE & BR/EDR" feature bit
definitions to hci.h.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Mon, 27 Feb 2012 23:07:22 +0000 (01:07 +0200)]
Bluetooth: Remove redundant read_host_features commands
Previously the write_le_enable would trigger a read_host_features
command but since we have access to the value LE support was set to we
can simply just clear or set the bit in hdev->host_features. This also
removes a second unnecessary read_host_features command from the device
initialization procedure since LE is only enabled after the first
read_host_features command completes.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Mon, 27 Feb 2012 22:57:24 +0000 (00:57 +0200)]
Bluetooth: Don't send unnecessary write_le_enable command
If the local host features indicate that LE is already in the state that
is desired there's no point in sending the HCI command to try to change
the setting.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Sun, 26 Feb 2012 11:04:52 +0000 (13:04 +0200)]
Bluetooth: Use kernel int types instead of ones from stdint.h
u8/__u8/u32/etc should be used in the kernel instead of stdint.h types.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Andrei Emeltchenko [Fri, 24 Feb 2012 14:00:00 +0000 (16:00 +0200)]
Bluetooth: Remove duplicated code in l2cap conn req
The same sequence sending L2CAP Connection Request was used in several
places. Using subroutine makes those places easy to read.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Reviewed-by: Ulisses Furquim <ulisses@profusion.mobi>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Andrei Emeltchenko [Fri, 24 Feb 2012 14:35:32 +0000 (16:35 +0200)]
Bluetooth: Fix double locking in LE and conless chan
Remove socket lock since chan->ops->recv locks socket itself.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Reviewed-by: Ulisses Furquim <ulisses@profusion.mobi>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Marcel Holtmann [Fri, 24 Feb 2012 16:09:38 +0000 (17:09 +0100)]
Bluetooth: Add support for creating HCI UART based AMP controllers
In reality this might never be used for real hardware, but it is a nice
feature for emulating AMP controllers within a virtual machine.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Marcel Holtmann [Fri, 24 Feb 2012 16:12:24 +0000 (17:12 +0100)]
Bluetooth: Allow HCI UART reset parameter via flags ioctl
The flags ioctl for HCI UART drivers already allows setting of certain
Bluetooth core quirks. The reset parameter fits right in here. So allow
this as well.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Andrei Emeltchenko [Fri, 24 Feb 2012 10:45:44 +0000 (12:45 +0200)]
Bluetooth: Fix init request completion with AMP controllers
Mark request status as done for Read Local Version HCI command. In AMP
initialization this HCI command is the last and needs to be completed.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Johan Hedberg [Fri, 24 Feb 2012 11:47:56 +0000 (13:47 +0200)]
Bluetooth: Fix init request completion with old controllers
With Bluetooth 1.1 controllers the last command in the HCI init sequence
will be a write_local_name, however there was no callback to indicate
init request completion in this case. This patch fixes the issue by
adding the necessary callback to the write_local_name_complete handler.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Johan Hedberg [Thu, 23 Feb 2012 21:24:30 +0000 (23:24 +0200)]
Bluetooth: mgmt: Fix clear_uuids response
Since the clear_uuids operation doesn't send an immediate HCI command
but just sets off a timer to wait for subsequent add_uuid calls it
doesn't make sense to wait until the timer fires off to send the
response. Instead send the response immediately.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Thu, 23 Feb 2012 21:09:40 +0000 (23:09 +0200)]
Bluetooth: mgmt: Fix dev_class related command response timing
All mgmt commands that may fire off a hci_write_class_of_device command
should wait for the completion of the HCI command before sending a
response to user space.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Thu, 23 Feb 2012 20:54:38 +0000 (22:54 +0200)]
Bluetooth: mgmt: Track pending class changes
This patch adds a flag to track pending changes to the class of device.
This is needed since we cannot cleanly handle multiple simultaneous
commands and need to return a "busy" error status in the mgmt commands
that might trigger a class change.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Thu, 23 Feb 2012 20:31:51 +0000 (22:31 +0200)]
Bluetooth: mgmt: Add flags parameter to device_connected
This patch updates the Device Connected events to match the latest API
by adding a flags parameter to them.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Thu, 23 Feb 2012 19:33:16 +0000 (21:33 +0200)]
Bluetooth: mgmt: Fix clear UUIDs response
We also need to send a proper response when clearing UUIDs. This patch
adds fixes the missing response for this use case.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Thu, 23 Feb 2012 19:30:12 +0000 (21:30 +0200)]
Bluetooth: mgmt: Move service cache setting to a more sensible place
Since we can now add UUIDs when powered off we don't really need to
always use the service cache to avoid large bursts of HCI commands.
Instead, the only important use case is when we're already powered and
user space starts to initialize itself. This can be easiest detected by
a "clear UUIDs" operation which is where this patch moves the service
cache setting.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Thu, 23 Feb 2012 13:57:46 +0000 (15:57 +0200)]
Bluetooth: mgmt: Fix return value of add/remove_uuid
The Add/Remove UUID commands should return the device class instead of
an empty parameter list.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Thu, 23 Feb 2012 11:30:41 +0000 (13:30 +0200)]
Bluetooth: mgmt: Fix update_eir/class with HCI_AUTO_OFF flag set
If we're powered but still have the HCI_AUTO_OFF flag set the
update_eir and update_class functions should not do anything.
Additionally these functions need to be called when the flag is finally
cleared through set_powered or when powering on for real.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Andre Guedes [Thu, 23 Feb 2012 14:50:05 +0000 (16:50 +0200)]
Bluetooth: Set DISCOVERY_STOPPED if controller resets
If controller is reset during the discovery procedure, Start Discovery
command stops working. This can be easily reproduced by running
"hciconfig hci0 reset" while discovering devices, for instance.
We should force discovery state to DISCOVERY_STOPPED in case we receive
a reset command complete event. Otherwise we may stuck in one of the
active discovery states (DISCOVERY_INQUIRY, DISCOVERY_LE_SCAN and
DISCOVERY_RESOLVING) and subsequent Start Discovery commands will simply
fail.
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>
Johan Hedberg [Thu, 23 Feb 2012 07:52:28 +0000 (09:52 +0200)]
Bluetooth: mgmt: Fix count parameter in get_connections reply
This patch fixes the count parameter in the Get Connections reply
message. We cannot know the right number until iterating through all
connections so set the parameter value only after the loop.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Andrei Emeltchenko [Wed, 22 Feb 2012 15:11:57 +0000 (17:11 +0200)]
Bluetooth: Remove socket lock check
Simplify code so that we do not need to check whether socket is locked.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Andrei Emeltchenko [Wed, 22 Feb 2012 15:11:56 +0000 (17:11 +0200)]
Bluetooth: Change sk lock to chan lock in L2CAP core
Change sk lock to chan lock in l2cap core and move sk locks
to l2cap sock code. bh_locks were used because of being RCU
critical section. When needed use explicit socket locks.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Reviewed-by: Ulisses Furquim <ulisses@profusion.mobi>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Andrei Emeltchenko [Wed, 22 Feb 2012 15:11:55 +0000 (17:11 +0200)]
Bluetooth: Add unlocked __l2cap_chan_add function
Add unlocked L2CAP channel add function. Unlocked version will
be used in later patches.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Reviewed-by: Ulisses Furquim <ulisses@profusion.mobi>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Johan Hedberg [Wed, 22 Feb 2012 22:38:59 +0000 (00:38 +0200)]
Bluetooth: mgmt: Add legacy pairing info to dev_found events
This patch makes sure that legacy pairing vs SSP infomation gets
properly propageted to the device_found events in the form of the legacy
pairing flag.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Wed, 22 Feb 2012 22:00:32 +0000 (00:00 +0200)]
Bluetooth: mgmt: Fix device_found parameters
According to the latest mgmt API there's a flags field instead of a
separate confirm_name paramter.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Wed, 22 Feb 2012 20:53:34 +0000 (22:53 +0200)]
Bluetooth: mgmt: Fix unpair_device responses
This patch adds an error return when not powered and cleans up/simpifies
the function logic in the same go.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Wed, 22 Feb 2012 20:41:18 +0000 (22:41 +0200)]
Bluetooth: mgmt: Add missing powered checks to commands
This patch adds missing powered checks to pair_device,
cancel_pair_device, add_remote_oob_data and remove_remote_oob_data.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Wed, 22 Feb 2012 20:11:32 +0000 (22:11 +0200)]
Bluetooth: mgmt: Allow class of device changes while powered off
This patch makes it possible to set the class when powered off. When
powering on the right class of device value will be automatically
writen to the controller.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Wed, 22 Feb 2012 20:06:38 +0000 (22:06 +0200)]
Bluetooth: mgmt: Check for HCI_UP in update_eir() and update_class()
These functions should just silently fail when we're not powered on
instead of trying to send HCI commands.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Wed, 22 Feb 2012 20:02:50 +0000 (22:02 +0200)]
Bluetooth: mgmt: Fix return value for set_class
The return parameters for Set Device Class should consist of the new
class value.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Wed, 22 Feb 2012 20:01:41 +0000 (22:01 +0200)]
Bluetooth: Fix clearing of dev_class when powering down
We should assume a value of 0 for the device class when powered off.
The appropriate place to do this is in hci_dev_do_close().
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Wed, 22 Feb 2012 19:46:22 +0000 (21:46 +0200)]
Bluetooth: mgmt: Fix missing short_name in read_info
The short name is part of the Read Controller Info response and should
be appropriately filled in based on the value of hdev->short_name.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Wed, 22 Feb 2012 19:39:58 +0000 (21:39 +0200)]
Bluetooth: mgmt: Fix name_changed event for short name changes
Since we can't reliably track the short name changes just assume that we
had a change whenever there's a pending mgmt command. In the worst case
we just get one unnecessary name_changed signal.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Wed, 22 Feb 2012 19:06:55 +0000 (21:06 +0200)]
Bluetooth: mgmt: Allow local name changes while powered off
This patch makes it possible to set the local name before powering on
the device. The name will be applied using the hci_write_local_name
command once the device gets powered on.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Wed, 22 Feb 2012 18:14:22 +0000 (20:14 +0200)]
Bluetooth: Fix read_name updating when HCI_SETUP is not set
The local name should only be updated as a consequence of a
hci_read_local_name if we are in the HCI_SETUP state. In all other
scenarios it should only be updated through hci_write_local_name.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Wed, 22 Feb 2012 17:19:09 +0000 (19:19 +0200)]
Bluetooth: Add hdev->short_name for EIR generation
It's possible to provide a short name through the mgmt interface and
this name can be used for EIR generation when the full name doesn't fit
there. This patch adds the preliminary tracking of the provided short
name.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Marcel Holtmann [Wed, 22 Feb 2012 17:38:01 +0000 (18:38 +0100)]
Bluetooth: Send management event for class of device changes
Currently there are no events to other management sockets if the class of
device got changed. So make sure they are sent.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Marcel Holtmann [Wed, 22 Feb 2012 17:21:00 +0000 (18:21 +0100)]
Bluetooth: Fix handling of discoverable setting with timeout
The current handling of the discoverable timeout was missing the proper
handling of the timeout when the mode was already set. Now the command
can be used to expire or retrigger the timeout.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Marcel Holtmann [Wed, 22 Feb 2012 17:06:34 +0000 (18:06 +0100)]
Bluetooth: Disabling discoverable with timeout is invalid
Add one extra sanity check to ensure that the supplied timeout value is
actually valid in this context.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Johan Hedberg [Wed, 22 Feb 2012 16:17:32 +0000 (18:17 +0200)]
Bluetooth: mgmt: Fix updating EIR when updating the name
Whenever we update the local device name the EIR data also needs to be
updated to reflect this. The update_eir() function in mgmt.c depends on
hdev->dev_name to be up to date so the patch also makes sure that the
mgmt function is called from hci_event.c after the update has happened.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Wed, 22 Feb 2012 16:11:53 +0000 (18:11 +0200)]
Bluetooth: Fix EIR data clearing when powering off
When powering off we should assume that the EIR data isn't valid
anymore. This patch makes sure it gets cleared in hci_dev_do_close and
thereby ensures that a correct new EIR is recreated when powering on
again.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Wed, 22 Feb 2012 14:37:11 +0000 (16:37 +0200)]
Bluetooth: mgmt: Implement Set LE command
This patch implements support for the Set LE mgmt command. Now, in
addition to the enable_le module parameter user space needs to send an
explicit Enable LE command to enable LE support.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Wed, 22 Feb 2012 14:35:26 +0000 (16:35 +0200)]
Bluetooth: mgmt: Fix Set SSP supported check
The test for SSP support needs to be earlier in the set_ssp function so
that we return an error when SSP is not supported even when the device
is powered off.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Marcel Holtmann [Wed, 22 Feb 2012 12:49:28 +0000 (13:49 +0100)]
Bluetooth: Enable timestamps for control channel
The control channel can be also monitored, so include timestamps here
as well. And make sure management events get their timestamp when they
are created.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Johan Hedberg [Wed, 22 Feb 2012 13:47:48 +0000 (15:47 +0200)]
Bluetooth: Explicitly clear EIR data upon hci_dev setup
Some controllers preserve their EIR data even after a reset so we need
to explicitly clear this during the device setup procedure.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Wed, 22 Feb 2012 13:38:48 +0000 (15:38 +0200)]
Bluetooth: mgmt: Fix clearing of hdev->eir
The hdev->eir buffer needs to be cleared when clearing the EIR data.
Otherwise subsequent attempts at setting the EIR to something valid
again may fail because the code thinks that the EIR hasn't changed.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Wed, 22 Feb 2012 13:10:59 +0000 (15:10 +0200)]
Bluetooth: mgmt: Fix EIR toggling with SSP
This patch fixes setting the EIR properly when the SSP flag has been set
when powered off (in such a case there is no pending Set_SSP command).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Andrei Emeltchenko [Wed, 22 Feb 2012 11:21:16 +0000 (13:21 +0200)]
Bluetooth: Fix coding style issues in mgmt code
In this case we need to use braces in both branches.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Marcel Holtmann [Wed, 22 Feb 2012 11:06:43 +0000 (12:06 +0100)]
Bluetooth: Fix two minor style issues in HCI code
WARNING: min() should probably be min_t(__u16, scb->expect, count)
+ len = min(scb->expect, (__u16)count);
WARNING: Statements terminations use 1 semicolon
+ INIT_LIST_HEAD(&conn->chan_list);;
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Marcel Holtmann [Wed, 22 Feb 2012 10:59:01 +0000 (11:59 +0100)]
Bluetooth: Fix two minor style issues in management code
WARNING: Statements terminations use 1 semicolon
+ return err;;
WARNING: space prohibited between function name and open parenthesis '('
+ err = cmd_status (sk, index, MGMT_OP_CONFIRM_NAME,
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Johan Hedberg [Wed, 22 Feb 2012 10:38:31 +0000 (12:38 +0200)]
Bluetooth: mgmt: Make Set SSP command callable while powered off
This patch makes it possible to enable SSP through mgmt even when
powered off. The setting will then get automatically actiated when
powering on.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Wed, 22 Feb 2012 10:28:39 +0000 (12:28 +0200)]
Bluetooth: Remove unneeded hci_cc_read_ssp_mode function
The kernel has no need to track the hci_read_ssp_mode command since it
has the hci_sent_cmd_data function to check what value was set when
hci_write_ssp_mode completes.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Wed, 22 Feb 2012 09:58:37 +0000 (11:58 +0200)]
Bluetooth: mgmt: Make Set Link Security callable while powered off
This patch makes it possible to change the Link Security setting while
powered off and have it automatically enabled when powering on a device.
To track the desired state once powered on a new HCI_LINK_SECURITY flag
is added.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Andrei Emeltchenko [Tue, 21 Feb 2012 10:54:58 +0000 (12:54 +0200)]
Bluetooth: Add socket error function
Use locked and unlocked versions to help removing socket
locks from l2cap core functions.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Reviewed-by: Ulisses Furquim <ulisses@profusion.mobi>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Andrei Emeltchenko [Tue, 21 Feb 2012 10:54:57 +0000 (12:54 +0200)]
Bluetooth: Add locked and unlocked state_change
Split to locked and unlocked versions of l2cap_state_change helping
to remove socket locks from l2cap code.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Reviewed-by: Ulisses Furquim <ulisses@profusion.mobi>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Andrei Emeltchenko [Tue, 21 Feb 2012 10:54:56 +0000 (12:54 +0200)]
Bluetooth: Add l2cap_chan_lock
Channel lock will be used to lock L2CAP channels which are locked
currently by socket locks.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Reviewed-by: Ulisses Furquim <ulisses@profusion.mobi>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Andrei Emeltchenko [Tue, 21 Feb 2012 10:54:55 +0000 (12:54 +0200)]
Bluetooth: Revert to mutexes from RCU list
Usage of RCU list looks not reasonalbe for a number of reasons:
our code sleep and we had to use socket spinlocks. Most parts
of code are updaters thus there is little sense to use RCU.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Reviewed-by: Ulisses Furquim <ulisses@profusion.mobi>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Andrei Emeltchenko [Tue, 21 Feb 2012 10:54:54 +0000 (12:54 +0200)]
Bluetooth: trivial: Fix long line
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>
Keng-Yu Lin [Wed, 30 Nov 2011 10:32:37 +0000 (18:32 +0800)]
Bluetooth: Add AR30XX device ID on Asus laptops
The ID is found on Asus K54HR and K53U.
Blacklist the AR3011-based device ID [0489:e03d]
and add to ath3k.c for firmware loading.
Below is the output of usb-devices script:
Before the fiwmware loading:
T: Bus=01 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 3 Spd=12 MxCh= 0
D: Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1
P: Vendor=0489 ProdID=e03d Rev=00.01
C: #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
I: If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
After the fiwmware loading:
T: Bus=01 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 5 Spd=12 MxCh= 0
D: Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1
P: Vendor=0cf3 ProdID=3005 Rev=00.01
C: #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
I: If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
Signed-off-by: Keng-Yu Lin <kengyu@canonical.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Johan Hedberg [Tue, 21 Feb 2012 18:47:06 +0000 (20:47 +0200)]
Bluetooth: mgmt: Fix connectable/discoverable response values
The connectable/discoverable flags need to be changed before sending the
response since otherwise the settings value will be incorrect.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Tue, 21 Feb 2012 15:55:47 +0000 (17:55 +0200)]
Bluetooth: Fix clearing of persistent dev_flags
Now that most flags are persistent, only the LE_SCAN flag should be
cleared after a reset.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Tue, 21 Feb 2012 17:40:05 +0000 (19:40 +0200)]
Bluetooth: mgmt: Fix New Settings event for connectable/discoverable
When powered off and doing changes to the Connectable or Discoverable
setting we should also send an appropriate New Settings event in
addition to the command response.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Tue, 21 Feb 2012 14:55:31 +0000 (16:55 +0200)]
Bluetooth: mgmt: Add convenience function for sending New Settings
The New Settings event needs to be sent from quite many places so it
makes sense to have a convenience function for it to simplify the code.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Tue, 21 Feb 2012 15:15:41 +0000 (17:15 +0200)]
Bluetooth: mgmt: Fix current settings values when powered off
We should not stop iterating through the various settings if powered off
since most may still be set even then.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Tue, 21 Feb 2012 17:15:49 +0000 (19:15 +0200)]
Bluetooth: mgmt: Fix Removing discoverable timeout in set_connectable
When switching connectable mode off any pending discoverable timeout
must also be disabled to avoid duplicate write_scan_enable commands.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Tue, 21 Feb 2012 14:01:30 +0000 (16:01 +0200)]
Bluetooth: mgmt: Allow connectable/discoverable changes in off state
This patch makes it possible to toggle the connectable & discoverable
settings when powered off. Two new hdev->dev_flags flags are added to
track what the scan mode should be when the device is finally powered
on.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Tue, 21 Feb 2012 15:25:22 +0000 (17:25 +0200)]
Bluetooth: mgmt: Fix pairable setting upon initialization
When mgmt is not in use the HCI_PAIRABLE flag will get implicitly set so
that pairing still works with old user space versions. However, as soon
as mgmt comes into play we should clear this flag so that it can be
properly set through the set_pairable command by user space.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Tue, 21 Feb 2012 14:40:33 +0000 (16:40 +0200)]
Bluetooth: mgmt: Fix set_fast_connectable error return
This patch ensures that Set Fast Connectable fails apropriately if we
are not already in a connectable state (which is a pre-requisite for
fast connectable).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Tue, 21 Feb 2012 12:32:24 +0000 (14:32 +0200)]
Bluetooth: mgmt: Fix set_local_name and set_dev_class powered checks
Both the Set Local Name and the Set Device Class commands should fail if
the adapter is not powered on.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Tue, 21 Feb 2012 12:13:02 +0000 (14:13 +0200)]
Bluetooth: mgmt: Fix powered checks for commands
Having the HCI_AUTO_OFF flag set means that from a mgmt interface
perspective we're still not powered, so all tests for HCI_UP should also
include a test for HCI_AUTO_OFF. This patch adds a convenience macro for
it.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Marcel Holtmann [Tue, 21 Feb 2012 11:33:48 +0000 (12:33 +0100)]
Bluetooth: Don't send New Settings event during setup power down
When the controller gets brought up for initial setup, it will be brought
back down after a timeout. In that case, don't send a New Settings event.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Marcel Holtmann [Tue, 21 Feb 2012 11:14:25 +0000 (12:14 +0100)]
Bluetooth: Only keep controller up after init if powered on
When a new controller gets added to the system, it needs to be brought
up briefly to read basic information like features, BD_ADDR etc. and
after a timeout it will be brought back down.
The only command that should overwrite this timeout is the set power
command from the management interface. Just reading the controller
list or information is not a good reason to keep the controller up.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Marcel Holtmann [Tue, 21 Feb 2012 07:14:26 +0000 (08:14 +0100)]
Bluetooth: Fix parameter list for setting local name
The parameter list for setting the local name via management interface
was missing the short name parameter.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Johan Hedberg [Mon, 20 Feb 2012 22:52:42 +0000 (00:52 +0200)]
Bluetooth: mgmt: Clear EIR data when disabling SSP
EIR shouldn't be enabled if SSP isn't enabled. This patch adds the
clearing of EIR data when disabling SSP and restores the data when SSP
is re-enabled.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Mon, 20 Feb 2012 21:53:46 +0000 (23:53 +0200)]
Bluetooth: mgmt: Fix Set SSP check for supported feature
If the local controller doesn't support SSP we should always return an
error for the Set SSP command.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Mon, 20 Feb 2012 21:50:38 +0000 (23:50 +0200)]
Bluetooth: mgmt: Add basic support for Set High Speed command
This patch adds rudimentary support for the Set High Speed command in
the form of a new HCI dev flag (HCI_HS_ENABLED).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Mon, 20 Feb 2012 21:30:44 +0000 (23:30 +0200)]
Bluetooth: mgmt: Add address type parameter to Discovering event
This patch adds an address type parameter to the Discovering event. The
value matches that given to Start/Stop Discovery.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg [Mon, 20 Feb 2012 21:25:18 +0000 (23:25 +0200)]
Bluetooth: mgmt: Add address type parameter to Stop Discovery command
This patch adds an address type parameter to the Stop Discovery command
which should match the value given to Start Discovery.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Marcel Holtmann [Mon, 20 Feb 2012 20:24:37 +0000 (21:24 +0100)]
Bluetooth: Always enable management interface
The management interface API has reached stable version 1.0 and thus
it can now be always enabled. All future changes will be made backwards
compatible.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Marcel Holtmann [Mon, 20 Feb 2012 20:47:49 +0000 (21:47 +0100)]
Bluetooth: Set supported settings based on enabled HS and/or LE
Since neither High Speed (HS) nor Low Energy (LE) are fully implemented
yet, only expose them in supported settings when enabled.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Marcel Holtmann [Mon, 20 Feb 2012 19:54:10 +0000 (20:54 +0100)]
Bluetooth: Restrict access to management interface
The management interface on the HCI control channel should be restricted
to applications with CAP_NET_ADMIN permission.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Marcel Holtmann [Mon, 20 Feb 2012 19:34:38 +0000 (20:34 +0100)]
Bluetooth: Add support for HCI monitor channel
The HCI monitor channel can be used to monitor all packets and events
from the Bluetooth subsystem. The monitor is not bound to any specific
HCI device and allows even capturing multiple devices at the same time.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Marcel Holtmann [Mon, 20 Feb 2012 13:50:37 +0000 (14:50 +0100)]
Bluetooth: Remove HCI notifier handling
The HCI notifier handling was never used outside of Bluetooth core layer
and thus remove it and replace it with direct function calls. Also move
the stack internal event generation into the HCI socket layer.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Marcel Holtmann [Mon, 20 Feb 2012 13:50:36 +0000 (14:50 +0100)]
Bluetooth: Fix issue with shared SKB between HCI raw socket and driver
Any HCI raw socket gets a copy of each SKB that is either received or
send via the Bluetooth subsystem. The raw socket uses SKB clones to
send out data, but the problem is that it needs to add an extra packet
type byte in front of it. And some drivers need to also add an extra
header before submitting the packet.
So far this all worked magically fine since all of the drivers and the
raw sockets are adding the same byte at the same location. But that is
by pure coincidence. Since the data of cloned SKBs is shared, this means
that the raw socket and driver kept writing into the shared data area.
To fix this the only safe way is if the HCI raw socket creates a copy of
the SKB before sending it out. To not always copy all SKBs around, the
copy is only created once and only after any of the HCI filter checks
succeeded.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Marcel Holtmann [Mon, 20 Feb 2012 13:50:35 +0000 (14:50 +0100)]
Bluetooth: Simplify HCI socket bind handling
The HCI socket bind handling checks a few too many times the channel
we are binding. So centralize this and make the function easier to read.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Marcel Holtmann [Mon, 20 Feb 2012 13:50:34 +0000 (14:50 +0100)]
Bluetooth: Add HCI CMSG details only to raw sockets
The HCI CMSG specific data is for raw sockets only. So only add them to
actual raw sockets.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Marcel Holtmann [Mon, 20 Feb 2012 13:50:33 +0000 (14:50 +0100)]
Bluetooth: Lock socket when reading HCI socket options
When reading the HCI raw socket option, the socket was never locked. So
lock the socket and in addition return EINVAL on non raw sockets.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Marcel Holtmann [Mon, 20 Feb 2012 13:50:32 +0000 (14:50 +0100)]
Bluetooth: Limit HCI raw socket options to actual raw sockets
Currently the socket options of HCI sockets can be set on raw and control
sockets, but on control sockets they make no sense. So just return EINVAL
in that case.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Marcel Holtmann [Mon, 20 Feb 2012 13:50:31 +0000 (14:50 +0100)]
Bluetooth: Remove unneeded bt_cb(skb)->channel variable
The bt_cb(skb)->channel was only needed to make hci_send_to_sock() be
used for HCI raw and control sockets. Since they have now separate sending
functions this is no longer needed.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Marcel Holtmann [Mon, 20 Feb 2012 13:50:30 +0000 (14:50 +0100)]
Bluetooth: Split sending for HCI raw and control sockets
The sending functions for HCI raw and control sockets have nothing in
common except that they iterate over the socket list. Split them into
two so they can do their job more efficient. In addition the code becomes
more readable.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>