public inbox for linux-kernel@vger.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 08/12] driver core: class: make class_create/remove_file*() options const
Date: Mon, 13 Mar 2023 19:18:39 +0100	[thread overview]
Message-ID: <20230313181843.1207845-8-gregkh@linuxfoundation.org> (raw)
In-Reply-To: <20230313181843.1207845-1-gregkh@linuxfoundation.org>

The class_create_file*() and class_remove_file*() functions do not
modify the struct class at all, so mark them as const * to enforce that.

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

diff --git a/drivers/base/class.c b/drivers/base/class.c
index 52ba0187e66d..3d65221b0dcb 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -87,7 +87,7 @@ static const struct kobj_type class_ktype = {
 static struct kset *class_kset;
 
 
-int class_create_file_ns(struct class *cls, const struct class_attribute *attr,
+int class_create_file_ns(const struct class *cls, const struct class_attribute *attr,
 			 const void *ns)
 {
 	int error;
@@ -101,7 +101,7 @@ int class_create_file_ns(struct class *cls, const struct class_attribute *attr,
 }
 EXPORT_SYMBOL_GPL(class_create_file_ns);
 
-void class_remove_file_ns(struct class *cls, const struct class_attribute *attr,
+void class_remove_file_ns(const struct class *cls, const struct class_attribute *attr,
 			  const void *ns)
 {
 	if (cls)
diff --git a/include/linux/device/class.h b/include/linux/device/class.h
index dfa8958105e7..75c1451fcc63 100644
--- a/include/linux/device/class.h
+++ b/include/linux/device/class.h
@@ -200,20 +200,20 @@ struct class_attribute {
 #define CLASS_ATTR_WO(_name) \
 	struct class_attribute class_attr_##_name = __ATTR_WO(_name)
 
-extern int __must_check class_create_file_ns(struct class *class,
+extern int __must_check class_create_file_ns(const struct class *class,
 					     const struct class_attribute *attr,
 					     const void *ns);
-extern void class_remove_file_ns(struct class *class,
+extern void class_remove_file_ns(const struct class *class,
 				 const struct class_attribute *attr,
 				 const void *ns);
 
-static inline int __must_check class_create_file(struct class *class,
-					const struct class_attribute *attr)
+static inline int __must_check class_create_file(const struct class *class,
+						 const struct class_attribute *attr)
 {
 	return class_create_file_ns(class, attr, NULL);
 }
 
-static inline void class_remove_file(struct class *class,
+static inline void class_remove_file(const struct class *class,
 				     const struct class_attribute *attr)
 {
 	return class_remove_file_ns(class, attr, NULL);
-- 
2.39.2


  parent reply	other threads:[~2023-03-13 18:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-13 18:18 [PATCH 01/12] driver core: class: specify the module owner in __class_register() Greg Kroah-Hartman
2023-03-13 18:18 ` [PATCH 02/12] drivers: remove struct module * setting from struct class Greg Kroah-Hartman
2023-03-13 18:18 ` [PATCH 03/12] driver core: class: remove struct module owner out of " Greg Kroah-Hartman
2023-03-13 18:18 ` [PATCH 04/12] driver core: class: remove module * from class_create() Greg Kroah-Hartman
2023-03-15  8:34   ` Benjamin Tissoires
2023-03-13 18:18 ` [PATCH 05/12] driver core: class: make class_dev_iter_init() options const Greg Kroah-Hartman
2023-03-13 18:18 ` [PATCH 06/12] driver core: class: make class_for_each_device() " Greg Kroah-Hartman
2023-03-13 18:18 ` [PATCH 07/12] driver core: class: make class_find_device*() " Greg Kroah-Hartman
2023-03-13 18:18 ` Greg Kroah-Hartman [this message]
2023-03-13 18:18 ` [PATCH 09/12] driver core: device: make device_destroy() take a const class * Greg Kroah-Hartman
2023-03-13 18:18 ` [PATCH 10/12] tpm: fix up the tpm_class shutdown_pre pointer when created Greg Kroah-Hartman
2023-03-14 11:09   ` Jarkko Sakkinen
2023-03-14 12:53     ` Greg Kroah-Hartman
2023-03-14 12:57       ` Jarkko Sakkinen
2023-03-13 18:18 ` [PATCH 11/12] driver core: device: mark struct class in struct device as constant Greg Kroah-Hartman
2023-03-13 18:18 ` [PATCH 12/12] driver core: device: make device_create*() take a const struct class * Greg Kroah-Hartman

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=20230313181843.1207845-8-gregkh@linuxfoundation.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox