linux-amlogic.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: linux-pwm@vger.kernel.org,
	Neil Armstrong <narmstrong@baylibre.com>,
	bichao.zheng@amlogic.com, linux-kernel@vger.kernel.org,
	thierry.reding@gmail.com, linux-amlogic@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org, jbrunet@baylibre.com
Subject: Re: [PATCH 1/2] pwm: meson: consider 128 a valid pre-divider
Date: Tue, 2 Apr 2019 21:55:54 +0200	[thread overview]
Message-ID: <20190402195554.5efbtjr6bswoigzt@pengutronix.de> (raw)
In-Reply-To: <CAFBinCDac9189=+UVLPLqdmJsJvudys_L0GE=Zf0FRkOWsruuw@mail.gmail.com>

On Tue, Apr 02, 2019 at 09:22:55PM +0200, Martin Blumenstingl wrote:
> Hello Uwe,
> 
> On Mon, Apr 1, 2019 at 8:38 PM Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> wrote:
> >
> > Hello Martin,
> >
> > On Mon, Apr 01, 2019 at 08:18:16PM +0200, Martin Blumenstingl wrote:
> > > diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
> > > index f6e738ad7bd9..4b708c1fcb1d 100644
> > > --- a/drivers/pwm/pwm-meson.c
> > > +++ b/drivers/pwm/pwm-meson.c
> > > @@ -188,7 +188,7 @@ static int meson_pwm_calc(struct meson_pwm *meson,
> > >       do_div(fin_ps, fin_freq);
> > >
> > >       /* Calc pre_div with the period */
> > > -     for (pre_div = 0; pre_div < MISC_CLK_DIV_MASK; pre_div++) {
> > > +     for (pre_div = 0; pre_div <= MISC_CLK_DIV_MASK; pre_div++) {
> > >               cnt = DIV_ROUND_CLOSEST_ULL((u64)period * 1000,
> > >                                           fin_ps * (pre_div + 1));
> > >               dev_dbg(meson->chip.dev, "fin_ps=%llu pre_div=%u cnt=%u\n",
> >
> > You could even calculate pre_div without the loop.
> >
> > Something like:
> >
> >         u64 pre_div = (u64)period * rate;
> >         do_div_round_up(pre_div, NSEC_PER_SEC * 0xffff);
> >         pre_div--;
> >
> > (I didn't check rounding and maybe its off by one and ...) This would
> > also get rid of the strange 1000 that is currently used in the
> > calculation without a real benefit (unless I missed something).
> personally I prefer using this simple patch applied first as it is
> easy to review and (due to the Fixes tag) may get backported to stable
> kernels.
> I'm not saying I don't like your suggestion, I propose to postpone
> implementing this cleanup. I need to have a closer look at the
> calculation because three values are derived from the input clock rate
> (pre_div, cnt, duty_cnt) and I don't want to mess up the cases that
> are already working as of today.
> 
> Please let me know what you think.

That's also ok for me. In this case take my

Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

  reply	other threads:[~2019-04-02 19:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-01 18:18 [PATCH 0/2] pwm: meson: two small bug-fixes Martin Blumenstingl
2019-04-01 18:18 ` [PATCH 1/2] pwm: meson: consider 128 a valid pre-divider Martin Blumenstingl
2019-04-01 18:38   ` Uwe Kleine-König
2019-04-02 19:22     ` Martin Blumenstingl
2019-04-02 19:55       ` Uwe Kleine-König [this message]
2019-04-03 11:19   ` Neil Armstrong
2019-04-01 18:18 ` [PATCH 2/2] pwm: meson: don't disable pwm when setting duty repeatedly Martin Blumenstingl
2019-04-03 11:19   ` Neil Armstrong
2019-05-09 14:52 ` [PATCH 0/2] pwm: meson: two small bug-fixes Thierry Reding

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=20190402195554.5efbtjr6bswoigzt@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=bichao.zheng@amlogic.com \
    --cc=jbrunet@baylibre.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=narmstrong@baylibre.com \
    --cc=thierry.reding@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).