GitHub/LineageOS/android_kernel_motorola_exynos9610.git
11 years agoBluetooth: Remove sk member from struct l2cap_chan
Gustavo Padovan [Mon, 21 Oct 2013 20:22:26 +0000 (18:22 -0200)]
Bluetooth: Remove sk member from struct l2cap_chan

There is no access to chan->sk in L2CAP core now. This change marks the
end of the task of splitting L2CAP between Core and Socket, thus sk is now
gone from struct l2cap_chan.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Use bt_cb(skb)->chan to send raw data back
Gustavo Padovan [Mon, 21 Oct 2013 20:22:25 +0000 (18:22 -0200)]
Bluetooth: Use bt_cb(skb)->chan to send raw data back

Instead of accessing skb->sk in L2CAP core we now compare the channel
a skb belongs to and not send it back if the channel is same. This change
removes another struct socket usage from L2CAP core.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Add L2CAP channel to skb private data
Gustavo Padovan [Mon, 21 Oct 2013 20:22:24 +0000 (18:22 -0200)]
Bluetooth: Add L2CAP channel to skb private data

Adding the channel to the skb private data makes possible to us know which
channel the skb we have came from.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Remove parent socket usage from l2cap_core.c
Gustavo Padovan [Mon, 21 Oct 2013 16:21:41 +0000 (14:21 -0200)]
Bluetooth: Remove parent socket usage from l2cap_core.c

The parent socket is not used inside the L2CAP core anymore. We only lock
it to indirect access through the new_connection() callback. The hold of
the socket lock was moved to the new_connection() callback.

Inside L2CAP core the channel lock is now used in l2cap_le_conn_ready()
and l2cap_conn_ready() to protect the execution of these two functions
during the handling of new incoming connections.

This change remove the socket lock usage from L2CAP core while keeping
the code safe against race conditions.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Remove socket lock from l2cap_state_change()
Gustavo Padovan [Mon, 21 Oct 2013 16:21:40 +0000 (14:21 -0200)]
Bluetooth: Remove socket lock from l2cap_state_change()

This simplify and make safer the state change handling inside l2cap_core.c.
we got rid of __l2cap_state_change(). And l2cap_state_change() doesn't lock
the socket anymore, instead the socket is locked inside the ops callback for
state change in l2cap_sock.c.

It makes the code safer because in some we were using a unlocked version,
and now we are calls to l2cap_state_change(), when dealing with sockets, use
the locked version.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Hold socket in defer callback in L2CAP socket
Gustavo Padovan [Mon, 21 Oct 2013 16:21:39 +0000 (14:21 -0200)]
Bluetooth: Hold socket in defer callback in L2CAP socket

In both places that we use the defer callback the socket lock is held for
a indirect sk access inside __l2cap_change_state() and chan->ops->defer(),
all the rest of the code between lock_sock() and release_sock() is
already protected by the channel lock and won't be affected by this
change.

We now use l2cap_change_state(), the locked version of the change state
function, and the defer callback does the locking itself now. This does
not affect other uses of the defer callback.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Do not access chan->sk directly
Gustavo Padovan [Mon, 21 Oct 2013 16:21:38 +0000 (14:21 -0200)]
Bluetooth: Do not access chan->sk directly

In the process of removing socket usage from L2CAP we now access the L2CAP
socket from the data member of struct l2cap_chan. For the L2CAP socket
user the data member points to the L2CAP socket.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Remove not used struct sock
Gustavo Padovan [Mon, 21 Oct 2013 16:21:37 +0000 (14:21 -0200)]
Bluetooth: Remove not used struct sock

It is a leftover from the recent effort of remove sk usage from L2CAP
core.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Fix enabling fast connectable on LE-only controllers
Johan Hedberg [Mon, 21 Oct 2013 13:51:53 +0000 (16:51 +0300)]
Bluetooth: Fix enabling fast connectable on LE-only controllers

The current "fast connectable" feature is BR/EDR-only, so add a proper
check for BR/EDR support before proceeding with the associated HCI
commands.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Update Set Discoverable to support LE
Johan Hedberg [Sun, 20 Oct 2013 16:00:07 +0000 (19:00 +0300)]
Bluetooth: Update Set Discoverable to support LE

This patch updates the Set Discoverable management command to also be
applicable for LE. In particular this affects the advertising flags
where we can say "general discoverable" or "limited discoverable".

Since the device flags may not be up-to-date when the advertising data
is written this patch introduces a get_adv_discov_flags() helper
function which also looks at any pending mgmt commands (a pending
set_discoverable would be the exception when the flags are not yet
correct).

The patch also adds HCI_DISCOVERABLE flag clearing to the
mgmt_discoverable_timeout function, since the code was previously
relying on the mgmt_discoverable callback to handle this, which is only
called for the BR/EDR-only HCI_Write_Scan_Enable command.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Move HCI_LIMITED_DISCOVERABLE changes to a general place
Johan Hedberg [Sat, 19 Oct 2013 20:38:22 +0000 (23:38 +0300)]
Bluetooth: Move HCI_LIMITED_DISCOVERABLE changes to a general place

