Use enum definition for register offset look up table entry. Signed-off-by: Jun Nie <jun.nie@xxxxxxxxxx> --- drivers/tty/serial/amba-pl011.c | 124 +++++++++++++++++++++------------------- 1 file changed, 66 insertions(+), 58 deletions(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 6db5ee4..6ab3143 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -67,7 +67,6 @@ #define AMBA_ISR_PASS_LIMIT 256 #define REG_NR 19 -#define IDX(x) ((x) >> 2) #define UART_DR_ERROR (UART011_DR_OE|UART011_DR_BE|UART011_DR_PE|UART011_DR_FE) #define UART_DUMMY_DR_RX (1 << 16) @@ -86,6 +85,26 @@ struct vendor_data { unsigned int (*get_fifosize)(struct amba_device *dev); }; +enum reg_idx { + REG_DR = 0, + REG_RSR, + REG_ST_DMAWM, + REG_LCRM, + REG_LCRL, + REG_FR = 6, + REG_LCRH_RX, + REG_ILPR, + REG_IBRD, + REG_FBRD, + REG_LCRH_TX, + REG_CR, + REG_IFLS, + REG_IMSC, + REG_RIS, + REG_MIS, + REG_ICR, + REG_DMACR, +}; #ifdef CONFIG_ARM_AMBA static unsigned int get_fifosize_arm(struct amba_device *dev) @@ -95,25 +114,21 @@ static unsigned int get_fifosize_arm(struct amba_device *dev) static u8 arm_reg[REG_NR] = { /* All registers offset are in order except LCRH as comment */ - [IDX(UART01x_DR)] = UART01x_DR, - [IDX(UART01x_RSR)] = UART01x_RSR, - [IDX(ST_UART011_DMAWM)] = ST_UART011_DMAWM, - [IDX(UART010_LCRM)] = UART010_LCRM, - [IDX(UART010_LCRL)] = UART010_LCRL, - [IDX(UART010_CR)] = UART010_CR, - [IDX(UART01x_FR)] = UART01x_FR, - [IDX(UART011_LCRH_RX)] = UART011_LCRH, /* remapped */ - [IDX(UART01x_ILPR)] = UART01x_ILPR, - [IDX(UART011_IBRD)] = UART011_IBRD, - [IDX(UART011_FBRD)] = UART011_FBRD, - [IDX(UART011_LCRH_TX)] = UART011_LCRH_TX, - [IDX(UART011_CR)] = UART011_CR, - [IDX(UART011_IFLS)] = UART011_IFLS, - [IDX(UART011_IMSC)] = UART011_IMSC, - [IDX(UART011_RIS)] = UART011_RIS, - [IDX(UART011_MIS)] = UART011_MIS, - [IDX(UART011_ICR)] = UART011_ICR, - [IDX(UART011_DMACR)] = UART011_DMACR, + [REG_DR] = UART01x_DR, + [REG_RSR] = UART01x_RSR, + [REG_FR] = UART01x_FR, + [REG_LCRH_RX] = UART011_LCRH, /* remapped */ + [REG_ILPR] = UART01x_ILPR, + [REG_IBRD] = UART011_IBRD, + [REG_FBRD] = UART011_FBRD, + [REG_LCRH_TX] = UART011_LCRH_TX, + [REG_CR] = UART011_CR, + [REG_IFLS] = UART011_IFLS, + [REG_IMSC] = UART011_IMSC, + [REG_RIS] = UART011_RIS, + [REG_MIS] = UART011_MIS, + [REG_ICR] = UART011_ICR, + [REG_DMACR] = UART011_DMACR, }; static struct vendor_data vendor_arm = { @@ -136,25 +151,22 @@ static unsigned int get_fifosize_st(struct amba_device *dev) static u8 st_reg[REG_NR] = { /* All registers offset are in order */ - [IDX(UART01x_DR)] = UART01x_DR, - [IDX(UART01x_RSR)] = UART01x_RSR, - [IDX(ST_UART011_DMAWM)] = ST_UART011_DMAWM, - [IDX(UART010_LCRM)] = UART010_LCRM, - [IDX(UART010_LCRL)] = UART010_LCRL, - [IDX(UART010_CR)] = UART010_CR, - [IDX(UART01x_FR)] = UART01x_FR, - [IDX(UART011_LCRH_RX)] = UART011_LCRH_RX, - [IDX(UART01x_ILPR)] = UART01x_ILPR, - [IDX(UART011_IBRD)] = UART011_IBRD, - [IDX(UART011_FBRD)] = UART011_FBRD, - [IDX(UART011_LCRH_TX)] = UART011_LCRH_TX, - [IDX(UART011_CR)] = UART011_CR, - [IDX(UART011_IFLS)] = UART011_IFLS, - [IDX(UART011_IMSC)] = UART011_IMSC, - [IDX(UART011_RIS)] = UART011_RIS, - [IDX(UART011_MIS)] = UART011_MIS, - [IDX(UART011_ICR)] = UART011_ICR, - [IDX(UART011_DMACR)] = UART011_DMACR, + [REG_DR] = UART01x_DR, + [REG_RSR] = UART01x_RSR, + [REG_ST_DMAWM] = ST_UART011_DMAWM, + [REG_FR] = UART01x_FR, + [REG_LCRH_RX] = ST_UART011_LCRH_RX, + [REG_ILPR] = UART01x_ILPR, + [REG_IBRD] = UART011_IBRD, + [REG_FBRD] = UART011_FBRD, + [REG_LCRH_TX] = UART011_LCRH_TX, + [REG_CR] = UART011_CR, + [REG_IFLS] = UART011_IFLS, + [REG_IMSC] = UART011_IMSC, + [REG_RIS] = UART011_RIS, + [REG_MIS] = UART011_MIS, + [REG_ICR] = UART011_ICR, + [REG_DMACR] = UART011_DMACR, }; static struct vendor_data vendor_st = { @@ -179,25 +191,21 @@ static unsigned int get_fifosize_zx(struct amba_device *dev) static u8 zx_reg[REG_NR] = { /* Registers offset are remapped from origin offset as in comment */ - [IDX(UART01x_DR)] = ZX_UART01x_DR, /* remapped */ - [IDX(UART01x_RSR)] = UART01x_RSR, - [IDX(ST_UART011_DMAWM)] = ST_UART011_DMAWM, - [IDX(UART010_LCRM)] = UART010_LCRM, - [IDX(UART010_LCRL)] = UART010_LCRL, - [IDX(UART010_CR)] = UART010_CR, - [IDX(UART01x_FR)] = ZX_UART01x_FR, /* remapped */ - [IDX(UART011_LCRH_RX)] = UART011_LCRH_RX, - [IDX(UART01x_ILPR)] = UART01x_ILPR, - [IDX(UART011_IBRD)] = UART011_IBRD, - [IDX(UART011_FBRD)] = UART011_FBRD, - [IDX(UART011_LCRH_TX)] = ZX_UART011_LCRH_TX, /* remapped */ - [IDX(UART011_CR)] = ZX_UART011_CR, /* remapped */ - [IDX(UART011_IFLS)] = ZX_UART011_IFLS, /* remapped */ - [IDX(UART011_IMSC)] = ZX_UART011_IMSC, /* remapped */ - [IDX(UART011_RIS)] = UART011_RIS, - [IDX(UART011_MIS)] = ZX_UART011_MIS, /* remapped */ - [IDX(UART011_ICR)] = ZX_UART011_ICR, /* remapped */ - [IDX(UART011_DMACR)] = ZX_UART011_DMACR, /* remapped */ + [REG_DR] = ZX_UART01x_DR, /* remapped */ + [REG_RSR] = UART01x_RSR, + [REG_FR] = ZX_UART01x_FR, /* remapped */ + [REG_LCRH_RX] = UART011_LCRH_RX, + [REG_ILPR] = UART01x_ILPR, + [REG_IBRD] = UART011_IBRD, + [REG_FBRD] = UART011_FBRD, + [REG_LCRH_TX] = ZX_UART011_LCRH_TX, /* remapped */ + [REG_CR] = ZX_UART011_CR, /* remapped */ + [REG_IFLS] = ZX_UART011_IFLS, /* remapped */ + [REG_IMSC] = ZX_UART011_IMSC, /* remapped */ + [REG_RIS] = UART011_RIS, + [REG_MIS] = ZX_UART011_MIS, /* remapped */ + [REG_ICR] = ZX_UART011_ICR, /* remapped */ + [REG_DMACR] = ZX_UART011_DMACR, /* remapped */ }; static struct vendor_data vendor_zx = { -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html