Quoting Martin Povišer (2022-01-20 04:11:34) > > > On 20. 1. 2022, at 6:38, Stephen Boyd <sboyd@xxxxxxxxxx> 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.