We'll soon be introducing also LE support for the Set Discoverable
management command, so move the HCI_LIMITED_DISCOVERABLE flag clearing
and setting out from the if-branch that is only used for a BR/EDR
specific HCI command.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Fix sending write_scan_enable when BR/EDR is disabled
Johan Hedberg [Sat, 19 Oct 2013 20:38:21 +0000 (23:38 +0300)]
Bluetooth: Fix sending write_scan_enable when BR/EDR is disabled

We should only send the HCI_Write_Scan_Enable command from
mgmt_set_powered_failed() when BR/EDR support is enabled. This is
particularly important when the discoverable setting is also tied to LE.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Move mgmt_pending_find to avoid forward declarations
Johan Hedberg [Sat, 19 Oct 2013 20:38:20 +0000 (23:38 +0300)]
Bluetooth: Move mgmt_pending_find to avoid forward declarations

We will soon need this function for updating the advertising data, so
move it higher up in mgmt.c to avoid a forward declaration.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Fix updating settings when there are no HCI commands to send
Johan Hedberg [Sat, 19 Oct 2013 20:38:19 +0000 (23:38 +0300)]
Bluetooth: Fix updating settings when there are no HCI commands to send

It is possible that the Set Connectable management command doesn't cause
any HCI commands to send (such as when BR/EDR is disabled). We can't
just send a response to user space in this case but must also update the
necessary device flags and settings. This patch fixes the issue by using
the recently introduced set_connectable_update_settings function.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Refactor set_connectable settings update to separate function
Johan Hedberg [Sat, 19 Oct 2013 20:38:18 +0000 (23:38 +0300)]
Bluetooth: Refactor set_connectable settings update to separate function

We will need to directly update the device flags and notify user space
of the new settings not just when we're powered off but also if it turns
out that there are no HCI commands to send (which can happen in
particular when BR/EDR is disabled). Since this is a considerable amount
of code, refactor it to a separate function so it can be reused for the
"no HCI commands to send" case.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Add missing check for BREDR_ENABLED flag in update_class()
Johan Hedberg [Sat, 19 Oct 2013 20:38:17 +0000 (23:38 +0300)]
Bluetooth: Add missing check for BREDR_ENABLED flag in update_class()

We shouldn't be sending the HCI_Write_Class_Of_Device command when
BR/EDR is disabled since this is a BR/EDR-only command.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Check for flag instead of features in update_adv_data()
Johan Hedberg [Sat, 19 Oct 2013 20:38:16 +0000 (23:38 +0300)]
Bluetooth: Check for flag instead of features in update_adv_data()

It's better to check for the device flag instead of device features so
that we avoid unnecessary HCI commands when the feature is supported but
disabled (i.e. the flag is unset).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Check for flag instead of features in update_scan_rsp_data()
Johan Hedberg [Sat, 19 Oct 2013 20:38:15 +0000 (23:38 +0300)]
Bluetooth: Check for flag instead of features in update_scan_rsp_data()

It's better to check for the device flag instead of device features so
that we avoid unnecessary HCI commands when the feature is supported but
disabled (i.e. the flag is unset).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Fix minor coding style issue in hci_core.c
Marcel Holtmann [Sat, 19 Oct 2013 17:19:15 +0000 (10:19 -0700)]
Bluetooth: Fix minor coding style issue in hci_core.c

A few variable assignments ended up with missing a space between the
variable and equal sign.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Fix UUID values in debugfs file
Marcel Holtmann [Sat, 19 Oct 2013 16:31:59 +0000 (09:31 -0700)]
Bluetooth: Fix UUID values in debugfs file

The uuid entry struct is used for the UUID byte stream. That is
actually the wrong value. The correct value is uuid->uuid.

Besides fixing this up, use the %pUb modifier to print the UUID
string. However since the UUID is stored in big endian with
reversed byte order, change the byte order before printing.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Add support for setting DUT mode
Marcel Holtmann [Sat, 19 Oct 2013 14:09:12 +0000 (07:09 -0700)]
Bluetooth: Add support for setting DUT mode

The Device Under Test (DUT) mode is useful for doing certification
testing and so expose this as debugfs option.

This mode is actually special since you can only enter it. Restoring
normal operation means that a HCI Reset is required. The current mode
value gets tracked as a new device flag and when disabling it, the
correct command to reset the controller is sent.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Expose debugfs settings for LE connection interval
Marcel Holtmann [Sat, 19 Oct 2013 14:09:13 +0000 (07:09 -0700)]
Bluetooth: Expose debugfs settings for LE connection interval

