diff options
| author | Ivan Orlov <ivan.orlov0322@gmail.com> | 2023-06-22 00:25:14 +0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-07-25 17:49:30 +0200 |
| commit | 015fbddefcfbf8b44c89b2e9b0b3dd77631f1e51 (patch) | |
| tree | 6bfe98b826ed9db73ef3a027334f84bcb74d07b5 /drivers/usb/core/usb.h | |
| parent | 2319b9c87fe243327285f2fefd7374ffd75a65fc (diff) | |
| download | linux-015fbddefcfbf8b44c89b2e9b0b3dd77631f1e51.tar.gz linux-015fbddefcfbf8b44c89b2e9b0b3dd77631f1e51.tar.bz2 linux-015fbddefcfbf8b44c89b2e9b0b3dd77631f1e51.zip | |
USB: make usb class a const structure
Now that the driver core allows for struct class to be in read-only
memory, remove the usb_class structure and create the usbmisc_class
const class structure declared at build time which places it into
read-only memory, instead of having it to be dynamically allocated
at load time.
Additionally, now we register usb class at startup and unregister it
when shutting down, so we don't have to count uses of the class.
Therefore we don't need the 'usb_class' structure anymore. Due to this
fact, remove all static functions related to class initialization and
deinitialization. We can't use them in 'usb.c' since they are static
and we don't really need them anymore.
Since we have to register the class in usb_init function in 'usb.c'
and use it in 'file.c' as well, declare the usbmisc_class structure
as 'export' in the 'usb.h' file.
Debatable moment: the class registration and unregistration functions
could be extracted to the 'file.c'. I think we don't want to do this
since it would be one-line functions. They would make the code paths
more confusing and add calling overhead.
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Link: https://lore.kernel.org/r/20230621202514.1223670-1-ivan.orlov0322@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/core/usb.h')
| -rw-r--r-- | drivers/usb/core/usb.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index ffe3f6818e9c..69ca59841083 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h @@ -141,6 +141,7 @@ static inline int usb_disable_usb2_hardware_lpm(struct usb_device *udev) #endif +extern const struct class usbmisc_class; extern const struct bus_type usb_bus_type; extern struct mutex usb_port_peer_mutex; extern struct device_type usb_device_type; |
