Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp304313lqh; Fri, 31 May 2024 01:37:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXWevdbC7V1sgulcqciagJRRkkP/C45vpB202QjCIYOzYHT1T0PrpqB/PzrXAQdjT/hxISeLYXdW/3fe57y1V8QCRcDLgp6YHFAzCW7Pg== X-Google-Smtp-Source: AGHT+IH9BbNjjrw7vXybfTYNSu8imargZF4MDkNzALNleG1ZKtRk5ZSqgmN0JHxjvxE9iIB5Euri X-Received: by 2002:a17:907:b010:b0:a5c:fc25:2730 with SMTP id a640c23a62f3a-a681fc5bab6mr66304066b.4.1717144666168; Fri, 31 May 2024 01:37:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717144666; cv=pass; d=google.com; s=arc-20160816; b=ia9Lz2z4nii/jx5jbIvHWS61Ryqd+XJUCoDYOvIq6IL64qJTnLBzYHV+iizHzLllT+ up/59A2N5Y+Xp6un7nmvRoKgv8OA9/TiCMeq+z++b5kkJvHCSv/4YvqmjpbBb6elk5cp 6JUvaSwMbgXrfVpB6pweDD93AZkk+UKe2O7KL3v3t7ugAH/yfyAkY8pTejyzU5kw5VWe 9rOkO0FZSFwDKArVhIU4GK0vrm8bZQR66gArEmF9+FKIFwOjhn5xAXGHIURuW3sJJ65S gluc4tH10PSg+pRMLLFEI+sJ2TCZOA9keDc1jRL+oex8RM95yogRWryBfjVdLf2A0vxe 0jnA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=S0ukmk1g2waDrHjd+R+8zkx4KdRvWUrWFxGLS+wgH5o=; fh=xEO3FYGHk3QAvBMTBRsmJpr0lWdIVV3Wr046zfF3JfQ=; b=vrx+fWohQUOEkpq7aiQqmlxssIPVVQO/rqAzjOz01SxVckmT0rfsx9oFvA38O1e74T +YTSXJHKHYRmqLUR1chO7N5aoeliuWQWhgtnDip9s+29SlTVCTjCkBYXnchXKNjrNIr7 yiWpJYpKLC1FHHG7gcKkL/HIr7UHwX677wwokhGrnCNRhKHSBfeXdm4prtMInvkRDW7J 6XMd889Ld17IFr1EQrIWBr/SwXAGLXoZAtr5aSkbnri/5Hws8EsH2AaxYP8SQOtv8vi2 AbMtGImWyLSGG/6J0CYtNsKrDQXCo2VClp+xBC/oEmA1OxvXTOj5j32GZnI5VyVUSOIe vD6Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=meMAKXV6; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-196485-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196485-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a67e6f031a8si71004466b.57.2024.05.31.01.37.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 01:37:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196485-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=meMAKXV6; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-196485-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196485-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DACD21F265E8 for ; Fri, 31 May 2024 08:37:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 92D65150984; Fri, 31 May 2024 08:36:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="meMAKXV6" Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D42BC14F9FA; Fri, 31 May 2024 08:36:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.248 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717144606; cv=none; b=Lsh7xY7qLUWFwGRRFc5w2JV9REZMuHEDv4XuHwbcibHDmGQVGYAms+MUJFW41HNvphQNGJlAnpC9tutAYuvgwOaOFQngEl7bqAnUQcrR4alB3pKH4V4sXh0tUyCa5pWXSLVaiSjCqpd6gWpMLBlU0JynnSLpQLRpgfkmaRv67s4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717144606; c=relaxed/simple; bh=TfQdA2XCPGkN/zEB747sTwVs1wSBXHbq/hbPTp30TYs=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=gD5JYgRbTD8WZDlp8qp8CJsqrcFYEsKHZyePgx5lTOdCfcMW1uE+HHyInq3X2hbnlO9H7L3fKCw9ZZDulnYqRQrye26/AloU4dBZVx8ghlFP5ZkGxvdn4SWpK0ojRA3ZfJoIqEjxaEAF6C3u+BNpS9LRbnFbkDbY6MtavUPkiF8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=meMAKXV6; arc=none smtp.client-ip=198.47.23.248 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 44V8aMR9042855; Fri, 31 May 2024 03:36:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1717144582; bh=S0ukmk1g2waDrHjd+R+8zkx4KdRvWUrWFxGLS+wgH5o=; h=Date:Subject:To:CC:References:From:In-Reply-To; b=meMAKXV66h+EykWFPDoMgyrkHcRwg0+dFJ/xtgo6dy/5/lpt8EuwgxEeH80KIrnSG U940IDV5SC45+69YFr2knqGlDA+G9lN0oYWmsx5AYL2M74hR/3iaqCyPhvJg8TOfCf sK7vMOV9TYdPqU1Kx/Gd3bBUepEm8LLSZ9pPOv+E= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 44V8aMc9051757 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 31 May 2024 03:36:22 -0500 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 31 May 2024 03:36:22 -0500 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 31 May 2024 03:36:22 -0500 Received: from [172.24.227.193] (devarsht.dhcp.ti.com [172.24.227.193] (may be forged)) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 44V8aEXd052311; Fri, 31 May 2024 03:36:14 -0500 Message-ID: <7bed5792-db9d-3bc8-5325-7333076822e9@ti.com> Date: Fri, 31 May 2024 14:06:13 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v10 06/11] math.h: Add macros for rounding to closest value Content-Language: en-US To: Andy Shevchenko CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , References: <20240530165925.2715837-1-devarsht@ti.com> <20240530171225.2749312-1-devarsht@ti.com> From: Devarsh Thakkar In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Hi Andy, Thanks for the review. On 31/05/24 00:49, Andy Shevchenko wrote: > On Thu, May 30, 2024 at 10:42:25PM +0530, Devarsh Thakkar wrote: >> Add below rounding related macros: >> >> round_closest_up(x, y) : Rounds x to closest multiple of y where y is a >> power of 2, with a preference to round up in case two nearest values are >> possible. >> >> round_closest_down(x, y) : Rounds x to closest multiple of y where y is a >> power of 2, with a preference to round down in case two nearest values are >> possible. >> >> roundclosest(x, y) : Rounds x to closest multiple of y, this macro should >> generally be used only when y is not multiple of 2 as otherwise >> round_closest* macros should be used which are much faster. >> >> Examples: >> * round_closest_up(17, 4) = 16 >> * round_closest_up(15, 4) = 16 >> * round_closest_up(14, 4) = 16 >> * round_closest_down(17, 4) = 16 >> * round_closest_down(15, 4) = 16 >> * round_closest_down(14, 4) = 12 >> * roundclosest(21, 5) = 20 >> * roundclosest(19, 5) = 20 >> * roundclosest(17, 5) = 15 > > ... > >> + * Examples : > > It's inconsistent with the other one below. > >> + * round_closest_up(17, 4) = 16 >> + * >> + * round_closest_up(15, 4) = 16 >> + * >> + * round_closest_up(14, 4) = 16 > > The three have TABs/spaces mixture. > > I believe you wanted: > > * Examples:: > * * round_closest_up(17, 4) = 16 > * * round_closest_up(15, 4) = 16 > * * round_closest_up(14, 4) = 16 > I initially referred the style from this link [1] but probably missed to remove extra space from my patch. But what you suggested looks better, I will go with what you suggested. [1] https://elixir.bootlin.com/linux/v6.9/source/include/linux/int_log.h#L22 Regards Devarsh