For testing purposes expose the default LE connection interval values
via debugfs.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Add support for setting SSP debug mode
Marcel Holtmann [Sat, 19 Oct 2013 14:09:11 +0000 (07:09 -0700)]
Bluetooth: Add support for setting SSP debug mode

Enabling and disabling SSP debug mode is useful for development. This
adds a debugfs entry that allows to configure the SSP debug mode.

On purpose this has been implemented as debugfs entry and not a public
API since it is really only useful during testing and development.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Remove interval parameter from HCI connection
Marcel Holtmann [Sat, 19 Oct 2013 12:26:57 +0000 (05:26 -0700)]
Bluetooth: Remove interval parameter from HCI connection

The conn->interval parameter of HCI connections is not used at all
and so just remove it.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Add LE features to debugfs if available
Marcel Holtmann [Sat, 19 Oct 2013 09:25:33 +0000 (02:25 -0700)]
Bluetooth: Add LE features to debugfs if available

For LE capable controllers at the special LE features page to the
debugfs list with all the other features pages.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Expose setting if debug keys are used or not
Marcel Holtmann [Sat, 19 Oct 2013 00:14:22 +0000 (17:14 -0700)]
Bluetooth: Expose setting if debug keys are used or not

The system can be figured to accept and use debug keys. Expose this
value in debugfs for debugging purposes.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Expose debugfs entry read/write own address type
Marcel Holtmann [Fri, 18 Oct 2013 23:38:10 +0000 (16:38 -0700)]
Bluetooth: Expose debugfs entry read/write own address type

For some testing it is important to know the current own addres type,
but also be able to change it. The change is lost over powery cycles
and only intended for debugging.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Select the own address type during initial setup phase
Marcel Holtmann [Fri, 18 Oct 2013 23:38:09 +0000 (16:38 -0700)]
Bluetooth: Select the own address type during initial setup phase

The own address type is based on the fact if the controller has
a public address or not. This means that this detail can be just
configured once during setup phase.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Expose current list of long term keys via debugfs
Marcel Holtmann [Fri, 18 Oct 2013 22:56:57 +0000 (15:56 -0700)]
Bluetooth: Expose current list of long term keys via debugfs

For debugging purposes expose the current list of long term keys
via debugfs. This file is read-only and limited to root access.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Expose white list size information in debugfs
Marcel Holtmann [Fri, 18 Oct 2013 22:23:46 +0000 (15:23 -0700)]
Bluetooth: Expose white list size information in debugfs

Knowing the white list size information is important for
debugging. So export it via debugfs.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Remove bus attribute in favor of hierarchy
Marcel Holtmann [Fri, 18 Oct 2013 19:39:27 +0000 (12:39 -0700)]
Bluetooth: Remove bus attribute in favor of hierarchy

The bus information are exposed in the actual hierarchy and should
not be exposed as attribute.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Expose current list of link keys via debugfs
Marcel Holtmann [Fri, 18 Oct 2013 19:04:52 +0000 (12:04 -0700)]
Bluetooth: Expose current list of link keys via debugfs

For debugging purposes expose the current list of link keys via
debugfs. This file is read-only and limited to root access.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Move export of class of device information into hci_core.c
Marcel Holtmann [Fri, 18 Oct 2013 19:04:51 +0000 (12:04 -0700)]
Bluetooth: Move export of class of device information into hci_core.c

The class of device debugfs information should be directly exported
from hci_core.c and so move them over there.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Store local version information only during setup phase
Marcel Holtmann [Fri, 18 Oct 2013 19:04:50 +0000 (12:04 -0700)]
Bluetooth: Store local version information only during setup phase

The local version information from the controller can not change
since they are static. So store them only once during setup
phase and not bother overwriting them every time this command
gets executed.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Move manufacturer, hci_ver and hci_rev into hci_core.c
Marcel Holtmann [Fri, 18 Oct 2013 19:04:49 +0000 (12:04 -0700)]
Bluetooth: Move manufacturer, hci_ver and hci_rev into hci_core.c

Move the debugfs entries for manufacturer, hci_ver and hci_rev into
hci_core.c and use the new helpers for static entries that will not
change at runtime. Once passed the setup procedure, they will stay
fixed.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Remove debug entry for connection features
Marcel Holtmann [Fri, 18 Oct 2013 19:04:48 +0000 (12:04 -0700)]
Bluetooth: Remove debug entry for connection features

The debug entry for connection features is incomplete and also does
not work with AMP controllers and physical links. So just remove it.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Add workaround for buggy max_page features page value
Marcel Holtmann [Fri, 18 Oct 2013 19:04:47 +0000 (12:04 -0700)]
Bluetooth: Add workaround for buggy max_page features page value

Some controllers list the max_page value from the extended features
response as 0 when SSP has not yet been enabled. To workaround this
issue, force the max_page value to 1 when SSP support has been
detected.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Move HCI device features into hci_core.c
Marcel Holtmann [Fri, 18 Oct 2013 19:04:46 +0000 (12:04 -0700)]
Bluetooth: Move HCI device features into hci_core.c

