Messages in this thread | | | From | Geert Uytterhoeven <> | Date | Mon, 10 Jan 2022 09:25:58 +0100 | Subject | Re: [PATCH v9 3/3] mmc: Add driver for LiteX's LiteSDCard interface |
| |
Hi Gabriel,
On Sun, Jan 9, 2022 at 1:26 AM Gabriel L. Somlo <gsomlo@gmail.com> wrote: > On Sat, Jan 08, 2022 at 07:43:19PM +0200, Andy Shevchenko wrote: > > On Sat, Jan 8, 2022 at 6:11 PM Gabriel Somlo <gsomlo@gmail.com> wrote: > > > + u32 div; > > > + > > > + div = freq ? host->ref_clk / freq : 256U; > > > > > + div = roundup_pow_of_two(div); > > > + div = clamp(div, 2U, 256U); > > > > Not sure why it becomes two lines again. > > Per my previous email, I have: > > div = clamp((u32)roundup_pow_of_two(div), 2U, 256U); > > ... lined up for v10 (pending also Geert's OK on the (u32) cast > to shut up compiler warnings) :)
JFY (as you decided to keep the two separate lines), this is exactly why clamp_t()exists: to avoid the explicit cast.
i.e.
div = clamp_t(u32, roundup_pow_of_two(div), 2U, 256U);
or
div = clamp_t(u32, roundup_pow_of_two(div), 2, 256);
(the implicit cast is applied to all parameters).
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
| |