[openib-general] Re: [PATCH] set eq->nent earlier in mthca_create_eq
Michael S. Tsirkin
mst at mellanox.co.il
Sat Sep 17 11:23:16 PDT 2005
Quoting r. Roland Dreier <rolandd at cisco.com>:
> Subject: Re: [PATCH] set eq->nent earlier in mthca_create_eq
>
> Thanks, good catch.
>
> How about if we get rid of any confusion by just using eq->nent all
> the time? And since we're touching the code anyway, we might as well
> us roundup_pow_of_two()...
>
> How's this seem to you?
>
> --- infiniband/hw/mthca/mthca_eq.c (revision 3432)
> +++ infiniband/hw/mthca/mthca_eq.c (working copy)
> @@ -476,12 +476,8 @@ static int __devinit mthca_create_eq(str
> int i;
> u8 status;
>
> - /* Make sure EQ size is aligned to a power of 2 size. */
> - for (i = 1; i < nent; i <<= 1)
> - ; /* nothing */
> - nent = i;
> -
> - eq->dev = dev;
> + eq->dev = dev;
> + eq->nent = roundup_pow_of_two(nent);
Looks good.
One nit: the min. eq size is 2, and roundup_pow_of_two cant handle 0
parameter. Of course create_eq is an internal function, so we can either
rely on all callers to pass at least 2 as a parameter, or write
roundup_pow_of_two(max(nent, 2))
I suggest the later as a form of documentation.
Thanks,
--
MST
More information about the general
mailing list