From patchwork Tue Aug 16 11:57:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 597776 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5B63C38145 for ; Tue, 16 Aug 2022 12:08:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234683AbiHPMIP (ORCPT ); Tue, 16 Aug 2022 08:08:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233950AbiHPMHh (ORCPT ); Tue, 16 Aug 2022 08:07:37 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8DFA302; Tue, 16 Aug 2022 04:58:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660651084; x=1692187084; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1UKIh5lVnmIBtDpa/AFX4y2MwA+uxmPJv1Yi4y10neY=; b=ZOqkhz0gXvSmIGe2T5t8WHxenGbTHS+sck7yvwAnS5lmECLp3WHvbEsT MdVveM+9veTWWu2+VNnd6qR1FrXbyAKgP5iPZR8KNSPi6ZwZdnpdphA6+ dHSKwXhRUpKuSLWVPztHWd7sUhkHWO67JAnf8q5LrDZmp7VR1G3yg/Pr2 ukAox3CtAy85Y0mOodWM182cL7SZIzLh4ChPxGA76gRWMhCnjdO0+kMub lDBScaWm04UsQijbckPBfTh6oJCX0gpWPwL+0pDgoR0r9BboLV6/Ly6T/ bnUGAHgaKUOQX16V4UXvsfYxxNrBp5vn9TqXnlGp29I13yUOzCmF//JJl Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10440"; a="356199331" X-IronPort-AV: E=Sophos;i="5.93,240,1654585200"; d="scan'208";a="356199331" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2022 04:58:04 -0700 X-IronPort-AV: E=Sophos;i="5.93,240,1654585200"; d="scan'208";a="667080809" Received: from tturcu-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.51.153]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2022 04:58:01 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-serial@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby , Andy Shevchenko , "Maciej W. Rozycki" , linux-kernel@vger.kernel.org Cc: Johan Hovold , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH 3/8] serial: dz: Assume previous baudrate is valid Date: Tue, 16 Aug 2022 14:57:34 +0300 Message-Id: <20220816115739.10928-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220816115739.10928-1-ilpo.jarvinen@linux.intel.com> References: <20220816115739.10928-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Assume previously used termios has a valid baudrate and use it directly. Signed-off-by: Ilpo Järvinen Acked-by: Maciej W. Rozycki --- drivers/tty/serial/dz.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/dz.c b/drivers/tty/serial/dz.c index 2e21acf39720..3eaf4e85bfdd 100644 --- a/drivers/tty/serial/dz.c +++ b/drivers/tty/serial/dz.c @@ -592,9 +592,12 @@ static void dz_set_termios(struct uart_port *uport, struct ktermios *termios, baud = uart_get_baud_rate(uport, termios, old_termios, 50, 9600); bflag = dz_encode_baud_rate(baud); - if (bflag < 0) { /* Try to keep unchanged. */ - baud = uart_get_baud_rate(uport, old_termios, NULL, 50, 9600); - bflag = dz_encode_baud_rate(baud); + if (bflag < 0) { + if (old_termios) { + /* Keep unchanged. */ + baud = tty_termios_baud_rate(old_termios); + bflag = dz_encode_baud_rate(baud); + } if (bflag < 0) { /* Resort to 9600. */ baud = 9600; bflag = DZ_B9600;