summaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/samsung.h
diff options
context:
space:
mode:
authorMatthew Leach <matthew@mattleach.net>2016-06-22 17:57:03 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-06-25 14:04:12 -0700
commitbbb5ff91225dfbf3e5c27619552e41661048ed61 (patch)
treea675a32e89dca885304a9b34c581290f59515289 /drivers/tty/serial/samsung.h
parente37697b3f75464dbf86ecb0f480eb11581cc75d2 (diff)
downloadlinux-bbb5ff91225dfbf3e5c27619552e41661048ed61.tar.bz2
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.h28
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