From patchwork Mon Jul 18 17:20:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 1657585 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=fpDA+3JU; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=YoVw+zAy; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Lmpdc6QsDz9sFs for ; Tue, 19 Jul 2022 03:20:52 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=K4f3Md+5X7c26Q2cwDsoGPKdtMLVhCH78jv/ZGnE8/M=; b=fpDA+3JUpbJIYf 5yP8QIBuh5rp26CI82RqVmx3LMbGCdEeoksEg98CPrN8IBeiwjftkN/lKOPjs+x9tAj1Aj1HHJGlx bqY3CQx91m7xu35X1mAnDQ0cR8qtTf9Oya78kbfawMsbJQN2eGud0eSl5JM2pzHD/Ow5TfOkr4uaF UfdJ2K+Lg7YRdMM34OmlVHw3f1g3V/RYY1+xvrSZrYKgDIUxy9aNSpzBQ8rFQxNClzQv8IEdqo8Oe yXnyWZ9kJ9qUEd/lH4xPpj6WwZJ52YCVO89zjNuxxezL94EnvJ/sVtss7hjCjo2j0EB+QSLFNFWiS oWhcjAztinrFRFHqCF3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oDUQC-00H7BS-Cw; Mon, 18 Jul 2022 17:20:40 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oDUQ9-00H76e-EU for opensbi@lists.infradead.org; Mon, 18 Jul 2022 17:20:38 +0000 Received: by mail-ej1-x62f.google.com with SMTP id ss3so22471867ejc.11 for ; Mon, 18 Jul 2022 10:20:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LHfH+UM0coRC140SwvweRAwY033gzgNgbuSMYyH3gXw=; b=YoVw+zAyVBJfSVh1VugTtrPOmmZla2o2mOw9sESPsSw8jd3xRNemUDWEf3fXN3j6TX 0TBkts141FQhnVh2Ssn6aG36YgCbKigFnc7oNhyBtLPxoO1LEUqHIrxxYzZeT2IvatPN d2fUEaUpIBALDzj8uL2RRiIBZnf6NYOUkYvMfbo9yUaPi+51N0uwOIkks3YPC9edcTZ7 eUapAxZhAYvlU1JWmz6PFvIXrS2SDqysSW8Tq9/7Uu0GYaSj3GwuEtwH2q2TFOO12DSw XApFV0U6Ri0EDw6D3ggKzYdEVPE/hWJLZ22FwDnl6sE1WGDGkHARhch3SbXsWqfOtQVM GrhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LHfH+UM0coRC140SwvweRAwY033gzgNgbuSMYyH3gXw=; b=cpnh5r7luJVgXe8iPA++paVbzD8lMgg4AvL3vjX2lGQ29MgZNmMjX9EjDrpU4DG0dS /G60aXfWJo6lUq4m6dLavc5Tui68HwTe7iRXS/jusQy3zNshn1FxkYYpcc71K4g+4yIY NM6t1FyyoejiOCXT7IqF+eQc3p26S/iH2HxSmG4z3bM2K0qG3MBYfvQsTwztB0iQE+k9 3OKOQaTQvmTuMFsz55Et9DD70bIXj+Y20KxztPwljH3fYJElk1PsWxmOabsnkwAClmGr vLvq1S/+Zm2A7ngnGhXvt2JgJz0tmllnpLB0NcZ+/JFJ7Fg+RQBweTW8JRWksUNFlrNB lKHA== X-Gm-Message-State: AJIora+IQoX7U0eA3jpnvS8w/BFYVzktxP6XimCgfR9TXIjuek1Tb012 9NirSTtvN06qMy2UzKSMT/2fIi67kJG/Xg== X-Google-Smtp-Source: AGRyM1s9uC/k5eZFDfbPGLNZjzaOTPDI2+29MqC4hiSEFwD3UrJ5Omf1bvADDsASMxFsIX0D6YXK9w== X-Received: by 2002:a17:907:9606:b0:70a:e140:6329 with SMTP id gb6-20020a170907960600b0070ae1406329mr26917826ejc.471.1658164833617; Mon, 18 Jul 2022 10:20:33 -0700 (PDT) Received: from localhost (cst2-173-67.cust.vodafone.cz. [31.30.173.67]) by smtp.gmail.com with ESMTPSA id n8-20020a170906378800b00705976bcd01sm5676882ejc.206.2022.07.18.10.20.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 10:20:33 -0700 (PDT) From: Andrew Jones To: opensbi@lists.infradead.org Cc: Atish Patra , Alistair Francis , Anup Patel , junliang.tan@linux.starfivetech.com Subject: [PATCH 3/4] lib: serial: Clean up coding style in sifive-uart.c Date: Mon, 18 Jul 2022 19:20:27 +0200 Message-Id: <20220718172028.2006166-4-ajones@ventanamicro.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220718172028.2006166-1-ajones@ventanamicro.com> References: <20220718172028.2006166-1-ajones@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220718_102037_507859_4C6C739C X-CRM114-Status: GOOD ( 11.52 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Signed-off-by: Andrew Jones --- lib/utils/serial/sifive-uart.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/utils/serial/sifive-uart.c b/lib/utils/serial/sifive-uart.c index 9478a77f8054..7078611a5274 100644 --- a/lib/utils/serial/sifive-uart.c +++ b/lib/utils/serial/sifive-uart.c @@ -48,12 [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:62f listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Signed-off-by: Andrew Jones Reviewed-by: Xiang W Reviewed-by: Anup Patel --- lib/utils/serial/sifive-uart.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/utils/serial/sifive-uart.c b/lib/utils/serial/sifive-uart.c index 9478a77f8054..7078611a5274 100644 --- a/lib/utils/serial/sifive-uart.c +++ b/lib/utils/serial/sifive-uart.c @@ -48,12 +48,12 @@ static inline unsigned int uart_min_clk_divisor(uint64_t in_freq, uint64_t max_target_hz) { uint64_t quotient = (in_freq + max_target_hz - 1) / (max_target_hz); + /* Avoid underflow */ - if (quotient == 0) { + if (quotient == 0) return 0; - } else { + else return quotient - 1; - } } static u32 get_reg(u32 num) @@ -77,8 +77,10 @@ static void sifive_uart_putc(char ch) static int sifive_uart_getc(void) { u32 ret = get_reg(UART_REG_RXFIFO); + if (!(ret & UART_RXFIFO_EMPTY)) return ret & UART_RXFIFO_DATA; + return -1; } @@ -97,10 +99,13 @@ int sifive_uart_init(unsigned long base, u32 in_freq, u32 baudrate) /* Configure baudrate */ if (in_freq) set_reg(UART_REG_DIV, uart_min_clk_divisor(in_freq, baudrate)); + /* Disable interrupts */ set_reg(UART_REG_IE, 0); + /* Enable TX */ set_reg(UART_REG_TXCTRL, UART_TXCTRL_TXEN); + /* Enable Rx */ set_reg(UART_REG_RXCTRL, UART_RXCTRL_RXEN);