Skip to content

Commit bb1d981

Browse files
krzkgregkh
authored andcommitted
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: Alim Akhtar <alim.akhtar@samsung.com> Reviewed-by: Jiri Slaby <jirislaby@kernel.org> Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Link: https://lore.kernel.org/r/20220308080919.152715-8-krzysztof.kozlowski@canonical.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8eea61c commit bb1d981

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

drivers/tty/serial/samsung_tty.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static void s3c24xx_serial_tx_chars(struct s3c24xx_uart_port *ourport);
164164
#define portaddrl(port, reg) \
165165
((unsigned long *)(unsigned long)((port)->membase + (reg)))
166166

167-
static u32 rd_reg(struct uart_port *port, u32 reg)
167+
static u32 rd_reg(const struct uart_port *port, u32 reg)
168168
{
169169
switch (port->iotype) {
170170
case UPIO_MEM:
@@ -179,7 +179,7 @@ static u32 rd_reg(struct uart_port *port, u32 reg)
179179

180180
#define rd_regl(port, reg) (readl_relaxed(portaddr(port, reg)))
181181

182-
static void wr_reg(struct uart_port *port, u32 reg, u32 val)
182+
static void wr_reg(const struct uart_port *port, u32 reg, u32 val)
183183
{
184184
switch (port->iotype) {
185185
case UPIO_MEM:
@@ -195,7 +195,7 @@ static void wr_reg(struct uart_port *port, u32 reg, u32 val)
195195

196196
/* Byte-order aware bit setting/clearing functions. */
197197

198-
static inline void s3c24xx_set_bit(struct uart_port *port, int idx,
198+
static inline void s3c24xx_set_bit(const struct uart_port *port, int idx,
199199
unsigned int reg)
200200
{
201201
unsigned long flags;
@@ -208,7 +208,7 @@ static inline void s3c24xx_set_bit(struct uart_port *port, int idx,
208208
local_irq_restore(flags);
209209
}
210210

211-
static inline void s3c24xx_clear_bit(struct uart_port *port, int idx,
211+
static inline void s3c24xx_clear_bit(const struct uart_port *port, int idx,
212212
unsigned int reg)
213213
{
214214
unsigned long flags;
@@ -221,19 +221,19 @@ static inline void s3c24xx_clear_bit(struct uart_port *port, int idx,
221221
local_irq_restore(flags);
222222
}
223223

224-
static inline struct s3c24xx_uart_port *to_ourport(const struct uart_port *port)
224+
static inline struct s3c24xx_uart_port *to_ourport(struct uart_port *port)
225225
{
226226
return container_of(port, struct s3c24xx_uart_port, port);
227227
}
228228

229229
/* translate a port to the device name */
230230

231-
static inline const char *s3c24xx_serial_portname(struct uart_port *port)
231+
static inline const char *s3c24xx_serial_portname(const struct uart_port *port)
232232
{
233233
return to_platform_device(port->dev)->name;
234234
}
235235

236-
static int s3c24xx_serial_txempty_nofifo(struct uart_port *port)
236+
static int s3c24xx_serial_txempty_nofifo(const struct uart_port *port)
237237
{
238238
return rd_regl(port, S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE;
239239
}
@@ -358,7 +358,7 @@ static void s3c24xx_serial_tx_dma_complete(void *args)
358358

359359
static void enable_tx_dma(struct s3c24xx_uart_port *ourport)
360360
{
361-
struct uart_port *port = &ourport->port;
361+
const struct uart_port *port = &ourport->port;
362362
u32 ucon;
363363

364364
/* Mask Tx interrupt */
@@ -387,7 +387,7 @@ static void enable_tx_dma(struct s3c24xx_uart_port *ourport)
387387

388388
static void enable_tx_pio(struct s3c24xx_uart_port *ourport)
389389
{
390-
struct uart_port *port = &ourport->port;
390+
const struct uart_port *port = &ourport->port;
391391
u32 ucon, ufcon;
392392

393393
/* Set ufcon txtrig */
@@ -580,9 +580,9 @@ static inline const struct s3c24xx_uart_info
580580
}
581581

582582
static inline const struct s3c2410_uartcfg
583-
*s3c24xx_port_to_cfg(struct uart_port *port)
583+
*s3c24xx_port_to_cfg(const struct uart_port *port)
584584
{
585-
struct s3c24xx_uart_port *ourport;
585+
const struct s3c24xx_uart_port *ourport;
586586

587587
if (port->dev == NULL)
588588
return NULL;
@@ -591,7 +591,7 @@ static inline const struct s3c2410_uartcfg
591591
return ourport->cfg;
592592
}
593593

594-
static int s3c24xx_serial_rx_fifocnt(struct s3c24xx_uart_port *ourport,
594+
static int s3c24xx_serial_rx_fifocnt(const struct s3c24xx_uart_port *ourport,
595595
unsigned long ufstat)
596596
{
597597
const struct s3c24xx_uart_info *info = ourport->info;
@@ -944,8 +944,8 @@ static irqreturn_t s3c24xx_serial_tx_irq(int irq, void *id)
944944
/* interrupt handler for s3c64xx and later SoC's.*/
945945
static irqreturn_t s3c64xx_serial_handle_irq(int irq, void *id)
946946
{
947-
struct s3c24xx_uart_port *ourport = id;
948-
struct uart_port *port = &ourport->port;
947+
const struct s3c24xx_uart_port *ourport = id;
948+
const struct uart_port *port = &ourport->port;
949949
unsigned int pend = rd_regl(port, S3C64XX_UINTP);
950950
irqreturn_t ret = IRQ_HANDLED;
951951

@@ -963,8 +963,8 @@ static irqreturn_t s3c64xx_serial_handle_irq(int irq, void *id)
963963
/* interrupt handler for Apple SoC's.*/
964964
static irqreturn_t apple_serial_handle_irq(int irq, void *id)
965965
{
966-
struct s3c24xx_uart_port *ourport = id;
967-
struct uart_port *port = &ourport->port;
966+
const struct s3c24xx_uart_port *ourport = id;
967+
const struct uart_port *port = &ourport->port;
968968
unsigned int pend = rd_regl(port, S3C2410_UTRSTAT);
969969
irqreturn_t ret = IRQ_NONE;
970970

@@ -1496,7 +1496,7 @@ static unsigned int s3c24xx_serial_getclk(struct s3c24xx_uart_port *ourport,
14961496
* This table takes the fractional value of the baud divisor and gives
14971497
* the recommended setting for the UDIVSLOT register.
14981498
*/
1499-
static u16 udivslot_table[16] = {
1499+
static const u16 udivslot_table[16] = {
15001500
[0] = 0x0000,
15011501
[1] = 0x0080,
15021502
[2] = 0x0808,
@@ -1672,7 +1672,7 @@ static void s3c24xx_serial_set_termios(struct uart_port *port,
16721672

16731673
static const char *s3c24xx_serial_type(struct uart_port *port)
16741674
{
1675-
struct s3c24xx_uart_port *ourport = to_ourport(port);
1675+
const struct s3c24xx_uart_port *ourport = to_ourport(port);
16761676

16771677
switch (ourport->info->type) {
16781678
case TYPE_S3C24XX:
@@ -2447,7 +2447,7 @@ s3c24xx_port_configured(unsigned int ucon)
24472447

24482448
static int s3c24xx_serial_get_poll_char(struct uart_port *port)
24492449
{
2450-
struct s3c24xx_uart_port *ourport = to_ourport(port);
2450+
const struct s3c24xx_uart_port *ourport = to_ourport(port);
24512451
unsigned int ufstat;
24522452

24532453
ufstat = rd_regl(port, S3C2410_UFSTAT);
@@ -2932,7 +2932,7 @@ module_exit(samsung_serial_exit);
29322932
* Early console.
29332933
*/
29342934

2935-
static void wr_reg_barrier(struct uart_port *port, u32 reg, u32 val)
2935+
static void wr_reg_barrier(const struct uart_port *port, u32 reg, u32 val)
29362936
{
29372937
switch (port->iotype) {
29382938
case UPIO_MEM:
@@ -2949,15 +2949,15 @@ struct samsung_early_console_data {
29492949
u32 rxfifo_mask;
29502950
};
29512951

2952-
static void samsung_early_busyuart(struct uart_port *port)
2952+
static void samsung_early_busyuart(const struct uart_port *port)
29532953
{
29542954
while (!(readl(port->membase + S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXFE))
29552955
;
29562956
}
29572957

2958-
static void samsung_early_busyuart_fifo(struct uart_port *port)
2958+
static void samsung_early_busyuart_fifo(const struct uart_port *port)
29592959
{
2960-
struct samsung_early_console_data *data = port->private_data;
2960+
const struct samsung_early_console_data *data = port->private_data;
29612961

29622962
while (readl(port->membase + S3C2410_UFSTAT) & data->txfull_mask)
29632963
;

0 commit comments

Comments
 (0)