diff --git a/core/bmi/src/bmi.c b/core/bmi/src/bmi.c index 33f5986cca0d..502f675faacd 100644 --- a/core/bmi/src/bmi.c +++ b/core/bmi/src/bmi.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2017 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -51,8 +51,9 @@ QDF_STATUS bmi_init(struct ol_context *ol_ctx) if (!info->bmi_cmd_buff) { info->bmi_cmd_buff = - qdf_mem_alloc_consistent(qdf_dev, qdf_dev->dev, MAX_BMI_CMDBUF_SZ, - &info->bmi_cmd_da); + qdf_mem_alloc_consistent(qdf_dev, qdf_dev->dev, + MAX_BMI_CMDBUF_SZ, + &info->bmi_cmd_da); if (!info->bmi_cmd_buff) { BMI_ERR("No Memory for BMI Command"); return QDF_STATUS_E_NOMEM; @@ -61,8 +62,9 @@ QDF_STATUS bmi_init(struct ol_context *ol_ctx) if (!info->bmi_rsp_buff) { info->bmi_rsp_buff = - qdf_mem_alloc_consistent(qdf_dev, qdf_dev->dev, MAX_BMI_CMDBUF_SZ, - &info->bmi_rsp_da); + qdf_mem_alloc_consistent(qdf_dev, qdf_dev->dev, + MAX_BMI_CMDBUF_SZ, + &info->bmi_rsp_da); if (!info->bmi_rsp_buff) { BMI_ERR("No Memory for BMI Response"); goto end; @@ -223,11 +225,11 @@ QDF_STATUS bmi_download_firmware(struct ol_context *ol_ctx) if (NO_BMI) { /* ol_ctx is not allocated in NO_BMI case */ return QDF_STATUS_SUCCESS; - } else { - BMI_ERR("ol_ctx is NULL"); - bmi_assert(0); - return QDF_STATUS_NOT_INITIALIZED; } + + BMI_ERR("ol_ctx is NULL"); + bmi_assert(0); + return QDF_STATUS_NOT_INITIALIZED; } scn = ol_ctx->scn; diff --git a/core/bmi/src/i_bmi.h b/core/bmi/src/i_bmi.h index 712bf9e30be5..477e4d9baad9 100644 --- a/core/bmi/src/i_bmi.h +++ b/core/bmi/src/i_bmi.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2017 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -97,14 +97,14 @@ struct hash_fw { u8 utf[SHA256_DIGEST_SIZE]; }; -typedef enum _ATH_BIN_FILE { +enum ATH_BIN_FILE { ATH_OTP_FILE, ATH_FIRMWARE_FILE, ATH_PATCH_FILE, ATH_BOARD_DATA_FILE, ATH_FLASH_FILE, ATH_SETUP_FILE, -} ATH_BIN_FILE; +}; #if defined(QCA_WIFI_3_0_ADRASTEA) #define NO_BMI 1 diff --git a/core/bmi/src/ol_fw.c b/core/bmi/src/ol_fw.c index faca36a5cb32..a9ed197df7ac 100644 --- a/core/bmi/src/ol_fw.c +++ b/core/bmi/src/ol_fw.c @@ -73,8 +73,8 @@ static int ol_target_coredump(void *inst, void *memory_block, uint32_t block_len); #ifdef FEATURE_SECURE_FIRMWARE -static int ol_check_fw_hash(struct device *dev, - const u8 *data, u32 fw_size, ATH_BIN_FILE file) +static int ol_check_fw_hash(struct device *dev, const u8 *data, + u32 fw_size, enum ATH_BIN_FILE file) { u8 *hash = NULL; u8 *fw_mem = NULL; @@ -147,8 +147,8 @@ end: #endif static int -__ol_transfer_bin_file(struct ol_context *ol_ctx, ATH_BIN_FILE file, - uint32_t address, bool compressed) +__ol_transfer_bin_file(struct ol_context *ol_ctx, enum ATH_BIN_FILE file, + uint32_t address, bool compressed) { struct hif_opaque_softc *scn = ol_ctx->scn; int status = EOK; @@ -255,7 +255,8 @@ __ol_transfer_bin_file(struct ol_context *ol_ctx, ATH_BIN_FILE file, #if defined(QCA_WIFI_FTM) /* Try default board data file if FTM specific - * board data file is not present. */ + * board data file is not present. + */ if (filename == bmi_ctx->fw_files.utf_board_data) { filename = bmi_ctx->fw_files.board_data; BMI_INFO("%s: Trying to load default %s", @@ -287,8 +288,8 @@ __ol_transfer_bin_file(struct ol_context *ol_ctx, ATH_BIN_FILE file, temp_eeprom = NULL; #ifdef FEATURE_SECURE_FIRMWARE - - if (ol_check_fw_hash(qdf_dev->dev, fw_entry->data, fw_entry_size, file)) { + if (ol_check_fw_hash(qdf_dev->dev, fw_entry->data, + fw_entry_size, file)) { BMI_ERR("Hash Check failed for file:%s", filename); status = -EINVAL; goto end; @@ -443,8 +444,8 @@ release_fw: } static int -ol_transfer_bin_file(struct ol_context *ol_ctx, ATH_BIN_FILE file, - uint32_t address, bool compressed) +ol_transfer_bin_file(struct ol_context *ol_ctx, enum ATH_BIN_FILE file, + uint32_t address, bool compressed) { int ret; qdf_device_t qdf_dev = ol_ctx->qdf_dev; @@ -583,7 +584,6 @@ out_fail: PLD_REASON_DEFAULT); else pld_device_crashed(qdf_dev->dev); - return; } void fw_indication_work_handler(void *data) @@ -656,8 +656,6 @@ void ol_target_failure(void *instance, QDF_STATUS status) qdf_sched_work(0, &ol_ctx->ramdump_work); else pr_debug("%s: athdiag read for target reg\n", __func__); - - return; } #ifdef CONFIG_DISABLE_CDC_MAX_PERF_WAR @@ -800,7 +798,7 @@ QDF_STATUS ol_configure_target(struct ol_context *ol_ctx) hi_option_flag2)), (uint8_t *)¶m, 4, ol_ctx) != QDF_STATUS_SUCCESS) { - BMI_ERR("bmi_read_memory for setting external SWREG failed"); + BMI_ERR("BMI READ failed for external SWREG"); return QDF_STATUS_E_FAILURE; } @@ -811,7 +809,7 @@ QDF_STATUS ol_configure_target(struct ol_context *ol_ctx) hi_option_flag2)), (uint8_t *)¶m, 4, ol_ctx) != QDF_STATUS_SUCCESS) { - BMI_ERR("BMI WRITE for setting external SWREG fail"); + BMI_ERR("BMI WRITE failed for external SWREG"); return QDF_STATUS_E_FAILURE; } } @@ -1274,7 +1272,7 @@ QDF_STATUS ol_download_firmware(struct ol_context *ol_ctx) /* Flash is either not available or invalid */ if (ol_transfer_bin_file(ol_ctx, ATH_BOARD_DATA_FILE, address, false) != EOK) { - return -1; + return QDF_STATUS_E_FAILURE; } /* Record the fact that Board Data is initialized */ @@ -1313,14 +1311,14 @@ QDF_STATUS ol_download_firmware(struct ol_context *ol_ctx) address = BMI_SEGMENTED_WRITE_ADDR; if (ol_transfer_bin_file(ol_ctx, ATH_FIRMWARE_FILE, address, true) != EOK) { - return -1; + return QDF_STATUS_E_FAILURE; } /* Apply the patches */ if (ol_check_dataset_patch(scn, &address)) { if ((ol_transfer_bin_file(ol_ctx, ATH_PATCH_FILE, address, - false)) != EOK) { - return -1; + false)) != EOK) { + return QDF_STATUS_E_FAILURE; } bmi_write_memory(hif_hia_item_address(target_type, offsetof(struct host_interest_s, hi_dset_list_head)), @@ -1415,6 +1413,7 @@ static int ol_diag_read(struct hif_opaque_softc *scn, uint8_t *buffer, size_t amount_read = 0; size_t readSize = PCIE_READ_LIMIT; size_t remainder = 0; + if (count > PCIE_READ_LIMIT) { while ((amount_read < count) && (0 == result)) { result = hif_diag_read_mem(scn, pos, @@ -1500,9 +1499,8 @@ static int ol_diag_read_reg_loc(struct hif_opaque_softc *scn, uint8_t *buffer, dump_len = curr_sec->end_addr - curr_sec->start_addr; if ((buffer_len - result) < dump_len) { - BMI_ERR("Not enough memory to dump the registers:" - " %d: 0x%08x-0x%08x", i, - curr_sec->start_addr, curr_sec->end_addr); + BMI_ERR("No buffer to dump regs:%d: 0x%08x-0x%08x", + i, curr_sec->start_addr, curr_sec->end_addr); goto out; } @@ -1523,10 +1521,9 @@ static int ol_diag_read_reg_loc(struct hif_opaque_softc *scn, uint8_t *buffer, + sizeof(*curr_sec)); fill_len = next_sec->start_addr - curr_sec->end_addr; if ((buffer_len - result) < fill_len) { - BMI_ERR("Not enough memory to fill registers:" - " %d: 0x%08x-0x%08x", i, - curr_sec->end_addr, - next_sec->start_addr); + BMI_ERR("No buf to fill regs:%d: 0x%08x-0x%08x", + i, curr_sec->end_addr, + next_sec->start_addr); goto out; } diff --git a/core/bmi/src/ol_fw_common.c b/core/bmi/src/ol_fw_common.c index 48e7fd0c1bf4..f79e450bef1f 100644 --- a/core/bmi/src/ol_fw_common.c +++ b/core/bmi/src/ol_fw_common.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2017 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -119,7 +119,8 @@ QDF_STATUS ol_sdio_extra_initialization(struct ol_context *ol_ctx) } /* note: we actually get the block size for mailbox 1, * for SDIO the block size on mailbox 0 is artificially - * set to 1 must be a power of 2 */ + * set to 1 must be a power of 2 + */ qdf_assert((blocksizes[1] & (blocksizes[1] - 1)) == 0); /* set the host interest area for the block size */ @@ -175,13 +176,13 @@ exit: } /** -* ol_extra_initialization() - OL extra initilization -* @ol_ctx: pointer to ol_context -* -* Bus specific initialization after firmware download -* -* Return: QDF_STATUS_SUCCESS on success and error QDF status on failure -*/ + * ol_extra_initialization() - OL extra initialization + * @ol_ctx: pointer to ol_context + * + * Bus specific initialization after firmware download + * + * Return: QDF_STATUS_SUCCESS on success and error QDF status on failure + */ QDF_STATUS ol_extra_initialization(struct ol_context *ol_ctx) { struct hif_opaque_softc *scn = ol_ctx->scn;