Move the handling of HCI device features debugfs into hci_core.c and
also extend it with handling of multiple feature pages.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Block ATT connection on LE when device is blocked
Marcel Holtmann [Fri, 18 Oct 2013 10:43:01 +0000 (03:43 -0700)]
Bluetooth: Block ATT connection on LE when device is blocked

When the remote LE device is blocked, then do not create a L2CAP
channel for it. Without a channel, all packets for that connection
will be dropped.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Use hcon directly instead of conn->hcon where possible
Marcel Holtmann [Fri, 18 Oct 2013 10:43:00 +0000 (03:43 -0700)]
Bluetooth: Use hcon directly instead of conn->hcon where possible

When the HCI connection hcon is already dereferenced, then use hcon
directly instead of conn->hcon.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Use BDADDR_BREDR type for old blacklist ioctl interface
Marcel Holtmann [Fri, 18 Oct 2013 08:10:28 +0000 (01:10 -0700)]
Bluetooth: Use BDADDR_BREDR type for old blacklist ioctl interface

The old blacklist ioctl interface was only able to operate on BR/EDR
addresses. So use the BDADDR_BREDR address type definition instead
of an open coded magic 0 value.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Fix ATT socket backwards compatibility with user space
Johan Hedberg [Fri, 18 Oct 2013 08:49:25 +0000 (11:49 +0300)]
Bluetooth: Fix ATT socket backwards compatibility with user space

Old user space versions bind the Attribute Protocol socket to
BDADDR_BREDR when they should be using BDADDR_LE_PUBLIC or
BDADDR_LE_RANDOM. The kernel recently introduced stricter checks on the
socket parameters but we need to punch this hole for old user space
versions to keep them working.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Move idle_timeout and sniff_{min,max}_interval to hci_core.c
Marcel Holtmann [Fri, 18 Oct 2013 02:16:02 +0000 (19:16 -0700)]
Bluetooth: Move idle_timeout and sniff_{min,max}_interval to hci_core.c

Move the debugfs configuration directly into hci_core.c and only expose
it when the controller actually support BR/EDR sniff power saving mode.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Include address type in blacklist debugfs data
Marcel Holtmann [Fri, 18 Oct 2013 00:24:20 +0000 (17:24 -0700)]
Bluetooth: Include address type in blacklist debugfs data

The address type is important for the blacklist entries. So include
it at well.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Move device_add handling into hci_register_dev
Marcel Holtmann [Fri, 18 Oct 2013 00:24:19 +0000 (17:24 -0700)]
Bluetooth: Move device_add handling into hci_register_dev

The device_add handling can be done directly in hci_register_dev and
device_remove within hci_unregister_dev.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Create root debugfs directory during module init
Marcel Holtmann [Fri, 18 Oct 2013 00:24:18 +0000 (17:24 -0700)]
Bluetooth: Create root debugfs directory during module init

Create the root Bluetooth debugfs directory during module init
and remove it on module exit.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Create HCI device debugfs directory in hci_register_dev
Marcel Holtmann [Fri, 18 Oct 2013 00:24:17 +0000 (17:24 -0700)]
Bluetooth: Create HCI device debugfs directory in hci_register_dev

Create the debugfs directory for each HCI device directly in
hci_register_dev function and remove it during hci_unregister_dev.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Use IS_ERR_OR_NULL for checking bt_debugfs
Marcel Holtmann [Fri, 18 Oct 2013 00:24:16 +0000 (17:24 -0700)]
Bluetooth: Use IS_ERR_OR_NULL for checking bt_debugfs

Make sure to use IS_ERR_OR_NULL for checking the existing of the root
debugfs dentry bt_debugfs.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Move uuids debugfs entry creation into hci_core.c
Marcel Holtmann [Fri, 18 Oct 2013 00:24:15 +0000 (17:24 -0700)]
Bluetooth: Move uuids debugfs entry creation into hci_core.c

The uuids debugfs should only be created together with the other
entries after the setup procedure has been finished.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Move blacklist debugfs entry creation into hci_core.c
Marcel Holtmann [Fri, 18 Oct 2013 00:24:14 +0000 (17:24 -0700)]
Bluetooth: Move blacklist debugfs entry creation into hci_core.c

The blacklist debugfs should only be created together with the other
entries after the setup procedure has been finished.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Add address type to device blacklist table
Marcel Holtmann [Fri, 18 Oct 2013 00:24:13 +0000 (17:24 -0700)]
Bluetooth: Add address type to device blacklist table

The device blacklist is not taking care of the address type. Actually
store the address type in the list entries and also use them when
looking up addresses in the table.

