From patchwork Thu Sep 15 17:22:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 9334385 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 DF56A608A0 for ; Thu, 15 Sep 2016 17:24:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D09C629AA7 for ; Thu, 15 Sep 2016 17:24:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C563329AA9; Thu, 15 Sep 2016 17:24:57 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 41CD829AAF for ; Thu, 15 Sep 2016 17:24:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753295AbcIORYx (ORCPT ); Thu, 15 Sep 2016 13:24:53 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:49747 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753362AbcIORXZ (ORCPT ); Thu, 15 Sep 2016 13:23:25 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A90DC61AB3; Thu, 15 Sep 2016 17:23:23 +0000 (UTC) Received: from drakthul.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B4C3261230; Thu, 15 Sep 2016 17:23:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org B4C3261230 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=pass smtp.mailfrom=okaya@codeaurora.org From: Sinan Kaya To: dmaengine@vger.kernel.org, timur@codeaurora.org, devicetree@vger.kernel.org, cov@codeaurora.org, vinod.koul@intel.com, jcm@redhat.com Cc: agross@codeaurora.org, arnd@arndb.de, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sinan Kaya , Dan Williams , linux-kernel@vger.kernel.org Subject: [PATCH V3 06/10] dmaengine: qcom_hidma: make error and success path common Date: Thu, 15 Sep 2016 13:22:42 -0400 Message-Id: <1473960166-30155-7-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1473960166-30155-1-git-send-email-okaya@codeaurora.org> References: <1473960166-30155-1-git-send-email-okaya@codeaurora.org> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Remove code duplication by feeding the error code from outside into successful data transfer handler. Signed-off-by: Sinan Kaya --- drivers/dma/qcom/hidma_ll.c | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/drivers/dma/qcom/hidma_ll.c b/drivers/dma/qcom/hidma_ll.c index 29fef4f..c911ca2 100644 --- a/drivers/dma/qcom/hidma_ll.c +++ b/drivers/dma/qcom/hidma_ll.c @@ -241,11 +241,11 @@ static int hidma_post_completed(struct hidma_lldev *lldev, int tre_iterator, * Return a positive number if there are pending TREs or EVREs. * Return 0 if there is nothing to consume or no pending TREs/EVREs found. */ -static int hidma_handle_tre_completion(struct hidma_lldev *lldev) +static int hidma_handle_tre_completion(struct hidma_lldev *lldev, u8 err_info, + u8 err_code) { u32 evre_ring_size = lldev->evre_ring_size; u32 tre_ring_size = lldev->tre_ring_size; - u32 err_info, err_code, evre_write_off; u32 tre_iterator, evre_iterator; u32 num_completed = 0; @@ -268,10 +268,13 @@ static int hidma_handle_tre_completion(struct hidma_lldev *lldev) u32 cfg; cfg = current_evre[HIDMA_EVRE_CFG_IDX]; - err_info = cfg >> HIDMA_EVRE_ERRINFO_BIT_POS; - err_info &= HIDMA_EVRE_ERRINFO_MASK; - err_code = - (cfg >> HIDMA_EVRE_CODE_BIT_POS) & HIDMA_EVRE_CODE_MASK; + if (!err_info) { + err_info = cfg >> HIDMA_EVRE_ERRINFO_BIT_POS; + err_info &= HIDMA_EVRE_ERRINFO_MASK; + } + if (!err_code) + err_code = (cfg >> HIDMA_EVRE_CODE_BIT_POS) & + HIDMA_EVRE_CODE_MASK; if (hidma_post_completed(lldev, tre_iterator, err_info, err_code)) @@ -314,27 +317,10 @@ static int hidma_handle_tre_completion(struct hidma_lldev *lldev) void hidma_cleanup_pending_tre(struct hidma_lldev *lldev, u8 err_info, u8 err_code) { - u32 tre_iterator; - u32 tre_ring_size = lldev->tre_ring_size; - int num_completed = 0; - u32 tre_read_off; - - tre_iterator = lldev->tre_processed_off; while (atomic_read(&lldev->pending_tre_count)) { - if (hidma_post_completed(lldev, tre_iterator, err_info, - err_code)) + if (hidma_handle_tre_completion(lldev, err_info, err_code)) break; - HIDMA_INCREMENT_ITERATOR(tre_iterator, HIDMA_TRE_SIZE, - tre_ring_size); - num_completed++; } - tre_read_off = (lldev->tre_processed_off + - HIDMA_TRE_SIZE * num_completed); - - tre_read_off = tre_read_off % tre_ring_size; - - /* record the last processed tre offset */ - lldev->tre_processed_off = tre_read_off; } static int hidma_ll_reset(struct hidma_lldev *lldev)