lkml.org 
[lkml]   [2022]   [Jan]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2 2/3] clk: clk-apple-nco: Add driver for Apple NCO
From
Date
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, &regs_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.

\
 
 \ /
  Last update: 2022-01-20 22:00    [W:0.065 / U:1.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site