This is actually a serious bug. When adding a LE public address to
the blacklist, then it would be blocking a device on BR/EDR. And this
is not the expected behavior.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Expose current voice setting in debugfs
Marcel Holtmann [Thu, 17 Oct 2013 19:02:31 +0000 (12:02 -0700)]
Bluetooth: Expose current voice setting in debugfs

For easier debugging of the current voice setting, expose the value
in debugfs if the controller is BR/EDR capable.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Expose static address value for LE capable controllers
Marcel Holtmann [Thu, 17 Oct 2013 18:45:09 +0000 (11:45 -0700)]
Bluetooth: Expose static address value for LE capable controllers

For LE capable controllers, the static address can be configured. For
debugging purposes expose the value in debugfs.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Expose auto_accept_delay debugfs only when SSP is supported
Marcel Holtmann [Thu, 17 Oct 2013 17:54:46 +0000 (10:54 -0700)]
Bluetooth: Expose auto_accept_delay debugfs only when SSP is supported

The auto_accept_delay debugfs entry is only valid for BR/EDR capable
controllers that also support SSP. If SSP is not available or it is
a LE-only single mode controller this value has no affect and so do
not expose it.

Since the value can be actually changed, switch the permissions
to 0644 to clearly indicate that the value is indeed writeable.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Expose inquiry_cache debugfs only on BR/EDR controllers
Marcel Holtmann [Wed, 16 Oct 2013 10:28:55 +0000 (03:28 -0700)]
Bluetooth: Expose inquiry_cache debugfs only on BR/EDR controllers

The inquiry_cache debugfs entry is only valid for BR/EDR capable
controllers. In case of single mode LE-only controllers that
entry is not valid.

Move the creating of the debugfs entries to the end of controller
init and only create the inquiry_cache entry if BR/EDR is actually
supported.

At the same time this avoids creating any debugfs entries for
AMP controllers since none of the entries are valid there.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Socket address parameter for CID is in little endian
Marcel Holtmann [Wed, 16 Oct 2013 16:31:17 +0000 (09:31 -0700)]
Bluetooth: Socket address parameter for CID is in little endian

The L2CAP socket parameter for CID are actually provided in little
endian. So convert our constants into little endian before comparing
them.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Convert idle timer to use delayed work
Johan Hedberg [Wed, 16 Oct 2013 15:11:40 +0000 (18:11 +0300)]
Bluetooth: Convert idle timer to use delayed work

There is no need to use a timer since the entire Bluetooth subsystem
runs using workqueues these days.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Convert auto accept timer to use delayed work
Johan Hedberg [Wed, 16 Oct 2013 15:11:39 +0000 (18:11 +0300)]
Bluetooth: Convert auto accept timer to use delayed work

Since the entire Bluetooth subsystem runs in workqueues these days there
is no need to use a timer for deferring work.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Reintroduce socket restrictions for LE sockets
Johan Hedberg [Wed, 16 Oct 2013 14:13:26 +0000 (17:13 +0300)]
Bluetooth: Reintroduce socket restrictions for LE sockets

Right now we do not allow user space to use connection oriented channels
on LE, and the only CID that can be used is the Attribute Protocol one.
These restrictions went away together with the recent refactoring of the
L2CAP code, but this patch puts them back to their appropriate places.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Fix updating the right variable in update_scan_rsp_data()
Johan Hedberg [Wed, 16 Oct 2013 12:31:07 +0000 (15:31 +0300)]
Bluetooth: Fix updating the right variable in update_scan_rsp_data()

This function should be operating on scan_rsp_data_len and scan_rsp_data
and not the advertising data variables.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Remove enable_hs declaration
Marcel Holtmann [Wed, 16 Oct 2013 09:09:01 +0000 (02:09 -0700)]
Bluetooth: Remove enable_hs declaration

This seems to be a left-over. The module parameter enable_hs has
been removed, but its extern declaration is still present. It is
not needed anymore, so just remove it.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Ignore SMP data on non-LE links
Johan Hedberg [Wed, 16 Oct 2013 08:37:01 +0000 (11:37 +0300)]
Bluetooth: Ignore SMP data on non-LE links

The SMP CID is only defined for LE transports. Instead of returning an
error from smp_sig_channel() in this case (which would cause a
disconnection) just return 0 to ignore the data, which is consistent
with the behavior for other unknown CIDs.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Ignore A2MP data on non-BR/EDR links
Johan Hedberg [Wed, 16 Oct 2013 08:37:00 +0000 (11:37 +0300)]
Bluetooth: Ignore A2MP data on non-BR/EDR links

The A2MP CID is only valid for BR/EDR transports. We should ignore A2MP
data on non-BR/EDR links and refuse to create an amp_mgr object.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Remove useless l2cap_err_to_reason function
Johan Hedberg [Wed, 16 Oct 2013 08:20:49 +0000 (11:20 +0300)]
Bluetooth: Remove useless l2cap_err_to_reason function

