Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2101787rdb; Mon, 20 Nov 2023 01:49:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+3Eeea1hjT9VI7tFxwXcOJ4oISyBBNevTcFhbzHi0blyOehnx9Lo07uNWs8D8mQSr37Za X-Received: by 2002:a05:6e02:13c4:b0:359:4ae3:cd9c with SMTP id v4-20020a056e0213c400b003594ae3cd9cmr8711762ilj.10.1700473799503; Mon, 20 Nov 2023 01:49:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700473799; cv=none; d=google.com; s=arc-20160816; b=BaE2uj9ST9HX7rV/imtz8ewZaMr9Mo94ahZWIrCEOcfIA+v52Iak4FxRA8jOfTcKe4 DGQ8xaPS411p84B2WogRAeLPKpLITTTlpISAu1PMZ2d9FvRPlXktKGRvwxOqePyEuNud B37YRzwUPaK2I5doKjUKMmcqltReEy3l5Okxwhih7bOYA+YRGeQpS93duo5Gp7Nzg+x2 0PUgJcEAq+i5JGCEWJc/NMYnmzq7XWXV6XtKXlOb/yl3rGrLpqt0rzsNfhVsxES/mRqn p9MQunPstumztZkSs93uoCEHBUuH5j/ndXQsesLCrLyimng6SBtrZz3Me8wdM5si8Sa+ C+dA== 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=HwMXYN1CqK95gePTaFzFF1wI1L46m/lEuk2xXoa7ocPZj5KWaaX4yZ4yKZ+r+0orj3 3mlI9AJkhyhT17SKGYRP9W+19qNQoBJ9pdi5BhDL/nIOj23Us142Rh2rjssouQMCR71g lNLB38Sgml6hhSIi+8sDTozMm9BDoBhBblbUOFk5c6gstwZdOjnTvow0UAyuICWNxQ6N oEs7J4BKul6XZT7HYjCehW8upqkiU4Irov8l1NAGKXgokmzytMmUbmT8YJZZh57KVXvN 8J22RkjNVN6gXlG8Tnl67zAfjf4BPTubOH8nUr1k2dIPvfQfqMAubslYk5lVJOMHEgdq zxVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dxFSKPK0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id o62-20020a634141000000b005c2193952a3si5540409pga.239.2023.11.20.01.49.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 01:49:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dxFSKPK0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id C5690804C497; Mon, 20 Nov 2023 01:49:56 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232719AbjKTJsz (ORCPT + 99 others); Mon, 20 Nov 2023 04:48:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232138AbjKTJsm (ORCPT ); Mon, 20 Nov 2023 04:48:42 -0500 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E316CD; Mon, 20 Nov 2023 01:48:38 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 6A4D62000F; Mon, 20 Nov 2023 09:48:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700473716; 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=dxFSKPK0gMc128alKfjCbtyy8R/198WYydgj5+1jn4bi6Qlc+eUfVII3rajGTiOyYR0EBJ 3OR6Bnp/SDnShGaoPtuZm1klpyNrirbCQPWh4fnEGcnyz+iItQAI9PsPevEoqZjMo4kRPq qOWBpFX78u0e1LB8UWpwM4AwLuJAmgd4cROEI4Ww5pj9qnNDRqfpY1fU7ROPT/EeRhJuz1 /+tVaOme+vnmUSsbXcBWwhuOzLApKfOljn37a+7XFOpjo2aZEXlf8KWsMrpYkDQAIxKbBj j2kzCX5dkEZaYwHTKOCPHDW7KzA2vIvLEizeAYG2DdRjLnd6v3rf4QTE2Bi/MQ== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Mon, 20 Nov 2023 10:48:28 +0100 Subject: [PATCH v3 5/6] tty: serial: amba-pl011: unindent pl011_console_get_options function body MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20231120-mbly-uart-v3-5-07ae35979f1f@bootlin.com> References: <20231120-mbly-uart-v3-0-07ae35979f1f@bootlin.com> In-Reply-To: <20231120-mbly-uart-v3-0-07ae35979f1f@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?Th=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 agentk.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 (agentk.vger.email [0.0.0.0]); Mon, 20 Nov 2023 01:49:57 -0800 (PST) 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) -- 2.42.0