From patchwork Thu Dec 7 17:56:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Th=C3=A9o_Lebrun?= X-Patchwork-Id: 175318 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4960341vqy; Thu, 7 Dec 2023 09:57:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IHl/BSSs4/FaRdaBxTWjGHf6gLmhle41WJs6bXEkXUKoz4RcMprgwiGgRL16FS3Y2riIsel X-Received: by 2002:a17:90a:94c6:b0:286:6cc0:cae4 with SMTP id j6-20020a17090a94c600b002866cc0cae4mr2658210pjw.91.1701971832343; Thu, 07 Dec 2023 09:57:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701971832; cv=none; d=google.com; s=arc-20160816; b=myGvrvYlOwoTpES3vNJ1PgMKMUwvWgUbsCxbpgaeRvA4FbzhjwOKrdl94Zxu+mtf4l Ukmxt9/1/0+D0766vaysEGVR1kq/FiMkQVbQfqkU1eBR7+2hsuT3BVWgPrJs1v4nv1X1 NdLDfyw1sY4HIDeXoaFHBDYZHZZvJKNyKoeMgKYPIVccFpfFtzeQ0a3urIGOk52TOhd1 pXySbZvdw756Ucx7qwkZki91ufbHuGVjXdVv/bVept5yxkSKW3Vcr95JE+qq7B4+TBmV BRSVefOFdY4giHJPOuAkL9UmiYE41HH9iztalN+EQQy73nrvuvcivbCSZV1a4HMiWKyW +pdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=cdalrHLUQP6uwbcSVcLW5+uO51pc2/mjYf1/i0LTryE=; fh=AHZzcI0NKFNU1WuuS/FWF2LprSMGsTAGL8gmMiTfjNU=; b=gK9r+1+nfqttMvV3XR9wLvqBH+n1+mCh+VIO99iwcpvlvyb72gX5r5sf0PR2ZHDjW6 8yCNen4K8GJnMP1yMlRUYSBMIlSciZDFhO/kcCXRhxSyFH9owOIHKXZ+2bANifoiIoLB aERj3bgNG/zTj1RMr6OheQWx/E0YdobwtCjHplGZkeDLkiIhZpVycXGyd3Bq/EZy9BDf zb51N7fG8aBJ5PZGzeFDuiUKD7n55fhO7KY1PtzlP3WSdLffX8X2rWsi8oduo6HmA3PS NA1/xC4FRXZUI3yf6iU90QrBGDJeg79nECu4V0Xynozc4RVKSBR1LDWntHrmAsuTqgPL zW7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=p7KtFQYr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id a9-20020a17090a8c0900b00286e5da4d84si175405pjo.158.2023.12.07.09.57.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 09:57:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=p7KtFQYr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 924CA83B00BA; Thu, 7 Dec 2023 09:57:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443656AbjLGR4h (ORCPT + 99 others); Thu, 7 Dec 2023 12:56:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443596AbjLGR42 (ORCPT ); Thu, 7 Dec 2023 12:56:28 -0500 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B1E81712; Thu, 7 Dec 2023 09:56:33 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 658EBE000C; Thu, 7 Dec 2023 17:56:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701971791; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cdalrHLUQP6uwbcSVcLW5+uO51pc2/mjYf1/i0LTryE=; b=p7KtFQYr1rF6N0LroqJ2zR+gxG6uEp5obi12Yn3TfptVF91M3etUe4qgCM094mQcdgAwW4 NBTGAUu0jsuTegOmjJJXBkG3i0lCiIKyAXMxOOCkZmf75gwE5bYfAahuZaWjdM71XV6bVE CEZJGrgWFekjXCYzB/wZQnSHL35NXV+HPAsJq3m/dCU/tLsrwK6p7RcZEl0Qa9lalFLqGQ J7WV5yjagT89BzjH1UTGajL4iShmqnm6gWYFkjL+7Uq8F0Lty8MPEhH/PHecxdqnzhhIGS fR2wyexsnH2JLRZRbdvhuMl6wwDZOYrHGARtUBmH18PdIIYYHVCfahGyG2WNGw== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Thu, 07 Dec 2023 18:56:10 +0100 Subject: [PATCH v6 5/8] tty: serial: amba-pl011: fix formatting of conditions MIME-Version: 1.0 Message-Id: <20231207-mbly-uart-v6-5-e384afa5e78c@bootlin.com> References: <20231207-mbly-uart-v6-0-e384afa5e78c@bootlin.com> In-Reply-To: <20231207-mbly-uart-v6-0-e384afa5e78c@bootlin.com> To: Russell King , Greg Kroah-Hartman , Jiri Slaby Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Linus Walleij , =?utf-8?q?Gr=C3=A9gory_Clement?= , Alexandre Belloni , Thomas Petazzoni , Vladimir Kondratiev , Tawfik Bayouk , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , =?utf-8?q?T?= =?utf-8?q?h=C3=A9o_Lebrun?= X-Mailer: b4 0.12.4 X-GND-Sasl: theo.lebrun@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 07 Dec 2023 09:57:09 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784646816507433519 X-GMAIL-MSGID: 1784646816507433519 Fix the following checkpatch warnings & checks: $ ./scripts/checkpatch.pl --strict --file \ drivers/tty/serial/amba-pl011.c CHECK: Unbalanced braces around else statement CHECK: Unnecessary parentheses around '[...]' CHECK: braces {} should be used on all arms of this statement CHECK: Comparison to NULL could be written "[...]" WARNING: Comparisons should place the constant on the right side of the test Reviewed-by: Linus Walleij Signed-off-by: Théo Lebrun --- drivers/tty/serial/amba-pl011.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index be8888db1a37..3c657bac2359 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -330,10 +330,11 @@ static int pl011_fifo_to_tty(struct uart_amba_port *uap) uap->port.icount.brk++; if (uart_handle_break(&uap->port)) continue; - } else if (ch & UART011_DR_PE) + } else if (ch & UART011_DR_PE) { uap->port.icount.parity++; - else if (ch & UART011_DR_FE) + } else if (ch & UART011_DR_FE) { uap->port.icount.frame++; + } if (ch & UART011_DR_OE) uap->port.icount.overrun++; @@ -464,7 +465,7 @@ static void pl011_dma_probe(struct uart_amba_port *uap) * If the controller does, check for suitable residue processing * otherwise assime all is well. */ - if (0 == dma_get_slave_caps(chan, &caps)) { + if (dma_get_slave_caps(chan, &caps) == 0) { if (caps.residue_granularity == DMA_RESIDUE_GRANULARITY_DESCRIPTOR) { dma_release_channel(chan); @@ -503,11 +504,11 @@ static void pl011_dma_probe(struct uart_amba_port *uap) if (uap->dmarx.auto_poll_rate) { u32 x; - if (0 == of_property_read_u32(dev->of_node, "poll-rate-ms", &x)) + if (of_property_read_u32(dev->of_node, "poll-rate-ms", &x) == 0) uap->dmarx.poll_rate = x; else uap->dmarx.poll_rate = 100; - if (0 == of_property_read_u32(dev->of_node, "poll-timeout-ms", &x)) + if (of_property_read_u32(dev->of_node, "poll-timeout-ms", &x) == 0) uap->dmarx.poll_timeout = x; else uap->dmarx.poll_timeout = 3000; @@ -615,9 +616,9 @@ static int pl011_dma_tx_refill(struct uart_amba_port *uap) if (count > PL011_DMA_BUFFER_SIZE) count = PL011_DMA_BUFFER_SIZE; - if (xmit->tail < xmit->head) + if (xmit->tail < xmit->head) { memcpy(&dmatx->buf[0], &xmit->buf[xmit->tail], count); - else { + } else { size_t first = UART_XMIT_SIZE - xmit->tail; size_t second; @@ -751,8 +752,9 @@ static inline bool pl011_dma_tx_start(struct uart_amba_port *uap) if (pl011_dma_tx_refill(uap) > 0) { uap->im &= ~UART011_TXIM; pl011_write(uap->im, uap, REG_IMSC); - } else + } else { ret = false; + } } else if (!(uap->dmacr & UART011_TXDMAE)) { uap->dmacr |= UART011_TXDMAE; pl011_write(uap->dmacr, uap, REG_DMACR); @@ -2139,9 +2141,9 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios, * else we see data corruption. */ if (uap->vendor->oversampling) { - if ((baud >= 3000000) && (baud < 3250000) && (quot > 1)) + if (baud >= 3000000 && baud < 3250000 && quot > 1) quot -= 1; - else if ((baud > 3250000) && (quot > 2)) + else if (baud > 3250000 && quot > 2) quot -= 2; } /* Set baud rate */ @@ -2668,7 +2670,7 @@ static int pl011_probe_dt_alias(int index, struct device *dev) ret = index; } else { seen_dev_with_alias = true; - if (ret >= ARRAY_SIZE(amba_ports) || amba_ports[ret] != NULL) { + if (ret >= ARRAY_SIZE(amba_ports) || amba_ports[ret]) { dev_warn(dev, "requested serial port %d not available.\n", ret); ret = index; } @@ -2702,7 +2704,7 @@ static int pl011_find_free_port(void) int i; for (i = 0; i < ARRAY_SIZE(amba_ports); i++) - if (amba_ports[i] == NULL) + if (!amba_ports[i]) return i; return -EBUSY;