From patchwork Thu Nov 23 13:42:43 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: 168942 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp454280vqx; Thu, 23 Nov 2023 05:43:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IGN6/Uwt+maGSgwI5jpYqeRafoRO0pVY5WTZ7+pjTVZF+x8SdxEGyLI5FCeUaWCf/oglZAx X-Received: by 2002:a05:6a20:c58f:b0:187:fa62:bb2d with SMTP id gn15-20020a056a20c58f00b00187fa62bb2dmr3822171pzb.36.1700747010916; Thu, 23 Nov 2023 05:43:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700747010; cv=none; d=google.com; s=arc-20160816; b=vgwFqlhKHskUfXAVA9bqTkk+aGVLK3C0Ipjr39v19Dit/QsBWt7Zyt9d66I7hwR4cX 6nwBvQ1kK508HE3NqEWxU4MkP31+KRmjlHLJ+88HFguplMZmUoYCD+BpHsI4GDoyKWcg xyIDa2HQSLc6vcryLL/QXJbfEFkDBW1RQdU9MIoK8aRjH1hMJqpKVBwcfTzKMMSAoOHk 9tq5/7HL7JAcbSLSysPg/91WYeLWCdsgrW/uHtRQThA6GWZ2vGC9KCGAPNFkxz9OXIXG QnqEiNKNXVrleuKD2Ap8rAgFeDVbIQ0zRIgzuUrpZVY0x3/aOpfMpqSuUVKz10qnv6rB t8Ag== 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=Axpf3/ym3riiBLvwrKRQW22UpcQG/DDMdTP47PTMwFk=; fh=AHZzcI0NKFNU1WuuS/FWF2LprSMGsTAGL8gmMiTfjNU=; b=SKmKMwCsLnhovMxKjknMdbcxMBAnf4b/G89gprPUcFjnl9f38RARmBUwon0m3YgncA Vk6/4UQvU+YlMJWCaUBEhy8B8QrhiZTIUVCebDUPjb2Y3q+jlBvHBr7a1zP9OG8ZYL7i UAiLGximHxUK8GDHPYUfT8FhLq6vRl+9itpHAWtPAHOjvfl91XAeeCgIUvZ/Kn9qreET 6ytKJOWhEZ/PPEMi7c9stOpwc5GGUWxUzhcqYgERQxnrt0U00coAsUHvsXvMRitzuCiz rA/jQSBjXZtTs4363qMi3koY7LC5R+EB4TkZ9cXDkKV/dKmWSTQV+2BDtSpFyN2ig1Ud E+3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Sl+3KmbI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id d13-20020a056a00244d00b006cb916f7794si1281120pfj.183.2023.11.23.05.43.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 05:43:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Sl+3KmbI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 6154B8088565; Thu, 23 Nov 2023 05:43:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345615AbjKWNnC (ORCPT + 99 others); Thu, 23 Nov 2023 08:43:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345562AbjKWNmn (ORCPT ); Thu, 23 Nov 2023 08:42:43 -0500 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91480D41; Thu, 23 Nov 2023 05:42:48 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id BFB9920013; Thu, 23 Nov 2023 13:42:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700746967; 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=Axpf3/ym3riiBLvwrKRQW22UpcQG/DDMdTP47PTMwFk=; b=Sl+3KmbIFIPbuoAbyEPAZJ7bkeFwMWoGDhKagTp1l+FB/2BsVDGSyz2MqLbLUY99XAo0pu gSzKSI5nk8vcf3TYBpBLDMcReKL7yAecVe8LbFJZ92I0LpXFUoUgYcUdNt9PT9/1WXmmXi LIJ69jIYUCCsoHwF4QNyi/G3D7nNE/bKyDs5yn8i+br+ORMA1vin4MXGabe8m3dZwCy8+9 jmALJsAtT6clJ0ITl2928+jydoSuo/249jcvvPqYZ/vDptoJ7kD0h1Oga4EexnX0qfWYtg AQUHXU3RczmE9lp6HzWpWLlf70tRfUdvh1re8XeRqxR6GbzhGHbwpXmxm1vBnA== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Thu, 23 Nov 2023 14:42:43 +0100 Subject: [PATCH v4 5/6] tty: serial: amba-pl011: unindent pl011_console_get_options function body MIME-Version: 1.0 Message-Id: <20231123-mbly-uart-v4-5-7f913a74ff89@bootlin.com> References: <20231123-mbly-uart-v4-0-7f913a74ff89@bootlin.com> In-Reply-To: <20231123-mbly-uart-v4-0-7f913a74ff89@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.3 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 pete.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 (pete.vger.email [0.0.0.0]); Thu, 23 Nov 2023 05:43:21 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783362497593904339 X-GMAIL-MSGID: 1783362497593904339 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 Reviewed-by: Ilpo Järvinen Signed-off-by: Théo Lebrun --- drivers/tty/serial/amba-pl011.c | 43 ++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index cf9aefe2fd28..4185d6fd243b 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -2369,35 +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'; + } - ibrd = pl011_read(uap, REG_IBRD); - fbrd = pl011_read(uap, REG_FBRD); + if ((lcr_h & 0x60) == UART01x_LCRH_WLEN_7) + *bits = 7; + else + *bits = 8; - *baud = uap->port.uartclk * 4 / (64 * ibrd + fbrd); + ibrd = pl011_read(uap, REG_IBRD); + fbrd = pl011_read(uap, REG_FBRD); - if (uap->vendor->oversampling) { - if (pl011_read(uap, REG_CR) - & ST_UART011_CR_OVSFACT) - *baud *= 2; - } - } + *baud = uap->port.uartclk * 4 / (64 * ibrd + fbrd); + + if (uap->vendor->oversampling && + (pl011_read(uap, REG_CR) & ST_UART011_CR_OVSFACT)) + *baud *= 2; } static int pl011_console_setup(struct console *co, char *options)