In several places, a loop tests for powers of two, or iterates through powers of two. In those places, replace the loop with an invocation of fls or ilog2 without changing the meaning of the code.
Details
Diff Detail
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
Looks good to me.
Potentially of interest are a couple of macros that I spotted in the code: roundup2p, roundup_pow_of_two.
Oh, and there's also ROUNDUP_POW_OF_TWO.
sys/dev/aic7xxx/aic79xx.c | ||
---|---|---|
8596 | This comment explains what the intent of 1 << ilog2() is. However, elsewhere, there isn't this explanatory comment. For most people, I believe that what this is really doing requires some thought. For that reason, I would add a new #define/inline with a self-documenting name. If Linux already has such a #define/inline, I would borrow its name. |
sys/dev/aic7xxx/aic79xx.c | ||
---|---|---|
8596 | The linuxkpi log2.h file has inlines roundup_pow_of_2 adn rounddown_pow_of_2. I could remove those from the linuxkpi file, put them in libkern.h, and use them all over the place. That file also has defined And that's all that's in the include file. Do you wish to see this file entirely absorbed into libkern.h? |
It would be nice if someone added a comment about what the operations in irdma_ctrl.c are doing, but I think I understand them and the replacements look ok to me.
I'll add @bartosz.sobczak_intel.com for his input.