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 2/3] staging: greybus: authentication: make cap_class constant
Date: Thu, 5 Oct 2023 15:58:35 +0200 [thread overview]
Message-ID: <2023100534-showoff-alright-6c95@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/authentication.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/greybus/authentication.c b/drivers/staging/greybus/authentication.c
index 7e01790a4659..b67315641d18 100644
--- a/drivers/staging/greybus/authentication.c
+++ b/drivers/staging/greybus/authentication.c
@@ -36,7 +36,10 @@ struct gb_cap {
dev_t dev_num;
};
-static struct class *cap_class;
+static const struct class cap_class = {
+ .name = "gb_authenticate",
+};
+
static dev_t cap_dev_num;
static DEFINE_IDA(cap_minors_map);
static LIST_HEAD(cap_list);
@@ -336,7 +339,7 @@ int gb_cap_connection_init(struct gb_connection *connection)
goto err_remove_ida;
/* Add a soft link to the previously added char-dev within the bundle */
- cap->class_device = device_create(cap_class, cap->parent, cap->dev_num,
+ cap->class_device = device_create(&cap_class, cap->parent, cap->dev_num,
NULL, "gb-authenticate-%d", minor);
if (IS_ERR(cap->class_device)) {
ret = PTR_ERR(cap->class_device);
@@ -370,7 +373,7 @@ void gb_cap_connection_exit(struct gb_connection *connection)
cap = gb_connection_get_data(connection);
- device_destroy(cap_class, cap->dev_num);
+ device_destroy(&cap_class, cap->dev_num);
cdev_del(&cap->cdev);
ida_simple_remove(&cap_minors_map, MINOR(cap->dev_num));
@@ -402,9 +405,9 @@ int cap_init(void)
{
int ret;
- cap_class = class_create("gb_authenticate");
- if (IS_ERR(cap_class))
- return PTR_ERR(cap_class);
+ ret = class_register(&cap_class);
+ if (ret)
+ return ret;
ret = alloc_chrdev_region(&cap_dev_num, 0, NUM_MINORS,
"gb_authenticate");
@@ -414,13 +417,13 @@ int cap_init(void)
return 0;
err_remove_class:
- class_destroy(cap_class);
+ class_unregister(&cap_class);
return ret;
}
void cap_exit(void)
{
unregister_chrdev_region(cap_dev_num, NUM_MINORS);
- class_destroy(cap_class);
+ class_unregister(&cap_class);
ida_destroy(&cap_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 ` Greg Kroah-Hartman [this message]
2023-10-05 15:50 ` [PATCH 2/3] staging: greybus: authentication: make cap_class constant Johan Hovold
2023-10-05 13:58 ` [PATCH 3/3] staging: greybus: fw-management: make fw_mgmt_class constant Greg Kroah-Hartman
2023-10-05 15:51 ` 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-showoff-alright-6c95@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 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.