From: mturquette@linaro.org (Mike Turquette)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] clk: Add axi-clkgen driver
Date: Tue, 22 Jan 2013 09:55:52 -0800 [thread overview]
Message-ID: <20130122175552.24671.27893@quantum> (raw)
In-Reply-To: <1357755120-32735-1-git-send-email-lars@metafoo.de>
Quoting Lars-Peter Clausen (2013-01-09 10:12:00)
<snip>
> +static void axi_clkgen_write(struct axi_clkgen *axi_clkgen,
> + unsigned int reg, unsigned int val)
> +{
> + iowrite32(val, axi_clkgen->base + reg);
Silly question: any reason to use this over readl()? This is more for
my understanding than a real criticism.
> +}
> +
> +static void axi_clkgen_read(struct axi_clkgen *axi_clkgen,
> + unsigned int reg, unsigned int *val)
> +{
> + *val = ioread32(axi_clkgen->base + reg);
Same as above, any reason to use this over writel?
<snip>
> +static unsigned long axi_clkgen_recalc_rate(struct clk_hw *clk_hw,
> + unsigned long parent_rate)
> +{
> + struct axi_clkgen *axi_clkgen = clk_hw_to_axi_clkgen(clk_hw);
> + unsigned int d, m, dout;
> + unsigned int reg;
> +
> + axi_clkgen_read(axi_clkgen, AXI_CLKGEN_REG_CLK_OUT1, ®);
> + dout = (reg & 0x3f) + ((reg >> 6) & 0x3f);
> + axi_clkgen_read(axi_clkgen, AXI_CLKGEN_REG_CLK_DIV, ®);
> + d = (reg & 0x3f) + ((reg >> 6) & 0x3f);
> + axi_clkgen_read(axi_clkgen, AXI_CLKGEN_REG_CLK_FB1, ®);
> + m = (reg & 0x3f) + ((reg >> 6) & 0x3f);
> +
> + if (d == 0 || dout == 0)
> + return 0;
> +
> + return parent_rate / d * m / dout;
Any chance of overflow here? Maybe do_div should be used?
Regards,
Mike
next prev parent reply other threads:[~2013-01-22 17:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-09 18:12 [PATCH] clk: Add axi-clkgen driver Lars-Peter Clausen
2013-01-22 17:55 ` Mike Turquette [this message]
2013-01-23 10:00 ` Lars-Peter Clausen
2013-01-23 10:27 ` Russell King - ARM Linux
2013-01-23 10:49 ` Lars-Peter Clausen
2013-01-23 10:57 ` Russell King - ARM Linux
2013-01-22 18:08 ` Josh Cartwright
2013-01-23 9:57 ` Lars-Peter Clausen
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=20130122175552.24671.27893@quantum \
--to=mturquette@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/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).