From patchwork Thu Sep 29 02:12:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 9355587 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 B161C6086A for ; Thu, 29 Sep 2016 02:18:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2B35297BC for ; Thu, 29 Sep 2016 02:18:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96965297C1; Thu, 29 Sep 2016 02:18:30 +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=unavailable 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 40C1F297BC for ; Thu, 29 Sep 2016 02:18:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753882AbcI2CRb (ORCPT ); Wed, 28 Sep 2016 22:17:31 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:60583 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755096AbcI2CRM (ORCPT ); Wed, 28 Sep 2016 22:17:12 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id E711F61716; Thu, 29 Sep 2016 02:17:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1475115430; bh=3246sV32mHdm3KPkVmvog05FEjOUQM/16+3OiDSPi6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BsQTDQJH34xsVkfmW3aOaH2jHIBN82fPD7oYpx8cPlApd43hooHUfoSNDQ45+vS4l nebSEKwEN1/IxGzUpHlC//vsMBRtgTZsuLHiYiflyjaGUyQIhERAmHECeW4iYwkN2f MboE2UjGYrooy6pdKzHOZ5+Jy5wsFT50+31Er/8A= 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 38708616FB; Thu, 29 Sep 2016 02:17:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1475115430; bh=3246sV32mHdm3KPkVmvog05FEjOUQM/16+3OiDSPi6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BsQTDQJH34xsVkfmW3aOaH2jHIBN82fPD7oYpx8cPlApd43hooHUfoSNDQ45+vS4l nebSEKwEN1/IxGzUpHlC//vsMBRtgTZsuLHiYiflyjaGUyQIhERAmHECeW4iYwkN2f MboE2UjGYrooy6pdKzHOZ5+Jy5wsFT50+31Er/8A= DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org 38708616FB 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 V4 06/10] dmaengine: qcom_hidma: make error and success path common Date: Wed, 28 Sep 2016 22:12:43 -0400 Message-Id: <1475115167-5898-7-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1475115167-5898-1-git-send-email-okaya@codeaurora.org> References: <1475115167-5898-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)