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 2/5] driver core: class: make class_register() take a const *
Date: Sun,  2 Apr 2023 19:58:47 +0200	[thread overview]
Message-ID: <2023040248-customary-release-4aec@gregkh> (raw)
In-Reply-To: <2023040244-duffel-pushpin-f738@gregkh>

Now that the class code is cleaned up to not modify the class pointer
registered with it, change class_register() to take a const * to allow
the structure to be placed into read-only memory.

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

diff --git a/drivers/base/base.h b/drivers/base/base.h
index e96f3343fd7c..eb4c0ace9242 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -54,7 +54,7 @@ struct subsys_private {
 	struct device *dev_root;
 
 	struct kset glue_dirs;
-	struct class *class;
+	const struct class *class;
 
 	struct lock_class_key lock_key;
 };
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 53fc7052340c..05bce79d3d19 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -93,7 +93,7 @@ static ssize_t class_attr_store(struct kobject *kobj, struct attribute *attr,
 static void class_release(struct kobject *kobj)
 {
 	struct subsys_private *cp = to_subsys_private(kobj);
-	struct class *class = cp->class;
+	const struct class *class = cp->class;
 
 	pr_debug("class '%s': release.\n", class->name);
 
@@ -110,7 +110,7 @@ static void class_release(struct kobject *kobj)
 static const struct kobj_ns_type_operations *class_child_ns_type(const struct kobject *kobj)
 {
 	const struct subsys_private *cp = to_subsys_private(kobj);
-	struct class *class = cp->class;
+	const struct class *class = cp->class;
 
 	return class->ns_type;
 }
@@ -175,7 +175,7 @@ static void klist_class_dev_put(struct klist_node *n)
 	put_device(dev);
 }
 
-int class_register(struct class *cls)
+int class_register(const struct class *cls)
 {
 	struct subsys_private *cp;
 	struct lock_class_key *key;
diff --git a/include/linux/device/class.h b/include/linux/device/class.h
index f3c418fa129a..4bf46f9bbb56 100644
--- a/include/linux/device/class.h
+++ b/include/linux/device/class.h
@@ -76,7 +76,7 @@ struct class_dev_iter {
 	const struct device_type	*type;
 };
 
-int __must_check class_register(struct class *class);
+int __must_check class_register(const struct class *class);
 void class_unregister(const struct class *class);
 bool class_is_registered(const struct class *class);
 
-- 
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 ` Greg Kroah-Hartman [this message]
2023-04-03 17:57   ` [PATCH 2/5] driver core: class: make class_register() take " Rafael J. Wysocki
2023-04-02 17:58 ` [PATCH 3/5] driver core: class: mark the struct class in struct class_interface constant Greg Kroah-Hartman
2023-04-03 17:57   ` 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=2023040248-customary-release-4aec@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.