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: 10307437 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 66DAC60353 for ; Mon, 26 Mar 2018 08:59:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5611E295CF for ; Mon, 26 Mar 2018 08:59:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4AAFD295D1; Mon, 26 Mar 2018 08:59:09 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 072DE295CF for ; Mon, 26 Mar 2018 08:59:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=oV0G+62hqDQbKIc/9gJtOXGJRiR5d80jzvo51Og9vwc=; b=jYj iQ0zECp9rLO6ksDtGVuuFr17LtthDHay5vmnbHrX+PZo8ugERvE+CecY7Qwfo66lt2Q5VPZ0DnvQ/ 2d8P1cfhpA9zqp06ABt0ajhU6LK28fchZpHl9p61DI30IX2s/5x64qvgU4RnqWzk1krQr6zy4oVCz fhBwEl2nEUCVpegpfk65J/tw7DzJ05tVoBWPQw32ilA6kI0AmIbVojkI+3NXnHEG0Hh7K3oAebdqY zeC8wDy1KGz3cOvR+xzN8bGyjhPLdvCy28m0as2Sr7AiNqQ2ps0MySccxSaATO0Tjp2iNry4zHOz9 udneMB/ZnUc9MavLlWZCuSixKfB3pvg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0Nxy-0000a7-D1; Mon, 26 Mar 2018 08:58:58 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0Nxv-0000YO-CO for ath10k@lists.infradead.org; Mon, 26 Mar 2018 08:58:56 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 9A59560558; 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180326_015855_460408_8EFB5811 X-CRM114-Status: GOOD ( 12.83 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-wireless@vger.kernel.org MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.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);