From patchwork Mon Jul 27 20:51:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 500775 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 102D41402CD for ; Tue, 28 Jul 2015 07:08:59 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DFAED4B95E; Mon, 27 Jul 2015 23:04:32 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Vp1e3z2btx9R; Mon, 27 Jul 2015 23:04:32 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B17AE4B946; Mon, 27 Jul 2015 23:01:58 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0A5E54B7E5 for ; Mon, 27 Jul 2015 22:54:11 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Jckv4KEtAANc for ; Mon, 27 Jul 2015 22:54:10 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by theia.denx.de (Postfix) with ESMTPS id 524D44B794 for ; Mon, 27 Jul 2015 22:53:50 +0200 (CEST) Received: from mail.nefkom.net (unknown [192.168.8.184]) by mail-out.m-online.net (Postfix) with ESMTP id 3mgCzL0zkxz3hkP6; Mon, 27 Jul 2015 22:53:50 +0200 (CEST) X-Auth-Info: BIguIGHfl0lSs/vXJa4G/LR6QXemkpXqQXyy6aPKm7k= Received: from chi.lan (host-82-135-33-74.customer.m-online.net [82.135.33.74]) by smtp-auth.mnet-online.de (Postfix) with ESMTPA id 3mgCzK6CPrzvdWS; Mon, 27 Jul 2015 22:53:49 +0200 (CEST) From: Marek Vasut To: u-boot@lists.denx.de Date: Mon, 27 Jul 2015 22:51:33 +0200 Message-Id: <1438030335-10631-131-git-send-email-marex@denx.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1438030335-10631-1-git-send-email-marex@denx.de> References: <1438030335-10631-1-git-send-email-marex@denx.de> Cc: Marek Vasut , trini@konsulko.com Subject: [U-Boot] [PATCH 130/172] ddr: altera: Clean up find_vfifo_read() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Fix data types, constify where applicable, fix comments and debug strings. In case enough failing reads are detected, just return right away instead of breaking from the loop. This lets us make the error handling at the end much simpler. Signed-off-by: Marek Vasut --- drivers/ddr/altera/sequencer.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/drivers/ddr/altera/sequencer.c b/drivers/ddr/altera/sequencer.c index 50a5b8e..fbbf874 100644 --- a/drivers/ddr/altera/sequencer.c +++ b/drivers/ddr/altera/sequencer.c @@ -1311,36 +1311,35 @@ static void rw_mgr_decr_vfifo(const u32 grp) rw_mgr_incr_vfifo(grp); } -static int find_vfifo_read(uint32_t grp, uint32_t *bit_chk) +/** + * find_vfifo_failing_read() - Push VFIFO to get a failing read + * @grp: Read/Write group + * + * Push VFIFO until a failing read happens. + */ +static int find_vfifo_failing_read(const u32 grp) { - uint32_t v; - uint32_t fail_cnt = 0; - uint32_t test_status; + u32 v, ret, bit_chk, fail_cnt = 0; for (v = 0; v < VFIFO_SIZE; v++) { - debug_cond(DLEVEL == 2, "%s:%d find_dqs_en_phase: vfifo %u\n", + debug_cond(DLEVEL == 2, "%s:%d: vfifo %u\n", __func__, __LINE__, v); - test_status = rw_mgr_mem_calibrate_read_test_all_ranks - (grp, 1, PASS_ONE_BIT, bit_chk, 0); - if (!test_status) { + ret = rw_mgr_mem_calibrate_read_test_all_ranks(grp, 1, + PASS_ONE_BIT, &bit_chk, 0); + if (!ret) { fail_cnt++; if (fail_cnt == 2) - break; + return v; } - /* fiddle with FIFO */ + /* Fiddle with FIFO. */ rw_mgr_incr_vfifo(grp); } - if (v >= VFIFO_SIZE) { - /* no failing read found!! Something must have gone wrong */ - debug_cond(DLEVEL == 2, "%s:%d find_dqs_en_phase: vfifo failed\n", - __func__, __LINE__); - return 0; - } else { - return v; - } + /* No failing read found! Something must have gone wrong. */ + debug_cond(DLEVEL == 2, "%s:%d: vfifo failed\n", __func__, __LINE__); + return 0; } /** @@ -1588,7 +1587,7 @@ static uint32_t rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase(uint32_t grp) /* ********************************************************* */ /* * Step 1 : First push vfifo until we get a failing read * */ - find_vfifo_read(grp, &bit_chk); + find_vfifo_failing_read(grp); /* ******************************************************** */ /* * step 2: find first working phase, increment in ptaps * */