mirror of
https://github.com/torvalds/linux
synced 2024-10-04 18:33:42 +00:00
mips: sibyte: make tb_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 tb_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
e5d9592c86
commit
8b2de7402f
|
@ -535,13 +535,14 @@ static const struct file_operations sbprof_tb_fops = {
|
||||||
.llseek = default_llseek,
|
.llseek = default_llseek,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct class *tb_class;
|
static const struct class tb_class = {
|
||||||
|
.name = "sb_tracebuffer",
|
||||||
|
};
|
||||||
static struct device *tb_dev;
|
static struct device *tb_dev;
|
||||||
|
|
||||||
static int __init sbprof_tb_init(void)
|
static int __init sbprof_tb_init(void)
|
||||||
{
|
{
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct class *tbc;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (register_chrdev(SBPROF_TB_MAJOR, DEVNAME, &sbprof_tb_fops)) {
|
if (register_chrdev(SBPROF_TB_MAJOR, DEVNAME, &sbprof_tb_fops)) {
|
||||||
|
@ -550,15 +551,11 @@ static int __init sbprof_tb_init(void)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
tbc = class_create("sb_tracebuffer");
|
err = class_register(&tb_class);
|
||||||
if (IS_ERR(tbc)) {
|
if (err)
|
||||||
err = PTR_ERR(tbc);
|
|
||||||
goto out_chrdev;
|
goto out_chrdev;
|
||||||
}
|
|
||||||
|
|
||||||
tb_class = tbc;
|
dev = device_create(&tb_class, NULL, MKDEV(SBPROF_TB_MAJOR, 0), NULL, "tb");
|
||||||
|
|
||||||
dev = device_create(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0), NULL, "tb");
|
|
||||||
if (IS_ERR(dev)) {
|
if (IS_ERR(dev)) {
|
||||||
err = PTR_ERR(dev);
|
err = PTR_ERR(dev);
|
||||||
goto out_class;
|
goto out_class;
|
||||||
|
@ -573,7 +570,7 @@ static int __init sbprof_tb_init(void)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_class:
|
out_class:
|
||||||
class_destroy(tb_class);
|
class_unregister(&tb_class);
|
||||||
out_chrdev:
|
out_chrdev:
|
||||||
unregister_chrdev(SBPROF_TB_MAJOR, DEVNAME);
|
unregister_chrdev(SBPROF_TB_MAJOR, DEVNAME);
|
||||||
|
|
||||||
|
@ -582,9 +579,9 @@ static int __init sbprof_tb_init(void)
|
||||||
|
|
||||||
static void __exit sbprof_tb_cleanup(void)
|
static void __exit sbprof_tb_cleanup(void)
|
||||||
{
|
{
|
||||||
device_destroy(tb_class, MKDEV(SBPROF_TB_MAJOR, 0));
|
device_destroy(&tb_class, MKDEV(SBPROF_TB_MAJOR, 0));
|
||||||
unregister_chrdev(SBPROF_TB_MAJOR, DEVNAME);
|
unregister_chrdev(SBPROF_TB_MAJOR, DEVNAME);
|
||||||
class_destroy(tb_class);
|
class_unregister(&tb_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init(sbprof_tb_init);
|
module_init(sbprof_tb_init);
|
||||||
|
|
Loading…
Reference in a new issue