From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sven Van Asbroeck <TheSven73@gmail.com>
Subject: [PATCH] staging: fieldbus: make controller_class constant
Date: Thu, 5 Oct 2023 15:43:53 +0200 [thread overview]
Message-ID: <2023100552-entrench-dingbat-093a@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: Sven Van Asbroeck <TheSven73@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/staging/fieldbus/anybuss/arcx-anybus.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/fieldbus/anybuss/arcx-anybus.c b/drivers/staging/fieldbus/anybuss/arcx-anybus.c
index 6f69758a8b27..34d18b09bedd 100644
--- a/drivers/staging/fieldbus/anybuss/arcx-anybus.c
+++ b/drivers/staging/fieldbus/anybuss/arcx-anybus.c
@@ -218,7 +218,10 @@ static const struct regulator_desc can_power_desc = {
.ops = &can_power_ops,
};
-static struct class *controller_class;
+static const struct class controller_class = {
+ .name = "arcx_anybus_controller",
+};
+
static DEFINE_IDA(controller_index_ida);
static int controller_probe(struct platform_device *pdev)
@@ -301,7 +304,7 @@ static int controller_probe(struct platform_device *pdev)
err = -ENOMEM;
goto out_ida;
}
- cd->class_dev->class = controller_class;
+ cd->class_dev->class = &controller_class;
cd->class_dev->groups = controller_attribute_groups;
cd->class_dev->parent = dev;
cd->class_dev->id = id;
@@ -351,12 +354,12 @@ static int __init controller_init(void)
{
int err;
- controller_class = class_create("arcx_anybus_controller");
- if (IS_ERR(controller_class))
- return PTR_ERR(controller_class);
+ err = class_register(&controller_class);
+ if (err)
+ return err;
err = platform_driver_register(&controller_driver);
if (err)
- class_destroy(controller_class);
+ class_unregister(&controller_class);
return err;
}
@@ -364,7 +367,7 @@ static int __init controller_init(void)
static void __exit controller_exit(void)
{
platform_driver_unregister(&controller_driver);
- class_destroy(controller_class);
+ class_unregister(&controller_class);
ida_destroy(&controller_index_ida);
}
--
2.42.0
reply other threads:[~2023-10-05 13:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=2023100552-entrench-dingbat-093a@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=TheSven73@gmail.com \
--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