From patchwork Mon Mar 23 12:38:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 6072201 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8C8DD9F39E for ; Mon, 23 Mar 2015 12:41:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A01762024F for ; Mon, 23 Mar 2015 12:41:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B4AC62025A for ; Mon, 23 Mar 2015 12:41:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752362AbbCWMlK (ORCPT ); Mon, 23 Mar 2015 08:41:10 -0400 Received: from mail-la0-f53.google.com ([209.85.215.53]:36703 "EHLO mail-la0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752300AbbCWMlH (ORCPT ); Mon, 23 Mar 2015 08:41:07 -0400 Received: by labe2 with SMTP id e2so57548790lab.3 for ; Mon, 23 Mar 2015 05:41:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ufVX4MKcS0wR4kcElYmUcD0hnFqMgKCvKxM4XQfSryI=; b=fnymxJtlOttnXW0gTLEpUQi2jRZ1s7ZA89XJowMFDbGnkGSKUoJvROyFOwrSBu9BoY 8uvcLUBzZHci3EdNF1DZyfuIuXtdedFwyAM0JFGoDJb/MepI8K/eNwKLJRc+Qks2hJ64 4mSuSkvfGl/7BkoKRSQilv/tOyFYUzewCZDR4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ufVX4MKcS0wR4kcElYmUcD0hnFqMgKCvKxM4XQfSryI=; b=Sk0IDlXTq+49hC8J6glw28+ux7Kdb5aX8VmAzFBxn0/b85A++eLtw/G1orKkEVCimH v8Hp+rhjtX+PwtZf0mNr2aVwf2nlzNeVqj722Npj2QLKvzCK51xXX/aWlKdOEihednyX C0/0dQXRvLpXLFRowMvDV8MYznSF3zhzH4+DRSjwx7PkMWft7jxGh9Yv7ptwE1MI9xEh dfwJDLjKjWr4eqhRFBKDCfqt9U9w2z4hjPfbFbHoIfogEyptlVHbMTO1txnxPePqkvUr g0gbuKEWzgFWmq+uiHkJKC6hK0uQPLPUSh2CsEuL/Nbac1NVQvmRUmh2VJNB+hjcoiAR HshA== X-Gm-Message-State: ALoCoQlkMEoZTl9Hlak3UQDsOyEczBIO7hLCm6Tnlarzgky4NiMgv7OB6gFqLPItNHWhRDYbc2aYPSNRyFtcoW+FFFIyQnWiwuyy0AG+Op7qOxSOxKt5Ofy25KLWhYDtQmLydKkQ2w3o X-Received: by 10.112.16.73 with SMTP id e9mr21113023lbd.92.1427114466377; Mon, 23 Mar 2015 05:41:06 -0700 (PDT) Received: from bob.homerouter.cpe (apn-77-113-71-242.dynamic.gprs.plus.pl. [77.113.71.242]) by mx.google.com with ESMTPSA id h10sm153441laa.41.2015.03.23.05.41.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Mar 2015 05:41:05 -0700 (PDT) From: Michal Kazior To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Michal Kazior Subject: [PATCH 1/2] ath10k: share board file loading code across FW APIs Date: Mon, 23 Mar 2015 12:38:20 +0000 Message-Id: <1427114301-18886-2-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1427114301-18886-1-git-send-email-michal.kazior@tieto.com> References: <1427114301-18886-1-git-send-email-michal.kazior@tieto.com> X-DomainID: tieto.com Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There's no need to implement the same thing twice. Reduce code duplication. Signed-off-by: Michal Kazior --- drivers/net/wireless/ath/ath10k/core.c | 68 +++++++++++++++------------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index c0e454b..1785e0e 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -482,6 +482,30 @@ static int ath10k_fetch_cal_file(struct ath10k *ar) return 0; } +static int ath10k_core_fetch_board_file(struct ath10k *ar) +{ + int ret; + + if (!ar->hw_params.fw.board) { + ath10k_err(ar, "failed to find board file fw entry\n"); + return -EINVAL; + } + + ar->board = ath10k_fetch_fw_file(ar, + ar->hw_params.fw.dir, + ar->hw_params.fw.board); + if (IS_ERR(ar->board)) { + ret = PTR_ERR(ar->board); + ath10k_err(ar, "failed to fetch board data: %d\n", ret); + return ret; + } + + ar->board_data = ar->board->data; + ar->board_len = ar->board->size; + + return 0; +} + static int ath10k_core_fetch_firmware_api_1(struct ath10k *ar) { int ret = 0; @@ -491,23 +515,6 @@ static int ath10k_core_fetch_firmware_api_1(struct ath10k *ar) return -EINVAL; } - if (ar->hw_params.fw.board == NULL) { - ath10k_err(ar, "board data file not defined"); - return -EINVAL; - } - - ar->board = ath10k_fetch_fw_file(ar, - ar->hw_params.fw.dir, - ar->hw_params.fw.board); - if (IS_ERR(ar->board)) { - ret = PTR_ERR(ar->board); - ath10k_err(ar, "could not fetch board data (%d)\n", ret); - goto err; - } - - ar->board_data = ar->board->data; - ar->board_len = ar->board->size; - ar->firmware = ath10k_fetch_fw_file(ar, ar->hw_params.fw.dir, ar->hw_params.fw.fw); @@ -695,27 +702,6 @@ static int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name) goto err; } - /* now fetch the board file */ - if (ar->hw_params.fw.board == NULL) { - ath10k_err(ar, "board data file not defined"); - ret = -EINVAL; - goto err; - } - - ar->board = ath10k_fetch_fw_file(ar, - ar->hw_params.fw.dir, - ar->hw_params.fw.board); - if (IS_ERR(ar->board)) { - ret = PTR_ERR(ar->board); - ath10k_err(ar, "could not fetch board data '%s/%s' (%d)\n", - ar->hw_params.fw.dir, ar->hw_params.fw.board, - ret); - goto err; - } - - ar->board_data = ar->board->data; - ar->board_len = ar->board->size; - return 0; err: @@ -730,6 +716,12 @@ static int ath10k_core_fetch_firmware_files(struct ath10k *ar) /* calibration file is optional, don't check for any errors */ ath10k_fetch_cal_file(ar); + ret = ath10k_core_fetch_board_file(ar); + if (ret) { + ath10k_err(ar, "failed to fetch board file: %d\n", ret); + return ret; + } + ar->fw_api = 4; ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api);