Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp929260ybh; Wed, 22 Jul 2020 17:35:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4JD1jJk0c/0WMh7HUVm01sA88ybDwgiT+JaH+COdycX6gV+uHbm4/xf/P0Ouxe6nszA8Q X-Received: by 2002:aa7:c656:: with SMTP id z22mr1933154edr.101.1595464542782; Wed, 22 Jul 2020 17:35:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595464542; cv=none; d=google.com; s=arc-20160816; b=K5iHoPpULCoNvhK9tS8saBzIas7PUL7awAmCKOqCtGRvCz/f1IIWA19KjrKQBWDgWb c+KXJ7zwwxszA66ypj9Fx2oafXRaXBE6ckP08Ec3iyK2E4claQL10cdUIK1zrbuB2jkh ZO2PCE5igPVGB68KQ6DKbnJR5s6+2+Nf0N2+JbRuUCvb2BweuT5ozM9zkdANjK8BqEnV bMDKwwDMQnEhGcxm9uXz7xTBtUJl53kovXQ3Uudd+tZPtbZFEDtLDGmKBEyty01j6EKY RxiEeenHlka2Op5XXjs3BhL6y8XwZZOkN11r63ILb5ukcx/itnyfkXisZee59/ndzYLr Lf2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=iZulryCk+ci+O7Pz8XjQWTLjwEcw06B5e9A/h+RAUl8=; b=raJCGBIF6r1xoOyaBwfNl2cPbAfcmuMzwUDREV97w5yYsJSAL3MDXnd8MYnq5rjPnT zpQvyNoJtEKj32VTl3MRofUqRaH0RPGUp9PWvvFy+ztTPHelTNiRnhiEVN0nDWIDneNA iTLIwgF4zq4Urt7RE9YnVRqe+w4so09b5hrnmhXaLm1QNd4wPgASYmYQFCijiQ9hopku oQtZB6oMGAVWQunrkFdvJOrezf405qPssmmwMJeYowZYGqP8LiqilGilqjnCraV4OR0T JMS2ZOChN4k/qItljKyDWHC2zdU/y4dImRwuC4XzgS2NX8MwNUt34l3UVsZ87L3+TqCj U82w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p16si972314edx.337.2020.07.22.17.35.20; Wed, 22 Jul 2020 17:35:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733079AbgGWAeH (ORCPT + 99 others); Wed, 22 Jul 2020 20:34:07 -0400 Received: from mail.baikalelectronics.com ([87.245.175.226]:60736 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728607AbgGWAeH (ORCPT ); Wed, 22 Jul 2020 20:34:07 -0400 Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 6AB198030816; Thu, 23 Jul 2020 00:34:01 +0000 (UTC) X-Virus-Scanned: amavisd-new at baikalelectronics.ru Received: from mail.baikalelectronics.ru ([127.0.0.1]) by localhost (mail.baikalelectronics.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jJq91sKe2DEP; Thu, 23 Jul 2020 03:34:00 +0300 (MSK) From: Serge Semin To: Greg Kroah-Hartman , Jiri Slaby , Andy Shevchenko CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Andy Shevchenko , Maxime Ripard , Will Deacon , Russell King , , , Subject: [PATCH v9 2/4] serial: 8250_dw: Simplify the ref clock rate setting procedure Date: Thu, 23 Jul 2020 03:33:55 +0300 Message-ID: <20200723003357.26897-3-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20200723003357.26897-1-Sergey.Semin@baikalelectronics.ru> References: <20200723003357.26897-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Really instead of twice checking the clk_round_rate() return value we could do it once, and if it isn't error the clock rate can be changed. By doing so we decrease a number of ret-value tests and remove a weird goto-based construction implemented in the dw8250_set_termios() method. Signed-off-by: Serge Semin --- Changelog v3: - This is a new patch. --- drivers/tty/serial/8250/8250_dw.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index aab3cccc6789..12866083731d 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -282,20 +282,13 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios, clk_disable_unprepare(d->clk); rate = clk_round_rate(d->clk, baud * 16); - if (rate < 0) - ret = rate; - else if (rate == 0) - ret = -ENOENT; - else + if (rate > 0) { ret = clk_set_rate(d->clk, rate); + if (!ret) + p->uartclk = rate; + } clk_prepare_enable(d->clk); - if (ret) - goto out; - - p->uartclk = rate; - -out: p->status &= ~UPSTAT_AUTOCTS; if (termios->c_cflag & CRTSCTS) p->status |= UPSTAT_AUTOCTS; -- 2.26.2