From: Stephen Boyd <sboyd@kernel.org>
To: "Martin Povišer" <povik@protonmail.com>
Cc: "Martin Povišer" <povik+lin@protonmail.com>,
"Michael Turquette" <mturquette@baylibre.com>,
"Rob Herring" <robh+dt@kernel.org>,
"Hector Martin" <marcan@marcan.st>,
"Sven Peter" <sven@svenpeter.dev>,
alyssa@rosenzweig.io, linux-clk <linux-clk@vger.kernel.org>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
"Mark Kettenis" <kettenis@openbsd.org>
Subject: Re: [PATCH v2 2/3] clk: clk-apple-nco: Add driver for Apple NCO
Date: Thu, 20 Jan 2022 12:59:05 -0800 [thread overview]
Message-ID: <20220120205907.4E365C340E0@smtp.kernel.org> (raw)
In-Reply-To: <ED361B6C-0BE2-4FDD-AF29-497E14A183A6@protonmail.com>
Quoting Martin Povišer (2022-01-20 04:11:34)
>
> > On 20. 1. 2022, at 6:38, Stephen Boyd <sboyd@kernel.org> wrote:
> >
> > Quoting Martin Povišer (2022-01-18 11:21:10)
> >> +
> >> +static int nco_set_rate(struct clk_hw *hw, unsigned long rate,
> >> + unsigned long parent_rate)
> >> +{
> >> + struct nco_channel *chan = to_nco_channel(hw);
> >> + unsigned long flags;
> >> + u32 div;
> >> + s32 inc1, inc2;
> >> + bool was_enabled;
> >> +
> >> + div = 2 * parent_rate / rate;
> >> + inc1 = 2 * parent_rate - div * rate;
> >> + inc2 = -((s32) (rate - inc1));
> >
> > Is the cast necessary?
>
> Answering that prompted me to get back to reading some C specification and now
> I am confident in moving away from signed types here and in nco_recalc_rate
> altogether.
Great! Operating with only unsigned types makes this easier to
understand.
> >> + struct nco_tables *tbl;
> >> + unsigned int nchannels;
> >> + int ret, i;
> >> +
> >> + regs = devm_platform_get_and_ioremap_resource(pdev, 0, ®s_res);
> >> + if (IS_ERR(regs))
> >> + return PTR_ERR(regs);
> >> +
> >> + if (resource_size(regs_res) < NCO_CHANNEL_REGSIZE)
> >> + return -EINVAL;
> >> + nchannels = (resource_size(regs_res) - NCO_CHANNEL_REGSIZE)
> >> + / NCO_CHANNEL_STRIDE + 1;
> >
> > Is this some sort of DIV_ROUND_UP()?
>
> Almost. I will shop around for a macro replacement.
Alright.
next prev parent reply other threads:[~2022-01-20 20:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-18 19:20 [PATCH v2 0/3] Support for Apple SoCs' NCO blocks Martin Povišer
2022-01-18 19:21 ` [PATCH v2 1/3] dt-bindings: clock: Add Apple NCO Martin Povišer
2022-01-18 22:00 ` Mark Kettenis
2022-01-19 2:55 ` Rob Herring
2022-01-19 14:01 ` Rob Herring
2022-01-18 19:21 ` [PATCH v2 2/3] clk: clk-apple-nco: Add driver for " Martin Povišer
2022-01-20 5:38 ` Stephen Boyd
2022-01-20 12:11 ` Martin Povišer
2022-01-20 20:59 ` Stephen Boyd [this message]
2022-01-18 19:21 ` [PATCH v2 3/3] MAINTAINERS: Add clk-apple-nco under ARM/APPLE MACHINE Martin Povišer
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=20220120205907.4E365C340E0@smtp.kernel.org \
--to=sboyd@kernel.org \
--cc=alyssa@rosenzweig.io \
--cc=devicetree@vger.kernel.org \
--cc=kettenis@openbsd.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcan@marcan.st \
--cc=mturquette@baylibre.com \
--cc=povik+lin@protonmail.com \
--cc=povik@protonmail.com \
--cc=robh+dt@kernel.org \
--cc=sven@svenpeter.dev \
/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).