Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2838718imm; Sun, 29 Jul 2018 04:42:20 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfQdKPPWtGvXrhUJ+NOAFOoTY74v3O9rzPFx+XCzQiF+0Ygz2uCov3Z7ErlKVvtlEp4Iyt3 X-Received: by 2002:a62:9f85:: with SMTP id v5-v6mr13769598pfk.27.1532864540047; Sun, 29 Jul 2018 04:42:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532864540; cv=none; d=google.com; s=arc-20160816; b=qaecuDGegCylBxPmyitSS2e6St1SI72GdYzfALrgbA/x3xfF895hb1byuGM1juSEYp y3yKwASlmIrKUfyzTx2Dt2L/jifLdgO/3V6t9sa5XuewfB9/zb8Svh8NkBqarJzKpFW/ oS+ksfBymrW3jbrTDAD3EllUSDQ2OqWfl7Ef9lTs1mADaBStmURLM7k3sP15yylDJsru 8GRt/ZxXFZi6X0zZRoiMozuoKTda8TWvibq0ESVMmzPDPUbru2r2EUb7QKeu8w8mrVS9 brVlYWJMzezee7yjuUaClK3LQjkm0IWZxJiAnsXAYn9rveY7vhgQazoqFiXUksV3NV+W 0IDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=/zGWAdUrLWMAGHUtdiQhvL6RJgET92M5/TQg0/U+EuE=; b=n47eQDglWIkpoBgj2MlcSXB0X3adI++N3VusuV2Zv04daTpj/GTRMYjHrJtK/coHv9 a6bZU5IbZeWbj8FS1XRnOTZY0DWUz2rZb3mb4RpH/xvITYH2u6Zb4vshrwtDUxquVOG4 AtUkhFJUr5toDfLXI0niH/rbBqht6CTeTHL1CSh0RjkqCl5QRHzJka3SAy7H5DMLl7ps RfzrV5XhafRXuTORAiGWQshojdJmb/t39iBmF/SlVN80Mx3deTHQyKibyZlj4/EG0QmD k5FvFmQYJMGQTxubf7urliXCdZdEDLjcaZ6bsuLCU6WxPB3BMIVeUqVTY8O9vs8Nmgra Hoeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZiDz2o9f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y38-v6si7550734pgl.73.2018.07.29.04.42.06; Sun, 29 Jul 2018 04:42:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZiDz2o9f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726785AbeG2NLE (ORCPT + 99 others); Sun, 29 Jul 2018 09:11:04 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:32925 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726234AbeG2NLE (ORCPT ); Sun, 29 Jul 2018 09:11:04 -0400 Received: by mail-wr1-f66.google.com with SMTP id g6-v6so9674230wrp.0 for ; Sun, 29 Jul 2018 04:40:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=/zGWAdUrLWMAGHUtdiQhvL6RJgET92M5/TQg0/U+EuE=; b=ZiDz2o9fsfCqsA7qXJgnCM4tFlZ7R5RvDFKAJBh3dn+iEIIAcoMoOIkxpJBJ1hVEI+ F1F670H3KRcsOiYpdPt4ikvPh4i51M4Jbz2JzC6dUSed8ltPZk1in5kFU2esuuCj9/OS n+sQ0oaSYZkvuXF1RAZapAs0gXSfBFb+dj45NGeKtREgCBxlwxA03yZR+rYe0IaxBeHj 9QHCzhiF6h1Ej/8WybBk8LXYs/DwDE+4Fn4tWc5Q5wIvVj240N1YrjQnnLzPfKU5e7B1 TUUijfytfY00wy4olAbohRknzaU7sxGddcTQAUIEqtuhaogt8NFEOjJU8apfRMU1ss0O kfDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=/zGWAdUrLWMAGHUtdiQhvL6RJgET92M5/TQg0/U+EuE=; b=mRDbkdGVm0ybWibMuwu6lDnqQkJzV7DFot+jpVhAQX70RBfq9qEO0YPAGZ6t4K0xMa 3qKL3d3T0TikKi419ofkWMTZ8d65Hv/Rbymx+yBN+i4K3hBmGaTynwQA+LGokpr5j4x5 /fiBNt2yDEr7mPB04Pd8A2A8za5E4OIzqasMeiVHuX8LcPKRMqBKuv7ecVj+DAbddhOy 8+fRVY6c8S3jTRsX08p/c860U8WwdOy20pO+ZLt5C6eg1cAyPrhluqYhrMI9ajuuiZA6 7KiIRTc7cRSIZrSWhMZzAI38i1wA5QHfSYlSIiEnYK5u1IUHaiz3qWApxIDbg4mh7eRy dMTQ== X-Gm-Message-State: AOUpUlGAEV+r0mHyUkvUmKbEGnLzyALuRxbMKgsPTH5OC2oIlcJmnstR ptaXGk0PxIMpbeq5iXdcpW0= X-Received: by 2002:adf:db11:: with SMTP id s17-v6mr7594425wri.221.1532864452842; Sun, 29 Jul 2018 04:40:52 -0700 (PDT) Received: from we.local (ppp-2-87-92-87.home.otenet.gr. [2.87.92.87]) by smtp.gmail.com with ESMTPSA id z3-v6sm11742513wru.27.2018.07.29.04.40.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 29 Jul 2018 04:40:51 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by we.local (Postfix) with ESMTP id 76E476408D2; Sun, 29 Jul 2018 14:40:50 +0300 (EEST) X-Virus-Scanned: amavisd-new at local X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from we.local ([127.0.0.1]) by localhost (we.local [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0fSyIzIZ-Sil; Sun, 29 Jul 2018 14:40:50 +0300 (EEST) Received: by we.local (Postfix, from userid 1000) id 093B56408D3; Sun, 29 Jul 2018 14:40:50 +0300 (EEST) From: Georgios Tsotsos To: Greg Kroah-Hartman Cc: Georgios Tsotsos , Aaro Koskinen , James Hogan , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/2] Staging: octeon-usb: Changes macro CVMX_WAIT_FOR_FIELD32 to function call. Date: Sun, 29 Jul 2018 14:40:35 +0300 Message-Id: <0e52fbfefc34fe064201da9ad93e12e50e1e816c.1532864087.git.tsotsos@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: References: In-Reply-To: References: <20180727151527.GA2209@kroah.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replacing CVMX_WAIT_FOR_FIELD32 macro with equivalent function. Signed-off-by: Georgios Tsotsos --- drivers/staging/octeon-usb/octeon-hcd.c | 65 +++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index 4615133292b5..8a7bdf1a9fe6 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -377,29 +377,6 @@ struct octeon_hcd { struct cvmx_usb_tx_fifo nonperiodic; }; -/* This macro spins on a register waiting for it to reach a condition. */ -#define CVMX_WAIT_FOR_FIELD32(address, _union, cond, timeout_usec) \ - ({int result; \ - do { \ - u64 done = cvmx_get_cycle() + (u64)timeout_usec * \ - octeon_get_clock_rate() / 1000000; \ - union _union c; \ - \ - while (1) { \ - c.u32 = cvmx_usb_read_csr32(usb, address); \ - \ - if (cond) { \ - result = 0; \ - break; \ - } else if (cvmx_get_cycle() > done) { \ - result = -1; \ - break; \ - } else \ - __delay(100); \ - } \ - } while (0); \ - result; }) - /* * This macro logically sets a single field in a CSR. It does the sequence * read, modify, and write @@ -593,6 +570,42 @@ static inline int cvmx_usb_get_data_pid(struct cvmx_usb_pipe *pipe) return 0; /* Data0 */ } +/** + * Loop through register until txfflsh or rxfflsh become zero. + * + * @usb: USB block + * @address: 64bit address to read + * @timeout_usec: Timeout + * @fflsh_type: Indicates fflsh type, 0 for txfflsh, 1 for rxfflsh + * + */ +static int cvmx_wait_for_field32(struct octeon_hcd *usb, u64 address, + u64 timeout_usec, int fflsh_type) +{ + int result; + u64 done = cvmx_get_cycle() + timeout_usec * + (u64)octeon_get_clock_rate / 1000000; + + union cvmx_usbcx_grstctl c; + + while (1) { + c.u32 = cvmx_usb_read_csr32(usb, address); + if (fflsh_type == 0 && c.s.txfflsh == 0) { + result = 0; + break; + } else if (fflsh_type == 1 && c.s.rxfflsh == 0) { + result = 0; + break; + } else if (cvmx_get_cycle() > done) { + result = -1; + break; + } + + __delay(100); + } + return result; +} + static void cvmx_fifo_setup(struct octeon_hcd *usb) { union cvmx_usbcx_ghwcfg3 usbcx_ghwcfg3; @@ -635,11 +648,9 @@ static void cvmx_fifo_setup(struct octeon_hcd *usb) /* Flush all FIFOs */ USB_SET_FIELD32(address, cvmx_usbcx_grstctl, txfnum, 0x10); USB_SET_FIELD32(address, cvmx_usbcx_grstctl, txfflsh, 1); - CVMX_WAIT_FOR_FIELD32(address, cvmx_usbcx_grstctl, - c.s.txfflsh == 0, 100); + cvmx_wait_for_field32(usb, address, 0, 100); USB_SET_FIELD32(address, cvmx_usbcx_grstctl, rxfflsh, 1); - CVMX_WAIT_FOR_FIELD32(address, cvmx_usbcx_grstctl, - c.s.rxfflsh == 0, 100); + cvmx_wait_for_field32(usb, address, 1, 100); } /** -- 2.16.4