From: Sudha Bheemanna Date: Wed, 7 Sep 2016 09:52:08 +0000 (+0530) Subject: Bluetooth: Get Advertising TX power X-Git-Tag: accepted/tizen/unified/20240422.153132~51 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eb40dcf3dc1fc8a6baa98db2172c05da280e40ae;p=platform%2Fkernel%2Flinux-rpi.git Bluetooth: Get Advertising TX power This patch adds MGMT command to read the advertising TX power. Change-Id: Ic2f6a8dedc949d6114fc22f1a595fc2c6c6b4d69 Signed-off-by: Sudha Bheemanna Signed-off-by: Amit Purwar Signed-off-by: Wootak Jung Signed-off-by: Jaehoon Chung --- diff --git a/include/net/bluetooth/mgmt_tizen.h b/include/net/bluetooth/mgmt_tizen.h index 4eaa867..982c00d 100644 --- a/include/net/bluetooth/mgmt_tizen.h +++ b/include/net/bluetooth/mgmt_tizen.h @@ -161,6 +161,12 @@ struct mgmt_cp_set_voice_setting { } __packed; #define MGMT_SET_VOICE_SETTING_SIZE 9 +#define MGMT_OP_GET_ADV_TX_POWER (TIZEN_OP_CODE_BASE + 0x11) +#define MGMT_GET_ADV_TX_POWER_SIZE 0 +struct mgmt_rp_get_adv_tx_power { + __s8 adv_tx_power; +} __packed; + /* EVENTS */ /* For device name update changes */ diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 74142dd..4f1c159 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -8886,6 +8886,37 @@ unlock: return err; } +static int get_adv_tx_power(struct sock *sk, struct hci_dev *hdev, + void *data, u16 len) +{ + struct mgmt_rp_get_adv_tx_power *rp; + size_t rp_len; + int err; + + BT_DBG("%s", hdev->name); + + hci_dev_lock(hdev); + + rp_len = sizeof(*rp); + rp = kmalloc(rp_len, GFP_KERNEL); + if (!rp) { + err = -ENOMEM; + goto unlock; + } + + rp->adv_tx_power = hdev->adv_tx_power; + + err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_GET_ADV_TX_POWER, 0, rp, + rp_len); + + kfree(rp); + +unlock: + hci_dev_unlock(hdev); + + return err; +} + void mgmt_hardware_error(struct hci_dev *hdev, u8 err_code) { struct mgmt_ev_hardware_error ev; @@ -11249,6 +11280,7 @@ static const struct hci_mgmt_handler tizen_mgmt_handlers[] = { { set_manufacturer_data, MGMT_SET_MANUFACTURER_DATA_SIZE }, { le_set_scan_params, MGMT_LE_SET_SCAN_PARAMS_SIZE }, { set_voice_setting, MGMT_SET_VOICE_SETTING_SIZE }, + { get_adv_tx_power, MGMT_GET_ADV_TX_POWER_SIZE }, }; #endif