Re: [PATCH v9 3/3] mmc: Add driver for LiteX's LiteSDCard interface

From: Andy Shevchenko
Date: Sun Jan 09 2022 - 06:43:47 EST


On Sun, Jan 9, 2022 at 2:26 AM Gabriel L. Somlo <gsomlo@xxxxxxxxx> 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@xxxxxxxxx> 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) :)

Yeah, I have read that and I think we may survive without comment and
being in two lines.

That roundup_pow_of_two may return int, unsigned long, and who knows
what depending on the per arch implementations.

What a mess...

...

> /* wrapper for use with devm_add_action_or_reset(), below */

No need for this comment.

> static void litex_mmc_free_host_wrapper(void *ptr)
> {

> mmc_free_host((struct mmc_host *)ptr);

Casting is not needed, just name the variable as mmc

mmc_free_host(mmc);

> }

...

> I'll wait till sometime tomorrow for additional feedback on clamp()
> casting and voltage range hard-coding vs. regulators, before I send
> out v10 so we can continue from there.

Thanks!


--
With Best Regards,
Andy Shevchenko