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 1/3] staging: greybus: raw: make raw_class constant
Date: Thu, 5 Oct 2023 15:58:34 +0200 [thread overview]
Message-ID: <2023100533-broadband-hunk-9e91@gregkh> (raw)
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/raw.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/greybus/raw.c b/drivers/staging/greybus/raw.c
index 8bca8cb12cc6..a00978c8e1d2 100644
--- a/drivers/staging/greybus/raw.c
+++ b/drivers/staging/greybus/raw.c
@@ -32,7 +32,10 @@ struct raw_data {
u8 data[];
};
-static struct class *raw_class;
+static const struct class raw_class = {
+ .name = "gb_raw",
+};
+
static int raw_major;
static const struct file_operations raw_fops;
static DEFINE_IDA(minors);
@@ -195,7 +198,7 @@ static int gb_raw_probe(struct gb_bundle *bundle,
if (retval)
goto error_connection_disable;
- raw->device = device_create(raw_class, &connection->bundle->dev,
+ raw->device = device_create(&raw_class, &connection->bundle->dev,
raw->dev, raw, "gb!raw%d", minor);
if (IS_ERR(raw->device)) {
retval = PTR_ERR(raw->device);
@@ -229,7 +232,7 @@ static void gb_raw_disconnect(struct gb_bundle *bundle)
struct raw_data *temp;
// FIXME - handle removing a connection when the char device node is open.
- device_destroy(raw_class, raw->dev);
+ device_destroy(&raw_class, raw->dev);
cdev_del(&raw->cdev);
gb_connection_disable(connection);
ida_simple_remove(&minors, MINOR(raw->dev));
@@ -340,11 +343,9 @@ static int raw_init(void)
dev_t dev;
int retval;
- raw_class = class_create("gb_raw");
- if (IS_ERR(raw_class)) {
- retval = PTR_ERR(raw_class);
+ retval = class_register(&raw_class);
+ if (retval)
goto error_class;
- }
retval = alloc_chrdev_region(&dev, 0, NUM_MINORS, "gb_raw");
if (retval < 0)
@@ -361,7 +362,7 @@ static int raw_init(void)
error_gb:
unregister_chrdev_region(dev, NUM_MINORS);
error_chrdev:
- class_destroy(raw_class);
+ class_unregister(&raw_class);
error_class:
return retval;
}
@@ -371,7 +372,7 @@ static void __exit raw_exit(void)
{
greybus_deregister(&gb_raw_driver);
unregister_chrdev_region(MKDEV(raw_major, 0), NUM_MINORS);
- class_destroy(raw_class);
+ class_unregister(&raw_class);
ida_destroy(&minors);
}
module_exit(raw_exit);
--
2.42.0
next 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 Greg Kroah-Hartman [this message]
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 ` [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=2023100533-broadband-hunk-9e91@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.