From nobody Sat Feb 7 18:15:56 2026 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B6BE303A05 for ; Fri, 6 Feb 2026 06:20:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770358809; cv=none; b=iBODtzDEoQKOBT2I1iZYPpaedHmYZso9WrAmmnrMT95I+Leoo4TX8dY0klU1Rn+8OHyTDGliRi8OI8URBh/DcMTxQ+eYbEo87p+OFfiE65R449hbMzNrcY7c7fDQn7gY1dvDfpebMPwzilnqD/Zo6VjbCjgmqy4U0caIL2whugY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770358809; c=relaxed/simple; bh=xIOMITzk6t7GBFmQGzTwzNYLousGKE0G8vJxVVPGw2s=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=uZfRVZIltz53uWh6n5+QmAo4rsd6XpAmYjSu9wfxdy8V9maz0hiOkhSGUg0zsfFP1M/y9WDSXgcE0EJQMW6ToSrJGInuTBgtzv9CX+9az0B/miL1HPX9XZ4Z4YL13RBCEjnSqM1gqqAQHtfKM09X7YWImiKnDpIskg8bNhFdYGs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fWNFy18B; arc=none smtp.client-ip=209.85.218.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fWNFy18B" Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-b8e9f89a8e3so191578366b.1 for ; Thu, 05 Feb 2026 22:20:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770358808; x=1770963608; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=Z91AyLavQ9E+OzREQeugmqJzK6joS+ypk+HxCV0cQS0=; b=fWNFy18BwEyCuy7uCvLeURIv85h+6r6wWNU+5JMsebsj5TlgpZalkQwMgRatCG1F7S SrHQUmvPoEVhi88H2elMzUSYjKQIZYzSRcn2HsCyIdamz69tLWG9ZBJqB9902K0p8x65 dQh7SB5pAAqsp2e9i5Ppnye63WGYiA3vB1MyYtTSRF0e9vYB1qsaG3bhQt3AMTZcc+sq bOnAcGMJhpO4KEubovmN/IDW6N1ojEpn5d/zoD3PD8fo070cEYG7rzfuul+vVC3Wa5XH 2PVcPlKkhMwjZU1Rvb6qUXelfhUFa3SQCHH7WvWFktjOQmJzI+6Qh9UbB4Fa1zUydLAB +Jiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770358808; x=1770963608; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Z91AyLavQ9E+OzREQeugmqJzK6joS+ypk+HxCV0cQS0=; b=g9NhrB9FEnKbrc26DcGtg+o0hVlx2pMt3DFpUiqZbcEapyqhtuXxSh1ix8QBHnW7Zh 84BlR5AXyDA8u0GK0R/v90Wjf2/1n6WK3jFowI+Z4tKQNitWsgwkqGjcr1uQ9p1h9Ndx nJys0czJpxmdmxW1j72L4QWlgVB8N+mnuyu/UmsvolVJnxzR4RElPtx3g92+Z+NBJrk1 senH0x4oGx5mN6XkUtwbyZksu/red6xvstJUop7mPnlrTw6mTlMtxD8EoiW9FRsvDozO Qi6Obx4NIGQG82xB+9c9I8VQ0Cs36BEPxZUscHNRp2iA1psPlqv4pHq8Ji0s5txyeZw9 xnyw== X-Forwarded-Encrypted: i=1; AJvYcCURKvbfBWYedDFJmZ0GzWpmwXD9+dFNGPEj1hiO1Wn/AM4wOZSf1MpAEGBFoOpqPbE/63eBpUB4VBMCXTw=@vger.kernel.org X-Gm-Message-State: AOJu0Yxd62lUlGbpssMELUhtdiQNEMIcXqkwSXT70LidMpAc5PhPAHLC eAom8853elWv7iBMCV5JfuYUazI1WAqSRG+vkVX+lPH5r4FiRbdBy8D1FKnS6RxGJ9I= X-Gm-Gg: AZuq6aIzR5UIXmPRII5SQAOMwe/COcxJ9fnLiVF6eUE6v34wJLD1Cf1O84Doj8bCXv0 kr+YvQ+53kowUcyFSxhrgB9DPb1dHyCI9iC2ZPih6qd6q2maAYubXYXdVO2PotDd+BfdYsRV8Jv eVfVSIeVnsPQN8IO9XpKNwIPjpDuI//+vFjUl073pYZyRwHv5mPBr3Lz/+X3Nwc4BtykDzzKkqi L/zG1I7gDBg+JNHjiLxJm29Iz6SQz9XfKlKM2OOrZAEY8tVTP8Q8M5YkXF9fGfx3LA3k/AHQ6Yg BMoOYz07qu69orDcJmbCdhzbzHaSec/Uk89hiVg9zbIFZ7Ae4RzK2mv4VnISg/xfiah8qKXVoOa nHYeD85fpkpBalq/pycRzoTI1awU515u+VfhvIHpkyXvvCwtLyw6ZWQ+rdXPcSh4TDnUlWaMqXu 9MRw== X-Received: by 2002:a17:907:2d86:b0:b8e:796a:fd5c with SMTP id a640c23a62f3a-b8edf1f0e52mr86321466b.27.1770358807540; Thu, 05 Feb 2026 22:20:07 -0800 (PST) Received: from gmail.com ([2a09:bac5:4e27:270f::3e4:5d]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b8edae6fa84sm52835066b.67.2026.02.05.22.20.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Feb 2026 22:20:07 -0800 (PST) From: Qingfang Deng To: Greg Kroah-Hartman , Jiri Slaby , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH] tty: constify tty_ldisc_ops Date: Fri, 6 Feb 2026 14:20:03 +0800 Message-ID: <20260206062004.1273890-1-dqfext@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" tty_ldisc_ops is not modified once registered, so make it const. Signed-off-by: Qingfang Deng --- drivers/tty/tty_ldisc.c | 16 ++++++++-------- include/linux/tty_ldisc.h | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c index d80e9d4c974b..470a47aca03e 100644 --- a/drivers/tty/tty_ldisc.c +++ b/drivers/tty/tty_ldisc.c @@ -44,7 +44,7 @@ enum { =20 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]; =20 /** * 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; =20 @@ -80,7 +80,7 @@ EXPORT_SYMBOL(tty_register_ldisc); * Locking: takes %tty_ldiscs_lock to guard against ldisc races */ =20 -void tty_unregister_ldisc(struct tty_ldisc_ops *ldisc) +void tty_unregister_ldisc(const struct tty_ldisc_ops *ldisc) { unsigned long flags; =20 @@ -90,10 +90,10 @@ void tty_unregister_ldisc(struct tty_ldisc_ops *ldisc) } EXPORT_SYMBOL(tty_unregister_ldisc); =20 -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; =20 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags); ret =3D ERR_PTR(-EINVAL); @@ -107,7 +107,7 @@ static struct tty_ldisc_ops *get_ldops(int disc) return ret; } =20 -static void put_ldops(struct tty_ldisc_ops *ldops) +static void put_ldops(const struct tty_ldisc_ops *ldops) { unsigned long flags; =20 @@ -139,7 +139,7 @@ int tty_ldisc_autoload =3D IS_BUILTIN(CONFIG_LDISC_AUTO= LOAD); 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; =20 if (disc < N_TTY || disc >=3D NR_LDISCS) return ERR_PTR(-EINVAL); @@ -202,7 +202,7 @@ static void tty_ldiscs_seq_stop(struct seq_file *m, voi= d *v) static int tty_ldiscs_seq_show(struct seq_file *m, void *v) { int i =3D *(loff_t *)v; - struct tty_ldisc_ops *ldops; + const struct tty_ldisc_ops *ldops; =20 ldops =3D get_ldops(i); if (IS_ERR(ldops)) diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h index c5cccc3fc1e8..d227a58e3e49 100644 --- a/include/linux/tty_ldisc.h +++ b/include/linux/tty_ldisc.h @@ -266,7 +266,7 @@ struct tty_ldisc_ops { }; =20 struct tty_ldisc { - struct tty_ldisc_ops *ops; + const struct tty_ldisc_ops *ops; struct tty_struct *tty; }; =20 @@ -281,8 +281,8 @@ struct tty_ldisc *tty_ldisc_ref_wait(struct tty_struct = *); =20 void tty_ldisc_flush(struct tty_struct *tty); =20 -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); =20 #endif /* _LINUX_TTY_LDISC_H */ --=20 2.43.0