From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev
Cc: linux-kernel@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Johan Hovold <johan@kernel.org>, Alex Elder <elder@kernel.org>
Subject: [PATCH 3/3] staging: greybus: fw-management: make fw_mgmt_class constant
Date: Thu, 5 Oct 2023 15:58:36 +0200 [thread overview]
Message-ID: <2023100534-catty-moodiness-099e@gregkh> (raw)
In-Reply-To: <2023100533-broadband-hunk-9e91@gregkh>
Now that the driver core allows for struct class to be in read-only
memory, making all 'class' structures to be declared at build time
placing them into read-only memory, instead of having to be dynamically
allocated at load time.
Cc: Johan Hovold <johan@kernel.org>
Cc: Alex Elder <elder@kernel.org>
Cc: greybus-dev@lists.linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/staging/greybus/fw-management.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/greybus/fw-management.c b/drivers/staging/greybus/fw-management.c
index cd9141e4b794..93137a3c4907 100644
--- a/drivers/staging/greybus/fw-management.c
+++ b/drivers/staging/greybus/fw-management.c
@@ -55,7 +55,10 @@ struct fw_mgmt {
*/
#define NUM_MINORS U8_MAX
-static struct class *fw_mgmt_class;
+static const struct class fw_mgmt_class = {
+ .name = "gb_fw_mgmt",
+};
+
static dev_t fw_mgmt_dev_num;
static DEFINE_IDA(fw_mgmt_minors_map);
static LIST_HEAD(fw_mgmt_list);
@@ -629,7 +632,7 @@ int gb_fw_mgmt_connection_init(struct gb_connection *connection)
goto err_remove_ida;
/* Add a soft link to the previously added char-dev within the bundle */
- fw_mgmt->class_device = device_create(fw_mgmt_class, fw_mgmt->parent,
+ fw_mgmt->class_device = device_create(&fw_mgmt_class, fw_mgmt->parent,
fw_mgmt->dev_num, NULL,
"gb-fw-mgmt-%d", minor);
if (IS_ERR(fw_mgmt->class_device)) {
@@ -664,7 +667,7 @@ void gb_fw_mgmt_connection_exit(struct gb_connection *connection)
fw_mgmt = gb_connection_get_data(connection);
- device_destroy(fw_mgmt_class, fw_mgmt->dev_num);
+ device_destroy(&fw_mgmt_class, fw_mgmt->dev_num);
cdev_del(&fw_mgmt->cdev);
ida_simple_remove(&fw_mgmt_minors_map, MINOR(fw_mgmt->dev_num));
@@ -696,9 +699,9 @@ int fw_mgmt_init(void)
{
int ret;
- fw_mgmt_class = class_create("gb_fw_mgmt");
- if (IS_ERR(fw_mgmt_class))
- return PTR_ERR(fw_mgmt_class);
+ ret = class_register(&fw_mgmt_class);
+ if (ret)
+ return ret;
ret = alloc_chrdev_region(&fw_mgmt_dev_num, 0, NUM_MINORS,
"gb_fw_mgmt");
@@ -708,13 +711,13 @@ int fw_mgmt_init(void)
return 0;
err_remove_class:
- class_destroy(fw_mgmt_class);
+ class_unregister(&fw_mgmt_class);
return ret;
}
void fw_mgmt_exit(void)
{
unregister_chrdev_region(fw_mgmt_dev_num, NUM_MINORS);
- class_destroy(fw_mgmt_class);
+ class_unregister(&fw_mgmt_class);
ida_destroy(&fw_mgmt_minors_map);
}
--
2.42.0
next prev parent reply other threads:[~2023-10-05 13:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-05 13:58 [PATCH 1/3] staging: greybus: raw: make raw_class constant Greg Kroah-Hartman
2023-10-05 13:58 ` [PATCH 2/3] staging: greybus: authentication: make cap_class constant Greg Kroah-Hartman
2023-10-05 15:50 ` Johan Hovold
2023-10-05 13:58 ` Greg Kroah-Hartman [this message]
2023-10-05 15:51 ` [PATCH 3/3] staging: greybus: fw-management: make fw_mgmt_class constant Johan Hovold
2023-10-05 15:49 ` [PATCH 1/3] staging: greybus: raw: make raw_class constant Johan Hovold
2023-10-06 13:12 ` Deepak R Varma
2023-10-06 13:20 ` 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=2023100534-catty-moodiness-099e@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=elder@kernel.org \
--cc=greybus-dev@lists.linaro.org \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
/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