mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-24 12:44:11 +08:00
staging: fieldbus: make controller_class constant
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> Link: https://lore.kernel.org/r/2023100552-entrench-dingbat-093a@gregkh Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
06d0b81188
commit
9565794b1b
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user