linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Esteban Blanc" <eblanc@baylibre.com>
To: "Andy Shevchenko" <andy.shevchenko@gmail.com>
Cc: <linus.walleij@linaro.org>, <lgirdwood@gmail.com>,
	<broonie@kernel.org>, <a.zummo@towertech.it>,
	<alexandre.belloni@bootlin.com>, <linux-kernel@vger.kernel.org>,
	<linux-gpio@vger.kernel.org>, <linux-rtc@vger.kernel.org>,
	<jpanis@baylibre.com>, <jneanne@baylibre.com>,
	<aseketeli@baylibre.com>, <sterzik@ti.com>, <u-kumar1@ti.com>
Subject: Re: [PATCH v4 1/3] rtc: tps6594: Add driver for TPS6594 RTC
Date: Mon, 22 May 2023 13:49:58 +0200	[thread overview]
Message-ID: <CSSS892QYLWK.3T71MRNHOH0IZ@burritosblues> (raw)
In-Reply-To: <CAHp75Vfg+yAhJ58qt76GHqxWHD48hF-6ZnT=xEUh+1rzr7UvVg@mail.gmail.com>

On Wed May 17, 2023 at 6:52 PM CEST, Andy Shevchenko wrote:
> On Wed, May 17, 2023 at 7:47 PM Esteban Blanc <eblanc@baylibre.com> wrote:
> > On Fri May 12, 2023 at 7:22 PM CEST,  wrote:
> > > Fri, May 12, 2023 at 04:17:53PM +0200, Esteban Blanc kirjoitti:
>
> ...
>
> > > > +/* Multiplier for ppb conversions */
> > > > +#define PPB_MULT (1000000000LL)
> > >
> > > We have something in units.h. Can you use generic macro?
> >
> > I found GIGA, NANO and NANOHZ_PER_HZ that have the same value in
> > units.h. However I'm not sure any of them have the correct meaning in
> > this situation.
>
> MULT[IPLIER] has no units AFAIU, so SI macro can be used, no? NANO or
> GIGA depends on what the actual sign of the exponent of the multiplier
> is. Write it on paper and check the exponent in the equation(s) and
> hence decide which one to use.

Thanks. I've checked and it should be NANO.

> > > > +   if (tmp < 0)
> > > > +           tmp -= TICKS_PER_HOUR / 2LL;
> > > > +   else
> > > > +           tmp += TICKS_PER_HOUR / 2LL;
> > >
> > > Is it guaranteed to have no overflow here?
> >
> > We know from `tps6594_rtc_set_offset` that the loaded value can't be
> > more than 277774 (register default value is 0), So `tmp` can't exceed
> > 277774000000000 which is lower than 2^63-1. No overflow here.
> >
> > TICK_PER_HOUR / 2LL = 117964800, so at the end of this computation,
> > `tmp` can have a maximum value of 277774117964800 which is still
> > inferior to 2^63-1.
>
> Please add a respective comment.

I've reformatted this and put it in a SAFETY comment.

Thanks for your help,

-- 
Esteban Blanc
BayLibre

  reply	other threads:[~2023-05-22 11:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-12 14:17 [PATCH v4 0/3] TI TPS6594 PMIC support (RTC, pinctrl, regulators) Esteban Blanc
2023-05-12 14:17 ` [PATCH v4 1/3] rtc: tps6594: Add driver for TPS6594 RTC Esteban Blanc
2023-05-12 17:22   ` andy.shevchenko
2023-05-17 16:47     ` Esteban Blanc
2023-05-17 16:52       ` Andy Shevchenko
2023-05-22 11:49         ` Esteban Blanc [this message]
2023-05-12 14:17 ` [PATCH v4 2/3] pinctrl: tps6594: Add driver for TPS6594 pinctrl and GPIOs Esteban Blanc
2023-05-12 17:07   ` andy.shevchenko
2023-05-16 13:05     ` Esteban Blanc
2023-05-16 16:48       ` Andy Shevchenko
2023-05-17  9:58         ` Esteban Blanc
2023-05-17 13:51           ` Andy Shevchenko
2023-05-17 14:43             ` Esteban Blanc
2023-05-17 15:04               ` Andy Shevchenko
2023-05-22  8:45                 ` Esteban Blanc
2023-05-23  9:26                 ` Esteban Blanc
2023-05-23 11:03                   ` Andy Shevchenko
2023-05-23 11:32                     ` Esteban Blanc
2023-05-12 14:17 ` [PATCH v4 3/3] regulator: tps6594-regulator: Add driver for TI TPS6594 regulators Esteban Blanc
2023-05-12 17:34   ` andy.shevchenko

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=CSSS892QYLWK.3T71MRNHOH0IZ@burritosblues \
    --to=eblanc@baylibre.com \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=aseketeli@baylibre.com \
    --cc=broonie@kernel.org \
    --cc=jneanne@baylibre.com \
    --cc=jpanis@baylibre.com \
    --cc=lgirdwood@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=sterzik@ti.com \
    --cc=u-kumar1@ti.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).