mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
fpga: region: make fpga_region_class a static const structure
Now that the driver core allows for struct class to be in read-only memory, move the fpga_region_class structure to be declared at build time placing it into read-only memory, instead of having to be dynamically allocated at boot time. Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com> Acked-by: Xu Yilun <yilun.xu@intel.com> Link: https://lore.kernel.org/r/20230811073043.52808-3-ivan.orlov0322@gmail.com Signed-off-by: Xu Yilun <yilun.xu@intel.com>
This commit is contained in:
parent
909960e2e2
commit
1a22ec09a2
1 changed files with 11 additions and 12 deletions
|
@ -16,7 +16,7 @@
|
||||||
#include <linux/spinlock.h>
|
#include <linux/spinlock.h>
|
||||||
|
|
||||||
static DEFINE_IDA(fpga_region_ida);
|
static DEFINE_IDA(fpga_region_ida);
|
||||||
static struct class *fpga_region_class;
|
static const struct class fpga_region_class;
|
||||||
|
|
||||||
struct fpga_region *
|
struct fpga_region *
|
||||||
fpga_region_class_find(struct device *start, const void *data,
|
fpga_region_class_find(struct device *start, const void *data,
|
||||||
|
@ -24,7 +24,7 @@ fpga_region_class_find(struct device *start, const void *data,
|
||||||
{
|
{
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
|
||||||
dev = class_find_device(fpga_region_class, start, data, match);
|
dev = class_find_device(&fpga_region_class, start, data, match);
|
||||||
if (!dev)
|
if (!dev)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ fpga_region_register_full(struct device *parent, const struct fpga_region_info *
|
||||||
mutex_init(®ion->mutex);
|
mutex_init(®ion->mutex);
|
||||||
INIT_LIST_HEAD(®ion->bridge_list);
|
INIT_LIST_HEAD(®ion->bridge_list);
|
||||||
|
|
||||||
region->dev.class = fpga_region_class;
|
region->dev.class = &fpga_region_class;
|
||||||
region->dev.parent = parent;
|
region->dev.parent = parent;
|
||||||
region->dev.of_node = parent->of_node;
|
region->dev.of_node = parent->of_node;
|
||||||
region->dev.id = id;
|
region->dev.id = id;
|
||||||
|
@ -288,6 +288,12 @@ static void fpga_region_dev_release(struct device *dev)
|
||||||
kfree(region);
|
kfree(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct class fpga_region_class = {
|
||||||
|
.name = "fpga_region",
|
||||||
|
.dev_groups = fpga_region_groups,
|
||||||
|
.dev_release = fpga_region_dev_release,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fpga_region_init - creates the fpga_region class.
|
* fpga_region_init - creates the fpga_region class.
|
||||||
*
|
*
|
||||||
|
@ -295,19 +301,12 @@ static void fpga_region_dev_release(struct device *dev)
|
||||||
*/
|
*/
|
||||||
static int __init fpga_region_init(void)
|
static int __init fpga_region_init(void)
|
||||||
{
|
{
|
||||||
fpga_region_class = class_create("fpga_region");
|
return class_register(&fpga_region_class);
|
||||||
if (IS_ERR(fpga_region_class))
|
|
||||||
return PTR_ERR(fpga_region_class);
|
|
||||||
|
|
||||||
fpga_region_class->dev_groups = fpga_region_groups;
|
|
||||||
fpga_region_class->dev_release = fpga_region_dev_release;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit fpga_region_exit(void)
|
static void __exit fpga_region_exit(void)
|
||||||
{
|
{
|
||||||
class_destroy(fpga_region_class);
|
class_unregister(&fpga_region_class);
|
||||||
ida_destroy(&fpga_region_ida);
|
ida_destroy(&fpga_region_ida);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue