diff options
author | Matthew Leach <matthew@mattleach.net> | 2016-06-22 19:57:03 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-06-26 00:04:12 +0300 |
commit | bbb5ff91225dfbf3e5c27619552e41661048ed61 (patch) | |
tree | a675a32e89dca885304a9b34c581290f59515289 /drivers/tty/serial/samsung.h | |
parent | e37697b3f75464dbf86ecb0f480eb11581cc75d2 (diff) | |
download | linux-bbb5ff91225dfbf3e5c27619552e41661048ed61.tar.xz |
tty: serial: samsung: add byte-order aware bit functions
This driver makes use of the __set_bit() and __clear_bit() functions.
When running under big-endian, these functions don't convert the bit
indexes when working with peripheral registers, leading to the
incorrect bits being set and cleared when running big-endian.
Add two new driver functions for setting and clearing bits that are
byte-order aware.
Signed-off-by: Matthew Leach <matthew@mattleach.net>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/samsung.h')
-rw-r--r-- | drivers/tty/serial/samsung.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/tty/serial/samsung.h b/drivers/tty/serial/samsung.h index 8f96b715a7b0..2ae4fcee1814 100644 --- a/drivers/tty/serial/samsung.h +++ b/drivers/tty/serial/samsung.h @@ -123,4 +123,32 @@ struct s3c24xx_uart_port { #define wr_regb(port, reg, val) writeb_relaxed(val, portaddr(port, reg)) #define wr_regl(port, reg, val) writel_relaxed(val, portaddr(port, reg)) +/* Byte-order aware bit setting/clearing functions. */ + +static inline void s3c24xx_set_bit(struct uart_port *port, int idx, + unsigned int reg) +{ + unsigned long flags; + u32 val; + + local_irq_save(flags); + val = rd_regl(port, reg); + val |= (1 << idx); + wr_regl(port, reg, val); + local_irq_restore(flags); +} + +static inline void s3c24xx_clear_bit(struct uart_port *port, int idx, + unsigned int reg) +{ + unsigned long flags; + u32 val; + + local_irq_save(flags); + val = rd_regl(port, reg); + val &= ~(1 << idx); + wr_regl(port, reg, val); + local_irq_restore(flags); +} + #endif |