From patchwork Mon Nov 20 09:48:28 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: 167012 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp2087643vqn; Mon, 20 Nov 2023 01:50:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IGeIz9snwH84UWRVpUCplzW+L0aFAqLi7T3t5nvP7qvKuv8UdZmvLywXQ0VephhoCIIH7hx X-Received: by 2002:a05:6871:89e:b0:1ea:30b2:3fcc with SMTP id r30-20020a056871089e00b001ea30b23fccmr9335482oaq.31.1700473817870; Mon, 20 Nov 2023 01:50:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700473817; cv=none; d=google.com; s=arc-20160816; b=ogxP7XrVsNXZtzFO4/++HhUmkCZzOV3gaocyxrbdCiw+SzIDTp8nrfayXSOnAAmp36 dBUPNZi3lB19xHyz0LM3Yo7cKgZVIYDR7tmrMLJix84J1EYuJfPZPM9flZV8iQh/GAVd SH08nuEGavwmHwre4G/AZgVcooWQ0ZFb6r4FbXBhmaAwgajSbJpxtumQ7nMVuw3G87qj z0MSOCEYCZpCHhCMch67D2GFIusxaQS9T9ux3fdXe5qfv363r8QuhrIHJBMOfWoyEIcd Zb2Tt9u/JkznJ2FJflXjw5W60LknRnkx16Y95X4QTuPQvttaE8V6j5UZu+JwLoEGn/Bp O4ow== 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 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id f7-20020aa79687000000b006cb63513372si4091208pfk.12.2023.11.20.01.50.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 01:50:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; 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 2620:137:e000::3:7 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 C87ED802AF22; Mon, 20 Nov 2023 01:49:14 -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 S232723AbjKTJsz (ORCPT + 27 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 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?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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE 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]); Mon, 20 Nov 2023 01:49:14 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783076034227834638 X-GMAIL-MSGID: 1783076034227834638 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)