devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	linux-gpio@vger.kernel.org, linux-pwm@vger.kernel.org,
	"Alexandru Ardelean" <alexandru.ardelean@analog.com>,
	"Bartosz Golaszewski" <brgl@bgdev.pl>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Lee Jones" <lee@kernel.org>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Rob Herring" <robh@kernel.org>,
	"Uwe Kleine-König" <ukleinek@kernel.org>,
	"Clark Wang" <xiaoning.wang@nxp.com>
Subject: Re: [PATCH v2 4/4] pwm: adp5585: Add Analog Devices ADP5585 support
Date: Wed, 29 May 2024 09:22:54 +0300	[thread overview]
Message-ID: <CAHp75VfpNsSnyXBb6Oy2-qCYXPR9ROimWhC7yTosrKf4YXHciQ@mail.gmail.com> (raw)
In-Reply-To: <20240528202705.GD8500@pendragon.ideasonboard.com>

On Tue, May 28, 2024 at 11:27 PM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> On Tue, May 28, 2024 at 10:41:51PM +0300, Andy Shevchenko wrote:
> > Tue, May 28, 2024 at 10:03:14PM +0300, Laurent Pinchart kirjoitti:

...

> > > +#define ADP5585_PWM_OSC_FREQ_HZ            1000000U
> >
> > (1 * HZ_PER_MHZ) ?
>
> If we had an MHZ macro I would use 1 * MHZ, but I don't think HZ_PER_MHZ
> improves readability here.

We have MEGA. HZ is already the suffix in this definition.

> > > +#define ADP5585_PWM_MIN_PERIOD_NS  (2ULL * NSEC_PER_SEC / ADP5585_PWM_OSC_FREQ_HZ)
> > > +#define ADP5585_PWM_MAX_PERIOD_NS  (2ULL * 0xffff * NSEC_PER_SEC / ADP5585_PWM_OSC_FREQ_HZ)
> >
> > Wouldn't be better to use GENMASK() or (BIT(x) - 1) notation to show that
> > the limit is due to HW register bits in use?
>
> I think that would decrease readability to be honest.

I think it improves the robustness of the code. I always fail to count
3,4,5,6 f:s in those masks, using BIT()/GENMASK() notation makes it
better.

...

> > > +   ret = regmap_write(regmap, ADP5585_PWM_OFFT_LOW,
> > > +                      off & 0xff);
> > > +   if (ret)
> > > +           return ret;
> > > +   ret = regmap_write(regmap, ADP5585_PWM_OFFT_HIGH,
> > > +                      (off >> 8) & 0xff);
> > > +   if (ret)
> > > +           return ret;
> > > +   ret = regmap_write(regmap, ADP5585_PWM_ONT_LOW,
> > > +                      on & 0xff);
> > > +   if (ret)
> > > +           return ret;
> > > +   ret = regmap_write(regmap, ADP5585_PWM_ONT_HIGH,
> > > +                      (on >> 8) & 0xff);
> > > +   if (ret)
> > > +           return ret;
> >
> > Can be proper __le16/__be16 be used in conjunction with regmap bulk API?
>
> What I would really like is regmap growing an API similar to
> include/media/v4l2-cci.h. Any volunteer ? :-)

So, the answer here is yes?

...

> > > +   regmap_read(regmap, ADP5585_PWM_OFFT_LOW, &off);
> > > +   regmap_read(regmap, ADP5585_PWM_OFFT_HIGH, &val);
> > > +   off |= val << 8;
> > > +
> > > +   regmap_read(regmap, ADP5585_PWM_ONT_LOW, &on);
> > > +   regmap_read(regmap, ADP5585_PWM_ONT_HIGH, &val);
> > > +   on |= val << 8;
> >
> > As per above, can it be converted to use proper __le16/__be16 type and
> > regmap bulk API?
>
> As there are only 2 registers, I think that's a bit overkill really.

I do not think so. It increases readability (less LoCs) and improves a
lot of understanding of the hardware layout from reading the code.
Please, consider using it.

...

> > > +   device_set_of_node_from_dev(dev, dev->parent);
> >
> > Why this one? What's wrong with device_set_node()?
>
> See my reply to 3/4.

See additional questions there as well.

-- 
With Best Regards,
Andy Shevchenko

      reply	other threads:[~2024-05-29  6:23 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-28 19:03 [PATCH v2 0/4] ADP5585 GPIO expander, PWM and keypad controller support Laurent Pinchart
2024-05-28 19:03 ` [PATCH v2 1/4] dt-bindings: Add bindings for the Analog Devices ADP5585 Laurent Pinchart
2024-05-28 20:41   ` Rob Herring (Arm)
2024-05-28 20:49     ` Laurent Pinchart
2024-05-28 19:03 ` [PATCH v2 2/4] mfd: adp5585: Add Analog Devices ADP5585 core support Laurent Pinchart
2024-05-28 19:27   ` Andy Shevchenko
2024-05-28 20:13     ` Laurent Pinchart
2024-05-29  5:44       ` Andy Shevchenko
2024-05-29  9:35         ` Laurent Pinchart
2024-05-29 13:38           ` Andy Shevchenko
2024-05-28 19:03 ` [PATCH v2 3/4] gpio: adp5585: Add Analog Devices ADP5585 support Laurent Pinchart
2024-05-28 19:36   ` Andy Shevchenko
2024-05-28 20:20     ` Laurent Pinchart
2024-05-28 20:22       ` Laurent Pinchart
2024-05-28 20:23         ` Laurent Pinchart
2024-05-29  6:16       ` Andy Shevchenko
2024-05-29  9:47         ` Laurent Pinchart
2024-05-29 14:24           ` Andy Shevchenko
2024-05-29 14:35             ` Laurent Pinchart
2024-05-29 15:00               ` Andy Shevchenko
2024-05-29 15:17                 ` Laurent Pinchart
2024-05-28 19:03 ` [PATCH v2 4/4] pwm: " Laurent Pinchart
2024-05-28 19:41   ` Andy Shevchenko
2024-05-28 20:27     ` Laurent Pinchart
2024-05-29  6:22       ` Andy Shevchenko [this message]

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=CAHp75VfpNsSnyXBb6Oy2-qCYXPR9ROimWhC7yTosrKf4YXHciQ@mail.gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=alexandru.ardelean@analog.com \
    --cc=brgl@bgdev.pl \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=lee@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=ukleinek@kernel.org \
    --cc=xiaoning.wang@nxp.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).