Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1173276rwe; Thu, 1 Sep 2022 13:50:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR5xD6OY0ZD/MxDrY5U9QUu+L0vNeP5gR+f7MISEATt6vjl5hzpYOO3+xd2I63k8nhiCHGc4 X-Received: by 2002:aa7:d612:0:b0:447:7ac7:e686 with SMTP id c18-20020aa7d612000000b004477ac7e686mr30571348edr.145.1662065420547; Thu, 01 Sep 2022 13:50:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662065420; cv=none; d=google.com; s=arc-20160816; b=cwc8kiw1w1kZ5xJCGJCf1LdJBtDtiqyrBj/iQF+QW+86SznczknwH2gFvaNiqST0pe kFO+Di+eLDdDtrLEWjS9wWOIDotuFpcYZNHDL78lRIp5aC7fIe7ykBDSNRjIlvTC3PA0 ZujagcEUd8eENplFa4knOK9Xl2cyl6KhyG9iYpt9VazIL/A10HxeyJf1PwR23XCJ72c4 rSaVytMYBICUQC+rkck6GrDPvcFtdi43+UduJJcApmJOAA+Rpg/eb3kIS1JrTHtVhziA /w8VGnZmhQA8sI/rih7xXBhPv0GmsTuoYuE6b9Y3/zM+5DKRQN5ZgY4vqKw7G8IW3XZw ftpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=bp0TMLnzF3sJ+TFtE85vfsdnm4PLQQA52RHntuKIokc=; b=UZta9MuBsbSoU3PtiuPvwS2oQwQ68WRGitSv9wSKG8+ETzjVPz4rF/itDcvd3sADhM TxVhjjseYjQytv7TFujRBAPucW3qNrVAnfnYRGi/kSz9/8s9eNqPOkVrA6frzozthILJ QlZxmq0VmByxdrr7P9DykJJAQLJlQKNOi5MlIR5Oc+YyD8FDVAn6o8AKK9e/yfyW/77u aY6ECVAVMW2pj7t0qnPkTV2Rakk5TmWObMSt20DzVC5Pw6BpB/Z7wNBIop+EpQ1Je/hv UH5Rh9+nuMkTzoVsQ7eo0kvLO2RzD7b/+ajskHPYNN9cM53jIeH30mzcJ8j90jpOgZjJ WWOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TJayDPsg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q11-20020a1709066acb00b00734b2821879si133492ejs.898.2022.09.01.13.49.49; Thu, 01 Sep 2022 13:50:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TJayDPsg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234747AbiIAUI5 (ORCPT + 99 others); Thu, 1 Sep 2022 16:08:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229584AbiIAUIy (ORCPT ); Thu, 1 Sep 2022 16:08:54 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A77196764; Thu, 1 Sep 2022 13:08:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662062934; x=1693598934; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=tEaao3foBhQw2Xuc0GTtdg6hbZmqlCpEihIK2n8Jim8=; b=TJayDPsgqEjk5tiHztuG8leDRBg/al8Rz3oAz5XsGuKpf7wwwciSmPgK zzAKKuTDefjKawl21R0tm2BFEGZRecURim/V76lpJgKyzl2ovWDs3RP43 vRTSm5k/MrpRiHr8aW06H6CDHswJ57TRD+GE5dM3++Hh9yi9HAlCq1jwO FhQDKE3SwGQkaKEvNYGvVcfzaPcmKXxj1HwlJsuJnh+9jQj0bfZc5ciIi ZPHqukwuLFh6nzjMbjjWCiR9Msi9q5H7LE0r5Xe1TSOTWtP3J6jM786wO wMxzeNNBN74Eq41uNvsAzboWrDa/VFRNBeZzggTeDLNwsqTwCrkFINNK0 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10457"; a="382115562" X-IronPort-AV: E=Sophos;i="5.93,281,1654585200"; d="scan'208";a="382115562" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2022 13:08:53 -0700 X-IronPort-AV: E=Sophos;i="5.93,281,1654585200"; d="scan'208";a="563603640" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2022 13:08:48 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1oTqUX-0071pb-2n; Thu, 01 Sep 2022 23:08:45 +0300 Date: Thu, 1 Sep 2022 23:08:45 +0300 From: Andy Shevchenko To: "Farber, Eliav" Cc: jdelvare@suse.com, linux@roeck-us.net, robh+dt@kernel.org, p.zabel@pengutronix.de, rtanwar@maxlinear.com, linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, talel@amazon.com, hhhawa@amazon.com, jonnyc@amazon.com, hanochu@amazon.com, ronenk@amazon.com, itamark@amazon.com, shellykz@amazon.com, shorer@amazon.com, amitlavi@amazon.com, almogbs@amazon.com, dkl@amazon.com Subject: Re: [PATCH v3 12/19] hwmon: (mr75203) fix voltage equation for negative source input Message-ID: References: <20220830192212.28570-1-farbere@amazon.com> <20220830192212.28570-13-farbere@amazon.com> 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 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 01, 2022 at 03:47:39PM +0300, Farber, Eliav wrote: > On 8/31/2022 3:04 PM, Andy Shevchenko wrote: > > On Tue, Aug 30, 2022 at 07:22:05PM +0000, Eliav Farber wrote: > > > According to Moortec Embedded Voltage Monitor (MEVM) series 3 data > > > sheet, > > > the minimum input signal is -100mv and maximum input signal is +1000mv. > > > When n was small enough, such that PVT_N_CONST * n < PVT_R_CONST it > > > resulted in n overflowing to a very large number (since n is u32 type). > > > > > > This change fixes the problem by casting n to long and replacing shift > > > right with div operation. > > > > Fixes tag? > > For v4 I modified the commit message to (hopefully) be more > understandable: > > " > According to Moortec Embedded Voltage Monitor (MEVM) series 3 data > sheet, the minimum input signal is -100mv and maximum input signal > is +1000mv. > > On 64 bit machines sizeof(u32) = 4 and sizeof(long) = 8. > So when measuring a negative input and n is small enough, such that > PVT_N_CONST * n < PVT_R_CONST, it results in n overflowing to a very > large number which is not negative (because 4 MSB bytes of val are 0). > > This change fixes the sign problem and supports negative values by > casting n to long and replacing shift right with div operation. > " What I meant is to add the tag of the commit which this one is fixing. We have Fixes tag format for that. You may see how it's done by looking into Git history: git log --grep Fixes: -- With Best Regards, Andy Shevchenko