Skip to content

Commit 62a1e41

Browse files
committed
Merge branch 'isdn-constify-struct-class-usage'
Ricardo B. Marliere says: ==================== isdn: constify struct class usage This is a simple and straight forward cleanup series that aims to make the class structures in isdn constant. This has been possible since 2023 [1]. [1]: https://lore.kernel.org/all/2023040248-customary-release-4aec@gregkh/ ==================== Link: https://lore.kernel.org/r/20240305-class_cleanup-isdn-v1-0-6f0edca75b61@marliere.net Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents b724132 + 12fbd67 commit 62a1e41

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

drivers/isdn/capi/capi.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ MODULE_LICENSE("GPL");
4949
/* -------- driver information -------------------------------------- */
5050

5151
static DEFINE_MUTEX(capi_mutex);
52-
static struct class *capi_class;
52+
static const struct class capi_class = {
53+
.name = "capi",
54+
};
5355
static int capi_major = 68; /* allocated */
5456

5557
module_param_named(major, capi_major, uint, 0);
@@ -1393,18 +1395,19 @@ static int __init capi_init(void)
13931395
kcapi_exit();
13941396
return major_ret;
13951397
}
1396-
capi_class = class_create("capi");
1397-
if (IS_ERR(capi_class)) {
1398+
1399+
ret = class_register(&capi_class);
1400+
if (ret) {
13981401
unregister_chrdev(capi_major, "capi20");
13991402
kcapi_exit();
1400-
return PTR_ERR(capi_class);
1403+
return ret;
14011404
}
14021405

1403-
device_create(capi_class, NULL, MKDEV(capi_major, 0), NULL, "capi20");
1406+
device_create(&capi_class, NULL, MKDEV(capi_major, 0), NULL, "capi20");
14041407

14051408
if (capinc_tty_init() < 0) {
1406-
device_destroy(capi_class, MKDEV(capi_major, 0));
1407-
class_destroy(capi_class);
1409+
device_destroy(&capi_class, MKDEV(capi_major, 0));
1410+
class_unregister(&capi_class);
14081411
unregister_chrdev(capi_major, "capi20");
14091412
kcapi_exit();
14101413
return -ENOMEM;
@@ -1427,8 +1430,8 @@ static void __exit capi_exit(void)
14271430
{
14281431
proc_exit();
14291432

1430-
device_destroy(capi_class, MKDEV(capi_major, 0));
1431-
class_destroy(capi_class);
1433+
device_destroy(&capi_class, MKDEV(capi_major, 0));
1434+
class_unregister(&capi_class);
14321435
unregister_chrdev(capi_major, "capi20");
14331436

14341437
capinc_tty_exit();

drivers/isdn/mISDN/dsp_pipeline.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ struct dsp_element_entry {
3131
static LIST_HEAD(dsp_elements);
3232

3333
/* sysfs */
34-
static struct class *elements_class;
34+
static const struct class elements_class = {
35+
.name = "dsp_pipeline",
36+
};
3537

3638
static ssize_t
3739
attr_show_args(struct device *dev, struct device_attribute *attr, char *buf)
@@ -80,7 +82,7 @@ int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
8082
INIT_LIST_HEAD(&entry->list);
8183
entry->elem = elem;
8284

83-
entry->dev.class = elements_class;
85+
entry->dev.class = &elements_class;
8486
entry->dev.release = mISDN_dsp_dev_release;
8587
dev_set_drvdata(&entry->dev, elem);
8688
dev_set_name(&entry->dev, "%s", elem->name);
@@ -131,9 +133,11 @@ EXPORT_SYMBOL(mISDN_dsp_element_unregister);
131133

132134
int dsp_pipeline_module_init(void)
133135
{
134-
elements_class = class_create("dsp_pipeline");
135-
if (IS_ERR(elements_class))
136-
return PTR_ERR(elements_class);
136+
int err;
137+
138+
err = class_register(&elements_class);
139+
if (err)
140+
return err;
137141

138142
dsp_hwec_init();
139143

@@ -146,7 +150,7 @@ void dsp_pipeline_module_exit(void)
146150

147151
dsp_hwec_exit();
148152

149-
class_destroy(elements_class);
153+
class_unregister(&elements_class);
150154

151155
list_for_each_entry_safe(entry, n, &dsp_elements, list) {
152156
list_del(&entry->list);

0 commit comments

Comments
 (0)