diff options
author | Jiri Slaby <jirislaby@kernel.org> | 2023-07-31 10:59:56 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-07-31 17:16:20 +0200 |
commit | fe14cbc604af78348b5790832a5455541d572704 (patch) | |
tree | 71b9822050906a3284c48e94cc2bc0ce44f375f9 /drivers/tty | |
parent | 9b5752d1a882c96c0319aebe55bbfe9ad0c9aa30 (diff) |
tty: synclink_gt: convert CALC_REGADDR() macro to an inline
It makes the code more readable and less error-prone as the result is
returned and not stored in a variable newly defined inside the macro.
Note that cast to 'unsigned long' and back to 'void *' was eliminated as
info->reg_addr is 'char *' already (so the addition is per bytes
already).
This nicely cleans up the callers too.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230731090002.15680-2-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/synclink_gt.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c index 16e469e581ec..00efed2c139e 100644 --- a/drivers/tty/synclink_gt.c +++ b/drivers/tty/synclink_gt.c @@ -3734,47 +3734,47 @@ module_exit(slgt_exit); * register access routines */ -#define CALC_REGADDR() \ - unsigned long reg_addr = ((unsigned long)info->reg_addr) + addr; \ - if (addr >= 0x80) \ - reg_addr += (info->port_num) * 32; \ - else if (addr >= 0x40) \ - reg_addr += (info->port_num) * 16; +static inline void __iomem *calc_regaddr(struct slgt_info *info, + unsigned int addr) +{ + void __iomem *reg_addr = info->reg_addr + addr; + + if (addr >= 0x80) + reg_addr += info->port_num * 32; + else if (addr >= 0x40) + reg_addr += info->port_num * 16; + + return reg_addr; +} static __u8 rd_reg8(struct slgt_info *info, unsigned int addr) { - CALC_REGADDR(); - return readb((void __iomem *)reg_addr); + return readb(calc_regaddr(info, addr)); } static void wr_reg8(struct slgt_info *info, unsigned int addr, __u8 value) { - CALC_REGADDR(); - writeb(value, (void __iomem *)reg_addr); + writeb(value, calc_regaddr(info, addr)); } static __u16 rd_reg16(struct slgt_info *info, unsigned int addr) { - CALC_REGADDR(); - return readw((void __iomem *)reg_addr); + return readw(calc_regaddr(info, addr)); } static void wr_reg16(struct slgt_info *info, unsigned int addr, __u16 value) { - CALC_REGADDR(); - writew(value, (void __iomem *)reg_addr); + writew(value, calc_regaddr(info, addr)); } static __u32 rd_reg32(struct slgt_info *info, unsigned int addr) { - CALC_REGADDR(); - return readl((void __iomem *)reg_addr); + return readl(calc_regaddr(info, addr)); } static void wr_reg32(struct slgt_info *info, unsigned int addr, __u32 value) { - CALC_REGADDR(); - writel(value, (void __iomem *)reg_addr); + writel(value, calc_regaddr(info, addr)); } static void rdma_reset(struct slgt_info *info) |