diff options
author | Ivan Orlov <ivan.orlov0322@gmail.com> | 2023-06-20 17:37:59 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-06-23 11:27:23 +0300 |
commit | 936cb492a13e767c63b75ab84fd321682a18f9a5 (patch) | |
tree | e4fce1f9a51c21218b1b93ec62bf95773a91cfff | |
parent | 11680fdf29cec560987fc8f6d290a5bfdb73e4e4 (diff) | |
download | linux-936cb492a13e767c63b75ab84fd321682a18f9a5.tar.xz |
xilinx_hwicap: make icap_class a static const structure
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>
Link: https://lore.kernel.org/r/20230620143751.578239-17-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/char/xilinx_hwicap/xilinx_hwicap.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c index 00e5cf42babc..f60bb6151402 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: @@ -811,7 +813,7 @@ static void hwicap_drv_remove(struct platform_device *pdev) drvdata = dev_get_drvdata(dev); - 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); @@ -848,7 +850,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); @@ -874,7 +878,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); |