mirror of
https://github.com/torvalds/linux
synced 2024-10-06 19:34:19 +00:00
mips: mt: make mt_class constant
Since commit 43a7206b09
("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>
This commit is contained in:
parent
5804be0618
commit
e5d9592c86
|
@ -26,6 +26,6 @@ static inline void mips_mt_set_cpuoptions(void) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct class;
|
struct class;
|
||||||
extern struct class *mt_class;
|
extern const struct class mt_class;
|
||||||
|
|
||||||
#endif /* __ASM_MIPS_MT_H */
|
#endif /* __ASM_MIPS_MT_H */
|
||||||
|
|
|
@ -229,19 +229,13 @@ void mips_mt_set_cpuoptions(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct class *mt_class;
|
const struct class mt_class = {
|
||||||
|
.name = "mt",
|
||||||
|
};
|
||||||
|
|
||||||
static int __init mips_mt_init(void)
|
static int __init mips_mt_init(void)
|
||||||
{
|
{
|
||||||
struct class *mtc;
|
return class_register(&mt_class);
|
||||||
|
|
||||||
mtc = class_create("mt");
|
|
||||||
if (IS_ERR(mtc))
|
|
||||||
return PTR_ERR(mtc);
|
|
||||||
|
|
||||||
mt_class = mtc;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
subsys_initcall(mips_mt_init);
|
subsys_initcall(mips_mt_init);
|
||||||
|
|
|
@ -95,11 +95,11 @@ int __init rtlx_module_init(void)
|
||||||
atomic_set(&channel_wqs[i].in_open, 0);
|
atomic_set(&channel_wqs[i].in_open, 0);
|
||||||
mutex_init(&channel_wqs[i].mutex);
|
mutex_init(&channel_wqs[i].mutex);
|
||||||
|
|
||||||
dev = device_create(mt_class, NULL, MKDEV(major, i), NULL,
|
dev = device_create(&mt_class, NULL, MKDEV(major, i), NULL,
|
||||||
"%s%d", RTLX_MODULE_NAME, i);
|
"%s%d", RTLX_MODULE_NAME, i);
|
||||||
if (IS_ERR(dev)) {
|
if (IS_ERR(dev)) {
|
||||||
while (i--)
|
while (i--)
|
||||||
device_destroy(mt_class, MKDEV(major, i));
|
device_destroy(&mt_class, MKDEV(major, i));
|
||||||
|
|
||||||
err = PTR_ERR(dev);
|
err = PTR_ERR(dev);
|
||||||
goto out_chrdev;
|
goto out_chrdev;
|
||||||
|
@ -127,7 +127,7 @@ int __init rtlx_module_init(void)
|
||||||
|
|
||||||
out_class:
|
out_class:
|
||||||
for (i = 0; i < RTLX_CHANNELS; i++)
|
for (i = 0; i < RTLX_CHANNELS; i++)
|
||||||
device_destroy(mt_class, MKDEV(major, i));
|
device_destroy(&mt_class, MKDEV(major, i));
|
||||||
out_chrdev:
|
out_chrdev:
|
||||||
unregister_chrdev(major, RTLX_MODULE_NAME);
|
unregister_chrdev(major, RTLX_MODULE_NAME);
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ void __exit rtlx_module_exit(void)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < RTLX_CHANNELS; i++)
|
for (i = 0; i < RTLX_CHANNELS; i++)
|
||||||
device_destroy(mt_class, MKDEV(major, i));
|
device_destroy(&mt_class, MKDEV(major, i));
|
||||||
|
|
||||||
unregister_chrdev(major, RTLX_MODULE_NAME);
|
unregister_chrdev(major, RTLX_MODULE_NAME);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue