Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1224001 > unrolled thread

Re: [PATCH v2] clk: add CS2000 Fractional-N driver

Started byGeert Uytterhoeven <geert@linux-m68k.org>
First post2015-09-14 12:20 +0200
Last post2015-09-14 12:20 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v2] clk: add CS2000 Fractional-N driver Geert Uytterhoeven <geert@linux-m68k.org> - 2015-09-14 12:20 +0200

#1224001 — Re: [PATCH v2] clk: add CS2000 Fractional-N driver

FromGeert Uytterhoeven <geert@linux-m68k.org>
Date2015-09-14 12:20 +0200
SubjectRe: [PATCH v2] clk: add CS2000 Fractional-N driver
Message-ID<q8z1E-3fP-5@gated-at.bofh.it>
On Mon, Sep 14, 2015 at 11:47 AM, Kuninori Morimoto
<kuninori.morimoto.gx@renesas.com> wrote:
> +static int cs2000_ratio_set(struct i2c_client *client,
> +                           int ch, u32 rate_in, u32 rate_out)
> +{
> +       u64 val;
> +       unsigned int i;
> +       int ret;
> +
> +       if (CH_SIZE_ERR(ch))
> +               return -EINVAL;
> +
> +       /*
> +        * ratio = rate_out / rate_in * 2^20
> +        *
> +        * To avoid over flow, rate_out is u64
> +        * The result should be u32
> +        */
> +
> +       val = rate_out;
> +       val *= (1 << 20);

val <<= 20

Or

    val = (u64)rate_out << 20;

> +       do_div(val, rate_in);

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web