mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 04:21:09 -04:00
pps: change pps_gen_class to a const struct
The class_create() call has been deprecated in favor of class_register() as the driver core now allows for a struct class to be in read-only memory. Change pps_gen_class to be a const struct class and drop the class_create() call. Signed-off-by: Jori Koolstra <jkoolstra@xs4all.nl> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Rodolfo Giometti <giometti@enneenne.com> Link: https://patch.msgid.link/20260302142436.3292766-1-jkoolstra@xs4all.nl Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
9aad71144f
commit
4dc0c899b1
@@ -26,7 +26,10 @@
|
||||
*/
|
||||
|
||||
static dev_t pps_gen_devt;
|
||||
static struct class *pps_gen_class;
|
||||
static const struct class pps_gen_class = {
|
||||
.name = "pps-gen",
|
||||
.dev_groups = pps_gen_groups
|
||||
};
|
||||
|
||||
static DEFINE_IDA(pps_gen_ida);
|
||||
|
||||
@@ -183,7 +186,7 @@ static int pps_gen_register_cdev(struct pps_gen_device *pps_gen)
|
||||
MAJOR(pps_gen_devt), pps_gen->id);
|
||||
goto free_ida;
|
||||
}
|
||||
pps_gen->dev = device_create(pps_gen_class, pps_gen->info->parent, devt,
|
||||
pps_gen->dev = device_create(&pps_gen_class, pps_gen->info->parent, devt,
|
||||
pps_gen, "pps-gen%d", pps_gen->id);
|
||||
if (IS_ERR(pps_gen->dev)) {
|
||||
err = PTR_ERR(pps_gen->dev);
|
||||
@@ -207,7 +210,7 @@ static int pps_gen_register_cdev(struct pps_gen_device *pps_gen)
|
||||
static void pps_gen_unregister_cdev(struct pps_gen_device *pps_gen)
|
||||
{
|
||||
pr_debug("unregistering pps-gen%d\n", pps_gen->id);
|
||||
device_destroy(pps_gen_class, pps_gen->dev->devt);
|
||||
device_destroy(&pps_gen_class, pps_gen->dev->devt);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -307,7 +310,7 @@ EXPORT_SYMBOL(pps_gen_event);
|
||||
|
||||
static void __exit pps_gen_exit(void)
|
||||
{
|
||||
class_destroy(pps_gen_class);
|
||||
class_unregister(&pps_gen_class);
|
||||
unregister_chrdev_region(pps_gen_devt, PPS_GEN_MAX_SOURCES);
|
||||
}
|
||||
|
||||
@@ -315,12 +318,11 @@ static int __init pps_gen_init(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
pps_gen_class = class_create("pps-gen");
|
||||
if (IS_ERR(pps_gen_class)) {
|
||||
pr_err("failed to allocate class\n");
|
||||
return PTR_ERR(pps_gen_class);
|
||||
err = class_register(&pps_gen_class);
|
||||
if (err) {
|
||||
pr_err("failed to register class\n");
|
||||
return err;
|
||||
}
|
||||
pps_gen_class->dev_groups = pps_gen_groups;
|
||||
|
||||
err = alloc_chrdev_region(&pps_gen_devt, 0,
|
||||
PPS_GEN_MAX_SOURCES, "pps-gen");
|
||||
@@ -332,7 +334,7 @@ static int __init pps_gen_init(void)
|
||||
return 0;
|
||||
|
||||
remove_class:
|
||||
class_destroy(pps_gen_class);
|
||||
class_unregister(&pps_gen_class);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user