1
0
Fork 0
Commit Graph

397242 Commits (8909f6d2c450d0a878bcb1d1184ed0114c5724c9)

Author SHA1 Message Date
Marcel Holtmann 8909f6d2c4 Bluetooth: Remove unused h4_check_data_len() function
The function h4_check_data_len() is actually not used. So just
remove it.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-11 07:51:09 +02:00
Marcel Holtmann 5108699194 Bluetooth: Remove return value from hci_send_frame() function
The return value of hci_send_frame() is never checked. So just make
this function void and print an error when the hdev->send driver
callback returns a negative value.

Having the error printed is actually an improvement over the
current situation where any driver error just gets ignored.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-11 00:19:44 +02:00
Marcel Holtmann 3d386acea0 Bluetooth: Remove pointless check of hci_send_frame parameter
The hdev parameter of hci_send_frame must be always valid. If the hdev
is not valid, it would not even make it to this stage. The callers
will have already accessed hdev at that point many times.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-11 00:10:11 +02:00
Marcel Holtmann 57d17d70df Bluetooth: Move skb->dev assignment for hdev->send into central place
The assignement of skb->dev is done all over the place. So it makes it
hard to eventually get rid of it. Move it all in one central place so
it gets assigned right before calling hdev->send driver callback.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-11 00:10:09 +02:00
Marcel Holtmann ac4b723661 Bluetooth: Move smp.h header file into net/bluetooth/
The smp.h header file is only used internally by the bluetooth.ko
module and is not a public API. So make it local to the core
Bluetooth module.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-11 00:10:07 +02:00
Marcel Holtmann 7024728ee5 Bluetooth: Move a2mp.h header file into net/bluetooth/
The a2mp.h header file is only used internally by the bluetooth.ko
module and is not a public API. So make it local to the core
Bluetooth module.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-11 00:10:05 +02:00
Marcel Holtmann 7ef9fbf088 Bluetooth: Move amp.h header file into net/bluetooth/
The amp.h header file is only used internally by the bluetooth.ko
module and is not a public API. So make it local to the core
Bluetooth module.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-11 00:10:03 +02:00
Marcel Holtmann 324d36ed26 Bluetooth: Remove hdev->ioctl driver callback
Since there is no use of hdev->ioctl by any Bluetooth driver since
ever, so just lets remove it.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-10 22:11:41 +02:00
Marcel Holtmann e93ac9c063 Bluetooth: Remove unused btmrvl_ioctl() callback
The btmrvl_ioctl() function is not used and thus remove it.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-10 22:11:35 +02:00
Marcel Holtmann 3c7288422f Bluetooth: Remove unused dtl1_hci_ioctl() callback
The dtl1_hci_ioctl() function is not used and thus remove it.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-10 22:11:00 +02:00
Marcel Holtmann 71f3903047 Bluetooth: Remove unused btuart_hci_ioctl() callback
The btuart_hci_ioctl() function is not used and thus remove it.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-10 22:10:37 +02:00
Marcel Holtmann 69b7e17057 Bluetooth: Remove unused bt3c_hci_ioctl() callback
The bt3c_hci_ioctl() function is not used and thus remove it.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-10 22:10:16 +02:00
Marcel Holtmann 87d82ee257 Bluetooth: Remove unused bluecard_hci_ioctl() callback
The bluecard_hci_ioctl() function is not used and thus remove it.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-10 22:10:00 +02:00
Marcel Holtmann 19cf55a234 Bluetooth: Remove unused bfusb_ioctl() callback
The bfusb_ioctl() function is not used and thus remove it.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-10 22:09:49 +02:00
Marcel Holtmann 5b69bef541 Bluetooth: AMP contollers do not support the legacy ioctls
The legacy ioctls for device specific commands including inquiry are
not support by AMP controllers. So just reject them right away instead
of trying to send the HCI command and wait for failure from the
actual hardware.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-10 22:08:37 +02:00
Marcel Holtmann 014f7bc787 Bluetooth: Use hci_conn_num() instead of direct connection hash access
When changing the alternate setting for the ISOC endpoints, use the
hci_conn_num() helper function to count currently established SCO
and eSCO connections and store the the value. This avoids direct
access to the connection hash.

In addition use the stored value instead accessing the connection
hash over and over again.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-10 22:08:02 +02:00
Marcel Holtmann b145edcd16 Bluetooth: Use hci_conn_num() for checking number of LE connections
When checking for the current number of LE connections, use
hci_conn_num() function instead of a full blown lookup within
the connection hash or direct access of the counters.

