mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
USB: mon: make mon_bin_class a static const structure
Now that the driver core allows for struct class to be in read-only memory, move the mon_bin_class structure to be declared at build time placing it into read-only memory, instead of having to be dynamically allocated at load time. Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com> Link: https://lore.kernel.org/r/20230620094412.508580-9-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
8e99143649
commit
e571e843f0
@@ -213,7 +213,10 @@ static unsigned char xfer_to_pipe[4] = {
|
|||||||
PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT
|
PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct class *mon_bin_class;
|
static const struct class mon_bin_class = {
|
||||||
|
.name = "usbmon",
|
||||||
|
};
|
||||||
|
|
||||||
static dev_t mon_bin_dev0;
|
static dev_t mon_bin_dev0;
|
||||||
static struct cdev mon_bin_cdev;
|
static struct cdev mon_bin_cdev;
|
||||||
|
|
||||||
@@ -1360,7 +1363,7 @@ int mon_bin_add(struct mon_bus *mbus, const struct usb_bus *ubus)
|
|||||||
if (minor >= MON_BIN_MAX_MINOR)
|
if (minor >= MON_BIN_MAX_MINOR)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
dev = device_create(mon_bin_class, ubus ? ubus->controller : NULL,
|
dev = device_create(&mon_bin_class, ubus ? ubus->controller : NULL,
|
||||||
MKDEV(MAJOR(mon_bin_dev0), minor), NULL,
|
MKDEV(MAJOR(mon_bin_dev0), minor), NULL,
|
||||||
"usbmon%d", minor);
|
"usbmon%d", minor);
|
||||||
if (IS_ERR(dev))
|
if (IS_ERR(dev))
|
||||||
@@ -1372,18 +1375,16 @@ int mon_bin_add(struct mon_bus *mbus, const struct usb_bus *ubus)
|
|||||||
|
|
||||||
void mon_bin_del(struct mon_bus *mbus)
|
void mon_bin_del(struct mon_bus *mbus)
|
||||||
{
|
{
|
||||||
device_destroy(mon_bin_class, mbus->classdev->devt);
|
device_destroy(&mon_bin_class, mbus->classdev->devt);
|
||||||
}
|
}
|
||||||
|
|
||||||
int __init mon_bin_init(void)
|
int __init mon_bin_init(void)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
mon_bin_class = class_create("usbmon");
|
rc = class_register(&mon_bin_class);
|
||||||
if (IS_ERR(mon_bin_class)) {
|
if (rc)
|
||||||
rc = PTR_ERR(mon_bin_class);
|
|
||||||
goto err_class;
|
goto err_class;
|
||||||
}
|
|
||||||
|
|
||||||
rc = alloc_chrdev_region(&mon_bin_dev0, 0, MON_BIN_MAX_MINOR, "usbmon");
|
rc = alloc_chrdev_region(&mon_bin_dev0, 0, MON_BIN_MAX_MINOR, "usbmon");
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
@@ -1401,7 +1402,7 @@ int __init mon_bin_init(void)
|
|||||||
err_add:
|
err_add:
|
||||||
unregister_chrdev_region(mon_bin_dev0, MON_BIN_MAX_MINOR);
|
unregister_chrdev_region(mon_bin_dev0, MON_BIN_MAX_MINOR);
|
||||||
err_dev:
|
err_dev:
|
||||||
class_destroy(mon_bin_class);
|
class_unregister(&mon_bin_class);
|
||||||
err_class:
|
err_class:
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -1410,5 +1411,5 @@ void mon_bin_exit(void)
|
|||||||
{
|
{
|
||||||
cdev_del(&mon_bin_cdev);
|
cdev_del(&mon_bin_cdev);
|
||||||
unregister_chrdev_region(mon_bin_dev0, MON_BIN_MAX_MINOR);
|
unregister_chrdev_region(mon_bin_dev0, MON_BIN_MAX_MINOR);
|
||||||
class_destroy(mon_bin_class);
|
class_unregister(&mon_bin_class);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user