linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Richardson <jonathar@broadcom.com>
To: Tim Kryger <tim.kryger@gmail.com>
Cc: Dmitry Torokhov <dtor@google.com>,
	Anatol Pomazau <anatol@google.com>,
	Arun Ramamurthy <arun.ramamurthy@broadcom.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	Scott Branden <sbranden@broadcom.com>,
	bcm-kernel-feedback-list <bcm-kernel-feedback-list@broadcom.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux PWM <linux-pwm@vger.kernel.org>
Subject: Re: [PATCH v8 4/5] pwm: kona: Add debug info to config function
Date: Fri, 12 Jun 2015 14:29:33 -0700	[thread overview]
Message-ID: <557B4F3D.2000001@broadcom.com> (raw)
In-Reply-To: <CAD7vxx+vaghG+Vc+wKYbGV69cj=XF9Wj+r18BNj=_gW9oyGGag@mail.gmail.com>

On 15-05-30 09:42 AM, Tim Kryger wrote:
> On Tue, May 26, 2015 at 1:08 PM, Jonathan Richardson
> <jonathar@broadcom.com> wrote:
>> Adds debugging info to config function where duty cycle and period
>> are calculated and verified.
>>
>> Signed-off-by: Jonathan Richardson <jonathar@broadcom.com>
>> ---
>>  drivers/pwm/pwm-bcm-kona.c |   25 +++++++++++++++++++++++--
>>  1 file changed, 23 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/pwm/pwm-bcm-kona.c b/drivers/pwm/pwm-bcm-kona.c
>> index c87621f..0ddf19b 100644
>> --- a/drivers/pwm/pwm-bcm-kona.c
>> +++ b/drivers/pwm/pwm-bcm-kona.c
>> @@ -138,18 +138,39 @@ static int kona_pwmc_config(struct pwm_chip *chip, struct pwm_device *pwm,
>>                 dc = div64_u64(val, div);
>>
>>                 /* If duty_ns or period_ns are not achievable then return */
>> -               if (pc < PERIOD_COUNT_MIN || dc < DUTY_CYCLE_HIGH_MIN)
> 
> The original code was based on the SPEAr PWM driver which has a non-zero
> PWMDCR_MIN_DUTY such that the second condition here can evaluate to true.
> 
> This isn't the case for the Kona PWM where DUTY_CYCLE_HIGH_MIN is zero.
> 
>> +               if (pc < PERIOD_COUNT_MIN) {
>> +                       dev_warn(chip->dev,
>> +                               "%s: pwm[%d]: period=%d is not achievable, pc=%lu, prescale=%lu\n",
>> +                               __func__, chan, period_ns, pc, prescale);
>>                         return -EINVAL;
>> +               }
> 
> Why not just print the minimum allowable period with the provided clock?
> 
> I don't think pc and prescale will be particularly helpful to users.
> 
> Also, do we really need to print __func__ here?
> 
>> +
>> +               if (dc < DUTY_CYCLE_HIGH_MIN) {
>> +                       if (0 != duty_ns) {
>> +                               dev_warn(chip->dev,
>> +                                       "%s: pwm[%d]: duty cycle=%d is not achievable, dc=%lu, prescale=%lu\n",
>> +                                       __func__, chan, duty_ns, dc, prescale);
>> +                       }
>> +                       return -EINVAL;
>> +               }
> 
> The above block is unreachable code.
> 
>>
>>                 /* If pc and dc are in bounds, the calculation is done */
>>                 if (pc <= PERIOD_COUNT_MAX && dc <= DUTY_CYCLE_HIGH_MAX)
>>                         break;
>>
>>                 /* Otherwise, increase prescale and recalculate pc and dc */
>> -               if (++prescale > PRESCALE_MAX)
>> +               if (++prescale > PRESCALE_MAX) {
>> +                       dev_warn(chip->dev,
>> +                               "%s: pwm[%d]: Prescale (=%lu) within max (=%d) for period=%d and duty cycle=%d is not achievable\n",
>> +                               __func__, chan, prescale, PRESCALE_MAX,
>> +                               period_ns, duty_ns);
>>                         return -EINVAL;
>> +               }
>>         }
> 
> The user got here because they specified a period larger than the maximum
> supported so why not tell them largest value that can be supported instead
> of confusing them with prescale and PRESCALE_MAX?
> 
>>
>> +       dev_dbg(chip->dev, "pwm[%d]: period=%lu, duty_high=%lu, prescale=%lu\n",
>> +               chan, pc, dc, prescale);
>> +
> 
> This could be more clear.  It prints pc but calls it period.
> 
>>         /*
>>          * Don't apply settings if disabled. The period and duty cycle are
>>          * always calculated above to ensure the new values are
>> --
>> 1.7.9.5
>>

We can defer this for now until I can look into it further. It's not a
priority. I'm more concerned with core changes and kona pwm fix.

Thanks,
Jon

  reply	other threads:[~2015-06-12 21:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-26 20:08 [PATCH v8 0/5] Fix bugs in kona pwm driver and pwm core Jonathan Richardson
2015-05-26 20:08 ` [PATCH v8 1/5] drivers: pwm: core: Add pwmchip_add_inversed Jonathan Richardson
2015-06-12  9:45   ` Thierry Reding
2015-06-15  0:51     ` Tim Kryger
2015-05-26 20:08 ` [PATCH v8 2/5] drivers: pwm: bcm-kona: Dont set polarity in probe Jonathan Richardson
2015-06-12  9:46   ` Thierry Reding
2015-05-26 20:08 ` [PATCH v8 3/5] pwm: kona: Fix incorrect config, disable, and polarity procedures Jonathan Richardson
2015-05-30 16:41   ` Tim Kryger
2015-06-12 21:28     ` Jonathan Richardson
2015-05-26 20:08 ` [PATCH v8 4/5] pwm: kona: Add debug info to config function Jonathan Richardson
2015-05-30 16:42   ` Tim Kryger
2015-06-12 21:29     ` Jonathan Richardson [this message]
2015-05-26 20:08 ` [PATCH v8 5/5] pwm: core: Set enable state properly on failed call to enable Jonathan Richardson
2015-06-12  9:49   ` Thierry Reding
2015-06-12 19:22     ` Jonathan Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=557B4F3D.2000001@broadcom.com \
    --to=jonathar@broadcom.com \
    --cc=anatol@google.com \
    --cc=arun.ramamurthy@broadcom.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=dtor@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=sbranden@broadcom.com \
    --cc=thierry.reding@gmail.com \
    --cc=tim.kryger@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).