From patchwork Mon Oct 30 07:35:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vamshi Gajjela X-Patchwork-Id: 739525 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 61470C4332F for ; Mon, 30 Oct 2023 07:36:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231919AbjJ3HgC (ORCPT ); Mon, 30 Oct 2023 03:36:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231945AbjJ3Hf6 (ORCPT ); Mon, 30 Oct 2023 03:35:58 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E2F4C2 for ; Mon, 30 Oct 2023 00:35:55 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5a828bdcfbaso39241467b3.2 for ; Mon, 30 Oct 2023 00:35:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698651354; x=1699256154; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=+7qdvEqH9UQsG0XvkLdIs7iHiJPjbaVFxlERbYdwdFA=; b=yGlGjCtzcTwGQw5JyaI6KGo0AWun2Q8LefN3Yl1A7nL/t1Bcpf20YlYdVF/NntJL7r JgCDQxAI6daFerTQlw1rjltEjj+xiM5kCWHHqlgqshfXtW7lzCu5we95ByeML6rEGdLM qLgguYIuAhBEg/1ANr1a8zcmrB4BGe1h6uRo9BGvPc2lFBrTOGLUT6R6LMVPon4bp3yU 6ZnLKVWXG+xhKZrzoCKKPC46l6WM7RovGNhCfTGe+JzIjDg4JfFi02goqLlBC2SnvoQy zy0oD/QsWX2ReMOtGiejPqRiLHba+o+XsUOK3QCb1Xk3F2q8wsiK7ya/cj5ZbxR9X1Ze cKxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698651354; x=1699256154; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+7qdvEqH9UQsG0XvkLdIs7iHiJPjbaVFxlERbYdwdFA=; b=vXYpj+pr1byQBwdxRIRw5k6r7FUZNSrVawqOzIVNpmymwWec++EH7SbFxtJmq1KYav XHJ5NvOcFokjEm+rfhf75sJ3wsFbCJ+/Aj/xDwRga/+bg9alDWxsYAD2fzjgKoB41N1G kLcIXNpepy5HSALVr325X/PX6TEE5u0fHFROB1tV9rcJPEMRVCSo8IeqzJ+QaBhCFkJV zfV3wYzXC2pltXCvy7L3D9SmzecMKg0iya/LmWxjeQxm565PI0GhUAQANHAkZWI8aT5/ 2dDcYFkftpHFQa+2sp9VM+stSfRvhvBqaXOG1y6D7lCxlc4ANOvNiWkQiY58jWlk6QbV IzrQ== X-Gm-Message-State: AOJu0YxFdsGvAZEWmhdg8mOQ2FnEwLA4kd61T7b0kat4V2kVK/mzRQPy IxN1uivuMrsZ3QVAJkABs6joojCtLldlK/YjzoR+ X-Google-Smtp-Source: AGHT+IGGMn7WMwzw88OqfixdLw4Ao7PBRbYTEGPedxH7JeJpUjbQjZTP62q2ukCPPrUZJ3e0E/0aiLvOHbvQYJeo9uGI X-Received: from vamshig51.c.googlers.com ([fda3:e722:ac3:cc00:3:22c1:c0a8:70c]) (user=vamshigajjela job=sendgmr) by 2002:a81:6cc5:0:b0:5a7:ad67:b4b6 with SMTP id h188-20020a816cc5000000b005a7ad67b4b6mr174772ywc.2.1698651354698; Mon, 30 Oct 2023 00:35:54 -0700 (PDT) Date: Mon, 30 Oct 2023 13:05:41 +0530 In-Reply-To: <20231030073542.251281-1-vamshigajjela@google.com> Mime-Version: 1.0 References: <20231030073542.251281-1-vamshigajjela@google.com> X-Mailer: git-send-email 2.42.0.820.g83a721a137-goog Message-ID: <20231030073542.251281-2-vamshigajjela@google.com> Subject: [PATCH v5 1/2] serial: core: Update uart_poll_timeout() function to return unsigned long From: Vamshi Gajjela To: Greg Kroah-Hartman , Jiri Slaby , ilpo.jarvinen@linux.intel.com Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, manugautam@google.com, Subhash Jadavani , Channa Kadabi , Vamshi Gajjela Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org The function uart_fifo_timeout() returns an unsigned long value, which is the number of jiffies. Therefore, change the variable timeout in the function uart_poll_timeout() from int to unsigned long. Change the return type of the function uart_poll_timeout() from int to unsigned long to be consistent with the type of timeout values. Signed-off-by: Vamshi Gajjela --- v5: - no change. Consistent version for series v4: - author name in capitals to lowercase v3: - updated description v2: - unsigned long instead of unsigned int - added () after function name in short log - updated description include/linux/serial_core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index bb6f073bc159..6916a1d7e477 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -773,9 +773,9 @@ static inline unsigned long uart_fifo_timeout(struct uart_port *port) } /* Base timer interval for polling */ -static inline int uart_poll_timeout(struct uart_port *port) +static inline unsigned long uart_poll_timeout(struct uart_port *port) { - int timeout = uart_fifo_timeout(port); + unsigned long timeout = uart_fifo_timeout(port); return timeout > 6 ? (timeout / 2 - 2) : 1; } From patchwork Mon Oct 30 07:35:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vamshi Gajjela X-Patchwork-Id: 739993 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 420F8C4167B for ; Mon, 30 Oct 2023 07:36:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232124AbjJ3HgH (ORCPT ); Mon, 30 Oct 2023 03:36:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232127AbjJ3HgD (ORCPT ); Mon, 30 Oct 2023 03:36:03 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F41CBE1 for ; Mon, 30 Oct 2023 00:36:00 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5afe220cadeso28312427b3.3 for ; Mon, 30 Oct 2023 00:36:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698651360; x=1699256160; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=MJYRMGz5Km6YdZ6S41UQtlr9nImkATltc1KA9WGy+hA=; b=yI67vC9fqrQEeXKZsIIS1FL+y29Hx2GYVD96oofZiRfIwyPbry7HG7w5KQqvm8TtYG d2dYUpJfgL7nZvgsJ6Yvl1n1BfHIfd4NLC7l4tJG/E0n3XyBy1OHSXbqSkqejesnBgpS 61OvFzVx+v9TH63rL/bOtCZ8ujOeDhVbnm1acE0YidnFr+AHx6SQUsHPv49k8j5Ky3a9 PHGc+Iytv8PXBACnIPRGj/jc0x6jqXFQRTw0SfMz7GXFjAcPtc1NyPogYpRz3F/zEa3O 7U70Pkr8/jjEBz3LeNu46vA7C7wt2ZJ9P39lWq7B6seQz+pITVm9jta4cmNPU0AGqs7d AGkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698651360; x=1699256160; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MJYRMGz5Km6YdZ6S41UQtlr9nImkATltc1KA9WGy+hA=; b=U6mxUiM1esoQAllVIKSfJhHPz4n2T76xt27fqI4L5Xrx6tCZ9hM/ij4l4TBx72uS3X mzHTUvM4uwflkZE2kNQ4tOiWaKlwVVTALyqt7W81lVCEewbMwxB9uZTkCaySI8RfoXp3 hnyPRKnhKoa6qPHwMlwINb4yo+i78eP1M98EU3J1ky4J7x5KAQGcZi+lA0zoiCGt6X4J iCGlvLZt3HT9jwB4DpJPGSEhCekgIoPMJ5JCIcaVAyhF+BwYD9xf4Am12ebq6rXDJjMu 6O7Fbw3riZr8NpwROZyZnLCxHAcZcu3wpzKTCNutbRSLbrih2Bz4jW3QnSiEnZDVEMY4 D0kA== X-Gm-Message-State: AOJu0Yw/uhiEkZaXIKTa1DYLkplOn6bttd17QC04NlIIT+A+btqqUIvb aVKv00orP6v8QPXCkqGf3vJlJOvOuiU6X5PzPRRD X-Google-Smtp-Source: AGHT+IH43k6QWEJV2RtBgKwWnWVAcIXj5xEnffXwHQsmz+m5ajj1E80bw/CPBrQ699JZ3HJWOMm33zn6gH7AL2HWwX8P X-Received: from vamshig51.c.googlers.com ([fda3:e722:ac3:cc00:3:22c1:c0a8:70c]) (user=vamshigajjela job=sendgmr) by 2002:a05:690c:2a45:b0:5af:a9ab:e131 with SMTP id ej5-20020a05690c2a4500b005afa9abe131mr155448ywb.1.1698651360172; Mon, 30 Oct 2023 00:36:00 -0700 (PDT) Date: Mon, 30 Oct 2023 13:05:42 +0530 In-Reply-To: <20231030073542.251281-1-vamshigajjela@google.com> Mime-Version: 1.0 References: <20231030073542.251281-1-vamshigajjela@google.com> X-Mailer: git-send-email 2.42.0.820.g83a721a137-goog Message-ID: <20231030073542.251281-3-vamshigajjela@google.com> Subject: [PATCH v5 2/2] serial: core: Clean up uart_update_timeout() function From: Vamshi Gajjela To: Greg Kroah-Hartman , Jiri Slaby , ilpo.jarvinen@linux.intel.com Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, manugautam@google.com, Subhash Jadavani , Channa Kadabi , Vamshi Gajjela Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Rename the variable size to temp and change its data type from unsigned int to u64 to avoid type casting in multiplication. Remove the intermediate variable frame_time and use temp instead to accommodate the nanoseconds. port->frame_time is an unsigned int, therefore an explicit cast is used to improve readability. Signed-off-by: Vamshi Gajjela --- v5: - shortlog changed from "serial: core: Make local variable size to u64" to "Clean up uart_update_timeout() function" - renamed local variable size to temp, generic name - removed intermediate variable frame_time - added typecast "unsigned int" while assigning to port->frame_time v4: - no change, not submitted with series v3: - no change, not submitted with series v2: - no change, not submitted with series drivers/tty/serial/serial_core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 7bdc21d5e13b..21d345a9812a 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -410,11 +410,10 @@ void uart_update_timeout(struct uart_port *port, unsigned int cflag, unsigned int baud) { - unsigned int size = tty_get_frame_size(cflag); - u64 frame_time; + u64 temp = tty_get_frame_size(cflag); - frame_time = (u64)size * NSEC_PER_SEC; - port->frame_time = DIV64_U64_ROUND_UP(frame_time, baud); + temp *= NSEC_PER_SEC; + port->frame_time = (unsigned int)DIV64_U64_ROUND_UP(temp, baud); } EXPORT_SYMBOL(uart_update_timeout);