Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp331502rdb; Thu, 30 Nov 2023 06:08:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IHfmaEvzVugnBygHyryyaYn5JGcPcZU73zlYSnm2X2LomhEhKoRQQPnmIsUUuOIdVL60kUa X-Received: by 2002:a05:6a20:3caa:b0:189:ca96:aa1b with SMTP id b42-20020a056a203caa00b00189ca96aa1bmr23814067pzj.53.1701353293137; Thu, 30 Nov 2023 06:08:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701353293; cv=none; d=google.com; s=arc-20160816; b=oa1oiAHrz7auUjhZkyau8v3/ujFcWyJwktXPA8ugX+qJp74aBkD7Gd/ksDprJNw+69 jxWY7itxZgCrqZMiZijDmbGI/FQaXBpCoGJFo0InzgSBh0mQDuJSW82n5I8PSWUc8tpO rpI5AKeYbt4GTHFIJsCQRdtrYAPW6G+IfIdDPlC/lOv2zP3IPy/9YSJOg60JU3lkdM/9 n0Nx2hqVYCmYzoy3dVLz6nwvWKqJHpjzNPJY2PEYdoCkaN0RbR96he2Jli3ovdxAYrMG /kt4xwZ2Kh7xcsGIDzwtEAdI+IAZPYLF5KnLrxWveZSU6tCzKD424Dgtgk/nBwYng6Ae Omdg== 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=jhHwMPKMhE6XsTNOR4sdwWV4X+Iddbs0ASEj4p1owTs=; fh=AHZzcI0NKFNU1WuuS/FWF2LprSMGsTAGL8gmMiTfjNU=; b=rOSNVThzgwsadplp0hbuKP05ug4cn35A18PnGsm2BsZd6bTtm7wsnpY8rz3mocROMj dovdmyk31CrlrPwD4oJgtEC1noFVO/rjlaxa8MHKnZtSzTWrW0nFygjK+3naBR4OMc8K io6PKIjrNWp1fP7ZgL/L9hw5jxJkNuNzpCdBNxpgpMJnsNxKtUtQkaDpsbMB6sfmYkMD dEoQgkKDprlN7jRyLJGCyR5IgFtXJeo7/5rHd7TkjRDuCOPnHaFf8DrV3crRKFWjmPyS HRwIRAYVY9L1Ginv1aRPTn1JGbIR7EC4ENfEciRfjWXAqdcba9W3/wYUjmkK6zxpR+D4 MrtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=CH6Wdsj4; 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 Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id h3-20020a056a00170300b006a68a46431bsi1335177pfc.50.2023.11.30.06.08.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 06:08:13 -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=CH6Wdsj4; 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 AF2A28026DC3; Thu, 30 Nov 2023 06:08:09 -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 S1345931AbjK3OHu (ORCPT + 99 others); Thu, 30 Nov 2023 09:07:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345841AbjK3OHd (ORCPT ); Thu, 30 Nov 2023 09:07:33 -0500 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4286F10E5; Thu, 30 Nov 2023 06:07:39 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 75A5140006; Thu, 30 Nov 2023 14:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701353257; 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=jhHwMPKMhE6XsTNOR4sdwWV4X+Iddbs0ASEj4p1owTs=; b=CH6Wdsj49typujP1ViAjaRdfAsbz4B7rNEffQT5CSu7gmjBauWw2hi37xBxThNAKqowt+g NGhsdC13nJ09p+vfVTwdLOBxHgxhpLjfJFr5If+r8Cm7Ippe4Ebb1ix/p1NvB0hQLI+Ci9 TYqQ9Uzft06CTSQqpo5F7nTi32rYxQlflgD8dV64JC5VnoakBOGLWrKp+QO5QdpSsHUTLM r4mFogZW0+Nr6i5DBWi4meIK/VOyRu3cceAzeX8tucB2ZhOI4KVslTbTaOQT+BxEj/yV+Y xiNmr82qxSW5dojMirq9JxNOCev3wS8mBd/bfRWokYTAtUhUs3O0s2HSUZHzbg== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Thu, 30 Nov 2023 15:07:20 +0100 Subject: [PATCH v5 8/9] 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: <20231130-mbly-uart-v5-8-6566703a04b5@bootlin.com> References: <20231130-mbly-uart-v5-0-6566703a04b5@bootlin.com> In-Reply-To: <20231130-mbly-uart-v5-0-6566703a04b5@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=-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 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, 30 Nov 2023 06:08:09 -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 d141af8f8a5f..fe910c5f3489 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -2363,35 +2363,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.43.0