From patchwork Wed Jan 13 14:01:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 8025761 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4FB6ABEEE5 for ; Wed, 13 Jan 2016 14:00:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C8DA20503 for ; Wed, 13 Jan 2016 14:00:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9DC392051A for ; Wed, 13 Jan 2016 14:00:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760926AbcAMOAI (ORCPT ); Wed, 13 Jan 2016 09:00:08 -0500 Received: from mail-lf0-f51.google.com ([209.85.215.51]:36046 "EHLO mail-lf0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759427AbcAMOAD (ORCPT ); Wed, 13 Jan 2016 09:00:03 -0500 Received: by mail-lf0-f51.google.com with SMTP id h129so60645557lfh.3 for ; Wed, 13 Jan 2016 06:00:02 -0800 (PST) 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=Nos4SPiZduPGwBynbiNYbRKUtbqU5wjVFb/puogVyKA=; b=KLVryuuYPtXJsigPkVTpJay7ZIcbXwJ/LKb6v8rCc3pFG+YiXlgYwYScaPDM0IpmJ/ JDZrn9K11jKhtpjVuB66graeAa6ljPYg0ELFFL3/HPyDeSQUsUnls10x7DLSyPiBtITY fVjZTHiUVvGP7IaDesI3ThSUVKMkGnqbOfgd8= 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=Nos4SPiZduPGwBynbiNYbRKUtbqU5wjVFb/puogVyKA=; b=GIRR6w9Fbok6doa1VYuCwRZJoH4gLgsKyrYU4FIvMX/X9p8j7QzkYvS5COtXAyDsEt 3acYitqjMs03dFj5E9Q6vvgvldV5OlPnWyZsG4MQ1Qb88S7eiBH5FkTcwrHV++IhDmzr xOus5J6HM2EjWYwzu148s9Epn0ZdYQza5p7IIifFRcRwYREURlFxntXKbaOZ5AlTwPaX nzUeym9YRZpas4IzHFy6KntoVWb9CmykpxS1gqsRoKmzNwp7N8UpnbopDM1nt8FPLVz5 OqUMD06T37ttWah0YVFuxS4aHb6RW5eTycTjuhvP0eSi1dvj5GYdC2SIWws/SI32+FNf cePg== X-Gm-Message-State: ALoCoQk8SHyHAF1IT4wUctxrHAFatZ/f2QzFf+sW3b13KBEsZXPYOaby7QqGOQv4Dll/f56tEC+MFpArIfkHKd6gar+KXX+8FI1JUQU3nvRKCtfquXYs4jl5crvA8HEc+HLt94pSoZRbE1flCOEbi0rvJ7vy6szuiA== X-Received: by 10.25.143.3 with SMTP id r3mr6355272lfd.59.1452693602081; Wed, 13 Jan 2016 06:00:02 -0800 (PST) Received: from localhost.localdomain ([91.198.246.10]) by smtp.gmail.com with ESMTPSA id jx8sm195606lbc.29.2016.01.13.06.00.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Jan 2016 06:00:01 -0800 (PST) From: Michal Kazior To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Michal Kazior Subject: [PATCH 4/5] ath10k: clean up cont frag desc init code Date: Wed, 13 Jan 2016 15:01:07 +0100 Message-Id: <1452693668-30030-5-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1452693668-30030-1-git-send-email-michal.kazior@tieto.com> References: <1452693668-30030-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,RP_MATCHES_RCVD,T_DKIM_INVALID,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 This makes the code easier to extend and re-use. While at it fix _warn to _err. Other than that there are no functional changes. Signed-off-by: Michal Kazior --- drivers/net/wireless/ath/ath10k/htt_tx.c | 58 ++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c b/drivers/net/wireless/ath/ath10k/htt_tx.c index b3adadb5f824..41a9811820e8 100644 --- a/drivers/net/wireless/ath/ath10k/htt_tx.c +++ b/drivers/net/wireless/ath/ath10k/htt_tx.c @@ -97,6 +97,41 @@ void ath10k_htt_tx_free_msdu_id(struct ath10k_htt *htt, u16 msdu_id) idr_remove(&htt->pending_tx, msdu_id); } +static void ath10k_htt_tx_free_cont_frag_desc(struct ath10k_htt *htt) +{ + size_t size; + + if (!htt->frag_desc.vaddr) + return; + + size = htt->max_num_pending_tx * sizeof(struct htt_msdu_ext_desc); + + dma_free_coherent(htt->ar->dev, + size, + htt->frag_desc.vaddr, + htt->frag_desc.paddr); +} + +static int ath10k_htt_tx_alloc_cont_frag_desc(struct ath10k_htt *htt) +{ + struct ath10k *ar = htt->ar; + size_t size; + + if (!ar->hw_params.continuous_frag_desc) + return 0; + + size = htt->max_num_pending_tx * sizeof(struct htt_msdu_ext_desc); + htt->frag_desc.vaddr = dma_alloc_coherent(ar->dev, size, + &htt->frag_desc.paddr, + GFP_DMA); + if (!htt->frag_desc.vaddr) { + ath10k_err(ar, "failed to alloc fragment desc memory\n"); + return -ENOMEM; + } + + return 0; +} + int ath10k_htt_tx_alloc(struct ath10k_htt *htt) { struct ath10k *ar = htt->ar; @@ -118,20 +153,12 @@ int ath10k_htt_tx_alloc(struct ath10k_htt *htt) goto free_idr_pending_tx; } - if (!ar->hw_params.continuous_frag_desc) - goto skip_frag_desc_alloc; - - size = htt->max_num_pending_tx * sizeof(struct htt_msdu_ext_desc); - htt->frag_desc.vaddr = dma_alloc_coherent(ar->dev, size, - &htt->frag_desc.paddr, - GFP_KERNEL); - if (!htt->frag_desc.vaddr) { - ath10k_warn(ar, "failed to alloc fragment desc memory\n"); - ret = -ENOMEM; + ret = ath10k_htt_tx_alloc_cont_frag_desc(htt); + if (ret) { + ath10k_err(ar, "failed to alloc cont frag desc: %d\n", ret); goto free_txbuf; } -skip_frag_desc_alloc: return 0; free_txbuf: @@ -139,8 +166,10 @@ free_txbuf: sizeof(struct ath10k_htt_txbuf); dma_free_coherent(htt->ar->dev, size, htt->txbuf.vaddr, htt->txbuf.paddr); + free_idr_pending_tx: idr_destroy(&htt->pending_tx); + return ret; } @@ -174,12 +203,7 @@ void ath10k_htt_tx_free(struct ath10k_htt *htt) htt->txbuf.paddr); } - if (htt->frag_desc.vaddr) { - size = htt->max_num_pending_tx * - sizeof(struct htt_msdu_ext_desc); - dma_free_coherent(htt->ar->dev, size, htt->frag_desc.vaddr, - htt->frag_desc.paddr); - } + ath10k_htt_tx_free_cont_frag_desc(htt); } void ath10k_htt_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb)