From patchwork Mon Mar 26 08:58:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalle Valo X-Patchwork-Id: 10307431 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E5B7160386 for ; Mon, 26 Mar 2018 08:58:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D47E6295CF for ; Mon, 26 Mar 2018 08:58:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C916B295D1; Mon, 26 Mar 2018 08:58:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E5E2295D0 for ; Mon, 26 Mar 2018 08:58:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751897AbeCZI6p (ORCPT ); Mon, 26 Mar 2018 04:58:45 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44324 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750955AbeCZI6p (ORCPT ); Mon, 26 Mar 2018 04:58:45 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 8992E60590; Mon, 26 Mar 2018 08:58:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522054724; bh=OzDXmubPHIz6KvqxgLyTv9XvWqOWVB4W/3ApJh5sDrA=; h=From:To:Cc:Subject:Date:From; b=WVfn1PRAHwA2iRtrC4vsqo6i6r0Bvkj0TdBbntShgCliT5CFuu5nRaexwQqBZ8NVI I/GG2UdDPeka6+1BHVP+b77bkNM3XUAvO5cU5M1pieW9V37ragGSNHQnP/IgzEOmBT 52CZDJTXAiNIDS9KRpFMBFK65dkeUkV2D9Fg7sPI= Received: from potku.adurom.net (88-114-240-52.elisa-laajakaista.fi [88.114.240.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: kvalo@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 6D41360251; Mon, 26 Mar 2018 08:58:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522054724; bh=OzDXmubPHIz6KvqxgLyTv9XvWqOWVB4W/3ApJh5sDrA=; h=From:To:Cc:Subject:Date:From; b=WVfn1PRAHwA2iRtrC4vsqo6i6r0Bvkj0TdBbntShgCliT5CFuu5nRaexwQqBZ8NVI I/GG2UdDPeka6+1BHVP+b77bkNM3XUAvO5cU5M1pieW9V37ragGSNHQnP/IgzEOmBT 52CZDJTXAiNIDS9KRpFMBFK65dkeUkV2D9Fg7sPI= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 6D41360251 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=kvalo@codeaurora.org From: Kalle Valo To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org Subject: [PATCH 1/2] ath10k: refactor ath10k_pci_dump_memory() in preparation for QCA9984 support Date: Mon, 26 Mar 2018 11:58:33 +0300 Message-Id: <1522054714-31492-1-git-send-email-kvalo@codeaurora.org> X-Mailer: git-send-email 2.7.4 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As QCA9984 needs two region types refactor the code to make it easier add the new types. No functional changes. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath10k/pci.c | 55 +++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index 808f3d67ba90..977b7dade44e 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c @@ -1584,6 +1584,36 @@ static int ath10k_pci_set_ram_config(struct ath10k *ar, u32 config) return 0; } +/* if an error happened returns < 0, otherwise the length */ +static int ath10k_pci_dump_memory_generic(struct ath10k *ar, + const struct ath10k_mem_region *current_region, + u8 *buf) +{ + int ret; + + if (current_region->section_table.size > 0) + /* Copy each section individually. */ + return ath10k_pci_dump_memory_section(ar, + current_region, + buf, + current_region->len); + + /* No individiual memory sections defined so we can + * copy the entire memory region. + */ + ret = ath10k_pci_diag_read_mem(ar, + current_region->start, + buf, + current_region->len); + if (ret) { + ath10k_warn(ar, "failed to copy ramdump region %s: %d\n", + current_region->name, ret); + return ret; + } + + return current_region->len; +} + static void ath10k_pci_dump_memory(struct ath10k *ar, struct ath10k_fw_crash_data *crash_data) { @@ -1642,27 +1672,14 @@ static void ath10k_pci_dump_memory(struct ath10k *ar, buf += sizeof(*hdr); buf_len -= sizeof(*hdr); - if (current_region->section_table.size > 0) { - /* Copy each section individually. */ - count = ath10k_pci_dump_memory_section(ar, - current_region, - buf, - current_region->len); - } else { - /* No individiual memory sections defined so we can - * copy the entire memory region. - */ - ret = ath10k_pci_diag_read_mem(ar, - current_region->start, - buf, - current_region->len); - if (ret) { - ath10k_warn(ar, "failed to copy ramdump region %s: %d\n", - current_region->name, ret); + switch (current_region->type) { + default: + ret = ath10k_pci_dump_memory_generic(ar, current_region, buf); + if (ret < 0) break; - } - count = current_region->len; + count = ret; + break; } hdr->region_type = cpu_to_le32(current_region->type);