Re: [PATCH v2] USB: make usb class a const structure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 21, 2023 at 07:09:03PM +0400, Ivan Orlov wrote:
> 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.

Nah, your cleanup here was much nicer overall:

>  drivers/usb/core/file.c | 63 ++++-------------------------------------
>  drivers/usb/core/usb.c  |  6 ++++
>  drivers/usb/core/usb.h  |  1 +
>  3 files changed, 13 insertions(+), 57 deletions(-)

Deleting more lines than added is always a good thing, thanks for the
revision!

greg k-h



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux