From patchwork Thu Dec 7 17:56:12 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: 175320 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4961239vqy; Thu, 7 Dec 2023 09:58:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IH5WSaYCZCjFZtkEE3N9gj+sUbq5cCpEzRLdpYTUrsYhv6JpaT5UBqvOv8M3llxPgV4w0I2 X-Received: by 2002:a17:90b:305:b0:286:6cc1:2cd8 with SMTP id ay5-20020a17090b030500b002866cc12cd8mr2454605pjb.98.1701971933189; Thu, 07 Dec 2023 09:58:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701971933; cv=none; d=google.com; s=arc-20160816; b=rX/MUC5yGsPAA4hmQJyLOH2oqTM1BhO7zT57CRnYQHihMbSVyT0ImASCYSRu4j0VVv d7bV1cy0dzkdeYNzIM3WYQR+WLiG7ZdPuratjiwWLQmR0RYbAHWqGR2Z0gr9jq6bxkbY ReQv/4Rrw80uDDjBTjkEDFmviCnZWMCwp3bjevj4oWaFlJLoDD/fc/C7ZLWm1+Ek5Yfp TPVloiBw75FG2Z10MlHozCWMeSRnKhWjmwUgqJThV+mqWSF3owImf80svZZ1pZKFUhX3 lsvSU4m/qKJjXA1KfYAUoOduTYTghvWVvVLKW6zBp4xVScwP/f485+36ejTifxA6WPZG xszg== 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=RW5jkYR107pRWoXMeyx5Ti/dtYqz0jJryNgE6RLtFFE9PIYV+j9cmcOXmIcDE5KgUZ sBKSrDMzMDObpofNpYhXH0U1kg/Y1Hx+8mtfOY6CLhlkIL7BI17TSrBC5pg5RcuyOiKo IDtF6ixJy2VGMjl1lTpxCUttR4nyaBdFUc5V6JZTCZXdhLEFbbkALUczfg8ZPM8gTMOP ATwvXtrtenFEL1LLc6iK1MISTAkojroLDD766DmMI2/dGMKYlCx2IeZbCtkolag7x2Nj hNZsG5xxmtZ2J6JwTV5gwcpna0DTSNzU98IM4dRKq8+eDRWAuJ2Qk253IvXIVccE95bo LS7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=iRXNpuby; 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 c6-20020a170903234600b001d060d48fb3si107624plh.460.2023.12.07.09.58.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 09:58:53 -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=iRXNpuby; 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 F329980C9C87; Thu, 7 Dec 2023 09:56:55 -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 S1443697AbjLGR4q (ORCPT + 99 others); Thu, 7 Dec 2023 12:56:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235231AbjLGR4n (ORCPT ); Thu, 7 Dec 2023 12:56:43 -0500 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B62B170E; Thu, 7 Dec 2023 09:56:36 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id C8B73E000D; Thu, 7 Dec 2023 17:56:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701971795; 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=iRXNpubyMa1hzA29zjFEdXwTtAN0FRlflcZxlzrXaLNY7pf/kDLoVh6QZS6lpGxNyHGrl0 T/PtkXC0h0OfGRz6oWIbncAuZuf4be9uY53cSwl990vFoVjwK7F/VrOk2jO0MHSbIRZyTa qk3Q2kVGLal8beIroZP1wMdyl4jv07kPsc5J+ZsMGxhwN8q8FtkR9i/IoOVn0WhO/XSDOK l959I9D8iM82r3CkhXmwhS/BnB+eAt2oI1K6cVma4X3V7VwQHZ2p+b5+nSrSY9iPOpTn5l PdZ+luWlWOSgzNFfQWlE0LSsV3j9tWUgaMgaCVOcPT03FuWC7qiv6nPdkuh3/A== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Thu, 07 Dec 2023 18:56:12 +0100 Subject: [PATCH v6 7/8] tty: serial: amba-pl011: unindent pl011_console_get_options function body MIME-Version: 1.0 Message-Id: <20231207-mbly-uart-v6-7-e384afa5e78c@bootlin.com> References: <20231207-mbly-uart-v6-0-e384afa5e78c@bootlin.com> In-Reply-To: <20231207-mbly-uart-v6-0-e384afa5e78c@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.4 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_H3,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]); Thu, 07 Dec 2023 09:56:56 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784646921284130805 X-GMAIL-MSGID: 1784646921284130805 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)