Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Hyuckjoo Lee <hyuckjoo.lee@samsung.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

authored by

Bing Zhao and committed by
Gustavo Padovan
8a4934f1 433a9389

+11 -18
+1 -1
drivers/bluetooth/btmrvl_drv.h
··· 120 120 #define PS_SLEEP 0x01 121 121 #define PS_AWAKE 0x00 122 122 123 - #define BT_CMD_DATA_SIZE 32 123 + #define BT_CAL_HDR_LEN 4 124 124 #define BT_CAL_DATA_SIZE 28 125 125 126 126 struct btmrvl_event {
+10 -17
drivers/bluetooth/btmrvl_main.c
··· 415 415 } 416 416 417 417 static int btmrvl_download_cal_data(struct btmrvl_private *priv, 418 - u8 *config_data) 418 + u8 *data, int len) 419 419 { 420 - int i, ret; 421 - u8 data[BT_CMD_DATA_SIZE]; 420 + int ret; 422 421 423 422 data[0] = 0x00; 424 423 data[1] = 0x00; 425 424 data[2] = 0x00; 426 - data[3] = BT_CMD_DATA_SIZE - 4; 427 - 428 - /* Swap cal-data bytes. Each four bytes are swapped. Considering 4 429 - * byte SDIO header offset, mapping of input and output bytes will be 430 - * {3, 2, 1, 0} -> {0+4, 1+4, 2+4, 3+4}, 431 - * {7, 6, 5, 4} -> {4+4, 5+4, 6+4, 7+4} */ 432 - for (i = 4; i < BT_CMD_DATA_SIZE; i++) 433 - data[i] = config_data[(i / 4) * 8 - 1 - i]; 425 + data[3] = len; 434 426 435 427 print_hex_dump_bytes("Calibration data: ", 436 - DUMP_PREFIX_OFFSET, data, BT_CMD_DATA_SIZE); 428 + DUMP_PREFIX_OFFSET, data, BT_CAL_HDR_LEN + len); 437 429 438 430 ret = btmrvl_send_sync_cmd(priv, BT_CMD_LOAD_CONFIG_DATA, data, 439 - BT_CMD_DATA_SIZE); 431 + BT_CAL_HDR_LEN + len); 440 432 if (ret) 441 433 BT_ERR("Failed to download caibration data\n"); 442 434 ··· 438 446 static int btmrvl_cal_data_dt(struct btmrvl_private *priv) 439 447 { 440 448 struct device_node *dt_node; 441 - u8 cal_data[BT_CAL_DATA_SIZE]; 449 + u8 cal_data[BT_CAL_HDR_LEN + BT_CAL_DATA_SIZE]; 442 450 const char name[] = "btmrvl_caldata"; 443 451 const char property[] = "btmrvl,caldata"; 444 452 int ret; ··· 447 455 if (!dt_node) 448 456 return -ENODEV; 449 457 450 - ret = of_property_read_u8_array(dt_node, property, cal_data, 451 - sizeof(cal_data)); 458 + ret = of_property_read_u8_array(dt_node, property, 459 + cal_data + BT_CAL_HDR_LEN, 460 + BT_CAL_DATA_SIZE); 452 461 if (ret) 453 462 return ret; 454 463 455 464 BT_DBG("Use cal data from device tree"); 456 - ret = btmrvl_download_cal_data(priv, cal_data); 465 + ret = btmrvl_download_cal_data(priv, cal_data, BT_CAL_DATA_SIZE); 457 466 if (ret) { 458 467 BT_ERR("Fail to download calibrate data"); 459 468 return ret;