Now that the only reason code this function can return is
L2CAP_REJ_NOT_UNDERSTOOD we can just do the necessary assignment without
needing a separate function at all.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Remove unused command reject mapping for EMSGSIZE
Johan Hedberg [Wed, 16 Oct 2013 08:20:48 +0000 (11:20 +0300)]
Bluetooth: Remove unused command reject mapping for EMSGSIZE

There is no command handler that would return an EMSGSIZE error, so just
remove this mapping from the l2cap_err_to_reason function.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Fix L2CAP "Command Reject: Invalid CID" response
Johan Hedberg [Wed, 16 Oct 2013 08:20:47 +0000 (11:20 +0300)]
Bluetooth: Fix L2CAP "Command Reject: Invalid CID" response

When the reason code in the L2CAP command reject is "invalid CID" there
should be four additional bytes of data in the PDU, namely the source
and destination CIDs (which should be zero if one or both are not
applicable). This patch fixes all occurrences of such errors to return
the right kind of PDU.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Remove duplicate definitions for advertising event types
Marcel Holtmann [Wed, 16 Oct 2013 07:16:51 +0000 (00:16 -0700)]
Bluetooth: Remove duplicate definitions for advertising event types

The constants for advertising event types have been defined twice. So
remove one copy of it.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Rename update_ad into update_adv_data
Marcel Holtmann [Wed, 16 Oct 2013 07:16:50 +0000 (00:16 -0700)]
Bluetooth: Rename update_ad into update_adv_data

Since there is update_scan_rsp_data, it is also better to use the
clear name update_adv_data instead of update_ad.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Store device name in scan response data
Marcel Holtmann [Wed, 16 Oct 2013 07:16:49 +0000 (00:16 -0700)]
Bluetooth: Store device name in scan response data

The scan response data is a better place to store the device name
since it has more space available and is also enforcing privacy.

When the controller is advertising, the connectable setting decides
if ADV_IND or ADV_NONCONN_IND is used. In case of ADV_IND, the
remote side is allowed to request the scan response data. Same as
with BR/EDR where either EIR is used or a remote name request. In
non-connectable mode, the device name is not available since it is
not allowed to request scan response data. Same as in BR/EDR where
the device is non-discoverable and no name requests are answered.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Set the scan response data when needed
Marcel Holtmann [Wed, 16 Oct 2013 07:16:48 +0000 (00:16 -0700)]
Bluetooth: Set the scan response data when needed

On controller power on and when enabling LE functionality,
make sure that also the scan response data is correctly set.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Store scan response data in HCI device
Marcel Holtmann [Wed, 16 Oct 2013 07:16:47 +0000 (00:16 -0700)]
Bluetooth: Store scan response data in HCI device

The scan response data needs to be stored in HCI device and so
add a buffer for it and also ensure to clear it when resetting
the controller.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Rename create_ad into create_adv_data
Marcel Holtmann [Wed, 16 Oct 2013 07:16:46 +0000 (00:16 -0700)]
Bluetooth: Rename create_ad into create_adv_data

Rename the create_ad function into create_adv_data to make it clear
that it is used to create the advertising data. This is important
since later on a function adding the scan response data will be
added.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Make mgmt_new_ltk() return void
Marcel Holtmann [Tue, 15 Oct 2013 21:26:29 +0000 (14:26 -0700)]
Bluetooth: Make mgmt_new_ltk() return void

The return value of mgmt_new_ltk() function is not used and
so just change it to return void.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
11 years agoBluetooth: Make mgmt_read_local_oob_data_reply_complete() return void
Marcel Holtmann [Tue, 15 Oct 2013 21:26:28 +0000 (14:26 -0700)]
Bluetooth: Make mgmt_read_local_oob_data_reply_complete() return void

The return value of mgmt_read_local_oob_data_reply_complete() function
is not used and so just change it to return void.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
11 years agoBluetooth: Make mgmt_set_local_name_complete() return void
Marcel Holtmann [Tue, 15 Oct 2013 21:26:27 +0000 (14:26 -0700)]
Bluetooth: Make mgmt_set_local_name_complete() return void

The return value of mgmt_set_local_name_complete() function is
not used and so just change it to return void.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
11 years agoBluetooth: Make mgmt_set_class_of_dev_complete() return void
Marcel Holtmann [Tue, 15 Oct 2013 21:26:26 +0000 (14:26 -0700)]
Bluetooth: Make mgmt_set_class_of_dev_complete() return void

The return value of mgmt_set_class_of_dev_complete() function is
not used and so just change it to return void.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
11 years agoBluetooth: Make mgmt_ssp_enable_complete() return void
Marcel Holtmann [Tue, 15 Oct 2013 21:26:25 +0000 (14:26 -0700)]
Bluetooth: Make mgmt_ssp_enable_complete() return void

