Re: [PATCH v3 4/4] media: rcar-csi2: Add D-PHY support for V4H

From: Geert Uytterhoeven
Date: Thu Jun 12 2025 - 07:20:20 EST


On Thu, 12 Jun 2025 at 12:01, Niklas Söderlund
<niklas.soderlund+renesas@xxxxxxxxxxxx> wrote:
> On 2025-06-12 02:04:12 +0300, Laurent Pinchart wrote:
> > > --- a/drivers/media/platform/renesas/rcar-csi2.c
> > > +++ b/drivers/media/platform/renesas/rcar-csi2.c
> > > + if (mbps >= 80) {
> > > + if (mbps >= 2560)
> > > + val = 6;
> > > + else if (mbps >= 1280)
> > > + val = 5;
> > > + else if (mbps >= 640)
> > > + val = 4;
> > > + else if (mbps >= 320)
> > > + val = 3;
> > > + else if (mbps >= 160)
> > > + val = 2;
> > > + else if (mbps >= 80)
> > > + val = 1;
> >
> > You could possibly replace this with
> >
> > val = ilog2(mbps / 80) + 1;
> >
> > Up to you.
>
> I opted to keep it as is to make it easier to match with the datasheet.
> The ilog2() is clever but I will never remember why it was used ;-)

+1 for ilog2() ;-)

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

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