Skip to content

Commit 936cb49

Browse files
ivanorlov2206gregkh
authored andcommitted
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>
1 parent 11680fd commit 936cb49

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

drivers/char/xilinx_hwicap/xilinx_hwicap.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ static DEFINE_MUTEX(hwicap_mutex);
113113
static bool probed_devices[HWICAP_DEVICES];
114114
static struct mutex icap_sem;
115115

116-
static struct class *icap_class;
116+
static const struct class icap_class = {
117+
.name = "xilinx_config",
118+
};
117119

118120
#define UNIMPLEMENTED 0xFFFF
119121

@@ -687,7 +689,7 @@ static int hwicap_setup(struct device *dev, int id,
687689
goto failed3;
688690
}
689691

690-
device_create(icap_class, dev, devt, NULL, "%s%d", DRIVER_NAME, id);
692+
device_create(&icap_class, dev, devt, NULL, "%s%d", DRIVER_NAME, id);
691693
return 0; /* success */
692694

693695
failed3:
@@ -811,7 +813,7 @@ static void hwicap_drv_remove(struct platform_device *pdev)
811813

812814
drvdata = dev_get_drvdata(dev);
813815

814-
device_destroy(icap_class, drvdata->devt);
816+
device_destroy(&icap_class, drvdata->devt);
815817
cdev_del(&drvdata->cdev);
816818
iounmap(drvdata->base_address);
817819
release_mem_region(drvdata->mem_start, drvdata->mem_size);
@@ -848,7 +850,9 @@ static int __init hwicap_module_init(void)
848850
dev_t devt;
849851
int retval;
850852

851-
icap_class = class_create("xilinx_config");
853+
retval = class_register(&icap_class);
854+
if (retval)
855+
return retval;
852856
mutex_init(&icap_sem);
853857

854858
devt = MKDEV(XHWICAP_MAJOR, XHWICAP_MINOR);
@@ -874,7 +878,7 @@ static void __exit hwicap_module_cleanup(void)
874878
{
875879
dev_t devt = MKDEV(XHWICAP_MAJOR, XHWICAP_MINOR);
876880

877-
class_destroy(icap_class);
881+
class_unregister(&icap_class);
878882

879883
platform_driver_unregister(&hwicap_platform_driver);
880884

0 commit comments

Comments
 (0)