Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tty: constify tty_ldisc_ops

tty_ldisc_ops is not modified once registered, so make it const.

Signed-off-by: Qingfang Deng <dqfext@gmail.com>
Link: https://patch.msgid.link/20260206062004.1273890-1-dqfext@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Qingfang Deng and committed by
Greg Kroah-Hartman
c670267f f2a880e8

+11 -11
+8 -8
drivers/tty/tty_ldisc.c
··· 44 44 45 45 static DEFINE_RAW_SPINLOCK(tty_ldiscs_lock); 46 46 /* Line disc dispatch table */ 47 - static struct tty_ldisc_ops *tty_ldiscs[NR_LDISCS]; 47 + static const struct tty_ldisc_ops *tty_ldiscs[NR_LDISCS]; 48 48 49 49 /** 50 50 * tty_register_ldisc - install a line discipline ··· 55 55 * 56 56 * Locking: takes %tty_ldiscs_lock to guard against ldisc races 57 57 */ 58 - int tty_register_ldisc(struct tty_ldisc_ops *new_ldisc) 58 + int tty_register_ldisc(const struct tty_ldisc_ops *new_ldisc) 59 59 { 60 60 unsigned long flags; 61 61 ··· 80 80 * Locking: takes %tty_ldiscs_lock to guard against ldisc races 81 81 */ 82 82 83 - void tty_unregister_ldisc(struct tty_ldisc_ops *ldisc) 83 + void tty_unregister_ldisc(const struct tty_ldisc_ops *ldisc) 84 84 { 85 85 unsigned long flags; 86 86 ··· 90 90 } 91 91 EXPORT_SYMBOL(tty_unregister_ldisc); 92 92 93 - static struct tty_ldisc_ops *get_ldops(int disc) 93 + static const struct tty_ldisc_ops *get_ldops(int disc) 94 94 { 95 95 unsigned long flags; 96 - struct tty_ldisc_ops *ldops, *ret; 96 + const struct tty_ldisc_ops *ldops, *ret; 97 97 98 98 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags); 99 99 ret = ERR_PTR(-EINVAL); ··· 107 107 return ret; 108 108 } 109 109 110 - static void put_ldops(struct tty_ldisc_ops *ldops) 110 + static void put_ldops(const struct tty_ldisc_ops *ldops) 111 111 { 112 112 unsigned long flags; 113 113 ··· 139 139 static struct tty_ldisc *tty_ldisc_get(struct tty_struct *tty, int disc) 140 140 { 141 141 struct tty_ldisc *ld; 142 - struct tty_ldisc_ops *ldops; 142 + const struct tty_ldisc_ops *ldops; 143 143 144 144 if (disc < N_TTY || disc >= NR_LDISCS) 145 145 return ERR_PTR(-EINVAL); ··· 202 202 static int tty_ldiscs_seq_show(struct seq_file *m, void *v) 203 203 { 204 204 int i = *(loff_t *)v; 205 - struct tty_ldisc_ops *ldops; 205 + const struct tty_ldisc_ops *ldops; 206 206 207 207 ldops = get_ldops(i); 208 208 if (IS_ERR(ldops))
+3 -3
include/linux/tty_ldisc.h
··· 266 266 }; 267 267 268 268 struct tty_ldisc { 269 - struct tty_ldisc_ops *ops; 269 + const struct tty_ldisc_ops *ops; 270 270 struct tty_struct *tty; 271 271 }; 272 272 ··· 281 281 282 282 void tty_ldisc_flush(struct tty_struct *tty); 283 283 284 - int tty_register_ldisc(struct tty_ldisc_ops *new_ldisc); 285 - void tty_unregister_ldisc(struct tty_ldisc_ops *ldisc); 284 + int tty_register_ldisc(const struct tty_ldisc_ops *new_ldisc); 285 + void tty_unregister_ldisc(const struct tty_ldisc_ops *ldisc); 286 286 int tty_set_ldisc(struct tty_struct *tty, int disc); 287 287 288 288 #endif /* _LINUX_TTY_LDISC_H */