All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: rafael@kernel.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH 3/5] driver core: class: mark the struct class in struct class_interface constant
Date: Sun,  2 Apr 2023 19:58:48 +0200	[thread overview]
Message-ID: <2023040249-handball-gruffly-5da7@gregkh> (raw)
In-Reply-To: <2023040244-duffel-pushpin-f738@gregkh>

The struct class pointer in struct class_interface is never modified, so
mark it as const so that no one accidentally tries to modify it in the
future.

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/base/class.c         | 2 +-
 include/linux/device/class.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/base/class.c b/drivers/base/class.c
index 05bce79d3d19..ad8b9f163fd2 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -498,7 +498,7 @@ EXPORT_SYMBOL_GPL(class_interface_register);
 void class_interface_unregister(struct class_interface *class_intf)
 {
 	struct subsys_private *sp;
-	struct class *parent = class_intf->class;
+	const struct class *parent = class_intf->class;
 	struct class_dev_iter iter;
 	struct device *dev;
 
diff --git a/include/linux/device/class.h b/include/linux/device/class.h
index 4bf46f9bbb56..53287aa105b8 100644
--- a/include/linux/device/class.h
+++ b/include/linux/device/class.h
@@ -217,7 +217,7 @@ ssize_t show_class_attr_string(const struct class *class, const struct class_att
 
 struct class_interface {
 	struct list_head	node;
-	struct class		*class;
+	const struct class	*class;
 
 	int (*add_dev)		(struct device *, struct class_interface *);
 	void (*remove_dev)	(struct device *, struct class_interface *);
-- 
2.40.0


  parent reply	other threads:[~2023-04-02 17:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-02 17:58 [PATCH 0/5] driver core: class: allow struct class to be static Greg Kroah-Hartman
2023-04-02 17:58 ` [PATCH 1/5] driver core: class: mark class_release() as taking a const * Greg Kroah-Hartman
2023-04-03 17:55   ` Rafael J. Wysocki
2023-04-02 17:58 ` [PATCH 2/5] driver core: class: make class_register() take " Greg Kroah-Hartman
2023-04-03 17:57   ` Rafael J. Wysocki
2023-04-02 17:58 ` Greg Kroah-Hartman [this message]
2023-04-03 17:57   ` [PATCH 3/5] driver core: class: mark the struct class in struct class_interface constant Rafael J. Wysocki
2023-04-02 17:58 ` [PATCH 4/5] driver core: class: remove struct class_interface * from callbacks Greg Kroah-Hartman
2023-04-03 15:43   ` Logan Gunthorpe
2023-04-03 17:59   ` Rafael J. Wysocki
2023-04-04 13:57   ` Guenter Roeck
2023-04-02 17:58 ` [PATCH 5/5] tty: make tty_class a static const structure Greg Kroah-Hartman
2023-04-03  5:47   ` Jiri Slaby

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2023040249-handball-gruffly-5da7@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.