In the case of re-enabling advertising, it is more useful to
check for any connection attempt or existing connection.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-10 22:07:20 +02:00
Marcel Holtmann 21b5187f23 Bluetooth: Fix too long line with set_advertising() function
The function declaration goes over 80 characters, so break it down.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-10 22:07:00 +02:00
Johan Hedberg cebf4cfd86 Bluetooth: Fix checking for HCI_SETUP flag when receiving mgmt commands
When the HCI_SETUP flag is set the controller has not yet been announced
over mgmt and therefore doesn't exist from that perspective. If we
nevertheless get a mgmt command for it we should respond with the
appropriate INVALID_INDEX error.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2013-10-10 09:13:45 -07:00
Johan Hedberg c4e5bafa66 Bluetooth: Fix potential double-frees of L2CAP skbs
The l2cap_recv_frame function is expected to take ownership and
eventually free the skb passed to it. We need to ensure that the
conn->rx_skb pointer is no longer reachable when calling
l2cap_recv_frame so that no other function, such as l2cap_conn_del, may
think that it can free conn->rx_skb.

An actual situation when this can happen is when smp_sig_channel (called
from l2cap_recv_frame) fails and l2cap_conn_del gets called as a
consequence. The l2cap_conn_del function would then try to free
conn->rx_skb, but as the same skb was just passed to smp_sig_channel and
freed we get a double-free.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2013-10-10 05:00:34 -07:00
Marcel Holtmann 9ecb3e2425 Bluetooth: Restrict high speed support to SSP enabled controllers
The support for Bluetooth High Speed can only be enabled on controllers
where also Secure Simple Pairing has been enabled. Trying to enable
high speed when SSP is disabled will result into an error. Disabling
SSP will at the same time disable high speed as well.

It is required to enforce this dependency on SSP since high speed
support is only defined for authenticated, unauthenticated and
debug link keys. These link key types require SSP.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-10 12:54:51 +02:00
Marcel Holtmann 72ef0c1a9e Bluetooth: Remove unneeded val variable when setting SSP
The variable val in the set_ssp() function of the management interface
is not needed. Just use cp->val directly since its input values have
already been validated.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-10 12:54:51 +02:00
Andre Guedes 620ad5219c Bluetooth: Refactor hci_connect_le
This patch does some code refactoring in hci_connect_le() by moving
the exception code into if statements and letting the main flow in
first level of function scope. It also adds extra comments to improve
the code readability.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2013-10-10 01:30:18 -07:00
Andre Guedes 1d399ae5c7 Bluetooth: Use HCI request for LE connection
This patch introduces a new helper, which uses the HCI request
framework, for creating LE connectons. All the handling is now
done by this function so we can remove the hci_cs_le_create_conn()
event handler.

This patch also removes the old hci_le_create_connection() since
it is not used anymore.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2013-10-10 01:30:18 -07:00
Johan Hedberg f74ca9b809 Bluetooth: Fix changing advertising setting while LE is connected
We only (re)enable advertising when LE is disconnected. Trying to enable
advertising using mgmt_set_advertising while connected should simply
change the flag but not do anything else (until the connection gets
dropped). This patch fixes this by making an LE connection lookup to
determine whether there are any connected devices or not.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2013-10-08 07:49:02 -07:00
Johannes Berg c1f23a2bfc Bluetooth: Fix variable shadow warnings
Sparse points out three places where variables are shadowed,
rename two of the variables and remove the duplicate third.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2013-10-07 09:52:12 -07:00
Marcel Holtmann f38ba94147 Bluetooth: Read flow control mode on AMP controller init
When initializing an AMP controller, read its current flow control
mode so that the correct value is used.

The AMP controller defaults to block based flow control and this
extra command is just to double check.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-07 16:53:43 +02:00
Marcel Holtmann 7528ca1c5a Bluetooth: Read location data on AMP controller init
When initializing an AMP controller, read its current known location
data so that it can be analyzed later on.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-07 16:53:40 +02:00
Marcel Holtmann f6996cfe2f Bluetooth: Read supported features and commands on AMP controllers
The commands for reading supported features and commands are both
supported by AMP controllers. Issue them during controller init
phase so their values are known.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-07 14:51:54 +02:00
Marcel Holtmann cd0a85c22c Bluetooth: List powered down AMP controllers correctly
Within the AMP discover response, list powered down AMP controllers
as powered down. No point in trying to make them look any different.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-07 10:08:42 +02:00
Marcel Holtmann 93c311a044 Bluetooth: Make mgmt power down notification for BR/EDR explicit
The management interface only operates on BR/EDR controllers. The check
for the power down notification is a bit intermixed with the check if
controller auto power off is active. Since there are more than just
BR/EDR controllers supported, make this check explicit since the auto
power off check also applies to AMP controllers and it has to happen
in this exact order. Otherwise the bit will not be cleared.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-07 10:08:39 +02:00
Marcel Holtmann 004b02589c Bluetooth: Power off AMP controllers after setup phase
Even AMP controllers should be powered off after the setup phase. It
is not a good idea to keep AMP controllers powered on all the time
if they are not in use.

