Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2612959rdh; Mon, 30 Oct 2023 02:33:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExWpMNJf1dLAdaHF41QLcvJ/CBWgcud3qFlEoSA2oyvTJCFqcPsT1/J+JfhwJ4wRWXkHKZ X-Received: by 2002:a05:6808:102:b0:3ae:5aab:a6f9 with SMTP id b2-20020a056808010200b003ae5aaba6f9mr8568431oie.46.1698658432000; Mon, 30 Oct 2023 02:33:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698658431; cv=none; d=google.com; s=arc-20160816; b=oGOIu2x4v3O7bAmY2mtRHSciPouwjPtHDnz+cCav6iWFCmeIR0zyyVVkm+ZO08xFaM fUBl4msZEuL3hRNeMY+qOYYKFuwgnrn20/XmrSGuyxdX0vhh8qSALQk//LRmvqAH3Ji9 ejH5LzD3gkVlIFsYr3Q7cxZnDiqZ0gDF+4+cF/zXZXPW8/ej/b9oRjWexKe+y6eHmD6W HdYS4Wr4mJ0lzADIMpyFXgODotheg81dVMjw//+4uCYiLE+5xrk83U0syOLwXs4rDsJw odJg/gIEFCofwGPDdtWnxsgTppYQf7KhGmoTXkKwGH0SbHYEb/ZhOeVMGSka39fhqhng YG1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=BCzTzufS7zugrx/3gPre5tzkMjqY1vvH+Tv2IKAztmY=; fh=Hy+wYgzvNBVyT2lmq4JbSc9QytG3mfcQdbHW9xG8aUU=; b=FwUMw5zglY0ITqp2PY2dt5v9hhVWnmPbiJ9DfuNtpqUwWDsch5Hn2JgaGKnmsYqkIR P53GKXGtC43ajIqE/QhKFGT8eT29mc/D/htQFwIRi65M65gxJcn6rPIyklcI1yNm4cit slxs9yeu4DPp3vCZOXQaYIU3nBjXi+XflRfLknCXfWe4IB+UGTiNcwcceoo3OUimXzlL 5RSBvry9EpVX6nm6yIdxiDElxtfVEXbqO0dyfOHraDISDdgt7rs78HE395rZBrNDD0X3 W+rP6xNBp8pIfHXiAMP5kLGENu7RIMkgZkiukZrsNVOXlWpj11wZIYlsYaE5qsiTHSM+ wx0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XufLPj3g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id k3-20020aa79d03000000b0069023e4bca8si4649252pfp.214.2023.10.30.02.33.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 02:33:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XufLPj3g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id A0D3B8098FD9; Mon, 30 Oct 2023 02:33:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232480AbjJ3Jdj (ORCPT + 99 others); Mon, 30 Oct 2023 05:33:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232084AbjJ3Jdi (ORCPT ); Mon, 30 Oct 2023 05:33:38 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C471C5; Mon, 30 Oct 2023 02:33:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698658416; x=1730194416; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=MGg7v733cJVIT8wJVh7PM70i+jR+qkVB9DzADA8OUSY=; b=XufLPj3gYhXw94I3awud52zmqtlyxoNa40w01xE9bFdZFnIWOUFFnjkg 8BzF51QceRWqihWOIjHQw5wQGrCdBJ1DxEqC4CanIJjI0Soxt2WT+5/2K EJ3Zay4po7eAUjFHKK7wCsrlkgDDRHK7p5gwS4o4cWSN7XzNzkW/QY8bQ XJjem/yNP6O6Svj/UObKNFWLvcQYgZ8BUMpGKqQAPezjNc0ToHg29zGnt MD4wIZ5Ea09qZ5RZSvuTJNp2Fx9IaCsObMzRp+Ja+9IJ+0g0jUrRAX0jl 7kkNxbUOrSJbVwg89Nh4K/+DdiUQv2YKTUlwT6nwtUvomAPeVMirqRuXQ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10878"; a="378414013" X-IronPort-AV: E=Sophos;i="6.03,263,1694761200"; d="scan'208";a="378414013" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2023 02:33:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,263,1694761200"; d="scan'208";a="8283768" Received: from sgruszka-mobl.ger.corp.intel.com ([10.252.50.181]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2023 02:33:33 -0700 Date: Mon, 30 Oct 2023 11:33:30 +0200 (EET) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Vamshi Gajjela cc: Greg Kroah-Hartman , Jiri Slaby , linux-serial , LKML , manugautam@google.com, Subhash Jadavani , Channa Kadabi Subject: Re: [PATCH v5 2/2] serial: core: Clean up uart_update_timeout() function In-Reply-To: <20231030073542.251281-3-vamshigajjela@google.com> Message-ID: <275b9b10-204f-534e-2155-98f623d9f63a@linux.intel.com> References: <20231030073542.251281-1-vamshigajjela@google.com> <20231030073542.251281-3-vamshigajjela@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Mon, 30 Oct 2023 02:33:49 -0700 (PDT) On Mon, 30 Oct 2023, Vamshi Gajjela wrote: > 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. You should focus more on why instead of what. So add explanation that the frame time is small (you could even calculate the largest value and add it to the commit message) and therefore it always fits safely to unsigned int. And that we do not upconvert the type to avoid unnecessary costly 64-bit arithmetic done in a few places in the serial code. > 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); > > -- i.