From patchwork Thu Nov 16 10:31:08 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: 165749 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp3118159vqg; Thu, 16 Nov 2023 02:32:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IHP1pTNUdaX4w5+bmCfIXi757cfasaz2RYGEMpuT3iAY5U/YocNKrf3hBnNsIWZl123V1sP X-Received: by 2002:a17:90b:1e12:b0:280:a6a6:9b1b with SMTP id pg18-20020a17090b1e1200b00280a6a69b1bmr13791523pjb.19.1700130735378; Thu, 16 Nov 2023 02:32:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700130735; cv=none; d=google.com; s=arc-20160816; b=BwYa1AmdxzXq5S4ujvWyC3V8NVA0weSRmBiKWweo9LXh984oC/ExJmTVvOfcosXMja ytXrrbTYyt3EYJPnuM7PzmD2x7mN+skt5SAoGbjd0q6VSnpzJ2Y3Cv8bMR5lb+78ydje YGhp/gmGC8uZL+UFiCBsF/5PKGNqId2BCU+1wHzKHX8MM45m8BCLECKXYmDEkQt4DoIR dSTCiDryZ04wj6j1FtycGJnkR/vg9oOxEKM72+thq/e/lkAbu152kVfTLFty2sqG95lA 8pJpvy3G90isEGS7wLHBmSM/cOTnymMY1U1z8HSXJlb7aINLTF/tFa0RfFGud/1o3CPl NGIA== 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=8Gilx4H3RKP8/lZDTxCW04nyKKjKNCSF+csRLPdNS2A=; fh=QQT0ysDV3C9K/ZwUoBeqi9VulQuaknzQuTSh/MRCItc=; b=0i8kX4ggGgwxIZYI8ySbkNTJT5MDP/APBGVSsFhom8tw5egJyNcIZymdqBNDUlx0Yy JQw+sJoiyjQf7mjitRm39bhXPz8/mE6eqAFe3/hBzCC+PYg78atDD0uIntxV56EAsM2C 2P7bqHlo7wHu5qI2e2uVbaanPPT3PTCqnurSWsIVZaVE88wZMWJQwlx0yFOUAaS+y+Dz vsQUW/ZUq+dUyVk1KmciZ5zWrxkkEgCI0eBsEgupwg4Fsi/5YJClcp2pylmk50kJQqss rvPO7fcwvO5fpPwUMrq1s1IZpyJMSlbEqixgNJLfwCzRkr2uDqvB1aKTjDlddDL8mvGb 7wXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=JGs2E4Pm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id pf1-20020a17090b1d8100b002800879f482si1830129pjb.87.2023.11.16.02.32.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 02:32:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=JGs2E4Pm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id E3B1881A6E79; Thu, 16 Nov 2023 02:31:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345023AbjKPKbj (ORCPT + 29 others); Thu, 16 Nov 2023 05:31:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233066AbjKPKbb (ORCPT ); Thu, 16 Nov 2023 05:31:31 -0500 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B846D1AE; Thu, 16 Nov 2023 02:31:26 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id DEF996001C; Thu, 16 Nov 2023 10:31:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700130685; 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=8Gilx4H3RKP8/lZDTxCW04nyKKjKNCSF+csRLPdNS2A=; b=JGs2E4Pm4ttEACnrdJLtXtseCSq4ZCZOGkeVwb0XK7HwE5wEyzJYbuUSED/lJJXzwU5+Jz aydtnjt7I4CmF/JEs83zg0J0OL7YFkQCtUOpViTQP640eIQmc80KockT651UVFfChIaBEx bWqZRjnMXbL4C6siWB88VN3om1jpFOnm16vCvWIuHcIWrLYzIydBY3eG5P1/4fgwTZ0rsU YguJIdOi87LeLchXoAYe556YcEtxiu1cSItiTjOakmvbo2gOT1G6VEZ19sjGs6PDSDIOOy S0F7f6gzyez5k2vVXdB8rMs+LPBa2XcIrsa40K0bdNc6PF8IaPR/kQvNFQyL8w== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Thu, 16 Nov 2023 11:31:08 +0100 Subject: [PATCH v2 5/5] tty: serial: amba-pl011: unindent pl011_console_get_options function body MIME-Version: 1.0 Message-Id: <20231116-mbly-uart-v2-5-863f665ce520@bootlin.com> References: <20231116-mbly-uart-v2-0-863f665ce520@bootlin.com> In-Reply-To: <20231116-mbly-uart-v2-0-863f665ce520@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?Th=C3=A9o_Lebrun?= X-Mailer: b4 0.12.3 X-GND-Sasl: theo.lebrun@bootlin.com X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Thu, 16 Nov 2023 02:31:54 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782716286103724550 X-GMAIL-MSGID: 1782716286103724550 The whole function body is encapsulated inside an if-condition. Reverse the if logic and early return to remove one indentation level. Also turn two nested ifs into a single one at the end of the function. Reviewed-by: Linus Walleij Signed-off-by: Théo Lebrun Reviewed-by: Ilpo Järvinen --- drivers/tty/serial/amba-pl011.c | 42 ++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index bb3082c4d35c..5774d48c7f16 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -2369,34 +2369,34 @@ pl011_console_write(struct console *co, const char *s, unsigned int count) static void pl011_console_get_options(struct uart_amba_port *uap, int *baud, int *parity, int *bits) { - if (pl011_read(uap, REG_CR) & UART01x_CR_UARTEN) { - unsigned int lcr_h, ibrd, fbrd; + unsigned int lcr_h, ibrd, fbrd; - lcr_h = pl011_read(uap, REG_LCRH_TX); + if (!(pl011_read(uap, REG_CR) & UART01x_CR_UARTEN)) + return; - *parity = 'n'; - if (lcr_h & UART01x_LCRH_PEN) { - if (lcr_h & UART01x_LCRH_EPS) - *parity = 'e'; - else - *parity = 'o'; - } + lcr_h = pl011_read(uap, REG_LCRH_TX); - if ((lcr_h & 0x60) == UART01x_LCRH_WLEN_7) - *bits = 7; + *parity = 'n'; + if (lcr_h & UART01x_LCRH_PEN) { + if (lcr_h & UART01x_LCRH_EPS) + *parity = 'e'; else - *bits = 8; + *parity = 'o'; + } + + if ((lcr_h & 0x60) == UART01x_LCRH_WLEN_7) + *bits = 7; + else + *bits = 8; - ibrd = pl011_read(uap, REG_IBRD); - fbrd = pl011_read(uap, REG_FBRD); + ibrd = pl011_read(uap, REG_IBRD); + fbrd = pl011_read(uap, REG_FBRD); - *baud = uap->port.uartclk * 4 / (64 * ibrd + fbrd); + *baud = uap->port.uartclk * 4 / (64 * ibrd + fbrd); - if (uap->vendor->oversampling) { - if (pl011_read(uap, REG_CR) - & ST_UART011_CR_OVSFACT) - *baud *= 2; - } + if (uap->vendor->oversampling && + (pl011_read(uap, REG_CR) & ST_UART011_CR_OVSFACT)) { + *baud *= 2; } }