Power on of the AMP controller can either be done manually via
command line commands or directly via A2MP. Especially since there
is an indication in A2MP for powered down controllers that can
be activated.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-07 10:08:36 +02:00
Marcel Holtmann 2f1e063bc0 Bluetooth: Make mgmt_discovering() return void
The return value of mgmt_discovering() 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>
2013-10-07 09:19:28 +02:00
Marcel Holtmann 9cf12aee8b Bluetooth: Make mgmt_remote_name() return void
The return value of mgmt_remote_name() 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>
2013-10-07 09:19:25 +02:00
Marcel Holtmann 901801b9a4 Bluetooth: Make mgmt_device_found() return void
The return value of mgmt_device_found() 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>
2013-10-07 09:19:23 +02:00
Marcel Holtmann 9b80ec5e8e Bluetooth: Make mgmt_device_disconnected() return void
The return value of mgmt_device_disconnected() 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>
2013-10-07 09:19:21 +02:00
Marcel Holtmann ecd90ae7f6 Bluetooth: Make mgmt_device_connected() return void
The return value of mgmt_device_connected() 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>
2013-10-07 09:19:19 +02:00
Marcel Holtmann 445608d078 Bluetooth: Make mgmt_connect_failed() return void
The return value of mgmt_connect_failed() function is not used
so change it to just return void.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-07 09:19:18 +02:00
Marcel Holtmann 7892924c7d Bluetooth: Make mgmt_disconnect_failed() return void
The return value of mgmt_disconnect_failed() function is not used
so change it to just return void.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-07 09:19:16 +02:00
Marcel Holtmann 3eec705e42 Bluetooth: Make mgmt_set_powered_failed() return void
The return value of mgmt_set_powered_failed() function is never used
and so make the function just return void.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-07 09:19:13 +02:00
Marcel Holtmann bf6b56db0a Bluetooth: Make mgmt_index_added() and mgmt_index_removed() return void
The return value from mgmt_index_added() and mgmt_index_removed()
functions is never used. So do not pretend that returning an error
would actually be handled and just make both functions return void.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-07 09:19:12 +02:00
Marcel Holtmann 5559435654 Bluetooth: Send new settings only when pairable changes
In case the current value of pairable is already configured, do not
send a new settings event indicating that something has changed while
in reality everything is the same.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-07 08:52:26 +02:00
Marcel Holtmann 1514b8928e Bluetooth: Remove mgmt_valid_hdev() helper function
The helper function mgmt_valid_hdev() is more obfuscating the code
then it makes it easier to read. So intead of this helper, use the
direct check for BR/EDR device type.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-06 17:58:45 +02:00
Marcel Holtmann a6d811ed28 Bluetooth: Remove no longer needed mgmt_new_settings() function
The mgmt_new_settings() function was only needed to handle the
error case when re-enabling advertising failed. Since that is
now handled internally inside the management core, this function
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>
2013-10-06 15:01:21 +02:00
Marcel Holtmann 5976e60811 Bluetooth: Use helper function for re-enabling advertising
When the all LE connections have been disconneted, then it is up to
the host to re-enable advertising at that point. To ensure that the
correct advertising parameters are used, force the usage of the
common helper to enable advertising.

The change just moves the manual enabling of advertising from the
event handler into the management core so that the helper can
be actually shared.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-06 15:00:07 +02:00
Marcel Holtmann b4faf30096 Bluetooth: Set LE advertising parameters before enabling it
The LE advertising parameters can only be modified when advertising
is disabled. So before enabling it, make sure the controller has all
the right parameters.

Right now all default values are used and thus this does no change
any existing behavior. One minor exception is that in case of single
mode LE-only controllers without a public address, now the random
address is used for advertising.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-06 14:59:25 +02:00
Marcel Holtmann c2f5ebd214 Bluetooth: Add constants for LE advertising types
Add constants for ADV_IND, ADV_DIRECT_IND, ADV_SCAN_IND and
ADV_NONCONN_IND advertising types.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-06 14:57:59 +02:00
Marcel Holtmann bba3aa550f Bluetooth: Use helper functions for enabling/disabling advertising
The tasks of enabling and disabling advertising are required in many
cases. So refactor the actual HCI operations into two common helpers
to make the code simpler.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-06 14:53:25 +02:00
Marcel Holtmann 03d87419de Bluetooth: Make it clear that disabling LE disables advertising
This is not a functional change, just change the code to make it easy
to understand that advertising gets disabled before LE support will
be turned off.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-06 14:53:08 +02:00
Marcel Holtmann 1e191893f3 Bluetooth: Add HCI structure for LE advertising parameters command
Add the basic HCI structure for building the LE advertising parameters
command.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-06 14:51:23 +02:00