summaryrefslogtreecommitdiff
path: root/drivers/tty
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2024-05-03 20:16:03 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-05-04 18:09:30 +0200
commit3c089d7ebfcb31ad6fb0530970a32303b1168991 (patch)
tree9cac0515b354e6576597ce0e25b169d4b1de1e1c /drivers/tty
parentd72c3018300e86590b2d5037fe959d040e50cd33 (diff)
downloadlwn-3c089d7ebfcb31ad6fb0530970a32303b1168991.tar.gz
lwn-3c089d7ebfcb31ad6fb0530970a32303b1168991.zip
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>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/8250/8250_exar.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index 306bc6d7c141..93d2c8dd3cd8 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -324,6 +324,7 @@ static inline u8 exar_ee_read_bit(struct exar8250 *priv)
* @ee_addr: Offset of EEPROM to read word from
*
* Read a single 16bit word from an Exar UART's EEPROM.
+ * The type of the EEPROM is AT93C46D.
*
* Return: EEPROM word
*/
@@ -340,13 +341,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);
+ // Read data 1 bit at a time starting with a dummy bit
+ for (i = UART_EXAR_REGB_EE_DATA_SIZE; i >= 0; i--) {
+ if (exar_ee_read_bit(priv))
+ data |= BIT(i);
}
exar_ee_deselect(priv);