summaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/samsung.h
diff options
context:
space:
mode:
authorMatthew Leach <matthew@mattleach.net>2016-06-22 18:57:03 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-06-25 23:04:12 +0200
commitbbb5ff91225dfbf3e5c27619552e41661048ed61 (patch)
treea675a32e89dca885304a9b34c581290f59515289 /drivers/tty/serial/samsung.h
parenttty: serial: samsung: fixup accessors for endian (diff)
downloadlinux-bbb5ff91225dfbf3e5c27619552e41661048ed61.tar.xz
linux-bbb5ff91225dfbf3e5c27619552e41661048ed61.zip
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