Re: [PATCH v1 11/13] serial: 8250_exar: Use BIT() in exar_ee_read()

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

 



On Thu, 2 May 2024, Andy Shevchenko wrote:

> Use BIT() in exar_ee_read() like other functions do.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> ---
>  drivers/tty/serial/8250/8250_exar.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
> index 306bc6d7c141..bf3730f4231d 100644
> --- a/drivers/tty/serial/8250/8250_exar.c
> +++ b/drivers/tty/serial/8250/8250_exar.c
> @@ -340,13 +340,13 @@ static u16 exar_ee_read(struct exar8250 *priv, u8 ee_addr)
>  	exar_ee_write_bit(priv, 0);
>  
>  	// Send address to read from
> -	for (i = 1 << (UART_EXAR_REGB_EE_ADDR_SIZE - 1); i; i >>= 1)
> -		exar_ee_write_bit(priv, (ee_addr & i));
> +	for (i = UART_EXAR_REGB_EE_ADDR_SIZE - 1; i >= 0; i--)
> +		exar_ee_write_bit(priv, ee_addr & BIT(i));
>  
>  	// Read data 1 bit at a time
>  	for (i = 0; i <= UART_EXAR_REGB_EE_DATA_SIZE; i++) {
> -		data <<= 1;
> -		data |= exar_ee_read_bit(priv);
> +		if (exar_ee_read_bit(priv))
> +			data |= BIT(i);

Does this end up reversing the order of bits? In the original, data was 
left shifted which moved the existing bits and added the lsb but the 
replacement adds highest bit on each iteration?

-- 
 i.





[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux