Bluetooth: Postpone adding hdev to debufs

This patch moves the hci_add_sysfs call from hci_register_dev() to
hci_dev_open(). This way hdev is only added to debugfs after it has
been properly initialized. This will enable us to export information
according to the device type (e.g. BR/EDR related information is not
exported if device is LE-only, and vice-versa).

This patch also moves the hci_del_sysfs call from hci_unregister_dev()
to hci_dev_do_close() so we keep it lined up with hci_add_sysfs call.

As a side effect, the hciX/ directory will be added to debugfs once
the adapter is powered on and it will be removed once the adapter is
powered off.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Fix hci_add_sysfs

The inquiry_cache, blacklist, uuids and auto_accept_delay files should
be added to debugfs only if the controller is BR/EDR capable.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Keep the LE connection parameters in its own structure

This will allow for easier parameterization of these fields. This is
the first step for allowing to change the parameters during runtime.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Add LE connection parameters to debugfs

This patch adds the LE connection parameters to debugfs. If the
controller is LE capable, the le_conn_param directory is created
under hciX directory.

For each connection parameter, a file is created under le_conn_param
directory. The files organization is the following:

bluetooth/hci0/le_conn_param/
bluetooth/hci0/le_conn_param/conn_interval_max
bluetooth/hci0/le_conn_param/conn_interval_min
bluetooth/hci0/le_conn_param/conn_latency
bluetooth/hci0/le_conn_param/min_ce_length
bluetooth/hci0/le_conn_param/max_ce_length
bluetooth/hci0/le_conn_param/scan_interval
bluetooth/hci0/le_conn_param/scan_window
bluetooth/hci0/le_conn_param/supervision_timeout

All parameter files have read and write permissions. This means, we
are able to change the LE connection parameters by writing new values
into the files. For instance, to change the default value for the
connection supervision timeout we can run:
$ echo 0x0040 > /sys/kernel/debug/hci0/le_conn_param/supervision_timeout

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Discovery parameters per hci_dev

This patch adds discovery parameters to struct hci_dev. This way, we
will be able to configure the discovery parameters per hci device.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Add discovery parameters to debugfs

This patch creates the discovery_param directory under hciX/. For
each discovery parameter, a file is created in discovery_param/.
For dual mode devices (both LE and BR/EDR capabilites) the directory
organization is the following:

bluetooth/hci0/discovery_param/
bluetooth/hci0/discovery_param/bredr_inquiry_length
bluetooth/hci0/discovery_param/interleaved_inquiry_length
bluetooth/hci0/discovery_param/interleaved_scan_timeout
bluetooth/hci0/discovery_param/le_scan_timeout
bluetooth/hci0/discovery_param/scan_interval
bluetooth/hci0/discovery_param/scan_type
bluetooth/hci0/discovery_param/scan_window

If the controller is LE-only, only LE related parameters are created,
as well as if the controller is BR/EDR-only, only BR/EDR parameters
are created.

All parameter files have read and write permissions. This means, we
are able to change discovery parameters by writing new values into
the files. For instance, to change the default value for the scanning
interval we can run:
$ echo 0x0016 > /sys/kernel/debug/bluetooth/hci0/discovery_param/scan_interval

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>