The return value of mgmt_ssp_enable_complete() function is not
used and so just change it to return void.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
11 years agoBluetooth: Make mgmt_auth_enable_complete() return void
Marcel Holtmann [Tue, 15 Oct 2013 21:26:24 +0000 (14:26 -0700)]
Bluetooth: Make mgmt_auth_enable_complete() return void

The return value of mgmt_auth_enable_complete() function is not
used and so just change it to return void.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
11 years agoBluetooth: Make mgmt_auth_failed() return void
Marcel Holtmann [Tue, 15 Oct 2013 21:26:23 +0000 (14:26 -0700)]
Bluetooth: Make mgmt_auth_failed() return void

The return value of mgmt_auth_failed() function is not used
and so just change it to return void.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
11 years agoBluetooth: Make mgmt_pin_code_neg_reply_complete() return void
Marcel Holtmann [Tue, 15 Oct 2013 21:26:22 +0000 (14:26 -0700)]
Bluetooth: Make mgmt_pin_code_neg_reply_complete() return void

The return value of mgmt_pin_code_neg_reply_complete() function is
not used and so just change it to return void.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
11 years agoBluetooth: Make mgmt_pin_code_reply_complete() return void
Marcel Holtmann [Tue, 15 Oct 2013 21:26:21 +0000 (14:26 -0700)]
Bluetooth: Make mgmt_pin_code_reply_complete() return void

The return value of mgmt_pin_code_reply_complete() function is not
used and so just change it to return void.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
11 years agoBluetooth: Make mgmt_pin_code_request() return void
Marcel Holtmann [Tue, 15 Oct 2013 21:26:20 +0000 (14:26 -0700)]
Bluetooth: Make mgmt_pin_code_request() return void

The return value of mgmt_pin_code_request() function is not used
and so just change it to return void.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
11 years agoBluetooth: Add l2cap_chan_no_resume stub for A2MP
Marcel Holtmann [Tue, 15 Oct 2013 23:47:11 +0000 (16:47 -0700)]
Bluetooth: Add l2cap_chan_no_resume stub for A2MP

The A2MP client for L2CAP channels needs to use l2cap_chan_no_resume
empty stub function.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
11 years agoBluetooth: use l2cap_chan_ready() instead of duplicate code
Gustavo Padovan [Tue, 15 Oct 2013 22:24:51 +0000 (19:24 -0300)]
Bluetooth: use l2cap_chan_ready() instead of duplicate code

In this case the replacement by l2cap_chan_ready() doesn't change the code
flow, the same operations will executed plus two others that have no
effect: the use of the parent socket, that a non-oriented channel doesn't
have and the reset of conf_state, which is also fine since the connection
is ready at this point.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Move l2cap_wait_ack() to l2cap_sock.c
Gustavo Padovan [Tue, 15 Oct 2013 22:24:49 +0000 (19:24 -0300)]
Bluetooth: Move l2cap_wait_ack() to l2cap_sock.c

The wait_ack code has a heavy dependency on the socket data structures
and, as of now, it won't be worthless change it to use non-socket
structures as the only user of such feature is a socket.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Add chan->ops->set_shutdown()
Gustavo Padovan [Tue, 15 Oct 2013 22:24:48 +0000 (19:24 -0300)]
Bluetooth: Add chan->ops->set_shutdown()

We need to remove all direct access of struct sock from L2CAP core.
This change is pretty simple and just add a new L2CAP channel callback to
do the work in the L2CAP socket side.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Access sk_sndtimeo indirectly in l2cap_core.c
Gustavo Padovan [Tue, 15 Oct 2013 22:24:47 +0000 (19:24 -0300)]
Bluetooth: Access sk_sndtimeo indirectly in l2cap_core.c

As part of the work to remove struct sock from l2cap_core.c and make it
more generic we remove in this commit the direct access to sk->sk_sndtimeo
member. This objective of this change is purely remove sk usage from
l2cap_core.c

Now we have a new l2cap ops to get the current value of sk->sndtimeo. A
l2cap_chan_no_get_sndtimeo was added for users of L2CAP that doesn't need
to set a timeout.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Add l2cap_state_change_and_error()
Gustavo Padovan [Tue, 15 Oct 2013 22:24:46 +0000 (19:24 -0300)]
Bluetooth: Add l2cap_state_change_and_error()

l2cap_state_change_and_error() introduces the ability to update a
l2cap_user with changes in channel's state and error code with just one
call. The main reason for this is to avoid race conditions between and
setting the state and then the error. Otherwise we would need to release
the lock between both operations.

This is another step of an ongoing work to make l2cap_core.c totally
independent from l2cap's struct sock.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Extend state_change() call to report errors too
Gustavo Padovan [Tue, 15 Oct 2013 22:24:45 +0000 (19:24 -0300)]
Bluetooth: Extend state_change() call to report errors too

Instead of creating an new function pointer to report errors we are just
reusing state_change for that and there is a simple reason for this, one
place in the l2cap_core.c code needs, in a locked sk, set both the sk_state
and sk_err. If we create two different functions for this we would need to
release the lock between the two operation putting the socket in non
desired state.

