Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

serial: 8250_exar: Use BIT() in exar_ee_read()

Use BIT() in exar_ee_read() like other functions do.

While at it, explain the EEPROM type and the dummy bit requirement.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Parker Newman <pnewman@connecttech.com>
Link: https://lore.kernel.org/r/20240503171917.2921250-12-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Andy Shevchenko and committed by
Greg Kroah-Hartman
3c089d7e d72c3018

+7 -6
+7 -6
drivers/tty/serial/8250/8250_exar.c
··· 324 324 * @ee_addr: Offset of EEPROM to read word from 325 325 * 326 326 * Read a single 16bit word from an Exar UART's EEPROM. 327 + * The type of the EEPROM is AT93C46D. 327 328 * 328 329 * Return: EEPROM word 329 330 */ ··· 341 340 exar_ee_write_bit(priv, 0); 342 341 343 342 // Send address to read from 344 - for (i = 1 << (UART_EXAR_REGB_EE_ADDR_SIZE - 1); i; i >>= 1) 345 - exar_ee_write_bit(priv, (ee_addr & i)); 343 + for (i = UART_EXAR_REGB_EE_ADDR_SIZE - 1; i >= 0; i--) 344 + exar_ee_write_bit(priv, ee_addr & BIT(i)); 346 345 347 - // Read data 1 bit at a time 348 - for (i = 0; i <= UART_EXAR_REGB_EE_DATA_SIZE; i++) { 349 - data <<= 1; 350 - data |= exar_ee_read_bit(priv); 346 + // Read data 1 bit at a time starting with a dummy bit 347 + for (i = UART_EXAR_REGB_EE_DATA_SIZE; i >= 0; i--) { 348 + if (exar_ee_read_bit(priv)) 349 + data |= BIT(i); 351 350 } 352 351 353 352 exar_ee_deselect(priv);