From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751313AbcFFG1s (ORCPT ); Mon, 6 Jun 2016 02:27:48 -0400 Received: from hqemgate16.nvidia.com ([216.228.121.65]:7621 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750789AbcFFG1q (ORCPT ); Mon, 6 Jun 2016 02:27:46 -0400 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Sun, 05 Jun 2016 23:24:42 -0700 Message-ID: <575514E3.7050802@nvidia.com> Date: Mon, 6 Jun 2016 11:44:59 +0530 From: Laxman Dewangan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Boris Brezillon , Brian Norris CC: Thierry Reding , , Mark Brown , Liam Girdwood , Heiko Stuebner , , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , , , , Milo Kim , Doug Anderson , Caesar Wang , Stephen Barber , Srinivas Kandagatla , Maxime Coquelin , Patrice Chotard , Subject: Re: [PATCH 10/14] regulator: pwm: Switch to the atomic PWM API References: <1464942192-25967-1-git-send-email-boris.brezillon@free-electrons.com> <1464942192-25967-11-git-send-email-boris.brezillon@free-electrons.com> <20160603205028.GH124478@google.com> <20160604082848.0b897b14@bbrezillon> In-Reply-To: <20160604082848.0b897b14@bbrezillon> X-Originating-IP: [10.19.65.30] X-ClientProxiedBy: BGMAIL104.nvidia.com (10.25.59.13) To bgmail102.nvidia.com (10.25.59.11) Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Saturday 04 June 2016 11:58 AM, Boris Brezillon wrote: > On Fri, 3 Jun 2016 13:50:28 -0700 > Brian Norris wrote: > >> + Laxman >> >> Hi, >> >> On Fri, Jun 03, 2016 at 10:23:08AM +0200, Boris Brezillon wrote: >>> - * calculation loss. >>> - */ >>> - req_period = req_diff * pargs.period; >>> - div_u64_rem(req_period, diff, &rem); >>> - if (!rem) { >>> - do_div(req_period, diff); >>> - duty_pulse = (unsigned int)req_period; >>> - } else { >>> - duty_pulse = (pargs.period / 100) * ((req_diff * 100) / diff); >>> - } >>> + /* We pass diff as the scale to get a uV precision. */ >>> + pwm_set_relative_duty_cycle(&pstate, req_diff, diff); >> Notably, you're dropping much of Laxman's commit fd786fb0276a ("regulator: >> pwm: Try to avoid voltage error in duty cycle calculation"), but I >> believe the DIV_ROUND_CLOSEST_ULL() in pwm_set_relative_duty_cycle() >> solves his problem better. > Oops, forgot to comment on that in the commit message. Indeed, the use > of pwm_set_relative_duty_cycle() solves the problem Laxman was seeing. > Yaah, the issue which I was seeing and had fix will be resolved with this also. I wanted to do req_diff * period first before any scaling/division. Function pwm_set_relative_duty_cycle() does the same, and hence it is fine. state->duty_cycle = DIV_ROUND_CLOSEST_ULL((u64)val * state->period, + scale); Acked-by: Laxman Dewangan Thanks, Laxman