The change is transparent to the l2cap_core.c code, user that only needs
to set the state won't need any modification.

This is another step of an ongoing work to make l2cap_core.c totally
independent from l2cap's struct sock.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
11 years agoBluetooth: Update class of device on discoverable timeout
Marcel Holtmann [Tue, 15 Oct 2013 17:57:40 +0000 (10:57 -0700)]
Bluetooth: Update class of device on discoverable timeout

When the discoverable timeout triggers and limited discoverable mode
was used, then the class of device needs to be updated to remove
the limited discoverable bit.

To keep the class of device logic in a central place, expose a new
function mgmt_discoverable_timeout that can be called from the
timeout callback. In case the class of device value needs updating,
it will add the HCI command to the transaction.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Move eir_get_length() function into hci_event.c
Marcel Holtmann [Tue, 15 Oct 2013 17:31:12 +0000 (10:31 -0700)]
Bluetooth: Move eir_get_length() function into hci_event.c

The eir_get_length() function is only used from hci_event.c and so
instead of having a public function move it to the location where
it is used.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Move eir_append_data() function into mgmt.c
Marcel Holtmann [Tue, 15 Oct 2013 17:26:39 +0000 (10:26 -0700)]
Bluetooth: Move eir_append_data() function into mgmt.c

The eir_append_data() function is only used from mgmt.c and so
instead of having a public function move it to the location where
it is used.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Make mgmt_new_link_key() return void
Marcel Holtmann [Tue, 15 Oct 2013 17:15:57 +0000 (10:15 -0700)]
Bluetooth: Make mgmt_new_link_key() return void

The return value of mgmt_new_link_key() function is not used
and so just change it to return void.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Add support for entering limited discoverable mode
Marcel Holtmann [Tue, 15 Oct 2013 16:13:39 +0000 (09:13 -0700)]
Bluetooth: Add support for entering limited discoverable mode

The limited discoverable mode should be used when a device is only
discoverable for a certain amount of time and after that it returns
back into being non-discoverable.

This adds another option to the set discoverable management command
to clearly distinguish limited discoverable from general discoverable
mode.

While the general discoverable mode can be set with a specific
timeout or as permanent setting, the limited discoverable mode
requires a timeout. The timeout is flexible and the kernel will
not enforce any specific limitations. That GAP part of this is
required by userspace to enforce according to the Bluetooth core
specification.

Devices in limited discoverable mode can still be found by the
general discovery procedure. It is mandatory that a device sets
both GIAC and LIAC when entering limited discoverable mode.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Add HCI command structure for writing current IAC LAP
Marcel Holtmann [Tue, 15 Oct 2013 15:34:15 +0000 (08:34 -0700)]
Bluetooth: Add HCI command structure for writing current IAC LAP

This patch just adds the HCI command structure for configuring the
current IAC LAP setting. The length of the command is variable and
supports more than two IAC. However since there is only general
discoverable and limited discoverable modes, this can be limited
to two possible IACs.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Simplify the code for re-arming discoverable timeout
Marcel Holtmann [Tue, 15 Oct 2013 15:28:51 +0000 (08:28 -0700)]
Bluetooth: Simplify the code for re-arming discoverable timeout

When only the discoverable timeout gets updated, just cancel the current
timeout, store the new timeout value. If the new timeout is valid, then
arm the discoverable timeout again.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Move arming of discoverable timeout to complete handler
Marcel Holtmann [Tue, 15 Oct 2013 15:11:02 +0000 (08:11 -0700)]
Bluetooth: Move arming of discoverable timeout to complete handler

The discoverable timeout is currently armed from hci_event.c and causes
some side effects when using HCI commands instead of the management
interface. To make this clear, only arm the discoverable timeout from
the management command complete handler.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Update class of device after changing discoverable mode
Marcel Holtmann [Tue, 15 Oct 2013 13:33:57 +0000 (06:33 -0700)]
Bluetooth: Update class of device after changing discoverable mode

When the discoverable mode gets changed, ensure that the class of
device value has the correct limited discoverable bit value set.

Since the class of device HCI command will only be send to the
controller when the value changes, it is safe to just always
trigger the update.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Make mgmt_write_scan_failed() return void
Marcel Holtmann [Tue, 15 Oct 2013 13:33:56 +0000 (06:33 -0700)]
Bluetooth: Make mgmt_write_scan_failed() return void

The return value of mgmt_write_scan_failed() function is not used
and so just change it to return void.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
11 years agoBluetooth: Make mgmt_connectable() return void
Marcel Holtmann [Tue, 15 Oct 2013 13:33:55 +0000 (06:33 -0700)]
Bluetooth: Make mgmt_connectable() return void

The return value of mgmt_connectable() function is not used
and so just change it to return void.

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