On Thu, Jul 05, 2018 at 04:18:40PM +0200, Niklas Söderlund wrote:
> From: Masaharu Hayakawa <[email protected]>
>
> When tuning each tap is issued CMD19 twice and the result of both runs
> recorded in host->taps. If the result is different between the two runs
> the wrong sampling clock position was selected. Fix this by merging the
> two runs and only keep the result for each tap if it was good in both
> sets.
>
> Signed-off-by: Masaharu Hayakawa <[email protected]>
> [Niklas: update commit message]
> Signed-off-by: Niklas Söderlund <[email protected]>
Much better commit message.
> + for (i = 0; i < host->tap_num * 2; i++) {
> + if (!test_bit(i, host->taps)) {
> + clear_bit(i % host->tap_num, host->taps);
> + clear_bit((i % host->tap_num) + host->tap_num,
> + host->taps);
> + }
> + }
I just think the code is a bit clumsy maybe?
a) it clears the bit which is already cleared
b) if a bit in the first half clears a bit in the second half,
they will both be cleared again when the loop processes the
second half
One idea I have is to let the loop iterate only over tap_num and then
use a mask 'BIT(i) | BIT(i+tap_num)' and work with binary operators
then. But maybe there are also macros to test and clear bit patterns?
And Geert's comment.