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 12/12] driver core: device: make device_create*() take a const struct class *
Date: Mon, 13 Mar 2023 19:18:43 +0100 [thread overview]
Message-ID: <20230313181843.1207845-12-gregkh@linuxfoundation.org> (raw)
In-Reply-To: <20230313181843.1207845-1-gregkh@linuxfoundation.org>
The functions device_create() and device_create_with_groups() do not
modify the struct class passed into it, so enforce this by changing the
function parameters to be struct const class.
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/base/core.c | 6 +++---
include/linux/device.h | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 0970db630839..f1889b9cab45 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -4253,7 +4253,7 @@ static void device_create_release(struct device *dev)
}
static __printf(6, 0) struct device *
-device_create_groups_vargs(struct class *class, struct device *parent,
+device_create_groups_vargs(const struct class *class, struct device *parent,
dev_t devt, void *drvdata,
const struct attribute_group **groups,
const char *fmt, va_list args)
@@ -4317,7 +4317,7 @@ device_create_groups_vargs(struct class *class, struct device *parent,
* Note: the struct class passed to this function must have previously
* been created with a call to class_create().
*/
-struct device *device_create(struct class *class, struct device *parent,
+struct device *device_create(const struct class *class, struct device *parent,
dev_t devt, void *drvdata, const char *fmt, ...)
{
va_list vargs;
@@ -4358,7 +4358,7 @@ EXPORT_SYMBOL_GPL(device_create);
* Note: the struct class passed to this function must have previously
* been created with a call to class_create().
*/
-struct device *device_create_with_groups(struct class *class,
+struct device *device_create_with_groups(const struct class *class,
struct device *parent, dev_t devt,
void *drvdata,
const struct attribute_group **groups,
diff --git a/include/linux/device.h b/include/linux/device.h
index f97a793c6683..b050c545a4dd 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -1013,10 +1013,10 @@ bool device_is_bound(struct device *dev);
* Easy functions for dynamically creating devices on the fly
*/
__printf(5, 6) struct device *
-device_create(struct class *cls, struct device *parent, dev_t devt,
+device_create(const struct class *cls, struct device *parent, dev_t devt,
void *drvdata, const char *fmt, ...);
__printf(6, 7) struct device *
-device_create_with_groups(struct class *cls, struct device *parent, dev_t devt,
+device_create_with_groups(const struct class *cls, struct device *parent, dev_t devt,
void *drvdata, const struct attribute_group **groups,
const char *fmt, ...);
void device_destroy(const struct class *cls, dev_t devt);
--
2.39.2
prev parent reply other threads:[~2023-03-13 18:19 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 ` [PATCH 08/12] driver core: class: make class_create/remove_file*() " Greg Kroah-Hartman
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 ` Greg Kroah-Hartman [this message]
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-12-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