Commit bb1d9818 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Greg Kroah-Hartman

tty: serial: samsung: constify variables and pointers

Constify variables, data pointed by several pointers and
"udivslot_table" static array.  This makes code a bit safer.
Tested-by: default avatarAlim Akhtar <alim.akhtar@samsung.com>
Reviewed-by: default avatarJiri Slaby <jirislaby@kernel.org>
Reviewed-by: default avatarAlim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Link: https://lore.kernel.org/r/20220308080919.152715-8-krzysztof.kozlowski@canonical.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8eea61c0
...@@ -164,7 +164,7 @@ static void s3c24xx_serial_tx_chars(struct s3c24xx_uart_port *ourport); ...@@ -164,7 +164,7 @@ static void s3c24xx_serial_tx_chars(struct s3c24xx_uart_port *ourport);
#define portaddrl(port, reg) \ #define portaddrl(port, reg) \
((unsigned long *)(unsigned long)((port)->membase + (reg))) ((unsigned long *)(unsigned long)((port)->membase + (reg)))
static u32 rd_reg(struct uart_port *port, u32 reg) static u32 rd_reg(const struct uart_port *port, u32 reg)
{ {
switch (port->iotype) { switch (port->iotype) {
case UPIO_MEM: case UPIO_MEM:
...@@ -179,7 +179,7 @@ static u32 rd_reg(struct uart_port *port, u32 reg) ...@@ -179,7 +179,7 @@ static u32 rd_reg(struct uart_port *port, u32 reg)
#define rd_regl(port, reg) (readl_relaxed(portaddr(port, reg))) #define rd_regl(port, reg) (readl_relaxed(portaddr(port, reg)))
static void wr_reg(struct uart_port *port, u32 reg, u32 val) static void wr_reg(const struct uart_port *port, u32 reg, u32 val)
{ {
switch (port->iotype) { switch (port->iotype) {
case UPIO_MEM: case UPIO_MEM:
...@@ -195,7 +195,7 @@ static void wr_reg(struct uart_port *port, u32 reg, u32 val) ...@@ -195,7 +195,7 @@ static void wr_reg(struct uart_port *port, u32 reg, u32 val)
/* Byte-order aware bit setting/clearing functions. */ /* Byte-order aware bit setting/clearing functions. */
static inline void s3c24xx_set_bit(struct uart_port *port, int idx, static inline void s3c24xx_set_bit(const struct uart_port *port, int idx,
unsigned int reg) unsigned int reg)
{ {
unsigned long flags; unsigned long flags;
...@@ -208,7 +208,7 @@ static inline void s3c24xx_set_bit(struct uart_port *port, int idx, ...@@ -208,7 +208,7 @@ static inline void s3c24xx_set_bit(struct uart_port *port, int idx,
local_irq_restore(flags); local_irq_restore(flags);
} }
static inline void s3c24xx_clear_bit(struct uart_port *port, int idx, static inline void s3c24xx_clear_bit(const struct uart_port *port, int idx,
unsigned int reg) unsigned int reg)
{ {
unsigned long flags; unsigned long flags;
...@@ -221,19 +221,19 @@ static inline void s3c24xx_clear_bit(struct uart_port *port, int idx, ...@@ -221,19 +221,19 @@ static inline void s3c24xx_clear_bit(struct uart_port *port, int idx,
local_irq_restore(flags); local_irq_restore(flags);
} }
static inline struct s3c24xx_uart_port *to_ourport(const struct uart_port *port) static inline struct s3c24xx_uart_port *to_ourport(struct uart_port *port)
{ {
return container_of(port, struct s3c24xx_uart_port, port); return container_of(port, struct s3c24xx_uart_port, port);
} }
/* translate a port to the device name */ /* translate a port to the device name */
static inline const char *s3c24xx_serial_portname(struct uart_port *port) static inline const char *s3c24xx_serial_portname(const struct uart_port *port)
{ {
return to_platform_device(port->dev)->name; return to_platform_device(port->dev)->name;
} }
static int s3c24xx_serial_txempty_nofifo(struct uart_port *port) static int s3c24xx_serial_txempty_nofifo(const struct uart_port *port)
{ {
return rd_regl(port, S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE; return rd_regl(port, S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE;
} }
...@@ -358,7 +358,7 @@ static void s3c24xx_serial_tx_dma_complete(void *args) ...@@ -358,7 +358,7 @@ static void s3c24xx_serial_tx_dma_complete(void *args)
static void enable_tx_dma(struct s3c24xx_uart_port *ourport) static void enable_tx_dma(struct s3c24xx_uart_port *ourport)
{ {
struct uart_port *port = &ourport->port; const struct uart_port *port = &ourport->port;
u32 ucon; u32 ucon;
/* Mask Tx interrupt */ /* Mask Tx interrupt */
...@@ -387,7 +387,7 @@ static void enable_tx_dma(struct s3c24xx_uart_port *ourport) ...@@ -387,7 +387,7 @@ static void enable_tx_dma(struct s3c24xx_uart_port *ourport)
static void enable_tx_pio(struct s3c24xx_uart_port *ourport) static void enable_tx_pio(struct s3c24xx_uart_port *ourport)
{ {
struct uart_port *port = &ourport->port; const struct uart_port *port = &ourport->port;
u32 ucon, ufcon; u32 ucon, ufcon;
/* Set ufcon txtrig */ /* Set ufcon txtrig */
...@@ -580,9 +580,9 @@ static inline const struct s3c24xx_uart_info ...@@ -580,9 +580,9 @@ static inline const struct s3c24xx_uart_info
} }
static inline const struct s3c2410_uartcfg static inline const struct s3c2410_uartcfg
*s3c24xx_port_to_cfg(struct uart_port *port) *s3c24xx_port_to_cfg(const struct uart_port *port)
{ {
struct s3c24xx_uart_port *ourport; const struct s3c24xx_uart_port *ourport;
if (port->dev == NULL) if (port->dev == NULL)
return NULL; return NULL;
...@@ -591,7 +591,7 @@ static inline const struct s3c2410_uartcfg ...@@ -591,7 +591,7 @@ static inline const struct s3c2410_uartcfg
return ourport->cfg; return ourport->cfg;
} }
static int s3c24xx_serial_rx_fifocnt(struct s3c24xx_uart_port *ourport, static int s3c24xx_serial_rx_fifocnt(const struct s3c24xx_uart_port *ourport,
unsigned long ufstat) unsigned long ufstat)
{ {
const struct s3c24xx_uart_info *info = ourport->info; const struct s3c24xx_uart_info *info = ourport->info;
...@@ -944,8 +944,8 @@ static irqreturn_t s3c24xx_serial_tx_irq(int irq, void *id) ...@@ -944,8 +944,8 @@ static irqreturn_t s3c24xx_serial_tx_irq(int irq, void *id)
/* interrupt handler for s3c64xx and later SoC's.*/ /* interrupt handler for s3c64xx and later SoC's.*/
static irqreturn_t s3c64xx_serial_handle_irq(int irq, void *id) static irqreturn_t s3c64xx_serial_handle_irq(int irq, void *id)
{ {
struct s3c24xx_uart_port *ourport = id; const struct s3c24xx_uart_port *ourport = id;
struct uart_port *port = &ourport->port; const struct uart_port *port = &ourport->port;
unsigned int pend = rd_regl(port, S3C64XX_UINTP); unsigned int pend = rd_regl(port, S3C64XX_UINTP);
irqreturn_t ret = IRQ_HANDLED; irqreturn_t ret = IRQ_HANDLED;
...@@ -963,8 +963,8 @@ static irqreturn_t s3c64xx_serial_handle_irq(int irq, void *id) ...@@ -963,8 +963,8 @@ static irqreturn_t s3c64xx_serial_handle_irq(int irq, void *id)
/* interrupt handler for Apple SoC's.*/ /* interrupt handler for Apple SoC's.*/
static irqreturn_t apple_serial_handle_irq(int irq, void *id) static irqreturn_t apple_serial_handle_irq(int irq, void *id)
{ {
struct s3c24xx_uart_port *ourport = id; const struct s3c24xx_uart_port *ourport = id;
struct uart_port *port = &ourport->port; const struct uart_port *port = &ourport->port;
unsigned int pend = rd_regl(port, S3C2410_UTRSTAT); unsigned int pend = rd_regl(port, S3C2410_UTRSTAT);
irqreturn_t ret = IRQ_NONE; irqreturn_t ret = IRQ_NONE;
...@@ -1496,7 +1496,7 @@ static unsigned int s3c24xx_serial_getclk(struct s3c24xx_uart_port *ourport, ...@@ -1496,7 +1496,7 @@ static unsigned int s3c24xx_serial_getclk(struct s3c24xx_uart_port *ourport,
* This table takes the fractional value of the baud divisor and gives * This table takes the fractional value of the baud divisor and gives
* the recommended setting for the UDIVSLOT register. * the recommended setting for the UDIVSLOT register.
*/ */
static u16 udivslot_table[16] = { static const u16 udivslot_table[16] = {
[0] = 0x0000, [0] = 0x0000,
[1] = 0x0080, [1] = 0x0080,
[2] = 0x0808, [2] = 0x0808,
...@@ -1672,7 +1672,7 @@ static void s3c24xx_serial_set_termios(struct uart_port *port, ...@@ -1672,7 +1672,7 @@ static void s3c24xx_serial_set_termios(struct uart_port *port,
static const char *s3c24xx_serial_type(struct uart_port *port) static const char *s3c24xx_serial_type(struct uart_port *port)
{ {
struct s3c24xx_uart_port *ourport = to_ourport(port); const struct s3c24xx_uart_port *ourport = to_ourport(port);
switch (ourport->info->type) { switch (ourport->info->type) {
case TYPE_S3C24XX: case TYPE_S3C24XX:
...@@ -2447,7 +2447,7 @@ s3c24xx_port_configured(unsigned int ucon) ...@@ -2447,7 +2447,7 @@ s3c24xx_port_configured(unsigned int ucon)
static int s3c24xx_serial_get_poll_char(struct uart_port *port) static int s3c24xx_serial_get_poll_char(struct uart_port *port)
{ {
struct s3c24xx_uart_port *ourport = to_ourport(port); const struct s3c24xx_uart_port *ourport = to_ourport(port);
unsigned int ufstat; unsigned int ufstat;
ufstat = rd_regl(port, S3C2410_UFSTAT); ufstat = rd_regl(port, S3C2410_UFSTAT);
...@@ -2932,7 +2932,7 @@ module_exit(samsung_serial_exit); ...@@ -2932,7 +2932,7 @@ module_exit(samsung_serial_exit);
* Early console. * Early console.
*/ */
static void wr_reg_barrier(struct uart_port *port, u32 reg, u32 val) static void wr_reg_barrier(const struct uart_port *port, u32 reg, u32 val)
{ {
switch (port->iotype) { switch (port->iotype) {
case UPIO_MEM: case UPIO_MEM:
...@@ -2949,15 +2949,15 @@ struct samsung_early_console_data { ...@@ -2949,15 +2949,15 @@ struct samsung_early_console_data {
u32 rxfifo_mask; u32 rxfifo_mask;
}; };
static void samsung_early_busyuart(struct uart_port *port) static void samsung_early_busyuart(const struct uart_port *port)
{ {
while (!(readl(port->membase + S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXFE)) while (!(readl(port->membase + S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXFE))
; ;
} }
static void samsung_early_busyuart_fifo(struct uart_port *port) static void samsung_early_busyuart_fifo(const struct uart_port *port)
{ {
struct samsung_early_console_data *data = port->private_data; const struct samsung_early_console_data *data = port->private_data;
while (readl(port->membase + S3C2410_UFSTAT) & data->txfull_mask) while (readl(port->membase + S3C2410_UFSTAT) & data->txfull_mask)
; ;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment