From: Greg Kroah-Hartman <gregkh@linuxfoundation•org>
To: linux-kernel@vger•kernel.org
Cc: Ivan Orlov <ivan.orlov0322@gmail•com>,
Arnd Bergmann <arnd@arndb•de>,
Michal Simek <michal.simek@amd•com>,
Benjamin Tissoires <benjamin.tissoires@redhat•com>,
linux-arm-kernel@lists•infradead.org,
Greg Kroah-Hartman <gregkh@linuxfoundation•org>
Subject: [PATCH 8/9] xilinx_hwicap: make icap_class a static const structure
Date: Tue, 20 Jun 2023 16:37:59 +0200 [thread overview]
Message-ID: <20230620143751.578239-17-gregkh@linuxfoundation.org> (raw)
In-Reply-To: <20230620143751.578239-10-gregkh@linuxfoundation.org>
From: Ivan Orlov <ivan.orlov0322@gmail•com>
Now that the driver core allows for struct class to be in read-only
memory, move the icap_class structure to be declared at build time
placing it into read-only memory, instead of having to be dynamically
allocated at load time.
Cc: Arnd Bergmann <arnd@arndb•de>
Cc: Michal Simek <michal.simek@amd•com>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat•com>
Cc: Ivan Orlov <ivan.orlov0322@gmail•com>
Cc: linux-arm-kernel@lists•infradead.org
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation•org>
Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail•com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation•org>
---
drivers/char/xilinx_hwicap/xilinx_hwicap.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
index a46f637da959..527153313a30 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
@@ -113,7 +113,9 @@ static DEFINE_MUTEX(hwicap_mutex);
static bool probed_devices[HWICAP_DEVICES];
static struct mutex icap_sem;
-static struct class *icap_class;
+static const struct class icap_class = {
+ .name = "xilinx_config",
+};
#define UNIMPLEMENTED 0xFFFF
@@ -687,7 +689,7 @@ static int hwicap_setup(struct device *dev, int id,
goto failed3;
}
- device_create(icap_class, dev, devt, NULL, "%s%d", DRIVER_NAME, id);
+ device_create(&icap_class, dev, devt, NULL, "%s%d", DRIVER_NAME, id);
return 0; /* success */
failed3:
@@ -730,7 +732,7 @@ static int hwicap_remove(struct device *dev)
if (!drvdata)
return 0;
- device_destroy(icap_class, drvdata->devt);
+ device_destroy(&icap_class, drvdata->devt);
cdev_del(&drvdata->cdev);
iounmap(drvdata->base_address);
release_mem_region(drvdata->mem_start, drvdata->mem_size);
@@ -856,7 +858,9 @@ static int __init hwicap_module_init(void)
dev_t devt;
int retval;
- icap_class = class_create("xilinx_config");
+ retval = class_register(&icap_class);
+ if (retval)
+ return retval;
mutex_init(&icap_sem);
devt = MKDEV(XHWICAP_MAJOR, XHWICAP_MINOR);
@@ -882,7 +886,7 @@ static void __exit hwicap_module_cleanup(void)
{
dev_t devt = MKDEV(XHWICAP_MAJOR, XHWICAP_MINOR);
- class_destroy(icap_class);
+ class_unregister(&icap_class);
platform_driver_unregister(&hwicap_platform_driver);
--
2.41.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists•infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
parent reply other threads:[~2023-06-20 14:38 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20230620143751.578239-10-gregkh@linuxfoundation.org>]
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=20230620143751.578239-17-gregkh@linuxfoundation.org \
--to=gregkh@linuxfoundation$(echo .)org \
--cc=arnd@arndb$(echo .)de \
--cc=benjamin.tissoires@redhat$(echo .)com \
--cc=ivan.orlov0322@gmail$(echo .)com \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=michal.simek@amd$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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