mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 02:01:18 -04:00
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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
f2a880e802
commit
c670267ff5
@@ -44,7 +44,7 @@ enum {
|
||||
|
||||
static DEFINE_RAW_SPINLOCK(tty_ldiscs_lock);
|
||||
/* Line disc dispatch table */
|
||||
static struct tty_ldisc_ops *tty_ldiscs[NR_LDISCS];
|
||||
static const struct tty_ldisc_ops *tty_ldiscs[NR_LDISCS];
|
||||
|
||||
/**
|
||||
* tty_register_ldisc - install a line discipline
|
||||
@@ -55,7 +55,7 @@ static struct tty_ldisc_ops *tty_ldiscs[NR_LDISCS];
|
||||
*
|
||||
* Locking: takes %tty_ldiscs_lock to guard against ldisc races
|
||||
*/
|
||||
int tty_register_ldisc(struct tty_ldisc_ops *new_ldisc)
|
||||
int tty_register_ldisc(const struct tty_ldisc_ops *new_ldisc)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
@@ -80,7 +80,7 @@ EXPORT_SYMBOL(tty_register_ldisc);
|
||||
* Locking: takes %tty_ldiscs_lock to guard against ldisc races
|
||||
*/
|
||||
|
||||
void tty_unregister_ldisc(struct tty_ldisc_ops *ldisc)
|
||||
void tty_unregister_ldisc(const struct tty_ldisc_ops *ldisc)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
@@ -90,10 +90,10 @@ void tty_unregister_ldisc(struct tty_ldisc_ops *ldisc)
|
||||
}
|
||||
EXPORT_SYMBOL(tty_unregister_ldisc);
|
||||
|
||||
static struct tty_ldisc_ops *get_ldops(int disc)
|
||||
static const struct tty_ldisc_ops *get_ldops(int disc)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct tty_ldisc_ops *ldops, *ret;
|
||||
const struct tty_ldisc_ops *ldops, *ret;
|
||||
|
||||
raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
|
||||
ret = ERR_PTR(-EINVAL);
|
||||
@@ -107,7 +107,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void put_ldops(struct tty_ldisc_ops *ldops)
|
||||
static void put_ldops(const struct tty_ldisc_ops *ldops)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
@@ -139,7 +139,7 @@ int tty_ldisc_autoload = IS_BUILTIN(CONFIG_LDISC_AUTOLOAD);
|
||||
static struct tty_ldisc *tty_ldisc_get(struct tty_struct *tty, int disc)
|
||||
{
|
||||
struct tty_ldisc *ld;
|
||||
struct tty_ldisc_ops *ldops;
|
||||
const struct tty_ldisc_ops *ldops;
|
||||
|
||||
if (disc < N_TTY || disc >= NR_LDISCS)
|
||||
return ERR_PTR(-EINVAL);
|
||||
@@ -202,7 +202,7 @@ static void tty_ldiscs_seq_stop(struct seq_file *m, void *v)
|
||||
static int tty_ldiscs_seq_show(struct seq_file *m, void *v)
|
||||
{
|
||||
int i = *(loff_t *)v;
|
||||
struct tty_ldisc_ops *ldops;
|
||||
const struct tty_ldisc_ops *ldops;
|
||||
|
||||
ldops = get_ldops(i);
|
||||
if (IS_ERR(ldops))
|
||||
|
||||
@@ -266,7 +266,7 @@ struct tty_ldisc_ops {
|
||||
};
|
||||
|
||||
struct tty_ldisc {
|
||||
struct tty_ldisc_ops *ops;
|
||||
const struct tty_ldisc_ops *ops;
|
||||
struct tty_struct *tty;
|
||||
};
|
||||
|
||||
@@ -281,8 +281,8 @@ struct tty_ldisc *tty_ldisc_ref_wait(struct tty_struct *);
|
||||
|
||||
void tty_ldisc_flush(struct tty_struct *tty);
|
||||
|
||||
int tty_register_ldisc(struct tty_ldisc_ops *new_ldisc);
|
||||
void tty_unregister_ldisc(struct tty_ldisc_ops *ldisc);
|
||||
int tty_register_ldisc(const struct tty_ldisc_ops *new_ldisc);
|
||||
void tty_unregister_ldisc(const struct tty_ldisc_ops *ldisc);
|
||||
int tty_set_ldisc(struct tty_struct *tty, int disc);
|
||||
|
||||
#endif /* _LINUX_TTY_LDISC_H */
|
||||
|
||||
Reference in New Issue
Block a user