Skip to content

Commit e5d9592

Browse files
rbmarlieretsbogend
authored andcommitted
mips: mt: make mt_class constant
Since commit 43a7206 ("driver core: class: make class_register() take a const *"), the driver core allows for struct class to be in read-only memory, so move the mt_class structure to be declared at build time placing it into read-only memory, instead of having to be dynamically allocated at boot time. Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
1 parent 5804be0 commit e5d9592

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

arch/mips/include/asm/mips_mt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ static inline void mips_mt_set_cpuoptions(void) { }
2626
#endif
2727

2828
struct class;
29-
extern struct class *mt_class;
29+
extern const struct class mt_class;
3030

3131
#endif /* __ASM_MIPS_MT_H */

arch/mips/kernel/mips-mt.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -229,19 +229,13 @@ void mips_mt_set_cpuoptions(void)
229229
}
230230
}
231231

232-
struct class *mt_class;
232+
const struct class mt_class = {
233+
.name = "mt",
234+
};
233235

234236
static int __init mips_mt_init(void)
235237
{
236-
struct class *mtc;
237-
238-
mtc = class_create("mt");
239-
if (IS_ERR(mtc))
240-
return PTR_ERR(mtc);
241-
242-
mt_class = mtc;
243-
244-
return 0;
238+
return class_register(&mt_class);
245239
}
246240

247241
subsys_initcall(mips_mt_init);

arch/mips/kernel/rtlx-mt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ int __init rtlx_module_init(void)
9595
atomic_set(&channel_wqs[i].in_open, 0);
9696
mutex_init(&channel_wqs[i].mutex);
9797

98-
dev = device_create(mt_class, NULL, MKDEV(major, i), NULL,
98+
dev = device_create(&mt_class, NULL, MKDEV(major, i), NULL,
9999
"%s%d", RTLX_MODULE_NAME, i);
100100
if (IS_ERR(dev)) {
101101
while (i--)
102-
device_destroy(mt_class, MKDEV(major, i));
102+
device_destroy(&mt_class, MKDEV(major, i));
103103

104104
err = PTR_ERR(dev);
105105
goto out_chrdev;
@@ -127,7 +127,7 @@ int __init rtlx_module_init(void)
127127

128128
out_class:
129129
for (i = 0; i < RTLX_CHANNELS; i++)
130-
device_destroy(mt_class, MKDEV(major, i));
130+
device_destroy(&mt_class, MKDEV(major, i));
131131
out_chrdev:
132132
unregister_chrdev(major, RTLX_MODULE_NAME);
133133

@@ -139,7 +139,7 @@ void __exit rtlx_module_exit(void)
139139
int i;
140140

141141
for (i = 0; i < RTLX_CHANNELS; i++)
142-
device_destroy(mt_class, MKDEV(major, i));
142+
device_destroy(&mt_class, MKDEV(major, i));
143143

144144
unregister_chrdev(major, RTLX_MODULE_NAME);
145145

0 commit comments

Comments
 (0)