From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 5ACA619BD7 for ; Tue, 31 Oct 2023 13:42:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="KLw0FFKk" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6250A9F; Tue, 31 Oct 2023 06:42:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698759767; x=1730295767; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=aJcpi54mkMrL0wdJC8MpLSy7I+gdOKYWH8wlzsQiXAI=; b=KLw0FFKk9Nf812PGKvbS1gYGeMnNrbGW1RY1t+nCzM3si+JEYbf1UMzE wasfcIQCoB5KOXo5GjmstJGq6++2Gfr4sBEpmJJ0Lq26eRiTGFuc6m2Wu i5Lo0bM0qHesBhPRrDfWDxIGxng3tu8dj9Ktn7zty9uEUf0FOmTCH8hmS q4n7dd4kO79EyMW52/isPQtsxp8E35YAvwHNz6DIuFHt07g7AMVIBip+c 1z5a5Ez9dvxzBgBbemqsJTdik8OxxXvPqoIMvmgL08I+8gXFlLXFnQAym FDQE29DsAMPfgf/mS0Z+utWQ4vgVmfS8QZzvnja+gft0gcLNRsRlI0L3r A==; X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="391158031" X-IronPort-AV: E=Sophos;i="6.03,265,1694761200"; d="scan'208";a="391158031" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2023 06:42:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="737070285" X-IronPort-AV: E=Sophos;i="6.03,265,1694761200"; d="scan'208";a="737070285" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga006.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2023 06:42:43 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.97-RC3) (envelope-from ) id 1qxp0y-0000000A9sT-0EmV; Tue, 31 Oct 2023 15:42:40 +0200 Date: Tue, 31 Oct 2023 15:42:39 +0200 From: Andy Shevchenko To: Matti Vaittinen Cc: Jonathan Cameron , Subhajit Ghosh , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Paul Gazzillo , Matt Ranostay , Stefan Windfeldt-Prytz , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] iio: light: Add support for APDS9306 Light Sensor Message-ID: References: <20231027074545.6055-1-subhajit.ghosh@tweaklogic.com> <20231027074545.6055-3-subhajit.ghosh@tweaklogic.com> <20231028162025.4259f1cc@jic23-huawei> <84d7c283-e8e5-4c98-835c-fe3f6ff94f4b@gmail.com> <6a697c62-6a7c-4b31-bc8e-10f40db0363d@gmail.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo On Tue, Oct 31, 2023 at 02:07:46PM +0200, Matti Vaittinen wrote: > On 10/31/23 12:38, Andy Shevchenko wrote: > > On Tue, Oct 31, 2023 at 09:11:37AM +0200, Matti Vaittinen wrote: > > > On 10/30/23 12:21, Matti Vaittinen wrote: > > > > On 10/29/23 17:51, Matti Vaittinen wrote: > > > > > On 10/28/23 18:20, Jonathan Cameron wrote: ... > > > tmp = gts->max_scale; > > > > > > rem = do_div(tmp, total_gain); > > > if (total_gain > 1 && rem >= total_gain / 2) > > > tmp += 1ULL; > > > > ...which is NIH DIV_ROUND_CLOSEST_ULL() > > There is a difference though. The DIV_ROUND_CLOSEST_ULL() does > > tmp + total_gain / 2; > > before division - which in theory may overflow. Then you can fix it there for everybody, no? -- With Best Regards, Andy Shevchenko