Commit 8a4934f1 authored by Bing Zhao's avatar Bing Zhao Committed by Gustavo Padovan

Bluetooth: btmrvl: remove cal-data byte swapping and redundant mem copy

The device tree property can define the cal-data in proper order.
There is no need to swap the bytes in driver.
Also remove the redundant cal-data memory copy after removing the
byte swapping.

Cc: Mike Frysinger <vapier@chromium.org>
Cc: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: default avatarBing Zhao <bzhao@marvell.com>
Signed-off-by: default avatarHyuckjoo Lee <hyuckjoo.lee@samsung.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 433a9389
...@@ -120,7 +120,7 @@ struct btmrvl_private { ...@@ -120,7 +120,7 @@ struct btmrvl_private {
#define PS_SLEEP 0x01 #define PS_SLEEP 0x01
#define PS_AWAKE 0x00 #define PS_AWAKE 0x00
#define BT_CMD_DATA_SIZE 32 #define BT_CAL_HDR_LEN 4
#define BT_CAL_DATA_SIZE 28 #define BT_CAL_DATA_SIZE 28
struct btmrvl_event { struct btmrvl_event {
......
...@@ -415,28 +415,20 @@ static int btmrvl_open(struct hci_dev *hdev) ...@@ -415,28 +415,20 @@ static int btmrvl_open(struct hci_dev *hdev)
} }
static int btmrvl_download_cal_data(struct btmrvl_private *priv, static int btmrvl_download_cal_data(struct btmrvl_private *priv,
u8 *config_data) u8 *data, int len)
{ {
int i, ret; int ret;
u8 data[BT_CMD_DATA_SIZE];
data[0] = 0x00; data[0] = 0x00;
data[1] = 0x00; data[1] = 0x00;
data[2] = 0x00; data[2] = 0x00;
data[3] = BT_CMD_DATA_SIZE - 4; data[3] = len;
/* Swap cal-data bytes. Each four bytes are swapped. Considering 4
* byte SDIO header offset, mapping of input and output bytes will be
* {3, 2, 1, 0} -> {0+4, 1+4, 2+4, 3+4},
* {7, 6, 5, 4} -> {4+4, 5+4, 6+4, 7+4} */
for (i = 4; i < BT_CMD_DATA_SIZE; i++)
data[i] = config_data[(i / 4) * 8 - 1 - i];
print_hex_dump_bytes("Calibration data: ", print_hex_dump_bytes("Calibration data: ",
DUMP_PREFIX_OFFSET, data, BT_CMD_DATA_SIZE); DUMP_PREFIX_OFFSET, data, BT_CAL_HDR_LEN + len);
ret = btmrvl_send_sync_cmd(priv, BT_CMD_LOAD_CONFIG_DATA, data, ret = btmrvl_send_sync_cmd(priv, BT_CMD_LOAD_CONFIG_DATA, data,
BT_CMD_DATA_SIZE); BT_CAL_HDR_LEN + len);
if (ret) if (ret)
BT_ERR("Failed to download caibration data\n"); BT_ERR("Failed to download caibration data\n");
...@@ -446,7 +438,7 @@ static int btmrvl_download_cal_data(struct btmrvl_private *priv, ...@@ -446,7 +438,7 @@ static int btmrvl_download_cal_data(struct btmrvl_private *priv,
static int btmrvl_cal_data_dt(struct btmrvl_private *priv) static int btmrvl_cal_data_dt(struct btmrvl_private *priv)
{ {
struct device_node *dt_node; struct device_node *dt_node;
u8 cal_data[BT_CAL_DATA_SIZE]; u8 cal_data[BT_CAL_HDR_LEN + BT_CAL_DATA_SIZE];
const char name[] = "btmrvl_caldata"; const char name[] = "btmrvl_caldata";
const char property[] = "btmrvl,caldata"; const char property[] = "btmrvl,caldata";
int ret; int ret;
...@@ -455,13 +447,14 @@ static int btmrvl_cal_data_dt(struct btmrvl_private *priv) ...@@ -455,13 +447,14 @@ static int btmrvl_cal_data_dt(struct btmrvl_private *priv)
if (!dt_node) if (!dt_node)
return -ENODEV; return -ENODEV;
ret = of_property_read_u8_array(dt_node, property, cal_data, ret = of_property_read_u8_array(dt_node, property,
sizeof(cal_data)); cal_data + BT_CAL_HDR_LEN,
BT_CAL_DATA_SIZE);
if (ret) if (ret)
return ret; return ret;
BT_DBG("Use cal data from device tree"); BT_DBG("Use cal data from device tree");
ret = btmrvl_download_cal_data(priv, cal_data); ret = btmrvl_download_cal_data(priv, cal_data, BT_CAL_DATA_SIZE);
if (ret) { if (ret) {
BT_ERR("Fail to download calibrate data"); BT_ERR("Fail to download calibrate data");
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment