Re: [PATCH v2 3/4] mmc: renesas_sdhi: Fix sampling clock position selecting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Wolfram,

Thanks for your feedback.

On 2018-07-18 11:44:13 +0200, Wolfram Sang wrote:
> 
> > > 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?
> > 
> > I agree that the loop is clumsy. Unfortunately I can't find any bitmap 
> > operations that work with bit patterns. If this where just integers the 
> > following would have been a better solution:
> > 
> >     mask = (1 << host->tap_num) - 1;
> >     taps = (host->taps & (host->taps >> host->tap_num)) & mask;
> >     host->taps = (taps << host->tap_num) | taps;
> 
> My above sketch doesn't work?
> 
> 	for (i = 0; i < host->tap_num; i++) {
> 		mask = BIT(i) | BIT(i + host->tap_num);
> 		if (host->taps & mask != mask)
> 			host->taps &= ~mask;
> 	}
> 
> Written from top of my head, maybe I overlooked something.
> 

Unfortunately not as host->taps is declared as a bitmap

    DECLARE_BITMAP(taps, BITS_PER_BYTE * sizeof(long));

So trying your sketch results in errors.

drivers/mmc/host/renesas_sdhi_core.c:394:32: error: invalid operands to binary & (have 'long unsigned int *' and 'int')
                 if (host->taps & mask != mask)
                     ~~~~       ^ ~~~~~~~~~~~~
drivers/mmc/host/renesas_sdhi_core.c:395:36: error: assignment to expression with array type
                         host->taps &= ~mask;

I'm sure one could dereference the host->taps variable and do the bit 
operations but that feels like a bad idea. The other option is to use 
bitmap_{from,to}_arr32() to access the bitmap as 32 bit integers but 
that too feels odd and more complex then using the bitmap helper 
functions.

I will await your feedback before on this before I post the next version 
of this series.

-- 
Regards,
Niklas Söderlund
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux